phantomjs2: build on darwin

This commit is contained in:
Jude Taylor 2016-01-12 21:52:39 -08:00
parent 5904738557
commit e6a892bb55
2 changed files with 82 additions and 7 deletions

View file

@ -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 = {

View file

@ -1,5 +1,5 @@
{ stdenv, fetchurl, pkgconfig, zlib, libjpeg, libpng, libtiff, pam
, dbus, acl, gmp
, dbus, acl, gmp, darwin
, libusb ? null, gnutls ? null, avahi ? null, libpaper ? null
}:
@ -16,8 +16,11 @@ stdenv.mkDerivation {
sha256 = "1gaakz24k6x5nc09rmpiq0xq20j1qdjc3szag8qwmyi4ky6ydmg1";
};
buildInputs = [ pkgconfig zlib libjpeg libpng libtiff libusb gnutls avahi libpaper ]
++ optionals stdenv.isLinux [ pam dbus.libs acl ];
buildInputs = [ pkgconfig zlib libjpeg libpng libtiff libusb gnutls libpaper ]
++ optionals stdenv.isLinux [ avahi pam dbus.libs acl ]
++ optionals stdenv.isDarwin (with darwin; [
configd apple_sdk.frameworks.ApplicationServices
]);
propagatedBuildInputs = [ gmp ];
@ -33,7 +36,11 @@ stdenv.mkDerivation {
] ++ optional (libusb != null) "--enable-libusb"
++ optional (gnutls != null) "--enable-ssl"
++ optional (avahi != null) "--enable-avahi"
++ optional (libpaper != null) "--enable-libpaper";
++ optional (libpaper != null) "--enable-libpaper"
++ optionals stdenv.isDarwin [
"--with-bundledir=$out"
"--disable-launchd"
];
installFlags =
[ # Don't try to write in /var at build time.