summary refs log tree commit diff
path: root/pkgs/development/libraries/v8
diff options
context:
space:
mode:
authorLukasz Czyzykowski <lukasz.czyzykowski@gmail.com>2017-05-15 19:25:33 +0200
committerLukasz Czyzykowski <lukasz.czyzykowski@gmail.com>2017-05-17 21:50:49 +0200
commit3de66330cd7e37822cbc033ea0e4de25bd044fb9 (patch)
tree5a52826e6d5bb33adf8e7dce808b47d4376158e2 /pkgs/development/libraries/v8
parent37cb24a318f1c54f2a84cbca84c9bfb1d500289c (diff)
downloadnixpkgs-3de66330cd7e37822cbc033ea0e4de25bd044fb9.tar
nixpkgs-3de66330cd7e37822cbc033ea0e4de25bd044fb9.tar.gz
nixpkgs-3de66330cd7e37822cbc033ea0e4de25bd044fb9.tar.bz2
nixpkgs-3de66330cd7e37822cbc033ea0e4de25bd044fb9.tar.lz
nixpkgs-3de66330cd7e37822cbc033ea0e4de25bd044fb9.tar.xz
nixpkgs-3de66330cd7e37822cbc033ea0e4de25bd044fb9.tar.zst
nixpkgs-3de66330cd7e37822cbc033ea0e4de25bd044fb9.zip
v8: fixes build on darwin
v8 compilation on macOS was failing because of missing dependency and
wrong linker. The approach to make it work is similar to the nodejs
package.
Diffstat (limited to 'pkgs/development/libraries/v8')
-rw-r--r--pkgs/development/libraries/v8/default.nix19
-rw-r--r--pkgs/development/libraries/v8/no-xcode.patch64
2 files changed, 77 insertions, 6 deletions
diff --git a/pkgs/development/libraries/v8/default.nix b/pkgs/development/libraries/v8/default.nix
index 2c6e818b4e1..00fb037168e 100644
--- a/pkgs/development/libraries/v8/default.nix
+++ b/pkgs/development/libraries/v8/default.nix
@@ -1,5 +1,5 @@
 { stdenv, lib, fetchgit, fetchFromGitHub, gyp, readline, python, which, icu
-, patchelf, coreutils
+, patchelf, coreutils, cctools
 , doCheck ? false
 , static ? false
 }:
