Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Sep 10, 2023
1 parent 4da8a0d commit 667b7c8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- uses: MSP-Greg/setup-ruby-pkgs@v1
with:
apt-get: _update_ build-essential cmake
mingw: _upgrade_ cmake
mingw: _upgrade_ cmake pkgconf
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake test:unit
Expand Down
15 changes: 7 additions & 8 deletions lib/mini_portile2/mini_portile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def fmt.%(x)
x ? x.inspect : self
end

MakeMakefile.checking_for "pkg-config for #{pkg}", fmt do
MakeMakefile.checking_for "mini_portile pkg-config for #{pkg}", fmt do
if ($PKGCONFIG ||=
(pkgconfig = MakeMakefile.with_config("pkg-config") {MakeMakefile.config_string("PKG_CONFIG") || "pkg-config"}) &&
MakeMakefile.find_executable0(pkgconfig) && pkgconfig)
Expand All @@ -122,14 +122,13 @@ def fmt.%(x)
raise RuntimeError, "pkg-config is not found"
end

get = proc {|opts|
opts = Array(opts).map { |o| "--#{o}" }
opts = MakeMakefile.xpopen([pkgconfig, *opts, *args], err:[:child, :out], &:read)
MakeMakefile::Logging.open {puts opts.each_line.map{|s|"=> #{s.inspect}"}}
opts.strip if $?.success?
}
opts = Array(options).map { |o| "--#{o}" }

output = MakeMakefile.xpopen([pkgconfig, *opts, *args], err:[:child, :out], &:read)
MakeMakefile::Logging.open {puts output.each_line.map{|s|"=> #{s.inspect}"}}
raise RuntimeError, output unless $?.success?

get[options]
output.strip
end
end

Expand Down
6 changes: 3 additions & 3 deletions test/test_activate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,20 @@ def test_activate_mkmf_LDFLAGS_global
recipe.activate(mkmf: true, pkgconf: LIBXML_PC)

assert_includes($LDFLAGS.split, "-lxml2")
assert_includes($LDFLAGS.split, "-L#{MiniPortile.native_path("/foo/libxml2/2.11.5/lib")}")
assert_includes($LDFLAGS.split, "-L/foo/libxml2/2.11.5/lib")
end

def test_activate_mkmf_CFLAGS_global
recipe.activate(mkmf: true, pkgconf: LIBXML_PC)

assert_includes($CFLAGS.split, "-I#{MiniPortile.native_path("/foo/libxml2/2.11.5/include/libxml2")}")
assert_includes($CFLAGS.split, "-I/foo/libxml2/2.11.5/include/libxml2")
end

def test_activate_mkmf_chains_pkgconf_path
recipe.activate(mkmf: true, pkgconf: LIBXML_PC)
recipe.activate(mkmf: true, pkgconf: LIBXSLT_PC)

xmlflags = $CFLAGS.split.select { |v| v == "-I#{MiniPortile.native_path("/foo/libxml2/2.11.5/include/libxml2")}" }
xmlflags = $CFLAGS.split.select { |v| v == "-I/foo/libxml2/2.11.5/include/libxml2" }

# the -I from libxml should be present twice -- once from libxml2 and once from libxslt (transitively)
assert_equal(2, xmlflags.size, $CFLAGS)
Expand Down

0 comments on commit 667b7c8

Please sign in to comment.