Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nokogumbo should be able to compile against Nokogiri by finding headers in extensions directory #1788

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,32 @@ matrix:
rvm: jruby-9.1.15.0
- os: linux
rvm: rbx-3
- name: packaged libraries
os: linux
rvm: 2.4.2
env:
- OVERRIDE_GEM_PATH=/tmp/gem_path
install:
- bundle install --jobs=3 --retry=3 --path vendor/bundle
- bundle exec rake
- bundle exec rake gem
- gem install -i /tmp/gem_path pkg/nokogiri-*.gem
- gem install -i /tmp/gem_path minitest
script:
- bundle exec rake test:package
- name: system libraries
os: linux
rvm: 2.4.2
env:
- OVERRIDE_GEM_PATH=/tmp/gem_path
install:
- bundle install --jobs=3 --retry=3 --path vendor/bundle
- bundle exec rake
- bundle exec rake gem
- gem install -i /tmp/gem_path pkg/nokogiri-*.gem -- --use-system-libraries
- gem install -i /tmp/gem_path minitest
script:
- bundle exec rake test:package
allow_failures:
- rvm: ruby-head
fast_finish: true
Expand Down
15 changes: 15 additions & 0 deletions ext/nokogiri/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,21 @@ def install
have_func('xmlSchemaSetValidStructuredErrors')
have_func('xmlSchemaSetParserStructuredErrors')

# Install the header files in the extension directory.
$INSTALLFILES << ['*.h', '$(archdir)/include']

unless using_system_libraries?
# $INSTALLFILES only works for files in this directory for some reason so
# copy the headers here first.
require 'fileutils'
FileUtils.rm_rf('include', secure: true)
FileUtils.mkdir('include')
[libxml2_recipe, libxslt_recipe].each do |recipe|
FileUtils.cp_r(Dir[File.join(recipe.path, 'include/*')], 'include')
end
$INSTALLFILES << ['include/**/*.h', '$(archdir)']
end

create_makefile('nokogiri/nokogiri')

if enable_config('clean', true)
Expand Down
7 changes: 7 additions & 0 deletions tasks/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,11 @@ def test_#{docfile.sub("#{base}/", '').gsub(/[\/\.-]/, '_')}
puts "repro: #{v[:cmd]}" unless passed
end
end

task :package do
Bundler.with_clean_env do
env = ENV['OVERRIDE_GEM_PATH'] ? { 'GEM_PATH' => ENV['OVERRIDE_GEM_PATH'] } : {}
sh(env, RbConfig.ruby, '-rminitest', 'test/package.rb', { verbose: true })
end
end
end
42 changes: 42 additions & 0 deletions test/package.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# These tests are only run by `rake test:package` and are intended to test the
# installed gem.
#
# This isn't called test_package.rb to prevent it being picked up by Hoe as a
# normal test.

require 'minitest/autorun'

class PackageTest < Minitest::Test
def setup
ext_dir = Gem::Specification.find_by_name('nokogiri').extension_dir
@headers_dir = File.join(ext_dir, 'nokogiri/include')
end

def test_nokogiri_headers
assert(File.directory?(@headers_dir))
installed_headers = Dir.chdir(@headers_dir) do
Dir['*.h'].sort!
end
source_headers = Dir.chdir(File.expand_path('../../ext/nokogiri', __FILE__)) do
Dir['*.h'].sort!
end
assert_equal(source_headers, installed_headers)
end

def test_packaged_headers
require 'nokogiri'
if Nokogiri::VERSION_INFO.has_key?('libxml') and
Nokogiri::VERSION_INFO['libxml']['source'] == 'packaged'
# Look for some files from libxml2 and libxslt
%w[libxml2/libxml/tree.h libxslt/xslt.h libexslt/exslt.h].each do |header|
assert(File.file?(File.join(@headers_dir, header)))
end
else
# Make sure the headers are not installed when they're not packaged.
%w[libxml2 libxslt libexslt].each do |dir|
refute(File.directory?(File.join(@headers_dir, dir)))
end
end
end
end
# vim: set sw=2 sts=2 ts=8 et: