2021-04-20 12:50:04 +01:00
|
|
|
{ lib, stdenv, fetchFromGitHub, rustPlatform, makeWrapper, callPackage
|
2020-10-12 20:05:09 +01:00
|
|
|
, nodePackages, cmake, nodejs, unzip, python3
|
2020-06-21 13:41:38 +01:00
|
|
|
}:
|
|
|
|
assert lib.versionAtLeast python3.version "3.5";
|
|
|
|
let
|
|
|
|
publisher = "vadimcn";
|
2020-10-12 20:05:09 +01:00
|
|
|
pname = "vscode-lldb";
|
2021-06-25 07:50:10 +01:00
|
|
|
version = "1.6.5";
|
2020-06-21 13:41:38 +01:00
|
|
|
|
2021-06-25 03:55:11 +01:00
|
|
|
vscodeExtUniqueId = "${publisher}.${pname}";
|
|
|
|
|
2020-06-21 13:41:38 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "vadimcn";
|
|
|
|
repo = "vscode-lldb";
|
|
|
|
rev = "v${version}";
|
2021-06-25 07:50:10 +01:00
|
|
|
sha256 = "sha256-ppiEWFKJiUtlF8LSqBb8Xvg26B+wHcIZJhU+ANE4J2k=";
|
2020-06-21 13:41:38 +01:00
|
|
|
};
|
|
|
|
|
2020-10-12 20:05:09 +01:00
|
|
|
lldb = callPackage ./lldb.nix {};
|
|
|
|
|
2020-06-21 13:41:38 +01:00
|
|
|
adapter = rustPlatform.buildRustPackage {
|
2020-10-12 20:05:09 +01:00
|
|
|
pname = "${pname}-adapter";
|
2020-06-21 13:41:38 +01:00
|
|
|
inherit version src;
|
|
|
|
|
|
|
|
# It will pollute the build environment of `buildRustPackage`.
|
|
|
|
cargoPatches = [ ./reset-cargo-config.patch ];
|
|
|
|
|
2021-06-25 07:50:10 +01:00
|
|
|
cargoSha256 = "sha256-ksRFlbtrFAbcX/Pc6rgWUHVl859GVUOvNckxM7Q971U=";
|
2020-10-12 20:05:09 +01:00
|
|
|
|
2020-06-21 13:41:38 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
buildAndTestSubdir = "adapter";
|
|
|
|
|
2020-10-12 20:05:09 +01:00
|
|
|
cargoFlags = [
|
|
|
|
"--lib"
|
|
|
|
"--bin=codelldb"
|
|
|
|
"--features=weak-linkage"
|
|
|
|
];
|
|
|
|
|
|
|
|
# Tests are linked to liblldb but it is not available here.
|
|
|
|
doCheck = false;
|
2020-06-21 13:41:38 +01:00
|
|
|
};
|
|
|
|
|
2020-10-12 20:05:09 +01:00
|
|
|
nodeDeps = nodePackages."vscode-lldb-build-deps-../../misc/vscode-extensions/vscode-lldb/build-deps";
|
2020-06-21 13:41:38 +01:00
|
|
|
|
2021-06-25 03:55:11 +01:00
|
|
|
in stdenv.mkDerivation {
|
|
|
|
pname = "vscode-extension-${publisher}-${pname}";
|
|
|
|
inherit src version vscodeExtUniqueId;
|
|
|
|
|
2020-10-12 20:05:09 +01:00
|
|
|
installPrefix = "share/vscode/extensions/${vscodeExtUniqueId}";
|
2020-06-21 13:41:38 +01:00
|
|
|
|
2020-10-12 20:05:09 +01:00
|
|
|
nativeBuildInputs = [ cmake nodejs unzip makeWrapper ];
|
2020-06-21 13:41:38 +01:00
|
|
|
|
2020-10-12 20:05:09 +01:00
|
|
|
patches = [ ./cmake-build-extension-only.patch ];
|
2020-06-21 13:41:38 +01:00
|
|
|
|
2020-10-12 20:05:09 +01:00
|
|
|
postConfigure = ''
|
|
|
|
cp -r ${nodeDeps}/lib/node_modules/vscode-lldb/{node_modules,package-lock.json} .
|
|
|
|
'';
|
2020-06-21 13:41:38 +01:00
|
|
|
|
2020-10-12 20:05:09 +01:00
|
|
|
cmakeFlags = [
|
|
|
|
# Do not append timestamp to version.
|
|
|
|
"-DVERSION_SUFFIX="
|
|
|
|
];
|
|
|
|
makeFlags = [ "vsix_bootstrap" ];
|
2020-06-21 13:41:38 +01:00
|
|
|
|
2020-10-12 20:05:09 +01:00
|
|
|
installPhase = ''
|
|
|
|
ext=$out/$installPrefix
|
|
|
|
runHook preInstall
|
2020-06-21 13:41:38 +01:00
|
|
|
|
2020-10-12 20:05:09 +01:00
|
|
|
unzip ./codelldb-bootstrap.vsix 'extension/*' -d ./vsix-extracted
|
2020-06-21 13:41:38 +01:00
|
|
|
|
2020-10-12 20:05:09 +01:00
|
|
|
mkdir -p $ext/{adapter,formatters}
|
|
|
|
mv -t $ext vsix-extracted/extension/*
|
|
|
|
cp -t $ext/adapter ${adapter}/{bin,lib}/* ../adapter/*.py
|
2021-06-01 08:25:13 +01:00
|
|
|
wrapProgram $ext/adapter/codelldb \
|
|
|
|
--set-default LLDB_DEBUGSERVER_PATH "${lldb.out}/bin/lldb-server"
|
2020-10-12 20:05:09 +01:00
|
|
|
cp -t $ext/formatters ../formatters/*.py
|
2021-06-01 08:25:13 +01:00
|
|
|
ln -s ${lldb.lib} $ext/lldb
|
2020-10-12 20:05:09 +01:00
|
|
|
# Mark that all components are installed.
|
|
|
|
touch $ext/platform.ok
|
2020-06-21 13:41:38 +01:00
|
|
|
|
2020-10-12 20:05:09 +01:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2020-06-21 13:41:38 +01:00
|
|
|
|
2020-10-12 20:05:09 +01:00
|
|
|
# `adapter` will find python binary and libraries at runtime.
|
2021-04-20 12:50:04 +01:00
|
|
|
postFixup = ''
|
2020-10-12 20:05:09 +01:00
|
|
|
wrapProgram $out/$installPrefix/adapter/codelldb \
|
|
|
|
--prefix PATH : "${python3}/bin" \
|
|
|
|
--prefix LD_LIBRARY_PATH : "${python3}/lib"
|
2020-06-21 13:41:38 +01:00
|
|
|
'';
|
|
|
|
|
2020-10-12 20:05:09 +01:00
|
|
|
passthru = {
|
|
|
|
inherit lldb adapter;
|
|
|
|
};
|
2020-06-21 13:41:38 +01:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A native debugger extension for VSCode based on LLDB";
|
|
|
|
homepage = "https://github.com/vadimcn/vscode-lldb";
|
|
|
|
license = with licenses; [ mit ];
|
|
|
|
maintainers = with maintainers; [ oxalica ];
|
2021-02-06 02:41:36 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
broken = stdenv.isDarwin; # Build failed on x86_64-darwin currently.
|
2020-06-21 13:41:38 +01:00
|
|
|
};
|
|
|
|
}
|