-
Notifications
You must be signed in to change notification settings - Fork 14
Add MSYS2 platform package requirement #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Could you add CI jobs?
|
|
This commit 3ab9fea raised the following error. I'm trying to fix it now on my fork. Failure: test_cflags(PkgConfigTest)
D:/a/pkg-config/pkg-config/test/test-pkg-config.rb:202:in 'PkgConfigTest#assert_pkg_config'
D:/a/pkg-config/pkg-config/test/test-pkg-config.rb:37:in 'PkgConfigTest#test_cflags'
34:
35: def test_cflags
36: omit("Fragile on macOS") if RUBY_PLATFORM.include?("darwin")
=> 37: assert_pkg_config("glib-2.0", ["--cflags"], @glib.cflags)
38: end
39:
40: def test_cflags_only_I
<"-ID:/a/_temp/msys64/clang64/include/glib-2.0 -I/tmp/local/lib/glib-2.0/include"> expected but was
<"-ID:/a/_temp/msys64/clang64/include/glib-2.0 -I/tmp/local/lib/glib-2.0/include -ID:/a/_temp/msys64/clang64/include">
diff:
? -ID:/a/_temp/msys64/clang64/include/glib-2.0 -I/tmp/local/lib/glib-2.0/include -ID:/a/_temp/msys64/clang64/include
Error: <"-ID:/a/_temp/msys64/clang64/include/glib-2.0 -I/tmp/local/lib/glib-2.0/include"> expected but was
<"-ID:/a/_temp/msys64/clang64/include/glib-2.0 -I/tmp/local/lib/glib-2.0/include -ID:/a/_temp/msys64/clang64/include">.https://github.com/otegami/pkg-config/actions/runs/19723831055/job/56511296660#step:5:9 |
|
I investigated the test failure on MSYS2 and found that the pkg-config gem includes cflags from Requires.private dependencies, while pkgconf does not. Investigation detailsThe test_cflags and test_cflags_only_I tests fail on MSYS2 because the pkg-config gem outputs an extra include path compared to pkgconf. ref: https://github.com/otegami/pkg-config/actions/runs/19724901555/job/56514480765#step:5:20 Root causeThe pkg-config gem includes cflags from Requires.private dependencies, while pkgconf does not include them in --cflags output. In the collect_cflags method, the gem uses all_required_packages which includes both Requires and Requires.private: Current behavior comparison
|
|
Hmm. I think that OK. Let's use Could you work on it as a separated PR? It may be something like the following: diff --git a/lib/pkg-config.rb b/lib/pkg-config.rb
index 197af8b..6ef996c 100644
--- a/lib/pkg-config.rb
+++ b/lib/pkg-config.rb
@@ -37,56 +37,58 @@ module PKGConfig
/mswin/.match(RUBY_PLATFORM) and /^cl\b/.match(RbConfig::CONFIG["CC"])
end
- def package_config(package)
+ def package_config(package, **options)
PackageConfig.new(package,
- :msvc_syntax => msvc?,
- :override_variables => @@override_variables,
- :paths => @@paths)
+ {
+ msvc_syntax: msvc?,
+ override_variables: @@override_variables,
+ paths: @@paths,
+ }.merge(options))
end
- def exist?(pkg)
- package_config(pkg).exist?
+ def exist?(pkg, **options)
+ package_config(pkg, **options).exist?
end
- def libs(pkg)
- package_config(pkg).libs
+ def libs(pkg, **options)
+ package_config(pkg, **options).libs
end
- def libs_only_l(pkg)
- package_config(pkg).libs_only_l
+ def libs_only_l(pkg, **options)
+ package_config(pkg, **options).libs_only_l
end
- def libs_only_L(pkg)
- package_config(pkg).libs_only_L
+ def libs_only_L(pkg, **options)
+ package_config(pkg, **options).libs_only_L
end
- def cflags(pkg)
- package_config(pkg).cflags
+ def cflags(pkg, **options)
+ package_config(pkg, **options).cflags
end
- def cflags_only_I(pkg)
- package_config(pkg).cflags_only_I
+ def cflags_only_I(pkg, **options)
+ package_config(pkg, **options).cflags_only_I
end
- def cflags_only_other(pkg)
- package_config(pkg).cflags_only_other
+ def cflags_only_other(pkg, **options)
+ package_config(pkg, **options).cflags_only_other
end
- def modversion(pkg)
- package_config(pkg).version
+ def modversion(pkg, **options)
+ package_config(pkg, **options).version
end
- def description(pkg)
- package_config(pkg).description
+ def description(pkg, **options)
+ package_config(pkg, **options).description
end
- def variable(pkg, name)
- package_config(pkg).variable(name)
+ def variable(pkg, name, **options)
+ package_config(pkg, **options).variable(name)
end
- def check_version?(pkg, major=0, minor=0, micro=0)
+ def check_version?(pkg, major=0, minor=0, micro=0, **options)
return false unless exist?(pkg)
- ver = modversion(pkg).split(".").collect {|item| item.to_i}
+ ver = modversion(pkg, **options).split(".").collect {|item| item.to_i}
(0..2).each {|i| ver[i] = 0 unless ver[i]}
(ver[0] > major ||
@@ -95,7 +97,7 @@ module PKGConfig
ver[2] >= micro))
end
- def have_package(pkg, major=nil, minor=0, micro=0)
+ def have_package(pkg, major=nil, minor=0, micro=0, **options)
message = "#{pkg}"
unless major.nil?
message << " version (>= #{major}.#{minor}.#{micro})"
@@ -105,7 +107,7 @@ module PKGConfig
if check_version?(pkg, major, minor, micro)
"yes (#{modversion(pkg)})"
else
- if exist?(pkg)
+ if exist?(pkg, **options)
"no (#{modversion(pkg)})"
else
"no (nonexistent)"
@@ -408,6 +410,7 @@ class PackageConfig
@paths.unshift(*(@options[:paths] || []))
@paths = normalize_paths(@paths)
@msvc_syntax = @options[:msvc_syntax]
+ @static = @options[:static]
@variables = @declarations = nil
override_variables = self.class.custom_override_variables
@override_variables = parse_override_variables(override_variables)
@@ -528,7 +531,12 @@ class PackageConfig
private
def collect_cflags
- target_packages = [self, *all_required_packages]
+ target_packages = [self]
+ if @static
+ target_packages += all_required_packages
+ else
+ target_packages += required_packages
+ end
cflags_set = []
target_packages.each do |package|
cflags_set << package.declaration("Cflags")
@@ -580,7 +588,12 @@ class PackageConfig
end
def collect_libs
- target_packages = [*required_packages, self]
+ if @static
+ target_packages = required_packages
+ else
+ target_packages = all_required_packages
+ end
+ target_packages += [self]
libs_set = []
target_packages.each do |package|
libs_set << package.declaration("Libs") |
GitHub: - ruby-gnome#41 (comment) - ruby-gnome#41 (comment) By default, exclude `Requires.private` dependencies from cflags and libs output to match pkgconf's behavior. When the new `static: true` option is specified, include `Requires.private` dependencies for static linking scenarios. This change makes the default behavior consistent with pkgconf while still supporting static linking use-cases through an explicit option. Co-Authored-By: kou <kou@clear-code.com>
|
@kou |
## Issue On MSYS2 environments, installing gems that depend on pkgconf might fail because the pkgconf system package cannot be automatically installed. ## Cause The pkg-config gem was missing MSYS2 platform configuration in its system package requirements. Without this, the rubygems-requirements-system gem cannot automatically install the pkgconfg system package on MSYS2 environments. ## Solution Add `system: pkgconf: msys2: pkgconf` to the gemspec requirements. This works with rubygems-requirements-system which supports MSYS2 platform.
3ab9fea to
66fed8a
Compare
Issue
On MSYS2 environments, installing gems that depend on pkgconf might fail because the pkgconf system package cannot be automatically installed.
Cause
The pkg-config gem was missing MSYS2 platform
configuration in its system package requirements.
Without this, the rubygems-requirements-system gem cannot automatically install the pkgconfg system
package on MSYS2 environments.
Solution
Add
system: pkgconf: msys2: pkgconfto the gemspec requirements.This works with rubygems-requirements-system which supports MSYS2 platform.