Unverified Commit 70ea2a50 authored by Austin Horstman's avatar Austin Horstman Committed by GitHub
Browse files

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

parents 20d2e6da 90b4f938
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
{
  lib,
  lldb,
  makeWrapper,
  rustPlatform,
  stdenv,

  pname,
  src,
  version,
}:
rustPlatform.buildRustPackage {
  pname = "${pname}-adapter";
  inherit version src;

  cargoHash = "sha256-e/Jki/4pCs0qzaBVR4iiUhdBFmWlTZYREQkuFSoWYFo=";

  buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ lldb ];

  nativeBuildInputs = [ makeWrapper ];

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

  buildAndTestSubdir = "adapter";

  buildFeatures = [ "weak-linkage" ];

  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.
    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
    ln -s ${lib.getLib lldb} $out/share/lldb
    makeWrapper $out/share/adapter/codelldb $out/bin/codelldb \
      --set-default LLDB_DEBUGSERVER_PATH "${lldb.out}/bin/lldb-server"
  '';

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

  # Tests are linked to liblldb but it is not available here.
  doCheck = false;
}
+35 −81
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
  lib,
  stdenv,
  fetchFromGitHub,
  runCommand,
  rustPlatform,
  makeWrapper,
  llvmPackages,
@@ -13,7 +12,6 @@
  python3,
  pkg-config,
  libsecret,
  darwin,
}:
assert lib.versionAtLeast python3.version "3.5";
let
@@ -33,83 +31,39 @@ let
  };

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

  adapter = rustPlatform.buildRustPackage {
    pname = "${pname}-adapter";
    inherit version src;

    cargoHash = "sha256-e/Jki/4pCs0qzaBVR4iiUhdBFmWlTZYREQkuFSoWYFo=";

    buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ lldb ];

    nativeBuildInputs = [ makeWrapper ];

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

    buildAndTestSubdir = "adapter";

    buildFeatures = [ "weak-linkage" ];

    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.
      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
      ln -s ${lib.getLib lldb} $out/share/lldb
      makeWrapper $out/share/adapter/codelldb $out/bin/codelldb \
        --set-default LLDB_DEBUGSERVER_PATH "${lldb.out}/bin/lldb-server"
    '';

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

    # Tests are linked to liblldb but it is not available here.
    doCheck = false;
  };

  nodeDeps = buildNpmPackage {
    pname = "${pname}-node-deps";
    inherit version src;
  adapter = (
    import ./adapter.nix {
      inherit
        lib
        lldb
        makeWrapper
        rustPlatform
        stdenv

    npmDepsHash = "sha256-fMKGi+AJTMlWl7SQtZ21hUwOLgqlFYDhwLvEergQLfI=";
        pname
        src
        version
        ;
    }
  );

    nativeBuildInputs = [
      python3
  nodeDeps = (
    import ./node_deps.nix {
      inherit
        buildNpmPackage
        libsecret
        pkg-config
    ];
        python3

    buildInputs =
      [ libsecret ]
      ++ lib.optionals stdenv.hostPlatform.isDarwin (
        with darwin.apple_sdk.frameworks;
        [
          Security
          AppKit
        ]
        pname
        src
        version
        ;
    }
  );

    dontNpmBuild = true;

    installPhase = ''
      runHook preInstall

      mkdir -p $out/lib
      cp -r node_modules $out/lib

      runHook postInstall
    '';
  };

  # debugservers on macOS require the 'com.apple.security.cs.debugger'
  # entitlement which nixpkgs' lldb-server does not yet provide; see
  # <https://github.com/NixOS/nixpkgs/pull/38624> for details
@@ -133,17 +87,17 @@ stdenv.mkDerivation {

  nativeBuildInputs = [
    cmake
    makeWrapper
    nodejs
    unzip
    makeWrapper
  ];

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

  postPatch = ''
    # temporary patch for forgotten version updates
    substituteInPlace CMakeLists.txt \
      --replace "1.9.2" ${version}
      --replace-fail "1.9.2" ${version}
  '';

  postConfigure =
+20 −20
Original line number Diff line number Diff line
# Patched lldb for Rust language support.
{
  fetchFromGitHub,
  runCommand,
  llvmPackages,
}:
let
@@ -12,8 +11,8 @@ let
    rev = "4c267c83cbb55fedf2e0b89644dc1db320fdfde7";
    hash = "sha256-jM//ej6AxnRYj+8BAn4QrxHPT6HiDzK5RqHPSg3dCcw=";
  };
in
(llvmPackages.lldb.overrideAttrs (oldAttrs: rec {

  lldbDrv = llvmPackages.lldb.overrideAttrs (oldAttrs: {
    passthru = (oldAttrs.passthru or { }) // {
      inherit llvmSrc;
    };
@@ -28,8 +27,9 @@ in
      echo "'lldb --version' returns: $versionOutput"
      echo "$versionOutput" | grep -q 'rust-enabled'
    '';
})).override
  ({
  });
in
lldbDrv.override {
  monorepoSrc = llvmSrc;
    libllvm = llvmPackages.libllvm.override ({ monorepoSrc = llvmSrc; });
  })
  libllvm = llvmPackages.libllvm.override { monorepoSrc = llvmSrc; };
}
+35 −0
Original line number Diff line number Diff line
{
  buildNpmPackage,

  libsecret,
  python3,
  pkg-config,

  pname,
  src,
  version,
}:
buildNpmPackage {
  pname = "${pname}-node-deps";
  inherit version src;

  npmDepsHash = "sha256-fMKGi+AJTMlWl7SQtZ21hUwOLgqlFYDhwLvEergQLfI=";

  nativeBuildInputs = [
    python3
    pkg-config
  ];

  buildInputs = [ libsecret ];

  dontNpmBuild = true;

  installPhase = ''
    runHook preInstall

    mkdir -p $out/lib
    cp -r node_modules $out/lib

    runHook postInstall
  '';
}
+0 −0

File moved.

Loading