2022-09-19 00:42:18 +00:00
|
|
|
{ pkgs, lib, stdenv, fetchFromGitHub, runCommand, rustPlatform, makeWrapper, llvmPackages
|
2023-05-21 01:55:18 +00:00
|
|
|
, buildNpmPackage, cmake, nodejs, unzip, python3, pkg-config, libsecret, darwin
|
2020-06-21 12:41:38 +00:00
|
|
|
}:
|
|
|
|
assert lib.versionAtLeast python3.version "3.5";
|
|
|
|
let
|
|
|
|
publisher = "vadimcn";
|
2020-10-12 19:05:09 +00:00
|
|
|
pname = "vscode-lldb";
|
2023-06-16 11:42:36 +00:00
|
|
|
version = "1.9.2";
|
2020-06-21 12:41:38 +00:00
|
|
|
|
2021-06-25 02:55:11 +00:00
|
|
|
vscodeExtUniqueId = "${publisher}.${pname}";
|
2022-12-13 13:30:26 +00:00
|
|
|
vscodeExtPublisher = publisher;
|
|
|
|
vscodeExtName = pname;
|
2021-06-25 02:55:11 +00:00
|
|
|
|
2020-06-21 12:41:38 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "vadimcn";
|
|
|
|
repo = "vscode-lldb";
|
|
|
|
rev = "v${version}";
|
2023-06-16 11:42:36 +00:00
|
|
|
hash = "sha256-6QmYRlSv8jY3OE3RcYuZt+c3z6GhFc8ESETVfCfF5RI=";
|
2020-06-21 12:41:38 +00:00
|
|
|
};
|
|
|
|
|
2022-09-19 00:42:18 +00:00
|
|
|
# need to build a custom version of lldb and llvm for enhanced rust support
|
|
|
|
lldb = (import ./lldb.nix { inherit fetchFromGitHub runCommand llvmPackages; });
|
2020-10-12 19:05:09 +00:00
|
|
|
|
2020-06-21 12:41:38 +00:00
|
|
|
adapter = rustPlatform.buildRustPackage {
|
2020-10-12 19:05:09 +00:00
|
|
|
pname = "${pname}-adapter";
|
2020-06-21 12:41:38 +00:00
|
|
|
inherit version src;
|
|
|
|
|
2023-06-16 11:42:36 +00:00
|
|
|
cargoHash = "sha256-Qq2igtH1XIB+NAEES6hdNZcMbEmaFN69qIJ+gTYupvQ=";
|
2020-10-12 19:05:09 +00:00
|
|
|
|
2020-06-21 12:41:38 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
buildAndTestSubdir = "adapter";
|
|
|
|
|
2021-11-15 23:58:52 +00:00
|
|
|
buildFeatures = [ "weak-linkage" ];
|
|
|
|
|
2021-07-24 01:15:38 +00:00
|
|
|
cargoBuildFlags = [
|
2020-10-12 19:05:09 +00:00
|
|
|
"--lib"
|
|
|
|
"--bin=codelldb"
|
|
|
|
];
|
|
|
|
|
2023-06-16 11:42:36 +00:00
|
|
|
patches = [ ./adapter-output-shared_object.patch ];
|
|
|
|
|
2020-10-12 19:05:09 +00:00
|
|
|
# Tests are linked to liblldb but it is not available here.
|
|
|
|
doCheck = false;
|
2020-06-21 12:41:38 +00:00
|
|
|
};
|
|
|
|
|
2023-05-20 14:32:40 +00:00
|
|
|
nodeDeps = buildNpmPackage {
|
|
|
|
pname = "${pname}-node-deps";
|
|
|
|
inherit version src;
|
|
|
|
|
2023-06-16 11:42:36 +00:00
|
|
|
npmDepsHash = "sha256-fMKGi+AJTMlWl7SQtZ21hUwOLgqlFYDhwLvEergQLfI=";
|
2023-05-20 14:32:40 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
python3
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libsecret
|
2023-05-21 01:55:18 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
|
|
|
|
Security
|
|
|
|
AppKit
|
|
|
|
]);
|
2023-05-20 14:32:40 +00:00
|
|
|
|
|
|
|
dontNpmBuild = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/lib
|
|
|
|
cp -r node_modules $out/lib
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
};
|
2020-06-21 12:41:38 +00:00
|
|
|
|
2021-06-25 02:55:11 +00:00
|
|
|
in stdenv.mkDerivation {
|
|
|
|
pname = "vscode-extension-${publisher}-${pname}";
|
2022-12-13 13:30:26 +00:00
|
|
|
inherit src version vscodeExtUniqueId vscodeExtPublisher vscodeExtName;
|
2021-06-25 02:55:11 +00:00
|
|
|
|
2020-10-12 19:05:09 +00:00
|
|
|
installPrefix = "share/vscode/extensions/${vscodeExtUniqueId}";
|
2020-06-21 12:41:38 +00:00
|
|
|
|
2020-10-12 19:05:09 +00:00
|
|
|
nativeBuildInputs = [ cmake nodejs unzip makeWrapper ];
|
2020-06-21 12:41:38 +00:00
|
|
|
|
2020-10-12 19:05:09 +00:00
|
|
|
patches = [ ./cmake-build-extension-only.patch ];
|
2020-06-21 12:41:38 +00:00
|
|
|
|
2020-10-12 19:05:09 +00:00
|
|
|
postConfigure = ''
|
2023-05-20 14:32:40 +00:00
|
|
|
cp -r ${nodeDeps}/lib/node_modules .
|
2020-10-12 19:05:09 +00:00
|
|
|
'';
|
2020-06-21 12:41:38 +00:00
|
|
|
|
2020-10-12 19:05:09 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
# Do not append timestamp to version.
|
|
|
|
"-DVERSION_SUFFIX="
|
|
|
|
];
|
|
|
|
makeFlags = [ "vsix_bootstrap" ];
|
2020-06-21 12:41:38 +00:00
|
|
|
|
2023-05-21 01:55:18 +00:00
|
|
|
preBuild = lib.optionalString stdenv.isDarwin ''
|
|
|
|
export HOME=$TMPDIR
|
|
|
|
'';
|
|
|
|
|
2020-10-12 19:05:09 +00:00
|
|
|
installPhase = ''
|
|
|
|
ext=$out/$installPrefix
|
|
|
|
runHook preInstall
|
2020-06-21 12:41:38 +00:00
|
|
|
|
2020-10-12 19:05:09 +00:00
|
|
|
unzip ./codelldb-bootstrap.vsix 'extension/*' -d ./vsix-extracted
|
2020-06-21 12:41:38 +00:00
|
|
|
|
2020-10-12 19:05:09 +00:00
|
|
|
mkdir -p $ext/{adapter,formatters}
|
|
|
|
mv -t $ext vsix-extracted/extension/*
|
2023-06-29 00:04:00 +00:00
|
|
|
cp -t $ext/adapter ${adapter}/{bin,lib}/*
|
|
|
|
cp -r ../adapter/scripts $ext/adapter
|
2021-06-01 07:25:13 +00:00
|
|
|
wrapProgram $ext/adapter/codelldb \
|
|
|
|
--set-default LLDB_DEBUGSERVER_PATH "${lldb.out}/bin/lldb-server"
|
2020-10-12 19:05:09 +00:00
|
|
|
cp -t $ext/formatters ../formatters/*.py
|
2021-06-01 07:25:13 +00:00
|
|
|
ln -s ${lldb.lib} $ext/lldb
|
2020-10-12 19:05:09 +00:00
|
|
|
# Mark that all components are installed.
|
|
|
|
touch $ext/platform.ok
|
2020-06-21 12:41:38 +00:00
|
|
|
|
2020-10-12 19:05:09 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2020-06-21 12:41:38 +00:00
|
|
|
|
2020-10-12 19:05:09 +00:00
|
|
|
# `adapter` will find python binary and libraries at runtime.
|
2021-04-20 11:50:04 +00:00
|
|
|
postFixup = ''
|
2020-10-12 19:05:09 +00:00
|
|
|
wrapProgram $out/$installPrefix/adapter/codelldb \
|
|
|
|
--prefix PATH : "${python3}/bin" \
|
|
|
|
--prefix LD_LIBRARY_PATH : "${python3}/lib"
|
2020-06-21 12:41:38 +00:00
|
|
|
'';
|
|
|
|
|
2020-10-12 19:05:09 +00:00
|
|
|
passthru = {
|
|
|
|
inherit lldb adapter;
|
2022-09-19 00:42:18 +00:00
|
|
|
updateScript = ./update.sh;
|
2020-10-12 19:05:09 +00:00
|
|
|
};
|
2020-06-21 12:41:38 +00:00
|
|
|
|
2023-03-18 19:40:30 +00:00
|
|
|
meta = {
|
2020-06-21 12:41:38 +00:00
|
|
|
description = "A native debugger extension for VSCode based on LLDB";
|
|
|
|
homepage = "https://github.com/vadimcn/vscode-lldb";
|
2023-03-18 19:40:30 +00:00
|
|
|
license = [ lib.licenses.mit ];
|
|
|
|
maintainers = [ lib.maintainers.nigelgbanks ];
|
|
|
|
platforms = lib.platforms.all;
|
2020-06-21 12:41:38 +00:00
|
|
|
};
|
|
|
|
}
|