Skip to content
This repository
Browse code

making fat binaries easy with nokogiri

  • Loading branch information...
commit 2dd18529ebaace4e09a9d60ef5a3c25ad66d1784 1 parent 1e59ebe
Aaron Patterson tenderlove authored

Showing 2 changed files with 27 additions and 31 deletions. Show diff stats Hide diff stats

  1. +26 25 Rakefile
  2. +1 6 lib/nokogiri.rb
51 Rakefile
@@ -41,8 +41,8 @@ unless java
41 41 require "rake/extensiontask"
42 42
43 43 RET = Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
44   - ext.lib_dir = "lib/nokogiri"
45   - ext.gem_spec.required_ruby_version = "~> #{RUBY_VERSION.sub(/\.\d+$/, '.0')}"
  44 + ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
  45 +
46 46 ext.config_options << ENV['EXTOPTS']
47 47 cross_dir = File.join(File.dirname(__FILE__), 'tmp', 'cross')
48 48 ext.cross_compile = true
@@ -55,14 +55,31 @@ unless java
55 55 "--with-xslt-dir=#{File.join(cross_dir, 'libxslt')}"
56 56 end
57 57
58   - task :muck_with_lib_dir do
59   - RET.lib_dir += "/#{RUBY_VERSION.sub(/\.\d$/, '')}"
60   - FileUtils.mkdir_p(RET.lib_dir)
61   - end
62   - if Rake::Task.task_defined?(:cross)
63   - Rake::Task[:cross].prerequisites << "muck_with_lib_dir"
  58 + ###
  59 + # To build the windows fat binary, do:
  60 + #
  61 + # rake fat_binary native gem
  62 + #
  63 + # I keep my ruby in multiruby, so my command is like this:
  64 + #
  65 + # RAKE19=~/.multiruby/install/1.9.1-p129/bin/rake \
  66 + # rake fat_binary native gem
  67 + task 'fat_binary' do
  68 + rake19 = ENV['RAKE19'] || 'rake1.9'
  69 + system("rake clean cross compile RUBY_CC_VERSION=1.8.6 FAT_DIR=1.8")
  70 + system("#{rake19} clean cross compile RUBY_CC_VERSION=1.9.1 FAT_DIR=1.9")
  71 + File.open("lib/#{HOE.name}/#{HOE.name}.rb", 'wb') do |f|
  72 + f.write <<-eoruby
  73 +require "#{HOE.name}/\#{RUBY_VERSION.sub(/\.\d+$/, '')}/#{HOE.name}"
  74 + eoruby
  75 + end
  76 + HOE.spec.extensions = []
  77 + HOE.spec.platform = 'i386-mingw32'
  78 + HOE.spec.files += Dir["lib/#{HOE.name}/#{HOE.name}.rb"]
  79 + HOE.spec.files += Dir["lib/#{HOE.name}/1.{8,9}/*"]
64 80 end
65   -
  81 + CLOBBER.include("lib/nokogiri/nokogiri.rb")
  82 + CLOBBER.include("lib/nokogiri/1.{8,9}")
66 83 end
67 84
68 85 namespace :gem do
@@ -156,15 +173,6 @@ task :debug do
156 173 ENV['CFLAGS'] += " -DDEBUG"
157 174 end
158 175
159   -if Rake::Task.task_defined?(:cross)
160   - task :add_dll_to_manifest do
161   - HOE.spec.files += Dir['ext/nokogiri/**.{dll,so}']
162   - HOE.spec.files += Dir['ext/nokogiri/{1.8,1.9}/**.{dll,so}']
163   - end
164   -
165   - Rake::Task[:cross].prerequisites << :add_dll_to_manifest
166   -end
167   -
168 176 # required_ruby_version
169 177
170 178 # Only do this on unix, since we can't build on windows
@@ -193,11 +201,4 @@ namespace :install do
193 201 end
194 202 end
195 203
196   -namespace :libxml do
197   - desc "What version of LibXML are we building against?"
198   - task :version => :compile do
199   - sh "#{RUBY} -Ilib:ext -rnokogiri -e 'puts Nokogiri::LIBXML_VERSION'"
200   - end
201   -end
202   -
203 204 # vim: syntax=Ruby
7 lib/nokogiri.rb
@@ -9,12 +9,7 @@
9 9 require 'ffi'
10 10 require 'nokogiri/ffi/libxml'
11 11 else
12   - if RUBY_PLATFORM =~/(mswin|mingw)/i
13   - # Fat binary gems, you make the Rockin' world go round
14   - require "nokogiri/#{RUBY_VERSION.sub(/\.\d+$/, '')}/nokogiri"
15   - else
16   - require 'nokogiri/nokogiri'
17   - end
  12 + require 'nokogiri/nokogiri'
18 13 end
19 14
20 15 require 'nokogiri/version'

0 comments on commit 2dd1852

Please sign in to comment.
Something went wrong with that request. Please try again.