From 62b9a6ed182005677d8bf5e149305f3764c4fccc Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 9 Sep 2023 12:41:08 -0400 Subject: [PATCH] test: add an example that uses MakeMakefile.pkg_config and a local pkgconf file. This should catch the issue with fedora's pkgconf in #118. --- examples/Rakefile | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/examples/Rakefile b/examples/Rakefile index 7e60c55..2db3eee 100644 --- a/examples/Rakefile +++ b/examples/Rakefile @@ -1,9 +1,11 @@ require 'rbconfig' +require 'mkmf' $: << File.expand_path(File.join(File.dirname(__FILE__), "../lib")) require "mini_portile2" recipes = [] +recipe_hooks = {} def windows? RbConfig::CONFIG['target_os'] =~ /mswin|mingw32/ @@ -119,6 +121,28 @@ zlib.files << { recipes.push zlib +# +# libyaml, using pkgconf for configuration +# +yaml = MiniPortile.new("yaml", "0.2.5") +yaml.files = [{ + url: "https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz", + sha256: "c642ae9b75fee120b2d96c712538bd2cf283228d2337df2cf2988e3c02678ef4", + }] +recipes.push(yaml) +recipe_hooks["yaml"] = lambda do |recipe| + expected = "-L" + File.join(recipe.path, "lib") + !$LDFLAGS.split.include?(expected) or raise "assertion failed on setup" + + conf = pkg_config(File.join(recipe.path, "lib", "pkgconfig", "yaml-0.1.pc")) + puts "pkg_config: #{conf.inspect}" + + $LDFLAGS.split.include?(expected) or raise(<<~MSG) + assertion failed: LDFLAGS not updated correctly: + #{$LDFLAGS} + should have included '#{expected}' + MSG +end namespace :ports do directory "ports" @@ -136,6 +160,9 @@ namespace :ports do task recipe.name => ["ports"] do |t| recipe.cook recipe.activate + if hook = recipe_hooks[recipe.name] + hook.call(recipe) + end end task :all => recipe.name @@ -146,7 +173,7 @@ namespace :ports do recipes.each do |recipe| puts "Artifacts of '#{recipe.name}' in '#{recipe.path}'" end - puts "LDFLAGS: " + ENV['LDFLAGS'].inspect + puts "LDFLAGS: #{ENV['LDFLAGS'].inspect}, #{$LDFLAGS.inspect}" end end