Skip to content

Commit

Permalink
Small changes to the libgumbo build branch
Browse files Browse the repository at this point in the history
- remove the `rebuild-libgumbo` target which is probably not needed
  once #3220 is merged
- avoid downloading googletest when just running `rake compile`
- update the Manifest check to ignore new gumbo-parser/ files
- simplify the 'host' variable in gumbo.rake, since we're only using
  it in development (and not cross-compiling)
  • Loading branch information
flavorjones committed Jun 7, 2024
1 parent 3c85081 commit 81c8a76
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 27 deletions.
13 changes: 1 addition & 12 deletions ext/nokogiri/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ def configure
$VPATH << "$(srcdir)/../../gumbo-parser/src"
find_header("nokogiri_gumbo.h") || abort("nokogiri_gumbo.h not found")
else
libgumbo_recipe = process_recipe("libgumbo", "1.0.0-nokogiri", static_p, cross_build_p, false) do |recipe|
process_recipe("libgumbo", "1.0.0-nokogiri", static_p, cross_build_p, false) do |recipe|
recipe.source_directory = File.join(PACKAGE_ROOT_DIR, "gumbo-parser")
end
end
Expand Down Expand Up @@ -1102,17 +1102,6 @@ def configure
\t-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ? "enable" : "disable"}-static
EOF
end
File.open("Makefile", "at") do |mk|
mk.print(<<~EOF)
.PHONY: rebuild-libgumbo
$(TARGET_SO): rebuild-libgumbo
rebuild-libgumbo:
\t-$(Q)$(MAKE) -C tmp/#{libgumbo_recipe.host}/ports/libgumbo/1.0.0-nokogiri/libgumbo-1.0.0-nokogiri install
EOF
end

end

# rubocop:enable Style/GlobalVars
5 changes: 5 additions & 0 deletions rakelib/check-manifest.rake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ task :check_manifest, [:verbose] do |_, args|
[0-9]*
appveyor.yml
**/compile_commands.json
gumbo-parser/Makefile.old
gumbo-parser/aclocal.m4
gumbo-parser/autom4te.cache/*
gumbo-parser/build-aux/*
gumbo-parser/fuzzer/*
gumbo-parser/googletest/*
gumbo-parser/test/*
gumbo-parser/gperf-filter.sed
lib/nokogiri/**/nokogiri.{jar,so}
Expand Down
28 changes: 13 additions & 15 deletions rakelib/gumbo.rake
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
# frozen_string_literal: true

# We want to run the gumbo test suite using exactly the same compiled gumbo-parser
# that Nokogiri uses.
#
# To that end, we first need to get the Rake ExtensionTask to run extconf.rb which will
# run the gumbo-parser's configure script. We don't want to compile the extension
# at this point, so we make `gumbo:test` depend on the Nokogiri Makefile.
namespace "gumbo" do
# We want to run the gumbo test suite using exactly the same compiled gumbo-parser
# that Nokogiri uses.
#
# To that end, we first need to get the Rake ExtensionTask to run extconf.rb which will
# run the gumbo-parser's configure script. We don't want to compile the extension
# at this point, so we make `gumbo:test` depend on the Nokogiri Makefile.

gtest_pkg = "gumbo-parser/googletest"
host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
host = host.gsub("i386", "i686")
host = RbConfig::CONFIG["host"]
nokogiri_makefile = File.join("tmp/#{RUBY_PLATFORM}/nokogiri/#{RUBY_VERSION}/Makefile")
gumbotest_builddir = "tmp/#{RUBY_PLATFORM}/nokogiri/#{RUBY_VERSION}/tmp/#{host}/ports/libgumbo/1.0.0-nokogiri/libgumbo-1.0.0-nokogiri"
gumbotest_configure = File.absolute_path("gumbo-parser/configure")

gtest_pkg = "gumbo-parser/googletest"
file gtest_pkg do
sh(<<~EOF)
curl -L https://github.com/google/googletest/archive/release-1.8.0.tar.gz | \
tar zxf - --strip-components 1 -C gumbo-parser googletest-release-1.8.0/googletest
EOF
end

file gumbotest_configure => gtest_pkg do
sh("autoreconf", "-fiv", chdir: "gumbo-parser")
end

desc "Run the gumbo parser test suite"
task "test" => nokogiri_makefile do
task "test" => [nokogiri_makefile, gtest_pkg] do
sh("make", "-j2", "-C", gumbotest_builddir, "check")
end

file gumbotest_configure do
sh("autoreconf", "-fiv", chdir: "gumbo-parser")
end

# Make sure the libgumbo configure script is created before trying to compile the extension.
file nokogiri_makefile => gumbotest_configure

Expand Down

0 comments on commit 81c8a76

Please sign in to comment.