diff options
author | talyz <kim.lindberger@gmail.com> | 2021-11-26 13:39:50 +0100 |
---|---|---|
committer | talyz <kim.lindberger@gmail.com> | 2021-11-30 23:05:48 +0100 |
commit | 679398b160ccb36674b2b21ccf79896daf2d9f70 (patch) | |
tree | 3245f8ffdb0dba105b5ee2311519cec3598e2829 | |
parent | 7f8ebc6d42e0ed6a0c548fb7f88358270f7e46db (diff) | |
download | nixpkgs-679398b160ccb36674b2b21ccf79896daf2d9f70.tar nixpkgs-679398b160ccb36674b2b21ccf79896daf2d9f70.tar.gz nixpkgs-679398b160ccb36674b2b21ccf79896daf2d9f70.tar.bz2 nixpkgs-679398b160ccb36674b2b21ccf79896daf2d9f70.tar.lz nixpkgs-679398b160ccb36674b2b21ccf79896daf2d9f70.tar.xz nixpkgs-679398b160ccb36674b2b21ccf79896daf2d9f70.tar.zst nixpkgs-679398b160ccb36674b2b21ccf79896daf2d9f70.zip |
nodejs: Provide a static v8 library output
Since building nodejs also builds v8, one way to get a static v8 library is to manually assemble it from the leftover object files. This seems like an easier way to get an up-to-date v8 library than trying to keep the v8 package updated.
-rw-r--r-- | pkgs/development/web/nodejs/nodejs.nix | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/pkgs/development/web/nodejs/nodejs.nix b/pkgs/development/web/nodejs/nodejs.nix index 3f0f0e78e07..56c83e38c4f 100644 --- a/pkgs/development/web/nodejs/nodejs.nix +++ b/pkgs/development/web/nodejs/nodejs.nix @@ -58,6 +58,10 @@ let nativeBuildInputs = [ which pkg-config python ] ++ optionals stdenv.isDarwin [ xcbuild ]; + outputs = [ "out" "libv8" ]; + setOutputFlags = false; + moveToDev = false; + configureFlags = let isCross = stdenv.hostPlatform != stdenv.buildPlatform; inherit (stdenv.hostPlatform) gcc isAarch32; @@ -130,6 +134,35 @@ let # install the missing headers for node-gyp cp -r ${concatStringsSep " " copyLibHeaders} $out/include/node + + # assemble a static v8 library and put it in the 'libv8' output + mkdir -p $libv8/lib + pushd out/Release/obj.target + find . -path "./torque_*/**/*.o" -or -path "./v8*/**/*.o" | sort -u >files + ${if stdenv.buildPlatform.isGnu then '' + ar -cqs $libv8/lib/libv8.a @files + '' else '' + cat files | while read -r file; do + ar -cqS $libv8/lib/libv8.a $file + done + ''} + popd + + # copy v8 headers + cp -r deps/v8/include $libv8/ + + # create a pkgconfig file for v8 + major=$(grep V8_MAJOR_VERSION deps/v8/include/v8-version.h | cut -d ' ' -f 3) + minor=$(grep V8_MINOR_VERSION deps/v8/include/v8-version.h | cut -d ' ' -f 3) + patch=$(grep V8_PATCH_LEVEL deps/v8/include/v8-version.h | cut -d ' ' -f 3) + mkdir -p $libv8/lib/pkgconfig + cat > $libv8/lib/pkgconfig/v8.pc << EOF + Name: v8 + Description: V8 JavaScript Engine + Version: $major.$minor.$patch + Libs: -L$libv8/lib -lv8 -pthread -licui18n + Cflags: -I$libv8/include + EOF '' + optionalString (stdenv.isDarwin && enableNpm) '' sed -i 's/raise.*No Xcode or CLT version detected.*/version = "7.0.0"/' $out/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py ''; |