Skip to content

Commit

Permalink
test: add an example that uses MakeMakefile.pkg_config
Browse files Browse the repository at this point in the history
and a local pkgconf file. This should catch the issue with fedora's
pkgconf in #118.
  • Loading branch information
flavorjones committed Sep 9, 2023
1 parent 9a51dfe commit dbbeb23
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion examples/Rakefile
Original file line number Diff line number Diff line change
@@ -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/
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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

Expand Down

0 comments on commit dbbeb23

Please sign in to comment.