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 c250c54
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
43 changes: 22 additions & 21 deletions lib/mini_portile2/mini_portile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,28 +109,29 @@ def fmt.%(x)
x ? x.inspect : self
end

MakeMakefile.checking_for "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)
# default to pkg-config command
pkgconfig = $PKGCONFIG
args = [pkg]
elsif MakeMakefile.find_executable0(pkgconfig = "#{pkg}-config")
# default to package specific config command, as a last resort.
else
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?
}

get[options]
if ($PKGCONFIG ||=
(pkgconfig = MakeMakefile.with_config("pkg-config") {MakeMakefile.config_string("PKG_CONFIG") || "pkg-config"}) &&
MakeMakefile.find_executable0(pkgconfig) && pkgconfig)
# default to pkg-config command
pkgconfig = $PKGCONFIG
args = [pkg]
elsif MakeMakefile.find_executable0(pkgconfig = "#{pkg}-config")
# default to package specific config command, as a last resort.
else
raise RuntimeError, "pkg-config is not found"
end

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

get[options]
end

def initialize(name, version, **kwargs)
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 c250c54

Please sign in to comment.