summary refs log tree commit diff
path: root/pkgs/development/tools/phantomjs2
diff options
context:
space:
mode:
authorJude Taylor <me@jude.bio>2016-01-12 21:52:39 -0800
committerJude Taylor <me@jude.bio>2016-01-12 21:52:49 -0800
commite6a892bb55e664a7ac151855fefb579812c66e60 (patch)
tree3e4d356066b611d643e56cd3f68b8937f55b94b8 /pkgs/development/tools/phantomjs2
parent59047385579c94a21256d226b9951c100bb7ca3a (diff)
downloadnixlib-e6a892bb55e664a7ac151855fefb579812c66e60.tar
nixlib-e6a892bb55e664a7ac151855fefb579812c66e60.tar.gz
nixlib-e6a892bb55e664a7ac151855fefb579812c66e60.tar.bz2
nixlib-e6a892bb55e664a7ac151855fefb579812c66e60.tar.lz
nixlib-e6a892bb55e664a7ac151855fefb579812c66e60.tar.xz
nixlib-e6a892bb55e664a7ac151855fefb579812c66e60.tar.zst
nixlib-e6a892bb55e664a7ac151855fefb579812c66e60.zip
phantomjs2: build on darwin
Diffstat (limited to 'pkgs/development/tools/phantomjs2')
-rw-r--r--pkgs/development/tools/phantomjs2/default.nix74
1 files changed, 71 insertions, 3 deletions
diff --git a/pkgs/development/tools/phantomjs2/default.nix b/pkgs/development/tools/phantomjs2/default.nix
index 8ef68f93a2f7..8c162589bf6e 100644
--- a/pkgs/development/tools/phantomjs2/default.nix
+++ b/pkgs/development/tools/phantomjs2/default.nix
@@ -1,8 +1,37 @@
 { stdenv, fetchurl,
-  bison2, flex, fontconfig, freetype, gperf, icu, openssl, libjpeg, libpng, perl, python, ruby, sqlite
+  bison2, flex, fontconfig, freetype, gperf, icu, openssl, libjpeg, libpng, perl, python, ruby, sqlite,
+  darwin, writeScriptBin, cups
 }:
 
-stdenv.mkDerivation rec {
+let
+  fakeXcrun = writeScriptBin "xcrun" ''
+    #!${stdenv.shell}
+    echo >&2 "Fake xcrun: ''$@"
+    args=()
+    while (("$#")); do
+      case "$1" in
+        -sdk*) shift;;
+        -find*) shift;;
+        *) args+=("$1");;
+      esac
+      shift
+    done
+
+    if [ "''${#args[@]}" -gt "0" ]; then
+      echo >&2 "Fake xcrun: ''${args[@]}"
+      exec "''${args[@]}"
+    fi
+  '';
+  fakeClang = writeScriptBin "clang" ''
+    #!${stdenv.shell}
+    if [[ "$@" == *.c ]]; then
+      exec "${stdenv.cc}/bin/clang" "$@"
+    else
+      exec "${stdenv.cc}/bin/clang++" "$@"
+    fi
+  '';
+
+in stdenv.mkDerivation rec {
   name = "phantomjs-${version}";
   version = "2.0.0-20150528";
 
@@ -11,19 +40,58 @@ stdenv.mkDerivation rec {
     sha256 = "18h37bxxg25lacry9k3vb5yim057bqcxmsifw97jrjp7gzfx56v5";
   };
 
-  buildInputs = [ bison2 flex fontconfig freetype gperf icu openssl libjpeg libpng perl python ruby sqlite ];
+  buildInputs = [ bison2 flex fontconfig freetype gperf icu openssl libjpeg libpng perl python ruby sqlite ]
+    ++ stdenv.lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
+      AGL ApplicationServices AppKit Cocoa OpenGL
+      darwin.libobjc fakeClang cups
+    ]);
+
 
   patchPhase = ''
     patchShebangs .
     sed -i -e 's|/bin/pwd|pwd|' src/qt/qtbase/configure 
+  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+    sed -i 's,-licucore,/usr/lib/libicucore.dylib,' src/qt/qtwebkit/Source/WTF/WTF.pri
+    substituteInPlace src/qt/qtwebkit/Tools/qmake/mkspecs/features/features.pri \
+      --replace "ENABLE_3D_RENDERING=1" "ENABLE_3D_RENDERING=0"
+    sed -i 88d src/qt/qtwebkit/Tools/qmake/mkspecs/features/features.prf
+    echo 'CONFIG -= create_cmake' >> src/qt/qtwebkit/Source/api.pri
+    echo 'CONFIG -= create_cmake' >> src/qt/qtwebkit/Source/widgetsapi.pri
+    pushd src/qt
+
+      substituteInPlace qtbase/configure \
+        --replace /usr/bin/xcode-select true \
+        --replace '/usr/bin/xcodebuild -sdk $sdk -version Path 2>/dev/null' 'echo /var/empty' \
+        --replace '/usr/bin/xcrun -sdk $sdk -find' 'type -P'
+      substituteInPlace qtbase/mkspecs/features/mac/default_pre.prf \
+        --replace '/usr/bin/xcode-select --print-path 2>/dev/null' "echo ${stdenv.libc}" \
+        --replace '/usr/bin/xcrun -find xcrun 2>/dev/null' 'echo success' \
+        --replace '/usr/bin/xcodebuild -version' 'echo Xcode 7.2; echo Build version 7C68' \
+        --replace 'sdk rez' ""
+      for file in $(grep -rl /usr/bin/xcrun .); do
+        substituteInPlace "$file" --replace "/usr/bin/xcrun" ${fakeXcrun}/bin/xcrun
+      done
+      substituteInPlace qtbase/src/tools/qlalr/lalr.cpp --replace _Nullable Nullable
+
+    popd
   '';
 
+  __impureHostDeps = stdenv.lib.optional stdenv.isDarwin "/usr/lib/libicucore.dylib";
+
   buildPhase = "./build.sh --confirm";
 
   installPhase = ''
     mkdir -p $out/share/doc/phantomjs
     cp -a bin $out
     cp -a ChangeLog examples LICENSE.BSD README.md third-party.txt $out/share/doc/phantomjs
+  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+    install_name_tool -change \
+        ${darwin.CF}/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation \
+        /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation \
+      -change \
+        ${darwin.configd}/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \
+        /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration \
+    $out/bin/phantomjs
   '';
 
   meta = {