Skip to content

Commit dbbeb23

Browse files
committed
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 9a51dfe commit dbbeb23

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
@@ -1,9 +1,11 @@
11
require 'rbconfig'
2+
require 'mkmf'
23

34
$: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
45
require "mini_portile2"
56

67
recipes = []
8+
recipe_hooks = {}
79

810
def windows?
911
RbConfig::CONFIG['target_os'] =~ /mswin|mingw32/
@@ -119,6 +121,28 @@ zlib.files << {
119121

120122
recipes.push zlib
121123

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

123147
namespace :ports do
124148
directory "ports"
@@ -136,6 +160,9 @@ namespace :ports do
136160
task recipe.name => ["ports"] do |t|
137161
recipe.cook
138162
recipe.activate
163+
if hook = recipe_hooks[recipe.name]
164+
hook.call(recipe)
165+
end
139166
end
140167

141168
task :all => recipe.name
@@ -146,7 +173,7 @@ namespace :ports do
146173
recipes.each do |recipe|
147174
puts "Artifacts of '#{recipe.name}' in '#{recipe.path}'"
148175
end
149-
puts "LDFLAGS: " + ENV['LDFLAGS'].inspect
176+
puts "LDFLAGS: #{ENV['LDFLAGS'].inspect}, #{$LDFLAGS.inspect}"
150177
end
151178
end
152179

0 commit comments

Comments
 (0)