From c250c5424bf5f983fecfa7901363c9bcebbdf37c Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sun, 10 Sep 2023 17:43:31 -0400 Subject: [PATCH] wip --- lib/mini_portile2/mini_portile.rb | 43 ++++++++++++++++--------------- test/test_activate.rb | 6 ++--- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/lib/mini_portile2/mini_portile.rb b/lib/mini_portile2/mini_portile.rb index 79f4c8e..c97e93c 100644 --- a/lib/mini_portile2/mini_portile.rb +++ b/lib/mini_portile2/mini_portile.rb @@ -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) diff --git a/test/test_activate.rb b/test/test_activate.rb index 5498cce..7d2d0f5 100644 --- a/test/test_activate.rb +++ b/test/test_activate.rb @@ -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)