2019-03-01 00:19:04 +00:00
|
|
|
{ stdenv, lib, fetchgit, fetchFromGitHub
|
2021-04-27 22:06:21 +01:00
|
|
|
, gn, ninja, python, pythonPackages, glib, pkg-config, icu
|
2019-03-01 00:19:04 +00:00
|
|
|
, xcbuild, darwin
|
|
|
|
, fetchpatch
|
2016-07-23 18:17:13 +01:00
|
|
|
}:
|
2012-01-18 20:32:23 +00:00
|
|
|
|
2016-07-23 18:17:13 +01:00
|
|
|
let
|
|
|
|
git_url = "https://chromium.googlesource.com";
|
|
|
|
|
2019-03-01 00:19:04 +00:00
|
|
|
# This data is from the DEPS file in the root of a V8 checkout
|
2016-07-23 18:17:13 +01:00
|
|
|
deps = {
|
2016-07-24 00:03:24 +01: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-03-12 11:27:21 +00:00
|
|
|
rev = "dab187b372fc17e51f5b9fad8201813d0aed5129";
|
|
|
|
sha256 = "0dmpj9hj4xv3xb0fl1kb9hm4bhpbs2s5csx3z8cgjd5vwvhdzig4";
|
2016-07-24 00:03:24 +01:00
|
|
|
};
|
2019-08-13 22:52:01 +01:00
|
|
|
build = fetchgit {
|
2019-03-01 00:19:04 +00:00
|
|
|
url = "${git_url}/chromium/src/build.git";
|
2021-03-12 11:27:21 +00:00
|
|
|
rev = "26e9d485d01d6e0eb9dadd21df767a63494c8fea";
|
|
|
|
sha256 = "1jjvsgj0cs97d26i3ba531ic1f9gqan8x7z4aya8yl8jx02l342q";
|
2016-07-24 00:03:24 +01:00
|
|
|
};
|
2019-03-01 00:19:04 +00:00
|
|
|
"third_party/googletest/src" = fetchgit {
|
|
|
|
url = "${git_url}/external/github.com/google/googletest.git";
|
2021-03-12 11:27:21 +00:00
|
|
|
rev = "e3f0319d89f4cbf32993de595d984183b1a9fc57";
|
|
|
|
sha256 = "18xz71l2xjrqsc0q317whgw4xi1i5db24zcj7v04f5g6r1hyf1a5";
|
2016-07-24 00:03:24 +01:00
|
|
|
};
|
2019-03-01 00:19:04 +00:00
|
|
|
"third_party/icu" = fetchgit {
|
|
|
|
url = "${git_url}/chromium/deps/icu.git";
|
2021-03-12 11:27:21 +00:00
|
|
|
rev = "f2223961702f00a8833874b0560d615a2cc42738";
|
|
|
|
sha256 = "0z5p53kbrjfkjn0i12dpk55cp8976j2zk7a4wk88423s2c5w87zl";
|
2016-07-24 00:03:24 +01:00
|
|
|
};
|
2019-03-01 00:19:04 +00:00
|
|
|
"third_party/jinja2" = fetchgit {
|
|
|
|
url = "${git_url}/chromium/src/third_party/jinja2.git";
|
|
|
|
rev = "b41863e42637544c2941b574c7877d3e1f663e25";
|
|
|
|
sha256 = "1qgilclkav67m6cl2xq2kmzkswrkrb2axc2z8mw58fnch4j1jf1r";
|
2016-07-23 18:17:13 +01:00
|
|
|
};
|
2019-03-01 00:19:04 +00:00
|
|
|
"third_party/markupsafe" = fetchgit {
|
|
|
|
url = "${git_url}/chromium/src/third_party/markupsafe.git";
|
|
|
|
rev = "8f45f5cfa0009d2a70589bcda0349b8cb2b72783";
|
|
|
|
sha256 = "168ppjmicfdh4i1l0l25s86mdbrz9fgxmiq1rx33x79mph41scfz";
|
2016-07-23 18:17:13 +01:00
|
|
|
};
|
2021-03-12 11:27:21 +00:00
|
|
|
"third_party/zlib" = fetchgit {
|
|
|
|
url = "${git_url}/chromium/src/third_party/zlib.git";
|
|
|
|
rev = "156be8c52f80cde343088b4a69a80579101b6e67";
|
|
|
|
sha256 = "0hxbkkzmlv714fjq2jlp5dd2jc339xyh6gkjx1sz3srwv33mlk92";
|
|
|
|
};
|
2016-07-23 18:17:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "v8";
|
2021-03-12 11:27:21 +00:00
|
|
|
version = "8.4.255";
|
2016-07-23 18:17:13 +01:00
|
|
|
|
2019-03-01 00:19:04 +00:00
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
patches = [
|
2021-04-27 22:06:21 +01:00
|
|
|
# Remove unrecognized clang debug flags
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://raw.githubusercontent.com/saiarcot895/chromium-ubuntu-build/663dbfc492fd2f8ba28d9af40fb3b1327e6aa56e/debian/patches/revert-Xclang-instcombine-lower-dbg-declare.patch";
|
|
|
|
sha256 = "07qp4bjgbwbdrzqslvl2bgbzr3v97b9isbp0539x3lc8cy3h02g1";
|
|
|
|
})
|
2019-03-01 00:19:04 +00:00
|
|
|
./darwin.patch
|
2021-03-12 11:27:21 +00:00
|
|
|
./gcc_arm.patch # Fix building zlib with gcc on aarch64, from https://gist.github.com/Adenilson/d973b6fd96c7709d33ddf08cf1dcb149
|
2019-03-01 00:19:04 +00:00
|
|
|
];
|
2016-07-23 18:17:13 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "v8";
|
|
|
|
repo = "v8";
|
|
|
|
rev = version;
|
2021-03-12 11:27:21 +00:00
|
|
|
sha256 = "07ymw4kqbz7kv311gpk5bs5q90wj73n2q7jkyfhqk4hvhs1q5bw7";
|
2016-07-23 18:17:13 +01: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 18:17:13 +01:00
|
|
|
'';
|
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
postPatch = lib.optionalString stdenv.isAarch64 ''
|
2019-09-12 13:13:26 +01:00
|
|
|
substituteInPlace build/toolchain/linux/BUILD.gn \
|
|
|
|
--replace 'toolprefix = "aarch64-linux-gnu-"' 'toolprefix = ""'
|
2021-04-27 22:06:21 +01:00
|
|
|
'' + 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'
|
2019-09-12 13:13:26 +01:00
|
|
|
'';
|
|
|
|
|
2019-03-01 00:19:04 +00:00
|
|
|
gnFlags = [
|
|
|
|
"use_custom_libcxx=false"
|
2020-10-14 00:46:17 +01: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 22:06:21 +01: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"
|
2021-04-27 22:06:21 +01:00
|
|
|
"init_stack_vars=false"
|
2019-03-01 00:19:04 +00:00
|
|
|
# ''custom_toolchain="//build/toolchain/linux/unbundle:default"''
|
|
|
|
''host_toolchain="//build/toolchain/linux/unbundle:default"''
|
|
|
|
''v8_snapshot_toolchain="//build/toolchain/linux/unbundle:default"''
|
2021-01-21 17:00:13 +00:00
|
|
|
] ++ lib.optional stdenv.cc.isClang ''clang_base_path="${stdenv.cc}"'';
|
2019-03-01 00:19:04 +00:00
|
|
|
|
2021-03-12 11:27:21 +00:00
|
|
|
NIX_CFLAGS_COMPILE = "-O2";
|
2021-04-27 22:06:21 +01:00
|
|
|
FORCE_MAC_SDK_MIN = stdenv.targetPlatform.sdkVer or "10.12";
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
gn
|
|
|
|
ninja
|
|
|
|
pkg-config
|
|
|
|
python
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
xcbuild
|
|
|
|
darwin.DarwinTools
|
|
|
|
pythonPackages.setuptools
|
|
|
|
];
|
2019-03-01 00:19:04 +00:00
|
|
|
buildInputs = [ glib icu ];
|
|
|
|
|
|
|
|
ninjaFlags = [ ":d8" "v8_monolith" ];
|
2016-07-23 18:17:13 +01:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
2019-03-01 00:19:04 +00:00
|
|
|
install -D d8 $out/bin/d8
|
|
|
|
install -D obj/libv8_monolith.a $out/lib/libv8.a
|
|
|
|
cp -r ../../include $out
|
2019-09-08 02:09:13 +01: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 18:17:13 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
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 18:17:13 +01:00
|
|
|
license = licenses.bsd3;
|
|
|
|
};
|
|
|
|
}
|