@@ -126,7 +126,13 @@ stdenv.mkDerivation rec {
 
   # Patch based off of:
   # https://github.com/cowboyd/libv8/tree/v5.1.281.67.0/patches
-  patches = lib.optional (!doCheck) ./libv8-5.4.232.patch;
+  patches = lib.optional (!doCheck) ./libv8-5.4.232.patch
+  ++ stdenv.lib.optionals stdenv.isDarwin [ ./no-xcode.patch ];
+
+  prePatch = ''
+    chmod +w tools/gyp/pylib/gyp
+    chmod +w tools/gyp/pylib/gyp/xcode_emulation.py
+  '';
 
   postPatch = ''
     sed -i 's,#!/usr/bin/env python,#!${python}/bin/python,' gypfiles/gyp_v8
@@ -152,12 +158,13 @@ stdenv.mkDerivation rec {
   '';
 
   nativeBuildInputs = [ which ];
-  buildInputs = [ readline python icu patchelf ];
+  buildInputs = [ readline python icu patchelf ]
+  ++ stdenv.lib.optionals stdenv.isDarwin [ cctools ];
 
   NIX_CFLAGS_COMPILE = "-Wno-error=strict-overflow";
 
   buildFlags = [
-    "LINK=g++"
+    "LINK=c++"
     "-C out"
     "builddir=$(CURDIR)/Release"
     "BUILDTYPE=Release"
@@ -174,7 +181,7 @@ stdenv.mkDerivation rec {
     install -vD out/Release/mksnapshot "$out/bin/mksnapshot"
     ${if static then ""
     else if stdenv.isDarwin then ''
-    install -vD out/Release/lib.target/libv8.dylib "$out/lib/libv8.dylib"
+    install -vD out/Release/libv8.dylib "$out/lib/libv8.dylib"
     install_name_tool -change /usr/local/lib/libv8.dylib $out/lib/libv8.dylib -change /usr/lib/libgcc_s.1.dylib ${stdenv.cc.cc.lib}/lib/libgcc_s.1.dylib $out/bin/d8
     install_name_tool -id $out/lib/libv8.dylib -change /usr/lib/libgcc_s.1.dylib ${stdenv.cc.cc.lib}/lib/libgcc_s.1.dylib $out/lib/libv8.dylib
     '' else ''
@@ -190,7 +197,7 @@ stdenv.mkDerivation rec {
   meta = with lib; {
     description = "Google's open source JavaScript engine";
     maintainers = with maintainers; [ cstrahan proglodyte ];
-    platforms = platforms.linux;
+    platforms = platforms.linux ++ platforms.darwin;
     license = licenses.bsd3;
   };
 }
diff --git a/pkgs/development/libraries/v8/no-xcode.patch b/pkgs/development/libraries/v8/no-xcode.patch
new file mode 100644
index 00000000000..5562ffaf64e
--- /dev/null
+++ b/pkgs/development/libraries/v8/no-xcode.patch
@@ -0,0 +1,64 @@
+--- a/tools/gyp/pylib/gyp/xcode_emulation.py
++++ a/tools/gyp/pylib/gyp/xcode_emulation.py
+@@ -473,10 +473,16 @@
+ 
+   def _XcodeSdkPath(self, sdk_root):
+     if sdk_root not in XcodeSettings._sdk_path_cache:
+-      sdk_path = self._GetSdkVersionInfoItem(sdk_root, '--show-sdk-path')
+-      XcodeSettings._sdk_path_cache[sdk_root] = sdk_path
+-      if sdk_root:
+-        XcodeSettings._sdk_root_cache[sdk_path] = sdk_root
++      try:
++        sdk_path = self._GetSdkVersionInfoItem(sdk_root, '--show-sdk-path')
++        XcodeSettings._sdk_path_cache[sdk_root] = sdk_path
++        if sdk_root:
++          XcodeSettings._sdk_root_cache[sdk_path] = sdk_root
++      except:
++        # if this fails it's because xcodebuild failed, which means
++        # the user is probably on a CLT-only system, where there
++        # is no valid SDK root
++        XcodeSettings._sdk_path_cache[sdk_root] = None
+     return XcodeSettings._sdk_path_cache[sdk_root]
+ 
+   def _AppendPlatformVersionMinFlags(self, lst):
+@@ -606,10 +612,11 @@
+       framework_root = sdk_root
+     else:
+       framework_root = ''
+-    config = self.spec['configurations'][self.configname]
+-    framework_dirs = config.get('mac_framework_dirs', [])
+-    for directory in framework_dirs:
+-      cflags.append('-F' + directory.replace('$(SDKROOT)', framework_root))
++    if 'SDKROOT' in self._Settings():
++      config = self.spec['configurations'][self.configname]
++      framework_dirs = config.get('mac_framework_dirs', [])
++      for directory in framework_dirs:
++        cflags.append('-F' + directory.replace('$(SDKROOT)', framework_root))
+ 
+     self.configname = None
+     return cflags
+@@ -861,10 +868,11 @@
+     sdk_root = self._SdkPath()
+     if not sdk_root:
+       sdk_root = ''
+-    config = self.spec['configurations'][self.configname]
+-    framework_dirs = config.get('mac_framework_dirs', [])
+-    for directory in framework_dirs:
+-      ldflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root))
++    if 'SDKROOT' in self._Settings():
++      config = self.spec['configurations'][self.configname]
++      framework_dirs = config.get('mac_framework_dirs', [])
++      for directory in framework_dirs:
++        ldflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root))
+ 
+     platform_root = self._XcodePlatformPath(configname)
+     if sdk_root and platform_root and self._IsXCTest():
+@@ -1358,7 +1366,7 @@
+     if version:
+       version = re.match(r'(\d\.\d\.?\d*)', version).groups()[0]
+     else:
+-      raise GypError("No Xcode or CLT version detected!")
++      version = "7.0.0"
+     # The CLT has no build information, so we return an empty string.
+     version_list = [version, '']
+   version = version_list[0]