mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-25 06:30:17 +02:00
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.
This commit is contained in:
parent
7f8ebc6d42
commit
679398b160
|
@ -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
|
||||
'';
|
||||
|
|
Loading…
Reference in a new issue