about summary refs log tree commit diff
path: root/pkgs/development/web/nodejs/nodejs.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/web/nodejs/nodejs.nix')
-rw-r--r--pkgs/development/web/nodejs/nodejs.nix33
1 files changed, 33 insertions, 0 deletions
diff --git a/pkgs/development/web/nodejs/nodejs.nix b/pkgs/development/web/nodejs/nodejs.nix
index 3f0f0e78e07a..56c83e38c4ff 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
     '';