Skip to content

Commit

Permalink
Merge pull request #2222 from sparklemotion/nokogumbo-functional-inte…
Browse files Browse the repository at this point in the history
…gration

get Nokogumbo's test suite green for basic cases
  • Loading branch information
flavorjones authored Apr 29, 2021
2 parents 5de6de3 + ebd76e7 commit 8387bcf
Show file tree
Hide file tree
Showing 91 changed files with 1,765 additions and 1,962 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# this is a work in progress!
name: windows
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize]
branches:
- '*'

jobs:
windows:
name: "windows, sys: ${{ matrix.sys }}, ${{ matrix.ruby }}"

env:
MAKEFLAGS: -j2

runs-on: windows-latest

strategy:
fail-fast: false
matrix:
sys: [ enable, disable ]
ruby: [ "2.5", "2.6", "2.7", "3.0", "mingw" ]

steps:
- name: configure git crlf on windows
run: |
git config --system core.autocrlf false
git config --system core.eol lf
- name: checkout
uses: actions/checkout@v2
- name: load Ruby and bundle install
uses: MSP-Greg/setup-ruby-pkgs@v1
with:
ruby-version: ${{ matrix.ruby }}
mingw: libxml2 libxslt
bundler-cache: true
- uses: actions/cache@v2
if: matrix.sys == 'disable'
with:
path: ports/archives
key: ${{ matrix.os }}-${{ matrix.ruby }}-tarballs-${{ hashFiles('**/dependencies.yml') }}
restore-keys: ${{ matrix.os }}-${{ matrix.ruby }}-tarballs-
- name: bundle exec rake compile
run: |
bundle exec rake compile -- --${{ matrix.sys }}-system-libraries
- name: bundle exec rake test
run: bundle exec rake test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/gems/
/lib/nokogiri/**/nokogiri.bundle
/lib/nokogiri/**/nokogiri.so
/lib/nokogumbo/**/nokogumbo.bundle
/lib/nokogumbo/**/nokogumbo.so
/lib/nokogiri/nokogiri.jar
/pkg/
/ports/
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Nokogiri follows [Semantic Versioning](https://semver.org/), please see the [REA

## next / unreleased

### Dependencies

* [MRI] Upgrade mini_portile2 dependency from `~> 2.5.0` to `~> 2.5.1`.


### Changed

* Introduce `Nokogiri::XML::ParseOptions::DEFAULT_XSLT` which adds the libxslt-preferred options of `NOENT | DTDLOAD | DTDATTR | NOCDATA` to `ParseOptions::DEFAULT_XML`.
Expand Down
2 changes: 1 addition & 1 deletion ext/java/nokogiri/XmlDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ private static class DocumentBuilderFactoryHolder
return new_root;
}
if (!(new_root instanceof XmlNode)) {
throw context.runtime.newArgumentError("expected Nokogiri::XML::Node but received " + new_root.getType());
throw context.runtime.newArgumentError("expected Nokogiri::XML::Node but received " + new_root.getType());
}
XmlNode newRoot = asXmlNode(context, new_root);

Expand Down
58 changes: 54 additions & 4 deletions ext/nokogiri/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# The gem version constraint in the Rakefile is not respected at install time.
# Keep this version in sync with the one in the Rakefile !
REQUIRED_MINI_PORTILE_VERSION = "~> 2.5.0"
REQUIRED_MINI_PORTILE_VERSION = "~> 2.5.1"
REQUIRED_PKG_CONFIG_VERSION = "~> 1.1"

# Keep track of what versions of what libraries we build against
Expand Down Expand Up @@ -402,7 +402,7 @@ def process_recipe(name, version, static_p, cross_p)
require 'mini_portile2'
message("Using mini_portile version #{MiniPortile::VERSION}\n")

if name != "libxml2" && name != "libxslt"
unless ["libxml2", "libxslt"].include?(name)
OTHER_LIBRARY_VERSIONS[name] = version
end

Expand Down Expand Up @@ -486,7 +486,7 @@ def process_recipe(name, version, static_p, cross_p)
end
end

message(<<~EOM)
message(<<~EOM) if name != "libgumbo"
The Nokogiri maintainers intend to provide timely security updates, but if
this is a concern for you and want to use your OS/distro system library
Expand All @@ -498,7 +498,7 @@ def process_recipe(name, version, static_p, cross_p)
EOM

message(<<~EOM) if name == 'libxml2'
Note, however, that nokogiri cannot guarantee compatiblity with every
Note, however, that nokogiri cannot guarantee compatibility with every
version of libxml2 that may be provided by OS/package vendors.
EOM
Expand Down Expand Up @@ -868,6 +868,56 @@ def compile
ensure_func("exsltFuncRegister", "libexslt/exslt.h")
end

libgumbo_recipe = process_recipe("libgumbo", "1.0.0-nokogiri", static_p, cross_build_p) do |recipe|
recipe.configure_options = []

class << recipe
def downloaded?
true
end

def extract
target = File.join(tmp_path, "gumbo-parser")
output "Copying gumbo-parser files into #{target}..."
FileUtils.mkdir_p target
FileUtils.cp Dir.glob(File.join(PACKAGE_ROOT_DIR, "gumbo-parser/src/*")), target
end

def configured?
true
end

def install
lib_dir = File.join(port_path, "lib")
inc_dir = File.join(port_path, "include")
FileUtils.mkdir_p([lib_dir, inc_dir])
FileUtils.cp File.join(work_path, "libgumbo.a"), lib_dir
FileUtils.cp Dir.glob(File.join(work_path, "*.h")), inc_dir
end

def compile
cflags = concat_flags(ENV["CFLAGS"], "-fPIC", "-g")

env = {"CC" => gcc_cmd, "CFLAGS" => cflags}
if config_cross_build?
if host =~ /darwin/
env["AR"] = "#{host}-libtool"
env["ARFLAGS"] = "-o"
else
env["AR"] = "#{host}-ar"
end
env["RANLIB"] = "#{host}-ranlib"
end

execute("compile", make_cmd, {env: env})
end
end
end
append_cppflags("-I#{File.join(libgumbo_recipe.path, "include")}")
$libs = $libs + " " + File.join(libgumbo_recipe.path, "lib", "libgumbo.a")
$LIBPATH = $LIBPATH | [File.join(libgumbo_recipe.path, "lib")]
ensure_func("gumbo_parse_with_options", "gumbo.h")

have_func('xmlHasFeature') || abort("xmlHasFeature() is missing.") # introduced in libxml 2.6.21
have_func('xmlFirstElementChild') # introduced in libxml 2.7.3
have_func('xmlRelaxNGSetParserStructuredErrors') # introduced in libxml 2.6.24
Expand Down
Loading

0 comments on commit 8387bcf

Please sign in to comment.