Skip to content

Instantly share code, notes, and snippets.

@chrmoritz
Created October 16, 2013 08:13
Show Gist options
  • Save chrmoritz/7004317 to your computer and use it in GitHub Desktop.
Save chrmoritz/7004317 to your computer and use it in GitHub Desktop.
require 'formula'
class Slimerjs < Formula
homepage 'http://www.slimerjs.org'
url 'http://download.slimerjs.org/v0.8/slimerjs-0.8.3.zip'
sha1 '8d2a6dc3b8200fa15cd9d65c84bc9358c11f03f8'
head 'https://github.com/laurentj/slimerjs.git'
option 'without-xulrunner', 'Do not add xulrunner (requires a local Firefox installation, default on OS X 10.6 and below)'
if build.with? 'xulrunner'
resource 'xulrunner' do
# keep this in sync with the slimerjs standalone version, because it defines a maxgecko version
# update version number in tar command (in resource('xulrunner').stage) too
url 'http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/24.0/source/xulrunner-24.0.source.tar.bz2'
sha1 '28726eb14fbefb124d14e38e9fae8109ac5eac43'
end
depends_on :python2 => '2.7' if MacOS.version > :snow_leopard
depends_on 'python' if MacOS.version <= :snow_leopard
# requiered for patching gcc check out, homebrew/versions should be tapped, since we use gcc-4.6+ here
depends_on 'homebrew/versions/autoconf213' if MacOS.version <= :snow_leopard
depends_on 'yasm' => :recommended # WebM support
fails_with :gcc do
cause 'Mozilla XULRunner only supports clang on OS X'
end
fails_with :gcc_4_0 do
cause 'Mozilla XULRunner only supports clang on OS X'
end
# requires at least gcc 4.6+ for build on OS X 10.6
%w[4.3 4.4 4.5].each do |v|
fails_with :gcc => v
end
fails_with :llvm do
cause 'Mozilla XULRunner only supports clang on OS X'
end
fails_with :clang do
build 77
cause 'clang on OS X 10.6 / XCode 3 is to old (requires clang++)'
end
end
def install
if build.head?
cd 'src/'
system 'zip -r omni.ja chrome/ components/ modules/ defaults/ chrome.manifest -x@package_exclude.lst'
end
libexec.install %w[application.ini omni.ja slimerjs]
bin.install_symlink libexec/'slimerjs'
resource('xulrunner').stage do
if MacOS.version <= :snow_leopard
inreplace 'configure', 'IS_GCC=$($CC -v 2>&1 | grep gcc)', 'IS_GCC=$($CC -v 2>&1 | grep gcc-4.2)'
inreplace 'build/autoconf/compiler-opts.m4', 'IS_GCC=$($CC -v 2>&1 | grep gcc)', 'IS_GCC=$($CC -v 2>&1 | grep gcc-4.2)'
inreplace 'js/src/build/autoconf/compiler-opts.m4', 'IS_GCC=$($CC -v 2>&1 | grep gcc)', 'IS_GCC=$($CC -v 2>&1 | grep gcc-4.2)'
curl '-O', 'https://gist.github.com/chrmoritz/6975406/raw/92116676a910aeb8675fe4129bdfee66223ae91a/.mozconfig'
ENV.j1
end
# build xulrunner to objdir and disable tests, updater.app and crashreporter.app
curl '-O', 'https://gist.github.com/chrmoritz/6952361/raw/d1ec6a29fe3ee2e59f39f854371ee9978cdb684a/.mozconfig' if MacOS.version > :snow_leopard
system 'make -f client.mk build'
system 'make -f client.mk package'
mkdir 'untar'
# change the version with every resource update
system 'tar -xvjf objdir/dist/xulrunner-24.0.en-US.mac64.tar.bz2 -C untar/'
mv 'untar/XUL.framework/Versions/Current', libexec/'xulrunner'
end if build.with? 'xulrunner'
end
def caveats; <<-EOS.undent
You should set the environment variable SLIMERJSLAUNCHER to a installation of Mozilla Firefox (or XULRunner).
For a standard Mozilla Firefox installation this would be:
export SLIMERJSLAUNCHER=/Applications/Firefox.app/Contents/MacOS/firefox
EOS
end if build.without? 'xulrunner'
test do
system 'slimerjs', '-v'
curl '-O', 'https://raw.github.com/laurentj/slimerjs/ec1e53a/examples/phantomjs/loadspeed.js'
system 'slimerjs loadspeed.js www.google.com'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment