Skip to content

Commit

Permalink
Merge 9f19c70 into b275421
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones authored Sep 7, 2020
2 parents b275421 + 9f19c70 commit 3e6f90c
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 113 deletions.
6 changes: 5 additions & 1 deletion .cross_rubies
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
2.7.0:x86_64-w64-mingw32
2.7.0:i686-linux-gnu
2.7.0:x86_64-linux-gnu
2.7.0:x86_64-darwin19
2.6.0:i686-w64-mingw32
2.6.0:x86_64-w64-mingw32
2.6.0:i686-linux-gnu
2.6.0:x86_64-linux-gnu
2.6.0:x86_64-darwin19
2.5.0:i686-w64-mingw32
2.5.0:x86_64-w64-mingw32
2.5.0:i686-linux-gnu
2.5.0:x86_64-linux-gnu
2.5.0:x86_64-darwin19
2.4.0:i686-w64-mingw32
2.4.0:x86_64-w64-mingw32
2.4.0:i686-linux-gnu
2.4.0:x86_64-linux-gnu
2.4.0:x86_64-linux-gnu
2.4.0:x86_64-darwin19
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ ext/java/nokogiri/**/*.class
ext/nokogiri/*.dll
gems
lib/nokogiri/**/nokogiri.so
lib/nokogiri/nokogiri.bundle
lib/nokogiri/**/nokogiri.bundle
lib/nokogiri/nokogiri.jar
lib/nokogiri/nokogiri.rb
pkg
ports
stash
Expand Down
3 changes: 2 additions & 1 deletion .hoerc
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ exclude: !ruby/regexp '/
|Manifest.txt
|Rakefile
|appveyor\.yml
|build_all
|CHANGELOG.md
|CODE_OF_CONDUCT.md
|CONTRIBUTING.md
|ROADMAP.md
|SECURITY.md
|STANDARD_RESPONSES.md
|Vagrantfile
|Y_U_NO_GEMSPEC.md
|C_CODING_STYLE.*
|scripts
|patches
)
|\.gitkeep
Expand Down
63 changes: 1 addition & 62 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Hoe.plugin :markdown
require 'shellwords'

require_relative "tasks/util"
require_relative "tasks/cross-ruby"

HOE = Hoe.spec 'nokogiri' do
developer 'Aaron Patterson', '[email protected]'
Expand Down Expand Up @@ -74,67 +73,7 @@ HOE = Hoe.spec 'nokogiri' do
self.test_prelude = 'require "helper"' # ensure simplecov gets loaded before anything else
end

if java?
# TODO: clean this section up.
require "rake/javaextensiontask"
Rake::JavaExtensionTask.new("nokogiri", HOE.spec) do |ext|
jruby_home = RbConfig::CONFIG['prefix']
ext.ext_dir = 'ext/java'
ext.lib_dir = 'lib/nokogiri'
ext.source_version = '1.6'
ext.target_version = '1.6'
jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
ext.classpath = jars.map { |x| File.expand_path x }.join ':'
ext.debug = true if ENV['JAVA_DEBUG']
end

task gem_build_path => [:compile] do
add_file_to_gem 'lib/nokogiri/nokogiri.jar'
end
else
require "rake/extensiontask"

HOE.spec.files.reject! { |f| f =~ %r{\.(java|jar)$} }

dependencies = YAML.load_file("dependencies.yml")

task gem_build_path do
%w[libxml2 libxslt].each do |lib|
version = dependencies[lib]["version"]
archive = File.join("ports", "archives", "#{lib}-#{version}.tar.gz")
add_file_to_gem archive
patchesdir = File.join("patches", lib)
patches = `#{['git', 'ls-files', patchesdir].shelljoin}`.split("\n").grep(/\.patch\z/)
patches.each { |patch|
add_file_to_gem patch
}
(untracked = Dir[File.join(patchesdir, '*.patch')] - patches).empty? or
at_exit {
untracked.each { |patch|
puts "** WARNING: untracked patch file not added to gem: #{patch}"
}
}
end
end

Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
ext.config_options << ENV['EXTOPTS']
ext.cross_compile = true
ext.cross_platform = CROSS_RUBIES.map(&:platform).uniq
ext.cross_config_options << "--enable-cross-build"
ext.cross_compiling do |spec|
libs = dependencies.map { |name, dep| "#{name}-#{dep["version"]}" }.join(', ')

spec.post_install_message = <<-EOS
Nokogiri is built with the packaged libraries: #{libs}.
EOS
spec.files.reject! { |path| File.fnmatch?('ports/*', path) }
spec.dependencies.reject! { |dep| dep.name=='mini_portile2' }
end
end
end

require_relative "tasks/cross-ruby"
require_relative "tasks/concourse"
require_relative "tasks/css-generate"
require_relative "tasks/debug"
Expand Down
1 change: 1 addition & 0 deletions lib/nokogiri/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def to_hash
vi["ruby"] = {}.tap do |ruby|
ruby["version"] = ::RUBY_VERSION
ruby["platform"] = ::RUBY_PLATFORM
ruby["gem_platform"] = ::Gem::Platform.local.to_s
ruby["description"] = ::RUBY_DESCRIPTION
ruby["engine"] = engine
ruby["jruby"] = jruby? if jruby?
Expand Down
File renamed without changes.
41 changes: 41 additions & 0 deletions scripts/setup-osx-native-builders
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#! /usr/bin/env bash

# https://github.com/postmodern/chruby
# (your file locations may be different)
source /opt/dev/sh/chruby/chruby.sh
RUBIES_DIR=${HOME}/.rubies

# prerequisites on OSX
if [[ -z "$(which ruby-install)" ]] ; then
echo "ERROR: ruby-install is not installed, please install it: https://github.com/postmodern/ruby-install"
exit 1
fi

set -o errexit
set -o pipefail

CROSS_FILE=".cross_rubies"
RUBIES=$(cat $CROSS_FILE | fgrep darwin | cut -d. -f1,2 | sort -u)
RAKE_COMPILER_CONFIG_DIR=${HOME}/.rake-compiler
RAKE_COMPILER_CONFIG=${RAKE_COMPILER_CONFIG_DIR}/config.yml

mkdir -p $RAKE_COMPILER_CONFIG_DIR
echo "---" > $RAKE_COMPILER_CONFIG

for ruby in $RUBIES ; do
ruby_zero="${ruby}.0"
ruby_fullname="native-builder-${ruby}"
if ! chruby $ruby_fullname ; then
echo "installing $ruby_fullname ..."
ruby-install -i ${RUBIES_DIR}/${ruby_fullname} ruby ${ruby} -- --disable-shared
source /opt/dev/sh/chruby/chruby.sh
else
echo "ruby $ruby_fullname is installed"
fi

chruby $ruby_fullname
platform=$(ruby -e 'puts RUBY_PLATFORM')
echo "rbconfig-${platform}-${ruby_zero}: \"${RUBIES_DIR}/${ruby_fullname}/lib/ruby/${ruby_zero}/${platform}/rbconfig.rb\"" >> $RAKE_COMPILER_CONFIG
done

cat $RAKE_COMPILER_CONFIG
Loading

0 comments on commit 3e6f90c

Please sign in to comment.