Skip to content

Commit 70ea2a5

Browse files
authored
vscode-extensions.vadimcn.vscode-lldb: refactoring (NixOS#373933)
2 parents 20d2e6d + 90b4f93 commit 70ea2a5

File tree

6 files changed

+142
-101
lines changed

6 files changed

+142
-101
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
lib,
3+
lldb,
4+
makeWrapper,
5+
rustPlatform,
6+
stdenv,
7+
8+
pname,
9+
src,
10+
version,
11+
}:
12+
rustPlatform.buildRustPackage {
13+
pname = "${pname}-adapter";
14+
inherit version src;
15+
16+
cargoHash = "sha256-e/Jki/4pCs0qzaBVR4iiUhdBFmWlTZYREQkuFSoWYFo=";
17+
18+
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ lldb ];
19+
20+
nativeBuildInputs = [ makeWrapper ];
21+
22+
env = lib.optionalAttrs stdenv.hostPlatform.isDarwin { NIX_LDFLAGS = "-llldb -lc++abi"; };
23+
24+
buildAndTestSubdir = "adapter";
25+
26+
buildFeatures = [ "weak-linkage" ];
27+
28+
cargoBuildFlags = [
29+
"--lib"
30+
"--bin=codelldb"
31+
];
32+
33+
postFixup = ''
34+
mkdir -p $out/share/{adapter,formatters}
35+
# codelldb expects libcodelldb.so to be in the same
36+
# directory as the executable, and can't find it in $out/lib.
37+
# To make codelldb executable as a standalone,
38+
# we put all files in $out/share, and then wrap the binary in $out/bin.
39+
mv $out/bin/* $out/share/adapter
40+
cp $out/lib/* $out/share/adapter
41+
cp -r adapter/scripts $out/share/adapter
42+
cp -t $out/share/formatters formatters/*.py
43+
ln -s ${lib.getLib lldb} $out/share/lldb
44+
makeWrapper $out/share/adapter/codelldb $out/bin/codelldb \
45+
--set-default LLDB_DEBUGSERVER_PATH "${lldb.out}/bin/lldb-server"
46+
'';
47+
48+
patches = [ ./patches/adapter-output-shared_object.patch ];
49+
50+
# Tests are linked to liblldb but it is not available here.
51+
doCheck = false;
52+
}

pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb/default.nix

Lines changed: 35 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
lib,
33
stdenv,
44
fetchFromGitHub,
5-
runCommand,
65
rustPlatform,
76
makeWrapper,
87
llvmPackages,
@@ -13,7 +12,6 @@
1312
python3,
1413
pkg-config,
1514
libsecret,
16-
darwin,
1715
}:
1816
assert lib.versionAtLeast python3.version "3.5";
1917
let
@@ -33,82 +31,38 @@ let
3331
};
3432

3533
# need to build a custom version of lldb and llvm for enhanced rust support
36-
lldb = (import ./lldb.nix { inherit fetchFromGitHub runCommand llvmPackages; });
37-
38-
adapter = rustPlatform.buildRustPackage {
39-
pname = "${pname}-adapter";
40-
inherit version src;
41-
42-
cargoHash = "sha256-e/Jki/4pCs0qzaBVR4iiUhdBFmWlTZYREQkuFSoWYFo=";
43-
44-
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ lldb ];
45-
46-
nativeBuildInputs = [ makeWrapper ];
47-
48-
env = lib.optionalAttrs stdenv.hostPlatform.isDarwin { NIX_LDFLAGS = "-llldb -lc++abi"; };
49-
50-
buildAndTestSubdir = "adapter";
51-
52-
buildFeatures = [ "weak-linkage" ];
53-
54-
cargoBuildFlags = [
55-
"--lib"
56-
"--bin=codelldb"
57-
];
58-
59-
postFixup = ''
60-
mkdir -p $out/share/{adapter,formatters}
61-
# codelldb expects libcodelldb.so to be in the same
62-
# directory as the executable, and can't find it in $out/lib.
63-
# To make codelldb executable as a standalone,
64-
# we put all files in $out/share, and then wrap the binary in $out/bin.
65-
mv $out/bin/* $out/share/adapter
66-
cp $out/lib/* $out/share/adapter
67-
cp -r adapter/scripts $out/share/adapter
68-
cp -t $out/share/formatters formatters/*.py
69-
ln -s ${lib.getLib lldb} $out/share/lldb
70-
makeWrapper $out/share/adapter/codelldb $out/bin/codelldb \
71-
--set-default LLDB_DEBUGSERVER_PATH "${lldb.out}/bin/lldb-server"
72-
'';
73-
74-
patches = [ ./adapter-output-shared_object.patch ];
75-
76-
# Tests are linked to liblldb but it is not available here.
77-
doCheck = false;
78-
};
79-
80-
nodeDeps = buildNpmPackage {
81-
pname = "${pname}-node-deps";
82-
inherit version src;
83-
84-
npmDepsHash = "sha256-fMKGi+AJTMlWl7SQtZ21hUwOLgqlFYDhwLvEergQLfI=";
85-
86-
nativeBuildInputs = [
87-
python3
88-
pkg-config
89-
];
90-
91-
buildInputs =
92-
[ libsecret ]
93-
++ lib.optionals stdenv.hostPlatform.isDarwin (
94-
with darwin.apple_sdk.frameworks;
95-
[
96-
Security
97-
AppKit
98-
]
99-
);
100-
101-
dontNpmBuild = true;
102-
103-
installPhase = ''
104-
runHook preInstall
105-
106-
mkdir -p $out/lib
107-
cp -r node_modules $out/lib
108-
109-
runHook postInstall
110-
'';
111-
};
34+
lldb = (import ./lldb.nix { inherit fetchFromGitHub llvmPackages; });
35+
36+
adapter = (
37+
import ./adapter.nix {
38+
inherit
39+
lib
40+
lldb
41+
makeWrapper
42+
rustPlatform
43+
stdenv
44+
45+
pname
46+
src
47+
version
48+
;
49+
}
50+
);
51+
52+
nodeDeps = (
53+
import ./node_deps.nix {
54+
inherit
55+
buildNpmPackage
56+
libsecret
57+
pkg-config
58+
python3
59+
60+
pname
61+
src
62+
version
63+
;
64+
}
65+
);
11266

11367
# debugservers on macOS require the 'com.apple.security.cs.debugger'
11468
# entitlement which nixpkgs' lldb-server does not yet provide; see
@@ -133,17 +87,17 @@ stdenv.mkDerivation {
13387

13488
nativeBuildInputs = [
13589
cmake
90+
makeWrapper
13691
nodejs
13792
unzip
138-
makeWrapper
13993
];
14094

141-
patches = [ ./cmake-build-extension-only.patch ];
95+
patches = [ ./patches/cmake-build-extension-only.patch ];
14296

14397
postPatch = ''
14498
# temporary patch for forgotten version updates
14599
substituteInPlace CMakeLists.txt \
146-
--replace "1.9.2" ${version}
100+
--replace-fail "1.9.2" ${version}
147101
'';
148102

149103
postConfigure =
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Patched lldb for Rust language support.
22
{
33
fetchFromGitHub,
4-
runCommand,
54
llvmPackages,
65
}:
76
let
@@ -12,24 +11,25 @@ let
1211
rev = "4c267c83cbb55fedf2e0b89644dc1db320fdfde7";
1312
hash = "sha256-jM//ej6AxnRYj+8BAn4QrxHPT6HiDzK5RqHPSg3dCcw=";
1413
};
15-
in
16-
(llvmPackages.lldb.overrideAttrs (oldAttrs: rec {
17-
passthru = (oldAttrs.passthru or { }) // {
18-
inherit llvmSrc;
19-
};
2014

21-
doInstallCheck = true;
15+
lldbDrv = llvmPackages.lldb.overrideAttrs (oldAttrs: {
16+
passthru = (oldAttrs.passthru or { }) // {
17+
inherit llvmSrc;
18+
};
2219

23-
# installCheck for lldb_14 currently broken
24-
# https://github.com/NixOS/nixpkgs/issues/166604#issuecomment-1086103692
25-
# ignore the oldAttrs installCheck
26-
installCheckPhase = ''
27-
versionOutput="$($out/bin/lldb --version)"
28-
echo "'lldb --version' returns: $versionOutput"
29-
echo "$versionOutput" | grep -q 'rust-enabled'
30-
'';
31-
})).override
32-
({
33-
monorepoSrc = llvmSrc;
34-
libllvm = llvmPackages.libllvm.override ({ monorepoSrc = llvmSrc; });
35-
})
20+
doInstallCheck = true;
21+
22+
# installCheck for lldb_14 currently broken
23+
# https://github.com/NixOS/nixpkgs/issues/166604#issuecomment-1086103692
24+
# ignore the oldAttrs installCheck
25+
installCheckPhase = ''
26+
versionOutput="$($out/bin/lldb --version)"
27+
echo "'lldb --version' returns: $versionOutput"
28+
echo "$versionOutput" | grep -q 'rust-enabled'
29+
'';
30+
});
31+
in
32+
lldbDrv.override {
33+
monorepoSrc = llvmSrc;
34+
libllvm = llvmPackages.libllvm.override { monorepoSrc = llvmSrc; };
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
buildNpmPackage,
3+
4+
libsecret,
5+
python3,
6+
pkg-config,
7+
8+
pname,
9+
src,
10+
version,
11+
}:
12+
buildNpmPackage {
13+
pname = "${pname}-node-deps";
14+
inherit version src;
15+
16+
npmDepsHash = "sha256-fMKGi+AJTMlWl7SQtZ21hUwOLgqlFYDhwLvEergQLfI=";
17+
18+
nativeBuildInputs = [
19+
python3
20+
pkg-config
21+
];
22+
23+
buildInputs = [ libsecret ];
24+
25+
dontNpmBuild = true;
26+
27+
installPhase = ''
28+
runHook preInstall
29+
30+
mkdir -p $out/lib
31+
cp -r node_modules $out/lib
32+
33+
runHook postInstall
34+
'';
35+
}

pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb/adapter-output-shared_object.patch renamed to pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb/patches/adapter-output-shared_object.patch

File renamed without changes.

pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb/cmake-build-extension-only.patch renamed to pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb/patches/cmake-build-extension-only.patch

File renamed without changes.

0 commit comments

Comments
 (0)