about summary refs log tree commit diff
path: root/nixpkgs/pkgs/misc/vscode-extensions/vscode-lldb/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/misc/vscode-extensions/vscode-lldb/default.nix')
-rw-r--r--nixpkgs/pkgs/misc/vscode-extensions/vscode-lldb/default.nix117
1 files changed, 56 insertions, 61 deletions
diff --git a/nixpkgs/pkgs/misc/vscode-extensions/vscode-lldb/default.nix b/nixpkgs/pkgs/misc/vscode-extensions/vscode-lldb/default.nix
index f22c9df36a1b..c4d228281038 100644
--- a/nixpkgs/pkgs/misc/vscode-extensions/vscode-lldb/default.nix
+++ b/nixpkgs/pkgs/misc/vscode-extensions/vscode-lldb/default.nix
@@ -1,100 +1,94 @@
-{ lib, stdenv, vscode-utils, fetchFromGitHub, rustPlatform, makeWrapper, jq
-, nodePackages, cmake, nodejs, unzip, python3, lldb, breakpointHook
-, setDefaultLldbPath ? true
+{ lib, stdenv, fetchFromGitHub, rustPlatform, makeWrapper, jq, callPackage
+, nodePackages, cmake, nodejs, unzip, python3
 }:
 assert lib.versionAtLeast python3.version "3.5";
 let
   publisher = "vadimcn";
-  name = "vscode-lldb";
-  version = "1.5.3";
-
-  dylibExt = stdenv.hostPlatform.extensions.sharedLibrary;
+  pname = "vscode-lldb";
+  version = "1.6.1";
 
   src = fetchFromGitHub {
     owner = "vadimcn";
     repo = "vscode-lldb";
     rev = "v${version}";
-    sha256 = "1139945j3z0fxc3nlyvd81k0ypymqsj051idrbgbibwshpi86y93";
+    sha256 = "sha256-mi+AeHg9zO0vjF0OZCufPkliInqxTvDGV350wqAwe90=";
     fetchSubmodules = true;
   };
 
+  lldb = callPackage ./lldb.nix {};
+
   adapter = rustPlatform.buildRustPackage {
-    pname = "${name}-adapter";
+    pname = "${pname}-adapter";
     inherit version src;
 
-    cargoSha256 = "0jl4msf2jcjxddwqkx8fr0c35wg4vwvg5c19mihri1v34i09zc5r";
-
     # It will pollute the build environment of `buildRustPackage`.
     cargoPatches = [ ./reset-cargo-config.patch ];
 
+    cargoSha256 = "sha256-HPVbqYsst/iFrHn5wvmWtqeVHOHR7JT8lu+/xZq1lK0=";
+
     nativeBuildInputs = [ makeWrapper ];
 
     buildAndTestSubdir = "adapter";
 
-    # Hack: Need a nightly compiler.
-    RUSTC_BOOTSTRAP = 1;
-
-    # `adapter` expects a special hierarchy to resolve everything well.
-    postInstall = ''
-      mkdir -p $out/adapter
-      mv -t $out/adapter \
-        $out/bin/* \
-        $out/lib/* \
-        ./adapter/*.py \
-        ./formatters/*.py
-      rmdir $out/{bin,lib}
-    '';
-
-    postFixup = ''
-      wrapProgram $out/adapter/codelldb \
-        --prefix PATH : "${python3}/bin" \
-        --prefix LD_LIBRARY_PATH : "${python3}/lib"
-    '';
+    cargoFlags = [
+      "--lib"
+      "--bin=codelldb"
+      "--features=weak-linkage"
+    ];
+
+    # Tests are linked to liblldb but it is not available here.
+    doCheck = false;
   };
 
-  build-deps = nodePackages."vscode-lldb-build-deps-../../misc/vscode-extensions/vscode-lldb/build-deps";
+  nodeDeps = nodePackages."vscode-lldb-build-deps-../../misc/vscode-extensions/vscode-lldb/build-deps";
 
-  vsix = stdenv.mkDerivation {
-    name = "${name}-${version}-vsix";
-    inherit src;
+in stdenv.mkDerivation rec {
+  name = "vscode-extension-${pname}";
+  inherit src;
+  vscodeExtUniqueId = "${publisher}.${pname}";
+  installPrefix = "share/vscode/extensions/${vscodeExtUniqueId}";
 
-    # Only build the extension. We handle `adapter` and `lldb` with nix.
-    patches = [ ./cmake-build-extension-only.patch ];
+  nativeBuildInputs = [ cmake nodejs unzip makeWrapper ];
 
-    nativeBuildInputs = [ cmake nodejs unzip breakpointHook ];
+  patches = [ ./cmake-build-extension-only.patch ];
 
-    postConfigure = ''
-      cp -r ${build-deps}/lib/node_modules/vscode-lldb/{node_modules,package-lock.json} .
-    '';
+  postConfigure = ''
+    cp -r ${nodeDeps}/lib/node_modules/vscode-lldb/{node_modules,package-lock.json} .
+  '';
 
-    makeFlags = [ "vsix_bootstrap" ];
+  cmakeFlags = [
+    # Do not append timestamp to version.
+    "-DVERSION_SUFFIX="
+  ];
+  makeFlags = [ "vsix_bootstrap" ];
 
-    installPhase = ''
-      unzip ./codelldb-bootstrap.vsix 'extension/*' -d ./vsix-extracted
-      mv vsix-extracted/extension $out
+  installPhase = ''
+    ext=$out/$installPrefix
+    runHook preInstall
 
-      ln -s ${adapter}/adapter $out
-      # Mark that adapter and lldb are installed.
-      touch $out/platform.ok
-    '';
+    unzip ./codelldb-bootstrap.vsix 'extension/*' -d ./vsix-extracted
 
-    dontStrip = true;
-    dontPatchELF = true;
-  };
+    mkdir -p $ext/{adapter,formatters}
+    mv -t $ext vsix-extracted/extension/*
+    cp -t $ext/adapter ${adapter}/{bin,lib}/* ../adapter/*.py
+    cp -t $ext/formatters ../formatters/*.py
+    ln -s ${lldb} $ext/lldb
+    # Mark that all components are installed.
+    touch $ext/platform.ok
 
-in vscode-utils.buildVscodeExtension {
-  inherit name;
-  src = vsix;
+    runHook postInstall
+  '';
 
-  nativeBuildInputs = lib.optional setDefaultLldbPath jq;
-  postUnpack = lib.optionalString setDefaultLldbPath ''
-    jq '.contributes.configuration.properties."lldb.library".default = $s' \
-      --arg s "${lldb}/lib/liblldb.so" \
-      $sourceRoot/package.json >$sourceRoot/package.json.new
-    mv $sourceRoot/package.json.new $sourceRoot/package.json
+  # `adapter` will find python binary and libraries at runtime.
+  fixupPhase = ''
+    wrapProgram $out/$installPrefix/adapter/codelldb \
+      --prefix PATH : "${python3}/bin" \
+      --prefix LD_LIBRARY_PATH : "${python3}/lib"
   '';
 
-  vscodeExtUniqueId = "${publisher}.${name}";
+  passthru = {
+    inherit lldb adapter;
+  };
 
   meta = with lib; {
     description = "A native debugger extension for VSCode based on LLDB";
@@ -102,5 +96,6 @@ in vscode-utils.buildVscodeExtension {
     license = with licenses; [ mit ];
     maintainers = with maintainers; [ oxalica ];
     platforms = platforms.all;
+    broken = stdenv.isDarwin; # Build failed on x86_64-darwin currently.
   };
 }