2019-03-01 00:19:04 +00:00
|
|
|
{ stdenv, lib, fetchgit, fetchFromGitHub
|
2021-09-15 17:20:21 +00:00
|
|
|
, gn, ninja, python3, glib, pkg-config, icu
|
2019-03-01 00:19:04 +00:00
|
|
|
, xcbuild, darwin
|
|
|
|
, fetchpatch
|
2022-09-01 04:55:06 +00:00
|
|
|
, llvmPackages
|
|
|
|
, symlinkJoin
|
2016-07-23 17:17:13 +00:00
|
|
|
}:
|
2012-01-18 20:32:23 +00:00
|
|
|
|
2021-09-15 17:20:21 +00:00
|
|
|
# Use update.sh to update all checksums.
|
|
|
|
|
2016-07-23 17:17:13 +00:00
|
|
|
let
|
2021-09-15 17:20:21 +00:00
|
|
|
version = "9.7.106.18";
|
|
|
|
v8Src = fetchgit {
|
|
|
|
url = "https://chromium.googlesource.com/v8/v8";
|
|
|
|
rev = version;
|
|
|
|
sha256 = "0cb3w733w1xn6zq9dsr43nx6llcg9hrmb2dkxairarj9c0igpzyh";
|
|
|
|
};
|
|
|
|
|
2016-07-23 17:17:13 +00:00
|
|
|
git_url = "https://chromium.googlesource.com";
|
|
|
|
|
2021-09-15 17:20:21 +00:00
|
|
|
# This data is from the DEPS file in the root of a V8 checkout.
|
2016-07-23 17:17:13 +00:00
|
|
|
deps = {
|
2016-07-23 23:03:24 +00:00
|
|
|
"base/trace_event/common" = fetchgit {
|
2019-03-01 00:19:04 +00:00
|
|
|
url = "${git_url}/chromium/src/base/trace_event/common.git";
|
2021-09-15 17:20:21 +00:00
|
|
|
rev = "7f36dbc19d31e2aad895c60261ca8f726442bfbb";
|
|
|
|
sha256 = "01b2fhbxznqbakxv42ivrzg6w8l7i9yrd9nf72d6p5xx9dm993j4";
|
2016-07-23 23:03:24 +00:00
|
|
|
};
|
2021-09-15 17:20:21 +00:00
|
|
|
"build" = fetchgit {
|
2019-03-01 00:19:04 +00:00
|
|
|
url = "${git_url}/chromium/src/build.git";
|
2021-09-15 17:20:21 +00:00
|
|
|
rev = "cf325916d58a194a935c26a56fcf6b525d1e2bf4";
|
|
|
|
sha256 = "1ix4h1cpx9bvgln8590xh7lllhsd9w1hd5k9l1gx5yxxrmywd3s4";
|
2016-07-23 23:03:24 +00:00
|
|
|
};
|
2019-03-01 00:19:04 +00:00
|
|
|
"third_party/googletest/src" = fetchgit {
|
|
|
|
url = "${git_url}/external/github.com/google/googletest.git";
|
2021-09-15 17:20:21 +00:00
|
|
|
rev = "16f637fbf4ffc3f7a01fa4eceb7906634565242f";
|
|
|
|
sha256 = "11012k3c3mxzdwcw2iparr9lrckafpyhqzclsj26hmfbgbdi0rrh";
|
2016-07-23 23:03:24 +00:00
|
|
|
};
|
2019-03-01 00:19:04 +00:00
|
|
|
"third_party/icu" = fetchgit {
|
|
|
|
url = "${git_url}/chromium/deps/icu.git";
|
2021-09-15 17:20:21 +00:00
|
|
|
rev = "eedbaf76e49d28465d9119b10c30b82906e606ff";
|
|
|
|
sha256 = "0mppvx7wf9zlqjsfaa1cf06brh1fjb6nmiib0lhbb9hd55mqjdjj";
|
|
|
|
};
|
|
|
|
"third_party/zlib" = fetchgit {
|
|
|
|
url = "${git_url}/chromium/src/third_party/zlib.git";
|
|
|
|
rev = "6da1d53b97c89b07e47714d88cab61f1ce003c68";
|
|
|
|
sha256 = "0v7ylmbwfwv6w6wp29qdf77kjjnfr2xzin08n0v1yvbhs01h5ppy";
|
2016-07-23 23:03:24 +00:00
|
|
|
};
|
2019-03-01 00:19:04 +00:00
|
|
|
"third_party/jinja2" = fetchgit {
|
|
|
|
url = "${git_url}/chromium/src/third_party/jinja2.git";
|
2021-09-15 17:20:21 +00:00
|
|
|
rev = "ee69aa00ee8536f61db6a451f3858745cf587de6";
|
|
|
|
sha256 = "1fsnd5h0gisfp8bdsfd81kk5v4mkqf8z368c7qlm1qcwc4ri4x7a";
|
2016-07-23 17:17:13 +00:00
|
|
|
};
|
2019-03-01 00:19:04 +00:00
|
|
|
"third_party/markupsafe" = fetchgit {
|
|
|
|
url = "${git_url}/chromium/src/third_party/markupsafe.git";
|
2021-09-15 17:20:21 +00:00
|
|
|
rev = "1b882ef6372b58bfd55a3285f37ed801be9137cd";
|
|
|
|
sha256 = "1jnjidbh03lhfaawimkjxbprmsgz4snr0jl06630dyd41zkdw5kr";
|
2021-03-12 11:27:21 +00:00
|
|
|
};
|
2016-07-23 17:17:13 +00:00
|
|
|
};
|
|
|
|
|
2021-09-15 17:20:21 +00:00
|
|
|
# See `gn_version` in DEPS.
|
|
|
|
gnSrc = fetchgit {
|
|
|
|
url = "https://gn.googlesource.com/gn";
|
|
|
|
rev = "8926696a4186279489cc2b8d768533e61bba73d7";
|
|
|
|
sha256 = "1084lnyb0a1khbgjvak05fcx6jy973wqvsf77n0alxjys18sg2yk";
|
|
|
|
};
|
|
|
|
|
|
|
|
myGn = gn.overrideAttrs (oldAttrs: {
|
|
|
|
version = "for-v8";
|
|
|
|
src = gnSrc;
|
|
|
|
});
|
|
|
|
|
2016-07-23 17:17:13 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "v8";
|
2021-09-15 17:20:21 +00:00
|
|
|
inherit version;
|
2016-07-23 17:17:13 +00:00
|
|
|
|
2019-03-01 00:19:04 +00:00
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./darwin.patch
|
|
|
|
];
|
2016-07-23 17:17:13 +00:00
|
|
|
|
2021-09-15 17:20:21 +00:00
|
|
|
src = v8Src;
|
2016-07-23 17:17:13 +00:00
|
|
|
|
|
|
|
postUnpack = ''
|
|
|
|
${lib.concatStringsSep "\n" (
|
|
|
|
lib.mapAttrsToList (n: v: ''
|
|
|
|
mkdir -p $sourceRoot/${n}
|
|
|
|
cp -r ${v}/* $sourceRoot/${n}
|
|
|
|
'') deps)}
|
2019-03-01 00:19:04 +00:00
|
|
|
chmod u+w -R .
|
2016-07-23 17:17:13 +00:00
|
|
|
'';
|
|
|
|
|
2021-09-15 17:20:21 +00:00
|
|
|
postPatch = ''
|
|
|
|
${lib.optionalString stdenv.isAarch64 ''
|
|
|
|
substituteInPlace build/toolchain/linux/BUILD.gn \
|
|
|
|
--replace 'toolprefix = "aarch64-linux-gnu-"' 'toolprefix = ""'
|
|
|
|
''}
|
|
|
|
${lib.optionalString stdenv.isDarwin ''
|
|
|
|
substituteInPlace build/config/compiler/compiler.gni \
|
|
|
|
--replace 'strip_absolute_paths_from_debug_symbols = true' \
|
|
|
|
'strip_absolute_paths_from_debug_symbols = false'
|
|
|
|
substituteInPlace build/config/compiler/BUILD.gn \
|
|
|
|
--replace 'current_toolchain == host_toolchain || !use_xcode_clang' \
|
|
|
|
'false'
|
|
|
|
''}
|
2023-01-21 17:25:58 +00:00
|
|
|
${lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) ''
|
|
|
|
substituteInPlace build/config/compiler/BUILD.gn \
|
|
|
|
--replace "-Wl,-fatal_warnings" ""
|
|
|
|
''}
|
2021-09-15 17:20:21 +00:00
|
|
|
touch build/config/gclient_args.gni
|
2023-02-04 09:19:58 +00:00
|
|
|
sed '1i#include <utility>' -i src/heap/cppgc/prefinalizer-handler.h # gcc12
|
2019-09-12 12:13:26 +00:00
|
|
|
'';
|
|
|
|
|
2022-09-01 04:55:06 +00:00
|
|
|
llvmCcAndBintools = symlinkJoin { name = "llvmCcAndBintools"; paths = [ stdenv.cc llvmPackages.llvm ]; };
|
|
|
|
|
2019-03-01 00:19:04 +00:00
|
|
|
gnFlags = [
|
|
|
|
"use_custom_libcxx=false"
|
2020-10-13 23:46:17 +00:00
|
|
|
"is_clang=${lib.boolToString stdenv.cc.isClang}"
|
2019-03-01 00:19:04 +00:00
|
|
|
"use_sysroot=false"
|
|
|
|
# "use_system_icu=true"
|
2021-04-27 21:06:21 +00:00
|
|
|
"clang_use_chrome_plugins=false"
|
2019-03-01 00:19:04 +00:00
|
|
|
"is_component_build=false"
|
|
|
|
"v8_use_external_startup_data=false"
|
|
|
|
"v8_monolithic=true"
|
|
|
|
"is_debug=true"
|
|
|
|
"is_official_build=false"
|
|
|
|
"treat_warnings_as_errors=false"
|
|
|
|
"v8_enable_i18n_support=true"
|
|
|
|
"use_gold=false"
|
|
|
|
# ''custom_toolchain="//build/toolchain/linux/unbundle:default"''
|
|
|
|
''host_toolchain="//build/toolchain/linux/unbundle:default"''
|
|
|
|
''v8_snapshot_toolchain="//build/toolchain/linux/unbundle:default"''
|
2022-09-01 04:55:06 +00:00
|
|
|
] ++ lib.optional stdenv.cc.isClang ''clang_base_path="${llvmCcAndBintools}"''
|
|
|
|
++ lib.optional stdenv.isDarwin ''use_lld=false'';
|
2019-03-01 00:19:04 +00:00
|
|
|
|
2023-02-19 19:23:32 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = "-O2";
|
2021-04-27 21:06:21 +00:00
|
|
|
FORCE_MAC_SDK_MIN = stdenv.targetPlatform.sdkVer or "10.12";
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2021-09-15 17:20:21 +00:00
|
|
|
myGn
|
2021-04-27 21:06:21 +00:00
|
|
|
ninja
|
|
|
|
pkg-config
|
2021-09-15 17:20:21 +00:00
|
|
|
python3
|
2021-04-27 21:06:21 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
xcbuild
|
2022-09-01 04:55:06 +00:00
|
|
|
llvmPackages.llvm
|
2021-09-15 17:20:21 +00:00
|
|
|
python3.pkgs.setuptools
|
2021-04-27 21:06:21 +00:00
|
|
|
];
|
2019-03-01 00:19:04 +00:00
|
|
|
buildInputs = [ glib icu ];
|
|
|
|
|
|
|
|
ninjaFlags = [ ":d8" "v8_monolith" ];
|
2016-07-23 17:17:13 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
2019-03-01 00:19:04 +00:00
|
|
|
install -D d8 $out/bin/d8
|
2021-09-15 17:20:21 +00:00
|
|
|
install -D -m644 obj/libv8_monolith.a $out/lib/libv8.a
|
|
|
|
install -D -m644 icudtl.dat $out/share/v8/icudtl.dat
|
2022-05-15 01:30:56 +00:00
|
|
|
ln -s libv8.a $out/lib/libv8_monolith.a
|
2019-03-01 00:19:04 +00:00
|
|
|
cp -r ../../include $out
|
2019-09-08 01:09:13 +00:00
|
|
|
|
|
|
|
mkdir -p $out/lib/pkgconfig
|
|
|
|
cat > $out/lib/pkgconfig/v8.pc << EOF
|
|
|
|
Name: v8
|
|
|
|
Description: V8 JavaScript Engine
|
|
|
|
Version: ${version}
|
|
|
|
Libs: -L$out/lib -lv8 -pthread
|
|
|
|
Cflags: -I$out/include
|
|
|
|
EOF
|
2016-07-23 17:17:13 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
2023-02-11 19:13:32 +00:00
|
|
|
homepage = "https://v8.dev/";
|
2016-07-23 17:17:13 +00:00
|
|
|
description = "Google's open source JavaScript engine";
|
2019-03-01 00:19:04 +00:00
|
|
|
maintainers = with maintainers; [ cstrahan proglodyte matthewbauer ];
|
|
|
|
platforms = platforms.unix;
|
2016-07-23 17:17:13 +00:00
|
|
|
license = licenses.bsd3;
|
|
|
|
};
|
|
|
|
}
|