diff options
author | oxalica <oxalicc@pm.me> | 2020-06-21 20:41:38 +0800 |
---|---|---|
committer | Jon <jonringer@users.noreply.github.com> | 2020-09-22 09:13:53 -0700 |
commit | 11c36334bfebed78ee32b8de333938c57a703f15 (patch) | |
tree | 988f25971305b1e3b360525a6bd7a8b712eb4e96 /pkgs/misc/vscode-extensions | |
parent | bd4805b659f5691010a1845e4f5c123ff4eb184a (diff) |
vscode-extensions.vadimcn.vscode-lldb: init at 1.5.3
Diffstat (limited to 'pkgs/misc/vscode-extensions')
5 files changed, 191 insertions, 1 deletions
diff --git a/pkgs/misc/vscode-extensions/default.nix b/pkgs/misc/vscode-extensions/default.nix index 04eabef9ec3c3..a0229f595d4e3 100644 --- a/pkgs/misc/vscode-extensions/default.nix +++ b/pkgs/misc/vscode-extensions/default.nix @@ -1,4 +1,4 @@ -{ stdenv, callPackage, vscode-utils, llvmPackages_8 }: +{ stdenv, callPackage, vscode-utils, llvmPackages_8, llvmPackages_latest }: let inherit (vscode-utils) buildVscodeMarketplaceExtension; @@ -178,6 +178,10 @@ in }; }; + vadimcn.vscode-lldb = callPackage ./vscode-lldb { + lldb = llvmPackages_latest.lldb; + }; + vscodevim.vim = buildVscodeMarketplaceExtension { mktplcRef = { name = "vim"; diff --git a/pkgs/misc/vscode-extensions/vscode-lldb/build-deps/package.json b/pkgs/misc/vscode-extensions/vscode-lldb/build-deps/package.json new file mode 100644 index 0000000000000..6e73ee446d86d --- /dev/null +++ b/pkgs/misc/vscode-extensions/vscode-lldb/build-deps/package.json @@ -0,0 +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" + } +} diff --git a/pkgs/misc/vscode-extensions/vscode-lldb/cmake-build-extension-only.patch b/pkgs/misc/vscode-extensions/vscode-lldb/cmake-build-extension-only.patch new file mode 100644 index 0000000000000..db62552b913b5 --- /dev/null +++ b/pkgs/misc/vscode-extensions/vscode-lldb/cmake-build-extension-only.patch @@ -0,0 +1,45 @@ +--- 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}") +-else() +- message(FATAL_ERROR "LLDB_ROOT not set." ) +-endif() +- + # 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) + 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 +- WORKING_DIRECTORY ${CMAKE_BINARY_DIR} +- RESULT_VARIABLE Result +-) +-if (NOT ${Result} EQUAL 0) +- message(FATAL_ERROR "npm intall failed: ${Result}") +-endif() +- + # Copy it back, so we can commit the lock file. + file(COPY ${CMAKE_CURRENT_BINARY_DIR}/package-lock.json DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}) + \ No newline at end of file diff --git a/pkgs/misc/vscode-extensions/vscode-lldb/default.nix b/pkgs/misc/vscode-extensions/vscode-lldb/default.nix new file mode 100644 index 0000000000000..f22c9df36a1ba --- /dev/null +++ b/pkgs/misc/vscode-extensions/vscode-lldb/default.nix @@ -0,0 +1,106 @@ +{ lib, stdenv, vscode-utils, fetchFromGitHub, rustPlatform, makeWrapper, jq +, nodePackages, cmake, nodejs, unzip, python3, lldb, breakpointHook +, setDefaultLldbPath ? true +}: +assert lib.versionAtLeast python3.version "3.5"; +let + publisher = "vadimcn"; + name = "vscode-lldb"; + version = "1.5.3"; + + dylibExt = stdenv.hostPlatform.extensions.sharedLibrary; + + src = fetchFromGitHub { + owner = "vadimcn"; + repo = "vscode-lldb"; + rev = "v${version}"; + sha256 = "1139945j3z0fxc3nlyvd81k0ypymqsj051idrbgbibwshpi86y93"; + fetchSubmodules = true; + }; + + adapter = rustPlatform.buildRustPackage { + pname = "${name}-adapter"; + inherit version src; + + cargoSha256 = "0jl4msf2jcjxddwqkx8fr0c35wg4vwvg5c19mihri1v34i09zc5r"; + + # It will pollute the build environment of `buildRustPackage`. + cargoPatches = [ ./reset-cargo-config.patch ]; + + 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" + ''; + }; + + build-deps = nodePackages."vscode-lldb-build-deps-../../misc/vscode-extensions/vscode-lldb/build-deps"; + + vsix = stdenv.mkDerivation { + name = "${name}-${version}-vsix"; + inherit src; + + # Only build the extension. We handle `adapter` and `lldb` with nix. + patches = [ ./cmake-build-extension-only.patch ]; + + nativeBuildInputs = [ cmake nodejs unzip breakpointHook ]; + + 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 + ''; + + vscodeExtUniqueId = "${publisher}.${name}"; + + meta = with lib; { + description = "A native debugger extension for VSCode based on LLDB"; + homepage = "https://github.com/vadimcn/vscode-lldb"; + license = with licenses; [ mit ]; + maintainers = with maintainers; [ oxalica ]; + platforms = platforms.all; + }; +} diff --git a/pkgs/misc/vscode-extensions/vscode-lldb/reset-cargo-config.patch b/pkgs/misc/vscode-extensions/vscode-lldb/reset-cargo-config.patch new file mode 100644 index 0000000000000..300f8cd96ef99 --- /dev/null +++ b/pkgs/misc/vscode-extensions/vscode-lldb/reset-cargo-config.patch @@ -0,0 +1,11 @@ +--- a/.cargo/config ++++ b/.cargo/config +@@ -1,8 +0,0 @@ +-[build] +-target-dir = "build/target" +- +-[target.armv7-unknown-linux-gnueabihf] +-linker = "arm-linux-gnueabihf-gcc" +- +-[target.aarch64-unknown-linux-gnu] +-linker = "aarch64-linux-gnu-gcc" |