Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6b1f096

Browse files
committedSep 10, 2023
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.
1 parent 5f75815 commit 6b1f096

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed
 

‎examples/Rakefile

+28-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ require 'rbconfig'
33
$: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
44
require "mini_portile2"
55

6+
require "mkmf"
7+
68
recipes = []
9+
recipe_hooks = {}
710

811
def windows?
912
RbConfig::CONFIG['target_os'] =~ /mswin|mingw32/
@@ -119,6 +122,26 @@ zlib.files << {
119122

120123
recipes.push zlib
121124

125+
#
126+
# libyaml, using pkgconf for configuration
127+
#
128+
yaml = MiniPortile.new("yaml", "0.2.5")
129+
yaml.files = [{
130+
url: "https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz",
131+
sha256: "c642ae9b75fee120b2d96c712538bd2cf283228d2337df2cf2988e3c02678ef4",
132+
}]
133+
recipes.push(yaml)
134+
recipe_hooks["yaml"] = lambda do |recipe|
135+
conf = pkg_config(File.join(recipe.path, "lib", "pkgconfig", "yaml-0.1.pc"))
136+
puts "pkg_config: #{conf.inspect}"
137+
138+
expected = "-L" + MiniPortile.native_path(File.join(recipe.path, "lib"))
139+
$LDFLAGS.split.include?(expected) or raise(<<~MSG)
140+
assertion failed: LDFLAGS not updated correctly:
141+
#{$LDFLAGS}
142+
should have included '#{expected}'
143+
MSG
144+
end
122145

123146
namespace :ports do
124147
directory "ports"
@@ -136,6 +159,9 @@ namespace :ports do
136159
task recipe.name => ["ports"] do |t|
137160
recipe.cook
138161
recipe.activate
162+
if hook = recipe_hooks[recipe.name]
163+
hook.call(recipe)
164+
end
139165
end
140166

141167
task :all => recipe.name
@@ -146,7 +172,8 @@ namespace :ports do
146172
recipes.each do |recipe|
147173
puts "Artifacts of '#{recipe.name}' in '#{recipe.path}'"
148174
end
149-
puts "LDFLAGS: " + ENV['LDFLAGS'].inspect
175+
puts "LIBRARY_PATH: #{ENV['LIBRARY_PATH'].inspect}"
176+
puts "LDFLAGS: #{ENV['LDFLAGS'].inspect}, #{$LDFLAGS.inspect}"
150177
end
151178
end
152179

0 commit comments

Comments
 (0)
Please sign in to comment.