2017-06-22 20:18:47 +01:00
|
|
|
{ stdenv, lib, fetchurl, gyp, readline, python, which, icu, utillinux, cctools }:
|
2014-08-09 20:55:31 +01:00
|
|
|
|
|
|
|
assert readline != null;
|
|
|
|
|
|
|
|
let
|
2016-04-29 00:00:38 +01:00
|
|
|
arch = if stdenv.isArm
|
|
|
|
then (if stdenv.is64bit then "arm64" else "arm")
|
|
|
|
else (if stdenv.is64bit then "x64" else "ia32");
|
|
|
|
armHardFloat = stdenv.isArm && (stdenv.platform.gcc.float or null) == "hard";
|
2014-08-09 20:55:31 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "v8-${version}";
|
2015-07-08 23:10:27 +01:00
|
|
|
version = "3.16.14.11";
|
2014-08-09 20:55:31 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://commondatastorage.googleapis.com/chromium-browser-official/"
|
|
|
|
+ "${name}.tar.bz2";
|
2015-07-08 23:10:27 +01:00
|
|
|
sha256 = "1gpf2xvhxfs5ll3m2jlslsx9jfjbmrbz55iq362plflrvf8mbxhj";
|
2014-08-09 20:55:31 +01:00
|
|
|
};
|
|
|
|
|
2015-10-01 18:40:41 +01:00
|
|
|
postPatch = ''
|
|
|
|
sed -i 's/-Werror//' build/standalone.gypi build/common.gypi
|
|
|
|
'';
|
|
|
|
|
2014-08-09 20:55:31 +01:00
|
|
|
configurePhase = stdenv.lib.optionalString stdenv.isDarwin ''
|
2017-06-22 20:18:47 +01:00
|
|
|
export GYP_DEFINES="mac_deployment_target=$MACOSX_DEPLOYMENT_TARGET"
|
2014-08-09 20:55:31 +01:00
|
|
|
'' + ''
|
|
|
|
PYTHONPATH="tools/generate_shim_headers:$PYTHONPATH" \
|
|
|
|
${gyp}/bin/gyp \
|
|
|
|
-f make \
|
|
|
|
--generator-output="out" \
|
|
|
|
-Dflock_index=0 \
|
|
|
|
-Dv8_enable_i18n_support=1 \
|
|
|
|
-Duse_system_icu=1 \
|
|
|
|
-Dconsole=readline \
|
|
|
|
-Dcomponent=shared_library \
|
|
|
|
-Dv8_target_arch=${arch} \
|
2016-04-29 00:00:38 +01:00
|
|
|
${lib.optionalString armHardFloat "-Dv8_use_arm_eabi_hardfloat=true"} \
|
2014-08-09 20:55:31 +01:00
|
|
|
--depth=. -Ibuild/standalone.gypi \
|
|
|
|
build/all.gyp
|
2017-06-22 20:18:47 +01:00
|
|
|
'' + stdenv.lib.optionalString stdenv.isDarwin ''
|
|
|
|
sed -i 's@/usr/bin/env python@${python}/bin/python@g' out/gyp-mac-tool
|
2014-08-09 20:55:31 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [ which ];
|
2017-06-22 20:18:47 +01:00
|
|
|
buildInputs = [ readline python icu ]
|
|
|
|
++ lib.optional stdenv.isLinux utillinux
|
|
|
|
++ lib.optional stdenv.isDarwin cctools;
|
2015-01-22 01:33:19 +00:00
|
|
|
|
2017-06-22 20:18:47 +01:00
|
|
|
NIX_CFLAGS_COMPILE = "-Wno-error -w";
|
2014-08-09 20:55:31 +01:00
|
|
|
|
|
|
|
buildFlags = [
|
|
|
|
"-C out"
|
|
|
|
"builddir=$(CURDIR)/Release"
|
|
|
|
"BUILDTYPE=Release"
|
|
|
|
];
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -vD out/Release/d8 "$out/bin/d8"
|
2016-11-02 22:29:31 +00:00
|
|
|
${if stdenv.isDarwin then ''
|
|
|
|
install -vD out/Release/libv8.dylib "$out/lib/libv8.dylib"
|
2014-08-09 20:55:31 +01:00
|
|
|
'' else ''
|
2015-01-22 01:33:19 +00:00
|
|
|
install -vD out/Release/lib.target/libv8.so "$out/lib/libv8.so"
|
2014-08-09 20:55:31 +01:00
|
|
|
''}
|
|
|
|
cp -vr include "$out/"
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = if stdenv.isDarwin then ''
|
2014-08-31 08:04:42 +01:00
|
|
|
install_name_tool -change /usr/local/lib/libv8.dylib $out/lib/libv8.dylib $out/bin/d8
|
|
|
|
install_name_tool -id $out/lib/libv8.dylib $out/lib/libv8.dylib
|
2014-08-09 20:55:31 +01:00
|
|
|
'' else null;
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "V8 is Google's open source JavaScript engine";
|
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
|
|
|
license = licenses.bsd3;
|
|
|
|
};
|
|
|
|
}
|