vscode-extensions.vadimcn.vscode-lldb: 1.5.3 -> 1.6.1 and refactor

This commit is contained in:
oxalica 2020-10-13 03:05:09 +08:00
parent 35fcd0461e
commit f302288918
No known key found for this signature in database
GPG Key ID: CED392DE0C483D00
6 changed files with 157 additions and 118 deletions

@ -1,4 +1,4 @@
{ config, lib, callPackage, vscode-utils, nodePackages,llvmPackages_8, llvmPackages_latest }:
{ config, lib, callPackage, vscode-utils, nodePackages,llvmPackages_8 }:
let
inherit (vscode-utils) buildVscodeMarketplaceExtension;
@ -689,9 +689,7 @@ let
};
};
vadimcn.vscode-lldb = callPackage ./vscode-lldb {
lldb = llvmPackages_latest.lldb;
};
vadimcn.vscode-lldb = callPackage ./vscode-lldb {};
vincaslt.highlight-matching-tag = buildVscodeMarketplaceExtension {
mktplcRef = {

@ -1,24 +1,24 @@
{
"name": "vscode-lldb",
"version": "1.5.3",
"dependencies": {
"@types/json5": "^0.0.30",
"@types/mocha": "^7.0.1",
"@types/node": "^8.10.50",
"@types/vscode": "^1.31.0",
"@types/yauzl": "^2.9.0",
"json5": "^2.1.0",
"memory-streams": "^0.1.3",
"mocha": "^7.0.1",
"source-map-support": "^0.5.12",
"string-argv": "^0.3.1",
"ts-loader": "^6.2.1",
"typescript": "^3.7.0",
"vsce": "^1.73.0",
"vscode-debugadapter-testsupport": "^1.35.0",
"vscode-debugprotocol": "^1.35.0",
"webpack": "^4.39.1",
"webpack-cli": "^3.3.7",
"yauzl": "^2.10.0"
}
"name": "vscode-lldb",
"version": "1.6.1",
"dependencies": {
"string-argv": "^0.3.1",
"yaml": "^1.10.0",
"yauzl": "^2.10.0",
"@types/vscode": "^1.31.0",
"@types/node": "^8.10.50",
"@types/mocha": "^7.0.1",
"@types/yauzl": "^2.9.0",
"@types/json5": "^0.0.30",
"typescript": "^3.7.0",
"mocha": "^7.0.1",
"source-map-support": "^0.5.12",
"memory-streams": "^0.1.3",
"vscode-debugprotocol": "^1.35.0",
"vscode-debugadapter-testsupport": "^1.35.0",
"vsce": "^1.73.0",
"webpack": "^4.39.1",
"webpack-cli": "^3.3.7",
"ts-loader": "^6.2.1"
}
}

@ -1,35 +1,25 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 890abd4..157a8a1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,13 +9,6 @@ include(cmake/CopyFiles.cmake)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_INSTALL_PREFIX $ENV{HOME}/.vscode/extensions/vscode-lldb CACHE PATH "Install location")
-set(LLDB_ROOT $ENV{LLDB_ROOT} CACHE PATH "Root of LLDB build directory")
-if (LLDB_ROOT)
- message("Using LLDB from ${LLDB_ROOT}")
@@ -16,13 +16,6 @@ endif()
set(VERSION "${VERSION}${VERSION_SUFFIX}")
message("Version ${VERSION}")
-set(LLDB_PACKAGE $ENV{LLDB_PACKAGE} CACHE PATH "Zip archive containing LLDB files")
-if (LLDB_PACKAGE)
- message("Using LLDB_PACKAGE=${LLDB_PACKAGE}")
-else()
- message(FATAL_ERROR "LLDB_ROOT not set." )
- message(FATAL_ERROR "LLDB_PACKAGE not set." )
-endif()
-
set(TEST_TIMEOUT 5000 CACHE STRING "Test timeout [ms]")
# General OS-specific definitions
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(DylibPrefix lib)
@@ -64,8 +57,9 @@ set(UpdateFile ${CMAKE_COMMAND} -E copy_if_different)
# Adapter
-add_subdirectory(adapter)
-add_subdirectory(lldb)
+add_custom_target(adapter)
+add_custom_target(lldb)
+add_custom_target(codelldb)
# Extension package content
@@ -74,16 +68,6 @@ configure_file(package.json ${CMAKE_CURRENT_BINARY_DIR}/package.json @ONLY)
@@ -87,16 +80,6 @@ configure_file(package.json ${CMAKE_CURRENT_BINARY_DIR}/package.json @ONLY)
configure_file(webpack.config.js ${CMAKE_CURRENT_BINARY_DIR}/webpack.config.js @ONLY)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/package-lock.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
-# Run 'npm install'
-execute_process(
- COMMAND ${NPM} install
@ -42,4 +32,3 @@
-
# Copy it back, so we can commit the lock file.
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/package-lock.json DESTINATION ${CMAKE_CURRENT_SOURCE_DIR})

@ -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;
};
adapter = rustPlatform.buildRustPackage {
pname = "${name}-adapter";
inherit version src;
lldb = callPackage ./lldb.nix {};
cargoSha256 = "0jl4msf2jcjxddwqkx8fr0c35wg4vwvg5c19mihri1v34i09zc5r";
adapter = rustPlatform.buildRustPackage {
pname = "${pname}-adapter";
inherit version src;
# 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;
cargoFlags = [
"--lib"
"--bin=codelldb"
"--features=weak-linkage"
];
# `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"
'';
# 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} .
'';
makeFlags = [ "vsix_bootstrap" ];
installPhase = ''
unzip ./codelldb-bootstrap.vsix 'extension/*' -d ./vsix-extracted
mv vsix-extracted/extension $out
ln -s ${adapter}/adapter $out
# Mark that adapter and lldb are installed.
touch $out/platform.ok
'';
dontStrip = true;
dontPatchELF = true;
};
in vscode-utils.buildVscodeExtension {
inherit name;
src = vsix;
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
postConfigure = ''
cp -r ${nodeDeps}/lib/node_modules/vscode-lldb/{node_modules,package-lock.json} .
'';
vscodeExtUniqueId = "${publisher}.${name}";
cmakeFlags = [
# Do not append timestamp to version.
"-DVERSION_SUFFIX="
];
makeFlags = [ "vsix_bootstrap" ];
installPhase = ''
ext=$out/$installPrefix
runHook preInstall
unzip ./codelldb-bootstrap.vsix 'extension/*' -d ./vsix-extracted
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
runHook postInstall
'';
# `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"
'';
passthru = {
inherit lldb adapter;
};
meta = with lib; {
description = "A native debugger extension for VSCode based on LLDB";

@ -0,0 +1,23 @@
# Patched lldb for Rust language support.
{ lldb_11, fetchFromGitHub }:
let
llvmSrc = fetchFromGitHub {
owner = "vadimcn";
repo = "llvm-project";
rev = "dd7efd9ea2d38e3227bc2e83a99772aceeb44242";
sha256 = "sha256-XY8J8Ie1cWb6ok72Gju/KUxZ4fIFQVitYVnuCezGRKQ=";
};
in lldb_11.overrideAttrs (oldAttrs: {
src = "${llvmSrc}/lldb";
passthru = (oldAttrs.passthru or {}) // {
inherit llvmSrc;
};
doInstallCheck = true;
postInstallCheck = (oldAttrs.postInstallCheck or "") + ''
versionOutput="$($out/bin/lldb --version)"
echo "'lldb --version' returns: $versionOutput"
echo "$versionOutput" | grep -q 'rust-enabled'
'';
})

@ -0,0 +1,35 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p git jq nix-prefetch
set -eo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
if [[ $# -ne 1 ]]; then
echo "Usage: ./update.sh <version>"
exit 1
fi
echo "
FIXME: This script doesn't update patched lldb. Please manually check branches
of https://github.com/vadimcn/llvm-project and update lldb with correct version of LLVM.
"
nixpkgs=../../../..
nixFile=./default.nix
owner=vadimcn
repo=vscode-lldb
version="$1"
sed -E 's/\bversion = ".*?"/version = "'$version'"/' --in-place "$nixFile"
srcHash=$(nix-prefetch fetchFromGitHub --owner vadimcn --repo vscode-lldb --rev "v$version" --fetchSubmodules)
sed -E 's/\bsha256 = ".*?"/sha256 = "'$srcHash'"/' --in-place "$nixFile"
cargoHash=$(nix-prefetch "{ sha256 }: (import $nixpkgs {}).vscode-extensions.vadimcn.vscode-lldb.adapter.cargoDeps.overrideAttrs (_: { outputHash = sha256; })")
sed -E 's#\bcargoSha256 = ".*?"#cargoSha256 = "'$cargoHash'"#' --in-place "$nixFile"
src="$(nix-build $nixpkgs -A vscode-extensions.vadimcn.vscode-lldb.src --no-out-link)"
jq '{ name, version: $version, dependencies: (.dependencies + .devDependencies) }' \
--arg version "$version" \
"$src/package.json" \
> build-deps/package.json
# Regenerate nodePackages.
cd "$nixpkgs/pkgs/development/node-packages"
exec ./generate.sh