Skip to content

Instantly share code, notes, and snippets.

@2bits
Created April 14, 2012 10:53
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 2bits/2383544 to your computer and use it in GitHub Desktop.
Save 2bits/2383544 to your computer and use it in GitHub Desktop.
wkhtmltopdf-0.11.0_rc1 hack to build their patched qt as an option
require 'formula'
class WkhtmltopdfQt < Formula
url 'git://gitorious.org/+wkhtml2pdf/qt/wkhtmltopdf-qt.git'
end
class Wkhtmltopdf < Formula
homepage 'http://code.google.com/p/wkhtmltopdf/'
url 'http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1.tar.bz2'
sha1 'db03922d281856e503b3d562614e3936285728c7'
version '0.11.0_rc1'
depends_on 'qt' unless ARGV.include? '--build-patched-qt'
#depends_on 'wkhtmltopdf-qt' if ARGV.include? '--build-patched-qt'
def options
[['--build-patched-qt', 'Download and build a special patched qt (~1hr)']]
end
def install
# fix that missing TEMP= include.
inreplace 'common.pri' do |s|
s.gsub! 'TEMP = $$[QT_INSTALL_LIBS] libQtGui.prl', ''
s.gsub! 'include($$join(TEMP, "/"))', ''
end
# build their patched qt if the user options that
if ARGV.include? '--build-patched-qt' then
WkhtmltopdfQt.new.brew { (buildpath).install Dir['*'] }
system "exit 1"
end
# It tries to build universally, but Qt is bottled as 64bit => build error.
# If we are 64bit, do not compile with -arch i386. This is a Homebrew
# issue with our Qt4, not upstream, because wkhtmltopdf bundles a patched
# Qt4 that Homebrew doesn't use.
if MacOS.prefer_64_bit?
inreplace 'src/pdf/pdf.pro', 'x86', 'x86_64'
inreplace 'src/image/image.pro', 'x86', 'x86_64'
end
system 'qmake', '-spec', 'macx-g++'
system 'make'
ENV['DYLD_LIBRARY_PATH'] = './bin'
`bin/wkhtmltopdf --manpage > wkhtmltopdf.1`
`bin/wkhtmltoimage --manpage > wkhtmltoimage.1`
# install binaries, libs, and man pages
bin.install Dir[ "bin/wkh*" ]
lib.install Dir[ "bin/lib*" ]
man1.install Dir[ "wkht*.1" ]
end
end
@atpjd
Copy link

atpjd commented Feb 11, 2013

Bumping into an error when trying:

brew install --build-patched-qt wkhtmltopdf

I get:

Error: can't dup NilClass

Without the --build-patched-qt wkhtmltopdf, the build works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment