python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / libraries / v8 / 8_x.nix
blobb5184bafcbff907745f24c03de254e48de7c5404
1 { stdenv, lib, fetchgit, fetchFromGitHub
2 , gn, ninja, python39, glib, pkg-config, icu
3 , xcbuild, darwin
4 , fetchpatch
5 }:
7 # Use update.sh to update all checksums.
9 let
10   version = "8.8.278.14";
11   v8Src = fetchgit {
12     url = "https://chromium.googlesource.com/v8/v8";
13     rev = version;
14     sha256 = "0w6zldyas9w6p394876ssn3pnr5rjzjy1a5dcsmdkfj51m4rlg8m";
15   };
17   git_url = "https://chromium.googlesource.com";
19   # This data is from the DEPS file in the root of a V8 checkout.
20   deps = {
21     "base/trace_event/common" = fetchgit {
22       url    = "${git_url}/chromium/src/base/trace_event/common.git";
23       rev    = "eb94f1c7aa96207f469008f29989a43feb2718f8";
24       sha256 = "14gym38ncc9cysknv3jrql7jvcpjxf2d1dh4m8jgqb967jyzy5cj";
25     };
26     "build" = fetchgit {
27       url    = "${git_url}/chromium/src/build.git";
28       rev    = "2101eff1ac4bfd25f2dfa71ad632a600a38c1ed9";
29       sha256 = "0i3xcwzi4pkv4xpgjkbmcpj5h6mji80zqskkx0jx3sx0ji63fylz";
30     };
31     "third_party/googletest/src" = fetchgit {
32       url    = "${git_url}/external/github.com/google/googletest.git";
33       rev    = "4fe018038f87675c083d0cfb6a6b57c274fb1753";
34       sha256 = "1ilm9dmnm2v4y6l1wyfsajsbqv56j29ldfbpd0ykg4q90gpxz201";
35     };
36     "third_party/icu" = fetchgit {
37       url    = "${git_url}/chromium/deps/icu.git";
38       rev    = "c2a4cae149aae7fd30c4cbe3cf1b30df03b386f1";
39       sha256 = "0lgzxf7hmfsgqazs74v5li9ifg8r0jx5m3gxh1mnw33vpwp7qqf4";
40     };
41     "third_party/zlib" = fetchgit {
42       url    = "${git_url}/chromium/src/third_party/zlib.git";
43       rev    = "e84c9a3fd75fdc39055b7ae27d6ec508e50bd39e";
44       sha256 = "03z30djnb3srhd0nvlxvx58sjqm2bvxk7j3vp4fk6h7a0sa2bdpi";
45     };
46     "third_party/jinja2" = fetchgit {
47       url    = "${git_url}/chromium/src/third_party/jinja2.git";
48       rev    = "a82a4944a7f2496639f34a89c9923be5908b80aa";
49       sha256 = "02mkjwkrzhrg16zx97z792l0faz7gc8vga8w10r5y94p98jymnyz";
50     };
51     "third_party/markupsafe" = fetchgit {
52       url    = "${git_url}/chromium/src/third_party/markupsafe.git";
53       rev    = "0944e71f4b2cb9a871bcbe353f95e889b64a611a";
54       sha256 = "052ij8i7nkqchbvzv6ykj929hvfxjbzq7az2l01r0l2gfazhvdb9";
55     };
56   };
58   # See `gn_version` in DEPS.
59   gnSrc = fetchgit {
60     url = "https://gn.googlesource.com/gn";
61     rev = "53d92014bf94c3893886470a1c7c1289f8818db0";
62     sha256 = "1xcm07qjk6m2czi150fiqqxql067i832adck6zxrishm70c9jbr9";
63   };
65   myGn = gn.overrideAttrs (oldAttrs: {
66     version = "for-v8";
67     src = gnSrc;
68   });
72 stdenv.mkDerivation rec {
73   pname = "v8";
74   inherit version;
76   doCheck = true;
78   patches = [
79     ./darwin.patch
80   ];
82   src = v8Src;
84   postUnpack = ''
85     ${lib.concatStringsSep "\n" (
86       lib.mapAttrsToList (n: v: ''
87         mkdir -p $sourceRoot/${n}
88         cp -r ${v}/* $sourceRoot/${n}
89       '') deps)}
90     chmod u+w -R .
91   '';
93   postPatch = ''
94     ${lib.optionalString stdenv.isAarch64 ''
95       substituteInPlace build/toolchain/linux/BUILD.gn \
96         --replace 'toolprefix = "aarch64-linux-gnu-"' 'toolprefix = ""'
97     ''}
98     ${lib.optionalString stdenv.isDarwin ''
99       substituteInPlace build/config/compiler/compiler.gni \
100         --replace 'strip_absolute_paths_from_debug_symbols = true' \
101                   'strip_absolute_paths_from_debug_symbols = false'
102       substituteInPlace build/config/compiler/BUILD.gn \
103         --replace 'current_toolchain == host_toolchain || !use_xcode_clang' \
104                   'false'
105     ''}
106     echo 'checkout_google_benchmark = false' > build/config/gclient_args.gni
107   '';
109   gnFlags = [
110     "use_custom_libcxx=false"
111     "is_clang=${lib.boolToString stdenv.cc.isClang}"
112     "use_sysroot=false"
113     # "use_system_icu=true"
114     "clang_use_chrome_plugins=false"
115     "is_component_build=false"
116     "v8_use_external_startup_data=false"
117     "v8_monolithic=true"
118     "is_debug=true"
119     "is_official_build=false"
120     "treat_warnings_as_errors=false"
121     "v8_enable_i18n_support=true"
122     "use_gold=false"
123     # ''custom_toolchain="//build/toolchain/linux/unbundle:default"''
124     ''host_toolchain="//build/toolchain/linux/unbundle:default"''
125     ''v8_snapshot_toolchain="//build/toolchain/linux/unbundle:default"''
126   ] ++ lib.optional stdenv.cc.isClang ''clang_base_path="${stdenv.cc}"'';
128   NIX_CFLAGS_COMPILE = "-O2";
129   FORCE_MAC_SDK_MIN = stdenv.targetPlatform.sdkVer or "10.12";
131   nativeBuildInputs = [
132     myGn
133     ninja
134     pkg-config
135     python39
136   ] ++ lib.optionals stdenv.isDarwin [
137     xcbuild
138     darwin.DarwinTools
139     python39.pkgs.setuptools
140   ];
141   buildInputs = [ glib icu ];
143   ninjaFlags = [ ":d8" "v8_monolith" ];
145   enableParallelBuilding = true;
147   installPhase = ''
148     install -D d8 $out/bin/d8
149     install -D -m644 obj/libv8_monolith.a $out/lib/libv8.a
150     install -D -m644 icudtl.dat $out/share/v8/icudtl.dat
151     ln -s libv8.a $out/lib/libv8_monolith.a
152     cp -r ../../include $out
154     mkdir -p $out/lib/pkgconfig
155     cat > $out/lib/pkgconfig/v8.pc << EOF
156     Name: v8
157     Description: V8 JavaScript Engine
158     Version: ${version}
159     Libs: -L$out/lib -lv8 -pthread
160     Cflags: -I$out/include
161     EOF
162   '';
164   meta = with lib; {
165     description = "Google's open source JavaScript engine";
166     maintainers = with maintainers; [ cstrahan proglodyte matthewbauer ];
167     platforms = platforms.unix;
168     license = licenses.bsd3;
169   };