Commit d8b50484 authored by Francis Gagné's avatar Francis Gagné Committed by Masum Reza
Browse files

vscode-extensions.vadimcn.vscode-lldb: 1.10.0 -> 1.11.4

- Remove custom lldb. The extension uses stock lldb since 1.11.0.
- Build the adapter with clang++.
- Build the adapter without weak linkage.
- Fix tools/prep-package.js failing due to missing devDependencies.
- Update GitHub repo name.
- Make various adjustments after upstream reorg.
parent a7f22e88
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -3,16 +3,20 @@
{
  autoPatchelfHook,
  callPackage,
  cargo,
  config,
  fetchurl,
  jdk,
  jq,
  lib,
  libcxxStdenv,
  llvmPackages,
  llvmPackages_14,
  llvmPackages_19,
  makeRustPlatform,
  moreutils,
  protobuf,
  python3Packages,
  rustc,
  stdenv,
  vscode-utils,
  zlib,
@@ -5119,7 +5123,17 @@ let
        };
      };

      vadimcn.vscode-lldb = callPackage ./vadimcn.vscode-lldb { llvmPackages = llvmPackages_14; };
      vadimcn.vscode-lldb = callPackage ./vadimcn.vscode-lldb {
        llvmPackages = llvmPackages_19;
        # The adapter is meant to be compiled with clang++,
        # based on the provided CMake toolchain files.
        # <https://github.com/vadimcn/codelldb/tree/master/cmake>
        rustPlatform = makeRustPlatform {
          stdenv = libcxxStdenv;
          inherit cargo rustc;
        };
        stdenv = libcxxStdenv;
      };

      valentjn.vscode-ltex = vscode-utils.buildVscodeMarketplaceExtension rec {
        mktplcRef = {
+16 −17
Original line number Diff line number Diff line
@@ -17,48 +17,47 @@ let
    if stdenv.hostPlatform.isDarwin then
      "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver"
    else
      "${lldb.out}/bin/lldb-server";
      "${lib.getBin lldb}/bin/lldb-server";
  LLVM_TRIPLE = stdenv.hostPlatform.config;
in
rustPlatform.buildRustPackage {
  pname = "${pname}-adapter";
  inherit version src;

  useFetchCargoVendor = true;
  cargoHash = "sha256-7tGX8wt2bb1segoWbBEBwZbznOaAiAyh9i/JC5FKUBU=";
  cargoHash = "sha256-Nh4YesgWa1JR8tLfrIRps9TBdsAfilXu6G2/kB08co8=";

  buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ lldb ];
  # Environment variables, based on <https://github.com/vadimcn/codelldb/blob/master/cargo_config.unix.toml>
  # The LLDB_* variables are used in adapter/lldb/build.rs.
  "CC_${LLVM_TRIPLE}" = "${stdenv.cc}/bin/cc";
  "CXX_${LLVM_TRIPLE}" = "${stdenv.cc}/bin/c++";
  LLDB_INCLUDE = "${lib.getDev lldb}/include";
  LLDB_LINK_LIB = "lldb";
  LLDB_LINK_SEARCH = "${lib.getLib lldb}/lib";

  nativeBuildInputs = [ makeWrapper ];

  env = lib.optionalAttrs stdenv.hostPlatform.isDarwin { NIX_LDFLAGS = "-llldb -lc++abi"; };

  buildAndTestSubdir = "adapter";

  buildFeatures = [ "weak-linkage" ];
  # There's isn't much point in enabling the `weaklink` feature
  # when we provide lldb via Nix.
  # buildFeatures = [ "weaklink" ];

  cargoBuildFlags = [
    "--lib"
    "--bin=codelldb"
  ];

  postFixup = ''
    mkdir -p $out/share/{adapter,formatters}
    # codelldb expects libcodelldb.so to be in the same
    # directory as the executable, and can't find it in $out/lib.
    # To make codelldb executable as a standalone,
    # we put all files in $out/share, and then wrap the binary in $out/bin.
    mkdir -p $out/share/{adapter,lang_support}
    mv $out/bin/* $out/share/adapter
    cp $out/lib/* $out/share/adapter
    cp -r adapter/scripts $out/share/adapter
    cp -t $out/share/formatters formatters/*.py
    cp -t $out/share/lang_support lang_support/*.py
    ln -s ${lib.getLib lldb} $out/share/lldb
    makeWrapper $out/share/adapter/codelldb $out/bin/codelldb \
      --set-default LLDB_DEBUGSERVER_PATH "${lldbServer}"
  '';

  patches = [ ./patches/adapter-output-shared_object.patch ];

  # Tests are linked to liblldb but it is not available here.
  # Tests fail to build (as of version 1.11.4).
  doCheck = false;

  passthru = { inherit lldbServer; };
+8 −10
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ assert lib.versionAtLeast python3.version "3.5";
let
  publisher = "vadimcn";
  pname = "vscode-lldb";
  version = "1.10.0";
  version = "1.11.4";

  vscodeExtUniqueId = "${publisher}.${pname}";
  vscodeExtPublisher = publisher;
@@ -25,13 +25,12 @@ let

  src = fetchFromGitHub {
    owner = "vadimcn";
    repo = "vscode-lldb";
    repo = "codelldb";
    rev = "v${version}";
    hash = "sha256-ExSS5HxDmJJtYypRYJNz7nY0D50gjoDBc4CnJMfgVw8=";
    hash = "sha256-+Pe7ij5ukF5pLgwvr+HOHjIv1TQDiPOEeJtkpIW9XWI=";
  };

  # need to build a custom version of lldb and llvm for enhanced rust support
  lldb = (import ./lldb.nix { inherit fetchFromGitHub llvmPackages; });
  lldb = llvmPackages.lldb;

  adapter = (
    import ./adapter.nix {
@@ -86,10 +85,9 @@ stdenv.mkDerivation {

  patches = [ ./patches/cmake-build-extension-only.patch ];

  postPatch = ''
    # temporary patch for forgotten version updates
    substituteInPlace CMakeLists.txt \
      --replace-fail "1.9.2" ${version}
  # Make devDependencies available to tools/prep-package.js
  preConfigure = ''
    cp -r ${nodeDeps}/lib/node_modules .
  '';

  postConfigure =
@@ -117,7 +115,7 @@ stdenv.mkDerivation {

    unzip ./codelldb-bootstrap.vsix 'extension/*' -d ./vsix-extracted

    mkdir -p $ext/{adapter,formatters}
    mkdir -p $ext/adapter
    mv -t $ext vsix-extracted/extension/*
    cp -t $ext/ -r ${adapter}/share/*
    wrapProgram $ext/adapter/codelldb \
+0 −35
Original line number Diff line number Diff line
# Patched lldb for Rust language support.
{
  fetchFromGitHub,
  llvmPackages,
}:
let
  llvmSrc = fetchFromGitHub {
    owner = "vadimcn";
    repo = "llvm-project";
    # codelldb/14.x branch
    rev = "4c267c83cbb55fedf2e0b89644dc1db320fdfde7";
    hash = "sha256-jM//ej6AxnRYj+8BAn4QrxHPT6HiDzK5RqHPSg3dCcw=";
  };

  lldbDrv = llvmPackages.lldb.overrideAttrs (oldAttrs: {
    passthru = (oldAttrs.passthru or { }) // {
      inherit llvmSrc;
    };

    doInstallCheck = true;

    # installCheck for lldb_14 currently broken
    # https://github.com/NixOS/nixpkgs/issues/166604#issuecomment-1086103692
    # ignore the oldAttrs installCheck
    installCheckPhase = ''
      versionOutput="$($out/bin/lldb --version)"
      echo "'lldb --version' returns: $versionOutput"
      echo "$versionOutput" | grep -q 'rust-enabled'
    '';
  });
in
lldbDrv.override {
  monorepoSrc = llvmSrc;
  libllvm = llvmPackages.libllvm.override { monorepoSrc = llvmSrc; };
}
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ buildNpmPackage {
  pname = "${pname}-node-deps";
  inherit version src;

  npmDepsHash = "sha256-fMKGi+AJTMlWl7SQtZ21hUwOLgqlFYDhwLvEergQLfI=";
  npmDepsHash = "sha256-Efeun7AFMAnoNXLbTGH7OWHaBHT2tO9CodfjKrIYw40=";

  nativeBuildInputs = [
    python3
Loading