vscode-extensions.vadimcn.vscode-lldb: refactoring (#373933)

authored by

Austin Horstman and committed by
GitHub
70ea2a50 20d2e6da

+138 -97
pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb/adapter-output-shared_object.patch pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb/patches/adapter-output-shared_object.patch
+52
pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb/adapter.nix
···
··· 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/cmake-build-extension-only.patch pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb/patches/cmake-build-extension-only.patch
+31 -77
pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb/default.nix
··· 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 - runCommand, 6 rustPlatform, 7 makeWrapper, 8 llvmPackages, ··· 13 python3, 14 pkg-config, 15 libsecret, 16 - darwin, 17 }: 18 assert lib.versionAtLeast python3.version "3.5"; 19 let ··· 33 }; 34 35 # 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 - }; 112 113 # debugservers on macOS require the 'com.apple.security.cs.debugger' 114 # entitlement which nixpkgs' lldb-server does not yet provide; see ··· 133 134 nativeBuildInputs = [ 135 cmake 136 nodejs 137 unzip 138 - makeWrapper 139 ]; 140 141 - patches = [ ./cmake-build-extension-only.patch ]; 142 143 postPatch = '' 144 # temporary patch for forgotten version updates 145 substituteInPlace CMakeLists.txt \ 146 - --replace "1.9.2" ${version} 147 ''; 148 149 postConfigure =
··· 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 rustPlatform, 6 makeWrapper, 7 llvmPackages, ··· 12 python3, 13 pkg-config, 14 libsecret, 15 }: 16 assert lib.versionAtLeast python3.version "3.5"; 17 let ··· 31 }; 32 33 # need to build a custom version of lldb and llvm for enhanced rust support 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 + ); 66 67 # debugservers on macOS require the 'com.apple.security.cs.debugger' 68 # entitlement which nixpkgs' lldb-server does not yet provide; see ··· 87 88 nativeBuildInputs = [ 89 cmake 90 + makeWrapper 91 nodejs 92 unzip 93 ]; 94 95 + patches = [ ./patches/cmake-build-extension-only.patch ]; 96 97 postPatch = '' 98 # temporary patch for forgotten version updates 99 substituteInPlace CMakeLists.txt \ 100 + --replace-fail "1.9.2" ${version} 101 ''; 102 103 postConfigure =
+20 -20
pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb/lldb.nix
··· 1 # Patched lldb for Rust language support. 2 { 3 fetchFromGitHub, 4 - runCommand, 5 llvmPackages, 6 }: 7 let ··· 12 rev = "4c267c83cbb55fedf2e0b89644dc1db320fdfde7"; 13 hash = "sha256-jM//ej6AxnRYj+8BAn4QrxHPT6HiDzK5RqHPSg3dCcw="; 14 }; 15 - in 16 - (llvmPackages.lldb.overrideAttrs (oldAttrs: rec { 17 - passthru = (oldAttrs.passthru or { }) // { 18 - inherit llvmSrc; 19 - }; 20 21 - doInstallCheck = true; 22 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 - })
··· 1 # Patched lldb for Rust language support. 2 { 3 fetchFromGitHub, 4 llvmPackages, 5 }: 6 let ··· 11 rev = "4c267c83cbb55fedf2e0b89644dc1db320fdfde7"; 12 hash = "sha256-jM//ej6AxnRYj+8BAn4QrxHPT6HiDzK5RqHPSg3dCcw="; 13 }; 14 15 + lldbDrv = llvmPackages.lldb.overrideAttrs (oldAttrs: { 16 + passthru = (oldAttrs.passthru or { }) // { 17 + inherit llvmSrc; 18 + }; 19 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 + }
+35
pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb/node_deps.nix
···
··· 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 + }