Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package rubygem-mini_portile2 for 
openSUSE:Factory checked in at 2023-11-05 12:18:45
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-mini_portile2 (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-mini_portile2.new.17445 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-mini_portile2"

Sun Nov  5 12:18:45 2023 rev:12 rq:1123196 version:2.8.5

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/rubygem-mini_portile2/rubygem-mini_portile2.changes  
    2023-10-01 21:22:10.288352754 +0200
+++ 
/work/SRC/openSUSE:Factory/.rubygem-mini_portile2.new.17445/rubygem-mini_portile2.changes
   2023-11-05 12:18:59.349566827 +0100
@@ -1,0 +2,21 @@
+Fri Nov  3 07:42:17 UTC 2023 - Dan Čermák <dan.cer...@posteo.net>
+
+- ### 2.8.5 / 2023-10-22
+
+#### Added
+
+- New methods `#lib_path` and `#include_path` which point at the installed 
directories under `ports`. (by @flavorjones)
+- Add config param for CMAKE_BUILD_TYPE, which now defaults to `Release`. 
(#136 by @Watson1978)
+
+#### Experimental
+
+Introduce experimental support for `MiniPortile#mkmf_config` which sets up 
MakeMakefile variables to properly link against the recipe. This should make it 
easier for C extensions to package third-party libraries. (by @flavorjones)
+
+- With no arguments, will set up just `$INCFLAGS`, `$libs`, and `$LIBPATH`.
+- Optionally, if provided a pkg-config file, will use that config to more 
precisely set `$INCFLAGS`, `$libs`, `$LIBPATH`, and `$CFLAGS`/`$CXXFLAGS`.
+- Optionally, if provided the name of a static archive, will rewrite linker 
flags to ensure correct linkage.
+
+Note that the behavior may change slightly before official support is 
announced. Please comment on 
[#118](https://github.com/flavorjones/mini_portile/issues/118) if you have 
feedback.
+
+
+-------------------------------------------------------------------

Old:
----
  mini_portile2-2.8.4.gem

New:
----
  mini_portile2-2.8.5.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-mini_portile2.spec ++++++
--- /var/tmp/diff_new_pack.R4NbV7/_old  2023-11-05 12:19:00.093594120 +0100
+++ /var/tmp/diff_new_pack.R4NbV7/_new  2023-11-05 12:19:00.093594120 +0100
@@ -24,25 +24,25 @@
 #
 
 Name:           rubygem-mini_portile2
-Version:        2.8.4
+Version:        2.8.5
 Release:        0
 %define mod_name mini_portile2
 %define mod_full_name %{mod_name}-%{version}
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 BuildRequires:  %{ruby >= 2.3.0}
 BuildRequires:  %{rubygem gem2rpm}
 BuildRequires:  ruby-macros >= 5
 URL:            https://github.com/flavorjones/mini_portile
 Source:         https://rubygems.org/gems/%{mod_full_name}.gem
 Source1:        gem2rpm.yml
-Summary:        Simplistic port-like solution for developers
+Summary:        Simple autoconf and cmake builder for developers
 License:        MIT
-Group:          Development/Languages/Ruby
 
 %description
-Simplistic port-like solution for developers. It provides a standard and
-simplified way to compile against dependency libraries without messing up your
-system.
+Simple autoconf and cmake builder for developers. It provides a standard way
+to compile against
+dependency libraries without requiring system-wide installation. It also
+simplifies
+vendoring and cross-compilation by providing a consistent build interface.
 
 %prep
 

++++++ mini_portile2-2.8.4.gem -> mini_portile2-2.8.5.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/.github/workflows/ci.yml new/.github/workflows/ci.yml
--- old/.github/workflows/ci.yml        2023-07-18 16:04:52.000000000 +0200
+++ new/.github/workflows/ci.yml        2023-10-22 17:13:47.000000000 +0200
@@ -67,5 +67,22 @@
       - uses: actions/cache@v3
         with:
           path: examples/ports/archives
-          key: ${{ matrix.platform }}-examples-${{ 
hashFiles('examples/Rakefile') }}
+          key: examples-${{ hashFiles('examples/Rakefile') }}
+      - run: bundle exec rake test:examples
+
+  fedora: # see https://github.com/flavorjones/mini_portile/issues/118
+    runs-on: ubuntu-latest
+    container:
+      image: fedora:35
+    steps:
+      - run: |
+          dnf group install -y "C Development Tools and Libraries"
+          dnf install -y ruby ruby-devel libyaml-devel git-all patch cmake xz
+      - uses: actions/checkout@v3
+      - uses: actions/cache@v3
+        with:
+          path: examples/ports/archives
+          key: examples-${{ hashFiles('examples/Rakefile') }}
+      - run: bundle install
+      - run: bundle exec rake test:unit
       - run: bundle exec rake test:examples
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/.gitignore new/.gitignore
--- old/.gitignore      2023-07-18 16:04:52.000000000 +0200
+++ new/.gitignore      2023-10-22 17:13:47.000000000 +0200
@@ -3,3 +3,4 @@
 pkg
 ports
 tmp
+mkmf.log
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md    2023-07-18 16:04:52.000000000 +0200
+++ new/CHANGELOG.md    2023-10-22 17:13:47.000000000 +0200
@@ -1,5 +1,23 @@
 ## mini_portile changelog
 
+### 2.8.5 / 2023-10-22
+
+#### Added
+
+- New methods `#lib_path` and `#include_path` which point at the installed 
directories under `ports`. (by @flavorjones)
+- Add config param for CMAKE_BUILD_TYPE, which now defaults to `Release`. 
(#136 by @Watson1978)
+
+#### Experimental
+
+Introduce experimental support for `MiniPortile#mkmf_config` which sets up 
MakeMakefile variables to properly link against the recipe. This should make it 
easier for C extensions to package third-party libraries. (by @flavorjones)
+
+- With no arguments, will set up just `$INCFLAGS`, `$libs`, and `$LIBPATH`.
+- Optionally, if provided a pkg-config file, will use that config to more 
precisely set `$INCFLAGS`, `$libs`, `$LIBPATH`, and `$CFLAGS`/`$CXXFLAGS`.
+- Optionally, if provided the name of a static archive, will rewrite linker 
flags to ensure correct linkage.
+
+Note that the behavior may change slightly before official support is 
announced. Please comment on 
[#118](https://github.com/flavorjones/mini_portile/issues/118) if you have 
feedback.
+
+
 ### 2.8.4 / 2023-07-18
 
 - cmake: set CMAKE compile flags to configure cross-compilation similarly to 
`autotools` `--host` flag: `SYSTEM_NAME`, `SYSTEM_PROCESSOR`, `C_COMPILER`, and 
`CXX_COMPILER`. [#130] (Thanks, @stanhu!)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md       2023-07-18 16:04:52.000000000 +0200
+++ new/README.md       2023-10-22 17:13:47.000000000 +0200
@@ -138,8 +138,8 @@
 The cmake command used is configurable, and in order of preference will use:
 
 - the `CMAKE` environment variable (if present)
-- the `cmake_command` value passed in to the constructor
-- `"cmake"`
+- the `:cmake_command` keyword argument passed into the constructor
+- `"cmake"` (the default)
 
 You can pass it in like so:
 
@@ -147,6 +147,19 @@
 MiniPortileCMake.new("libfoobar", "1.3.5", cmake_command: "cmake3")
 ```
 
+#### `cmake_build_type`
+
+The cmake build type is configurable as of v2.8.5, and in order of preference 
will use:
+
+- the `CMAKE_BUILD_TYPE` environment variable (if present)
+- the `:cmake_build_type` keyword argument passed into the constructor
+- `"Release"` (the default)
+
+You can pass it in like so:
+
+``` ruby
+MiniPortileCMake.new("libfoobar", "1.3.5", cmake_build_type: "Debug")
+```
 
 ### Local source directories
 
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mini_portile2/mini_portile.rb 
new/lib/mini_portile2/mini_portile.rb
--- old/lib/mini_portile2/mini_portile.rb       2023-07-18 16:04:52.000000000 
+0200
+++ new/lib/mini_portile2/mini_portile.rb       2023-10-22 17:13:47.000000000 
+0200
@@ -27,12 +27,14 @@
   end
 end
 
+$MINI_PORTILE_STATIC_LIBS = {}
+
 class MiniPortile
   DEFAULT_TIMEOUT = 10
 
-  attr_reader :name, :version, :original_host
+  attr_reader :name, :version, :original_host, :source_directory
   attr_writer :configure_options
-  attr_accessor :host, :files, :patch_files, :target, :logger, 
:source_directory
+  attr_accessor :host, :files, :patch_files, :target, :logger
 
   def self.windows?
     target_os =~ /mswin|mingw/
@@ -76,6 +78,24 @@
     RbConfig::CONFIG['target_cpu']
   end
 
+  def self.native_path(path)
+    path = File.expand_path(path)
+    if File::ALT_SEPARATOR
+      path.tr(File::SEPARATOR, File::ALT_SEPARATOR)
+    else
+      path
+    end
+  end
+
+  def self.posix_path(path)
+    path = File.expand_path(path)
+    if File::ALT_SEPARATOR
+      "/" + path.tr(File::ALT_SEPARATOR, File::SEPARATOR).tr(":", 
File::SEPARATOR)
+    else
+      path
+    end
+  end
+
   def initialize(name, version, **kwargs)
     @name = name
     @version = version
@@ -86,12 +106,12 @@
     @logger = STDOUT
     @source_directory = nil
 
-    @original_host = @host = detect_host
-
     @gcc_command = kwargs[:gcc_command]
     @make_command = kwargs[:make_command]
     @open_timeout = kwargs[:open_timeout] || DEFAULT_TIMEOUT
     @read_timeout = kwargs[:read_timeout] || DEFAULT_TIMEOUT
+
+    @original_host = @host = detect_host
   end
 
   def source_directory=(path)
@@ -219,11 +239,10 @@
   end
 
   def activate
-    lib_path = File.join(port_path, "lib")
     vars = {
       'PATH'          => File.join(port_path, 'bin'),
-      'CPATH'         => File.join(port_path, 'include'),
-      'LIBRARY_PATH'  => lib_path
+      'CPATH'         => include_path,
+      'LIBRARY_PATH'  => lib_path,
     }.reject { |env, path| !File.directory?(path) }
 
     output "Activating #{@name} #{@version} (from #{port_path})..."
@@ -240,7 +259,7 @@
 
     # rely on LDFLAGS when cross-compiling
     if File.exist?(lib_path) && (@host != @original_host)
-      full_path = File.expand_path(lib_path)
+      full_path = native_path(lib_path)
 
       old_value = ENV.fetch("LDFLAGS", "")
 
@@ -250,10 +269,109 @@
     end
   end
 
+  # pkg: the pkg-config file name (without the .pc extension)
+  # dir: inject the directory path for the pkg-config file (probably only 
useful for tests)
+  # static: the name of the static library archive (without the "lib" prefix 
or the file extension), or nil for dynamic linking
+  #
+  # we might be able to be terribly clever and infer the name of the static 
archive file, but
+  # unfortunately projects have so much freedom in what they can report (for 
name, for libs, etc.)
+  # that it feels unreliable to try to do so, so I'm preferring to just have 
the developer make it
+  # explicit.
+  def mkmf_config(pkg: nil, dir: nil, static: nil)
+    require "mkmf"
+
+    if pkg
+      dir ||= File.join(lib_path, "pkgconfig")
+      pcfile = File.join(dir, "#{pkg}.pc")
+      unless File.exist?(pcfile)
+        raise ArgumentError, "pkg-config file '#{pcfile}' does not exist"
+      end
+
+      output "Configuring MakeMakefile for #{File.basename(pcfile)} (in 
#{File.dirname(pcfile)})\n"
+
+      # on macos, pkg-config will not return --cflags without this
+      ENV["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "t"
+
+      # append to PKG_CONFIG_PATH as we go, so later pkg-config files can 
depend on earlier ones
+      ENV["PKG_CONFIG_PATH"] = [ENV["PKG_CONFIG_PATH"], 
dir].compact.join(File::PATH_SEPARATOR)
+
+      incflags = minimal_pkg_config(pcfile, "cflags-only-I")
+      cflags = minimal_pkg_config(pcfile, "cflags-only-other")
+      if static
+        ldflags = minimal_pkg_config(pcfile, "libs-only-L", "static")
+        libflags = minimal_pkg_config(pcfile, "libs-only-l", "static")
+      else
+        ldflags = minimal_pkg_config(pcfile, "libs-only-L")
+        libflags = minimal_pkg_config(pcfile, "libs-only-l")
+      end
+    else
+      output "Configuring MakeMakefile for #{@name} #{@version} (from 
#{path})\n"
+
+      lib_name = name.sub(/\Alib/, "") # TODO: use delete_prefix when we no 
longer support ruby 2.4
+
+      incflags = Dir.exist?(include_path) ? "-I#{include_path}" : ""
+      cflags = ""
+      ldflags = Dir.exist?(lib_path) ? "-L#{lib_path}" : ""
+      libflags = Dir.exist?(lib_path) ? "-l#{lib_name}" : ""
+    end
+
+    if static
+      libdir = lib_path
+      if pcfile
+        variables = minimal_pkg_config(pcfile, 
"print-variables").split("\n").map(&:strip)
+        if variables.include?("libdir")
+          libdir = minimal_pkg_config(pcfile, "variable=libdir")
+        end
+      end
+
+      #
+      # keep track of the libraries we're statically linking against, and fix 
up ldflags and
+      # libflags to make sure we link statically against the recipe's libaries.
+      #
+      # this avoids the unintentionally dynamically linking against system 
libraries, and makes sure
+      # that if multiple pkg-config files reference each other that we are 
able to intercept flags
+      # from dependent packages that reference the static archive.
+      #
+      $MINI_PORTILE_STATIC_LIBS[static] = libdir
+      static_ldflags = $MINI_PORTILE_STATIC_LIBS.values.map { |v| "-L#{v}" }
+      static_libflags = $MINI_PORTILE_STATIC_LIBS.keys.map { |v| "-l#{v}" }
+
+      # remove `-L#{libdir}` and `-lfoo`. we don't need them since we link 
against the static
+      # archive using the full path.
+      ldflags = ldflags.shellsplit.reject { |f| static_ldflags.include?(f) 
}.shelljoin
+      libflags = libflags.shellsplit.reject { |f| static_libflags.include?(f) 
}.shelljoin
+
+      # prepend the full path to the static archive to the linker flags
+      static_archive = File.join(libdir, "lib#{static}.#{$LIBEXT}")
+      libflags = [static_archive, libflags].join(" ").strip
+    end
+
+    # prefer this package by prepending to search paths and library flags
+    #
+    # convert the ldflags into a list of directories and append to $LIBPATH 
(instead of just using
+    # $LDFLAGS) to ensure we get the `-Wl,-rpath` linker flag for re-finding 
shared libraries.
+    $INCFLAGS = [incflags, $INCFLAGS].join(" ").strip
+    libpaths = ldflags.shellsplit.map { |f| f.sub(/\A-L/, "") }
+    $LIBPATH = libpaths | $LIBPATH
+    $libs = [libflags, $libs].join(" ").strip
+
+    # prefer this package's compiler flags by appending them to the command 
line
+    $CFLAGS = [$CFLAGS, cflags].join(" ").strip
+    $CXXFLAGS = [$CXXFLAGS, cflags].join(" ").strip
+  end
+
   def path
     File.expand_path(port_path)
   end
 
+  def include_path
+    File.join(path, "include")
+  end
+
+  def lib_path
+    File.join(path, "lib")
+  end
+
   def gcc_cmd
     (ENV["CC"] || @gcc_command || RbConfig::CONFIG["CC"] || "gcc").dup
   end
@@ -265,21 +383,11 @@
   private
 
   def native_path(path)
-    path = File.expand_path(path)
-    if File::ALT_SEPARATOR
-      path.tr(File::SEPARATOR, File::ALT_SEPARATOR)
-    else
-      path
-    end
+    MiniPortile.native_path(path)
   end
 
   def posix_path(path)
-    path = File.expand_path(path)
-    if File::ALT_SEPARATOR
-      "/" + path.tr(File::ALT_SEPARATOR, File::SEPARATOR).tr(":", 
File::SEPARATOR)
-    else
-      path
-    end
+    MiniPortile.posix_path(path)
   end
 
   def tmp_path
@@ -648,4 +756,29 @@
     FileUtils.mkdir_p File.dirname(full_path)
     FileUtils.mv temp_file.path, full_path, :force => true
   end
+
+  #
+  #  this minimal version of pkg_config is based on ruby 29dc9378 (2023-01-09)
+  #
+  #  specifically with the fix from b90e56e6 to support multiple pkg-config 
options, and removing
+  #  code paths that aren't helpful for mini-portile's use case of parsing pc 
files.
+  #
+  def minimal_pkg_config(pkg, *pcoptions)
+    if pcoptions.empty?
+      raise ArgumentError, "no pkg-config options are given"
+    end
+
+    if ($PKGCONFIG ||=
+        (pkgconfig = MakeMakefile.with_config("pkg-config") 
{MakeMakefile.config_string("PKG_CONFIG") || "pkg-config"}) &&
+        MakeMakefile.find_executable0(pkgconfig) && pkgconfig)
+      pkgconfig = $PKGCONFIG
+    else
+      raise RuntimeError, "pkg-config is not found"
+    end
+
+    pcoptions = Array(pcoptions).map { |o| "--#{o}" }
+    response = IO.popen([pkgconfig, *pcoptions, pkg], err:[:child, :out], 
&:read)
+    raise RuntimeError, response unless $?.success?
+    response.strip
+  end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mini_portile2/mini_portile_cmake.rb 
new/lib/mini_portile2/mini_portile_cmake.rb
--- old/lib/mini_portile2/mini_portile_cmake.rb 2023-07-18 16:04:52.000000000 
+0200
+++ new/lib/mini_portile2/mini_portile_cmake.rb 2023-10-22 17:13:47.000000000 
+0200
@@ -11,6 +11,7 @@
   def initialize(name, version, **kwargs)
     super(name, version, **kwargs)
     @cmake_command = kwargs[:cmake_command]
+    @cmake_build_type = kwargs[:cmake_build_type]
   end
 
   def configure_defaults
@@ -49,6 +50,10 @@
     (ENV["CMAKE"] || @cmake_command || "cmake").dup
   end
 
+  def cmake_build_type
+    (ENV["CMAKE_BUILD_TYPE"] || @cmake_build_type || "Release").dup
+  end
+
   private
 
   def generator_defaults
@@ -69,7 +74,8 @@
       "-DCMAKE_SYSTEM_NAME=#{cmake_system_name}",
       "-DCMAKE_SYSTEM_PROCESSOR=#{cpu_type}",
       "-DCMAKE_C_COMPILER=#{c_compiler}",
-      "-DCMAKE_CXX_COMPILER=#{cxx_compiler}"
+      "-DCMAKE_CXX_COMPILER=#{cxx_compiler}",
+      "-DCMAKE_BUILD_TYPE=#{cmake_build_type}",
     ]
   end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mini_portile2/version.rb 
new/lib/mini_portile2/version.rb
--- old/lib/mini_portile2/version.rb    2023-07-18 16:04:52.000000000 +0200
+++ new/lib/mini_portile2/version.rb    2023-10-22 17:13:47.000000000 +0200
@@ -1,3 +1,3 @@
 class MiniPortile
-  VERSION = "2.8.4"
+  VERSION = "2.8.5"
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2023-07-18 16:04:52.000000000 +0200
+++ new/metadata        2023-10-22 17:13:47.000000000 +0200
@@ -1,7 +1,7 @@
 --- !ruby/object:Gem::Specification
 name: mini_portile2
 version: !ruby/object:Gem::Version
-  version: 2.8.4
+  version: 2.8.5
 platform: ruby
 authors:
 - Luis Lavena
@@ -10,7 +10,7 @@
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2023-07-18 00:00:00.000000000 Z
+date: 2023-10-22 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: bundler
@@ -96,9 +96,10 @@
     - - "~>"
       - !ruby/object:Gem::Version
         version: '1.7'
-description: Simplistic port-like solution for developers. It provides a 
standard
-  and simplified way to compile against dependency libraries without messing 
up your
-  system.
+description: |
+  Simple autoconf and cmake builder for developers. It provides a standard way 
to compile against
+  dependency libraries without requiring system-wide installation. It also 
simplifies
+  vendoring and cross-compilation by providing a consistent build interface.
 email: mike.dales...@gmail.com
 executables: []
 extensions: []
@@ -123,17 +124,23 @@
 - test/assets/gpg-fixtures/data.asc
 - test/assets/gpg-fixtures/data.invalid.asc
 - test/assets/patch 1.diff
+- test/assets/pkgconf/libxml2/libxml-2.0.pc
+- test/assets/pkgconf/libxslt/libexslt.pc
+- test/assets/pkgconf/libxslt/libxslt.pc
 - test/assets/test mini portile-1.0.0/configure
 - test/assets/test-cmake-1.0/CMakeLists.txt
 - test/assets/test-cmake-1.0/hello.c
 - test/assets/test-download-archive.tar.gz
 - test/helper.rb
+- test/test_activate.rb
 - test/test_cmake.rb
 - test/test_cook.rb
 - test/test_digest.rb
 - test/test_download.rb
 - test/test_execute.rb
+- test/test_mkmf_config.rb
 - test/test_proxy.rb
+- test/test_recipe.rb
 homepage: https://github.com/flavorjones/mini_portile
 licenses:
 - MIT
@@ -153,24 +160,30 @@
     - !ruby/object:Gem::Version
       version: '0'
 requirements: []
-rubygems_version: 3.4.10
+rubygems_version: 3.4.19
 signing_key: 
 specification_version: 4
-summary: Simplistic port-like solution for developers
+summary: Simple autoconf and cmake builder for developers
 test_files:
 - test/assets/git/config
 - test/assets/gpg-fixtures/data
 - test/assets/gpg-fixtures/data.asc
 - test/assets/gpg-fixtures/data.invalid.asc
 - test/assets/patch 1.diff
+- test/assets/pkgconf/libxml2/libxml-2.0.pc
+- test/assets/pkgconf/libxslt/libexslt.pc
+- test/assets/pkgconf/libxslt/libxslt.pc
 - test/assets/test mini portile-1.0.0/configure
 - test/assets/test-cmake-1.0/CMakeLists.txt
 - test/assets/test-cmake-1.0/hello.c
 - test/assets/test-download-archive.tar.gz
 - test/helper.rb
+- test/test_activate.rb
 - test/test_cmake.rb
 - test/test_cook.rb
 - test/test_digest.rb
 - test/test_download.rb
 - test/test_execute.rb
+- test/test_mkmf_config.rb
 - test/test_proxy.rb
+- test/test_recipe.rb
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mini_portile2.gemspec new/mini_portile2.gemspec
--- old/mini_portile2.gemspec   2023-07-18 16:04:52.000000000 +0200
+++ new/mini_portile2.gemspec   2023-10-22 17:13:47.000000000 +0200
@@ -1,7 +1,4 @@
-# coding: utf-8
-lib = File.expand_path("../lib", __FILE__)
-$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-require "mini_portile2/version"
+require_relative "lib/mini_portile2/version"
 
 Gem::Specification.new do |spec|
   spec.name = "mini_portile2"
@@ -10,8 +7,12 @@
   spec.authors = ["Luis Lavena", "Mike Dalessio", "Lars Kanis"]
   spec.email = "mike.dales...@gmail.com"
 
-  spec.summary = "Simplistic port-like solution for developers"
-  spec.description = "Simplistic port-like solution for developers. It 
provides a standard and simplified way to compile against dependency libraries 
without messing up your system."
+  spec.summary = "Simple autoconf and cmake builder for developers"
+  spec.description = <<~TEXT
+    Simple autoconf and cmake builder for developers. It provides a standard 
way to compile against
+    dependency libraries without requiring system-wide installation. It also 
simplifies
+    vendoring and cross-compilation by providing a consistent build interface.
+  TEXT
 
   spec.homepage = "https://github.com/flavorjones/mini_portile";
   spec.licenses = ["MIT"]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/assets/pkgconf/libxml2/libxml-2.0.pc 
new/test/assets/pkgconf/libxml2/libxml-2.0.pc
--- old/test/assets/pkgconf/libxml2/libxml-2.0.pc       1970-01-01 
01:00:00.000000000 +0100
+++ new/test/assets/pkgconf/libxml2/libxml-2.0.pc       2023-10-22 
17:13:47.000000000 +0200
@@ -0,0 +1,13 @@
+prefix=/foo/libxml2/2.11.5
+exec_prefix=${prefix}
+libdir=/foo/libxml2/2.11.5/lib
+includedir=${prefix}/include
+modules=1
+
+Name: libXML
+Version: 2.11.5
+Description: libXML library version2.
+Requires:
+Libs: -L${libdir} -lxml2
+Libs.private: -L/foo/zlib/1.3/lib -lz     -lm  
+Cflags: -I${includedir}/libxml2 -ggdb3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/assets/pkgconf/libxslt/libexslt.pc 
new/test/assets/pkgconf/libxslt/libexslt.pc
--- old/test/assets/pkgconf/libxslt/libexslt.pc 1970-01-01 01:00:00.000000000 
+0100
+++ new/test/assets/pkgconf/libxslt/libexslt.pc 2023-10-22 17:13:47.000000000 
+0200
@@ -0,0 +1,13 @@
+prefix=/foo/libxslt/1.1.38
+exec_prefix=${prefix}
+libdir=/foo/libxslt/1.1.38/lib
+includedir=${prefix}/include
+
+
+Name: libexslt
+Version: 0.8.21
+Description: EXSLT Extension library
+Requires: libxml-2.0, libxslt
+Cflags: -I${includedir}
+Libs: -L${libdir} -lexslt
+Libs.private: -lm 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/assets/pkgconf/libxslt/libxslt.pc 
new/test/assets/pkgconf/libxslt/libxslt.pc
--- old/test/assets/pkgconf/libxslt/libxslt.pc  1970-01-01 01:00:00.000000000 
+0100
+++ new/test/assets/pkgconf/libxslt/libxslt.pc  2023-10-22 17:13:47.000000000 
+0200
@@ -0,0 +1,13 @@
+prefix=/foo/libxslt/1.1.38
+exec_prefix=${prefix}
+libdir=/foo/libxslt/1.1.38/lib
+includedir=${prefix}/include
+
+
+Name: libxslt
+Version: 1.1.38
+Description: XSLT library version 2.
+Requires: libxml-2.0
+Cflags: -I${includedir} -Wno-deprecated-enum-enum-conversion
+Libs: -L${libdir} -lxslt
+Libs.private: -lm
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/test_activate.rb new/test/test_activate.rb
--- old/test/test_activate.rb   1970-01-01 01:00:00.000000000 +0100
+++ new/test/test_activate.rb   2023-10-22 17:13:47.000000000 +0200
@@ -0,0 +1,139 @@
+require File.expand_path('../helper', __FILE__)
+
+class TestActivate < TestCase
+  attr_reader :recipe
+
+  def setup
+    super
+
+    @save_env = %w[PATH CPATH LIBRARY_PATH LDFLAGS].inject({}) do |env, var|
+      env.update(var => ENV[var])
+    end
+
+    FileUtils.rm_rf(["tmp", "ports"]) # remove any previous test files
+
+    @recipe = MiniPortile.new("foo", "1.0.0").tap do |recipe|
+      recipe.logger = StringIO.new
+    end
+  end
+
+  def teardown
+    FileUtils.rm_rf(["tmp", "ports"]) # remove any previous test files
+
+    @save_env.each do |var, val|
+      ENV[var] = val
+    end
+
+    super
+  end
+
+  def test_PATH_env_var_when_bin_does_not_exist
+    ENV["PATH"] = "foo"
+    refute(Dir.exist?(bin_path))
+    refute_includes(path_elements('PATH'), bin_path)
+
+    recipe.activate
+
+    refute_includes(path_elements('PATH'), bin_path)
+  end
+
+  def test_PATH_env_var_when_bin_exists
+    ENV["PATH"] = "foo"
+    FileUtils.mkdir_p(bin_path)
+    refute_includes(path_elements('PATH'), bin_path)
+
+    recipe.activate
+
+    assert_includes(path_elements('PATH'), bin_path)
+    assert_equal(path_elements('PATH').first, bin_path)
+  end
+
+  def test_CPATH_env_var_when_include_does_not_exist
+    ENV["CPATH"] = "foo"
+    refute(Dir.exist?(include_path))
+    refute_includes(path_elements('CPATH'), include_path)
+
+    recipe.activate
+
+    refute_includes(path_elements('CPATH'), include_path)
+  end
+
+  def test_CPATH_env_var_when_include_exists
+    ENV["CPATH"] = "foo"
+    FileUtils.mkdir_p(include_path)
+    refute_includes(path_elements('CPATH'), include_path)
+
+    recipe.activate
+
+    assert_includes(path_elements('CPATH'), include_path)
+    assert_equal(path_elements('CPATH').first, include_path)
+  end
+
+  def test_LIBRARY_PATH_env_var_when_lib_does_not_exist
+    ENV["LIBRARY_PATH"] = "foo"
+    refute(Dir.exist?(lib_path))
+    refute_includes(path_elements('LIBRARY_PATH'), lib_path)
+
+    recipe.activate
+
+    refute_includes(path_elements('LIBRARY_PATH'), lib_path)
+  end
+
+  def test_LIBRARY_PATH_env_var_when_lib_exists
+    ENV["LIBRARY_PATH"] = "foo"
+    FileUtils.mkdir_p(lib_path)
+    refute_includes(path_elements('LIBRARY_PATH'), lib_path)
+
+    recipe.activate
+
+    assert_includes(path_elements('LIBRARY_PATH'), lib_path)
+    assert_equal(path_elements('LIBRARY_PATH').first, lib_path)
+  end
+
+  def test_LDFLAGS_env_var_when_not_cross_compiling
+    ENV["LDFLAGS"] = "-lfoo"
+    FileUtils.mkdir_p(lib_path)
+    assert_equal(recipe.host, recipe.original_host) # assert on setup)
+
+    refute_includes(flag_elements('LDFLAGS'), "-L#{lib_path}")
+
+    recipe.activate
+
+    refute_includes(flag_elements('LDFLAGS'), "-L#{lib_path}")
+  end
+
+  def test_LDFLAGS_env_var_when_cross_compiling
+    ENV["LDFLAGS"] = "-lfoo"
+    recipe.host = recipe.original_host + "-x" # make them not-equal
+    FileUtils.mkdir_p(lib_path)
+
+    refute_includes(flag_elements('LDFLAGS'), "-L#{lib_path}")
+
+    recipe.activate
+
+    assert_includes(flag_elements('LDFLAGS'), "-L#{lib_path}")
+    assert_equal(flag_elements('LDFLAGS').first, "-L#{lib_path}")
+  end
+
+  private
+
+  def path_elements(varname)
+    ENV.fetch(varname, "").split(File::PATH_SEPARATOR)
+  end
+
+  def flag_elements(varname)
+    ENV.fetch(varname, "").split
+  end
+
+  def bin_path
+    MiniPortile.native_path(File.join(recipe.path, "bin"))
+  end
+
+  def include_path
+    MiniPortile.native_path(File.join(recipe.path, "include"))
+  end
+
+  def lib_path
+    MiniPortile.native_path(File.join(recipe.path, "lib"))
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/test_cmake.rb new/test/test_cmake.rb
--- old/test/test_cmake.rb      2023-07-18 16:04:52.000000000 +0200
+++ new/test/test_cmake.rb      2023-10-22 17:13:47.000000000 +0200
@@ -96,7 +96,8 @@
                   "-DCMAKE_SYSTEM_NAME=Darwin",
                   "-DCMAKE_SYSTEM_PROCESSOR=arm64",
                   "-DCMAKE_C_COMPILER=some-host-clang",
-                  "-DCMAKE_CXX_COMPILER=some-host-clang++"
+                  "-DCMAKE_CXX_COMPILER=some-host-clang++",
+                  "-DCMAKE_BUILD_TYPE=Release"
                 ],
                 recipe.configure_defaults)
             end
@@ -119,7 +120,8 @@
                 "-DCMAKE_SYSTEM_NAME=Custom",
                 "-DCMAKE_SYSTEM_PROCESSOR=x86_64",
                 "-DCMAKE_C_COMPILER=gcc",
-                "-DCMAKE_CXX_COMPILER=g++"
+                "-DCMAKE_CXX_COMPILER=g++",
+                "-DCMAKE_BUILD_TYPE=Release"
               ],
               recipe.configure_defaults)
           end
@@ -194,6 +196,17 @@
     end
   end
 
+  def test_cmake_build_type_configuration
+    without_env("CMAKE_BUILD_TYPE") do
+      assert_equal("Release", MiniPortileCMake.new("test", 
"1.0.0").cmake_build_type)
+      assert_equal("xyzzy", MiniPortileCMake.new("test", "1.0.0", 
cmake_build_type: "xyzzy").cmake_build_type)
+    end
+    with_env("CMAKE_BUILD_TYPE"=>"Debug") do
+      assert_equal("Debug", MiniPortileCMake.new("test", 
"1.0.0").cmake_build_type)
+      assert_equal("Debug", MiniPortileCMake.new("test", "1.0.0", 
cmake_build_type: "xyzzy").cmake_build_type)
+    end
+  end
+
   private
 
   def with_stubbed_target(os: 'linux', cpu: 'x86_64')
@@ -227,7 +240,8 @@
       "-DCMAKE_SYSTEM_NAME=Linux",
       "-DCMAKE_SYSTEM_PROCESSOR=x86_64",
       "-DCMAKE_C_COMPILER=gcc",
-      "-DCMAKE_CXX_COMPILER=g++"
+      "-DCMAKE_CXX_COMPILER=g++",
+      "-DCMAKE_BUILD_TYPE=Release"
     ]
   end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/test_mkmf_config.rb new/test/test_mkmf_config.rb
--- old/test/test_mkmf_config.rb        1970-01-01 01:00:00.000000000 +0100
+++ new/test/test_mkmf_config.rb        2023-10-22 17:13:47.000000000 +0200
@@ -0,0 +1,202 @@
+require File.expand_path('../helper', __FILE__)
+
+require "mkmf" # initialize $LDFLAGS et al here, instead of in the middle of a 
test
+
+class TestMkmfConfig < TestCase
+  attr_reader :recipe
+
+  LIBXML_PCP = File.join(__dir__, "assets", "pkgconf", "libxml2")
+  LIBXSLT_PCP = File.join(__dir__, "assets", "pkgconf", "libxslt")
+
+  def make_recipe(name, version)
+    MiniPortile.new(name, version).tap do |recipe|
+      recipe.logger = StringIO.new # hush output
+    end
+  end
+
+  def setup
+    super
+
+    @save_env = %w[PATH CPATH LIBRARY_PATH LDFLAGS PKG_CONFIG_PATH].inject({}) 
do |env, var|
+      env.update(var => ENV[var])
+    end
+    $INCFLAGS = "-I/xxx"
+    $LIBPATH = ["xxx"]
+    $CFLAGS = "-xxx"
+    $CXXFLAGS = "-xxx"
+    $libs = "-lxxx"
+    $MINI_PORTILE_STATIC_LIBS = {}
+
+    FileUtils.rm_rf(["tmp", "ports"]) # remove any previous test files
+
+    @recipe = make_recipe("libfoo", "1.0.0")
+  end
+
+  def teardown
+    FileUtils.rm_rf(["tmp", "ports"]) # remove any previous test files
+
+    $INCFLAGS = ""
+    $LIBPATH = []
+    $CFLAGS = ""
+    $CXXFLAGS = ""
+    $libs = ""
+    $MINI_PORTILE_STATIC_LIBS = {}
+    @save_env.each do |var, val|
+      ENV[var] = val
+    end
+
+    super
+  end
+
+  def test_mkmf_config_recipe_LIBPATH_global_lib_dir_does_not_exist
+    recipe.mkmf_config
+
+    refute_includes($LIBPATH, recipe.lib_path)
+    refute_includes($libs.shellsplit, "-lfoo")
+  end
+
+  def test_mkmf_config_recipe_LIBPATH_global_not_static
+    FileUtils.mkdir_p(recipe.lib_path)
+
+    recipe.mkmf_config
+
+    assert_includes($LIBPATH, recipe.lib_path)
+    assert_operator($LIBPATH.index(recipe.lib_path), :<, 
$LIBPATH.index("xxx")) # prepend
+
+    assert_includes($libs.shellsplit, "-lfoo") # note the recipe name is 
"libfoo"
+    assert_match(%r{-lfoo.*-lxxx}, $libs) # prepend
+  end
+
+  def test_mkmf_config_recipe_LIBPATH_global_static
+    FileUtils.mkdir_p(recipe.lib_path)
+    static_lib_path = File.join(recipe.lib_path, "libfoo.#{$LIBEXT}")
+
+    recipe.mkmf_config(static: "foo")
+
+    refute_includes($LIBPATH, recipe.lib_path)
+
+    refute_includes($libs.shellsplit, "-lfoo") # note the recipe name is 
"libfoo"
+    assert_includes($libs.shellsplit, static_lib_path)
+    assert_match(%r{#{static_lib_path}.*-lxxx}, $libs) # prepend
+  end
+
+  def test_mkmf_config_recipe_INCFLAGS_global_include_dir_does_not_exist
+    recipe.mkmf_config
+
+    refute_includes($INCFLAGS.shellsplit, "-I#{recipe.include_path}")
+  end
+
+  def test_mkmf_config_recipe_INCFLAGS_global
+    FileUtils.mkdir_p(recipe.include_path)
+
+    recipe.mkmf_config
+
+    assert_includes($INCFLAGS.shellsplit, "-I#{recipe.include_path}")
+    assert_match(%r{-I#{recipe.include_path}.*-I/xxx}, $INCFLAGS) # prepend
+  end
+
+  def test_mkmf_config_pkgconf_does_not_exist
+    assert_raises(ArgumentError) do
+      recipe.mkmf_config(pkg: "foo")
+    end
+  end
+
+  def test_mkmf_config_pkgconf_LIBPATH_global_not_static
+    # can't get the pkgconf utility to install on windows with ruby 2.3 in CI
+    skip if MiniPortile.windows? && RUBY_VERSION < "2.4"
+
+    recipe.mkmf_config(pkg: "libxml-2.0", dir: LIBXML_PCP)
+
+    assert_includes($LIBPATH, "/foo/libxml2/2.11.5/lib")
+    assert_operator($LIBPATH.index("/foo/libxml2/2.11.5/lib"), :<, 
$LIBPATH.index("xxx")) # prepend
+    refute_includes($LIBPATH, "/foo/zlib/1.3/lib")
+
+    assert_includes($libs.shellsplit, "-lxml2")
+    assert_match(%r{-lxml2.*-lxxx}, $libs) # prepend
+    refute_includes($libs.shellsplit, "-lz")
+  end
+
+  def test_mkmf_config_pkgconf_LIBPATH_global_static
+    # can't get the pkgconf utility to install on windows with ruby 2.3 in CI
+    skip if MiniPortile.windows? && RUBY_VERSION < "2.4"
+
+    static_lib_path = "/foo/libxml2/2.11.5/lib/libxml2.#{$LIBEXT}"
+
+    recipe.mkmf_config(pkg: "libxml-2.0", dir: LIBXML_PCP, static: "xml2")
+
+    refute_includes($LIBPATH, "/foo/libxml2/2.11.5/lib")
+    refute_includes($libs.shellsplit, "-lxml2")
+    assert_includes($libs.shellsplit, static_lib_path)
+    assert_match(%r{#{static_lib_path}.*-lxxx}, $libs) # prepend
+
+    assert_includes($LIBPATH, "/foo/zlib/1.3/lib") # from --static
+    assert_includes($libs.shellsplit, "-lz") # from --static
+  end
+
+  def test_mkmf_config_pkgconf_CFLAGS_global
+    # can't get the pkgconf utility to install on windows with ruby 2.3 in CI
+    skip if MiniPortile.windows? && RUBY_VERSION < "2.4"
+
+    recipe.mkmf_config(pkg: "libxml-2.0", dir: LIBXML_PCP)
+
+    assert_includes($INCFLAGS.shellsplit, 
"-I/foo/libxml2/2.11.5/include/libxml2")
+    assert_match(%r{-I/foo/libxml2/2.11.5/include/libxml2.*-I/xxx}, $INCFLAGS) 
# prepend
+
+    assert_includes($CFLAGS.shellsplit, "-ggdb3")
+    assert_match(%r{-xxx.*-ggdb3}, $CFLAGS) # append
+
+    assert_includes($CXXFLAGS.shellsplit, "-ggdb3")
+    assert_match(%r{-xxx.*-ggdb3}, $CXXFLAGS) # append
+  end
+
+  def test_mkmf_config_pkgconf_path_accumulation
+    # can't get the pkgconf utility to install on windows with ruby 2.3 in CI
+    skip if MiniPortile.windows? && RUBY_VERSION < "2.4"
+
+    (ENV["PKG_CONFIG_PATH"] || "").split(File::PATH_SEPARATOR).tap do |pcpaths|
+      refute_includes(pcpaths, LIBXML_PCP)
+      refute_includes(pcpaths, LIBXSLT_PCP)
+    end
+
+    make_recipe("libxml2", "2.11.5").tap do |recipe|
+      recipe.mkmf_config(pkg: "libxml-2.0", dir: LIBXML_PCP, static: "xml2")
+
+      ENV["PKG_CONFIG_PATH"].split(File::PATH_SEPARATOR).tap do |pcpaths|
+        assert_includes(pcpaths, LIBXML_PCP)
+        refute_includes(pcpaths, LIBXSLT_PCP)
+      end
+    end
+
+    make_recipe("libxslt", "1.13.8").tap do |recipe|
+      recipe.mkmf_config(pkg: "libxslt", dir: LIBXSLT_PCP, static: "xslt")
+
+      ENV["PKG_CONFIG_PATH"].split(File::PATH_SEPARATOR).tap do |pcpaths|
+        assert_includes(pcpaths, LIBXML_PCP)
+        assert_includes(pcpaths, LIBXSLT_PCP)
+      end
+
+      recipe.mkmf_config(pkg: "libexslt", dir: LIBXSLT_PCP, static: "exslt")
+    end
+
+    $INCFLAGS.shellsplit.tap do |incflags|
+      assert_includes(incflags, "-I/foo/libxml2/2.11.5/include/libxml2")
+      assert_includes(incflags, "-I/foo/libxslt/1.1.38/include")
+    end
+    $CFLAGS.shellsplit.tap do |cflags|
+      assert_includes(cflags, "-ggdb3")
+      assert_includes(cflags, "-Wno-deprecated-enum-enum-conversion")
+    end
+    refute_includes($LIBPATH, "/foo/libxml2/2.11.5/lib")
+    refute_includes($LIBPATH, "/foo/libxslt/1.1.38/lib")
+    assert_includes($LIBPATH, "/foo/zlib/1.3/lib") # from `--static`
+    $libs.shellsplit.tap do |libflags|
+      refute_includes(libflags, "-lxml2")
+      assert_includes(libflags, "/foo/libxml2/2.11.5/lib/libxml2.#{$LIBEXT}")
+      refute_includes(libflags, "-lxslt")
+      assert_includes(libflags, "/foo/libxslt/1.1.38/lib/libxslt.#{$LIBEXT}")
+      refute_includes(libflags, "-lexslt")
+      assert_includes(libflags, "/foo/libxslt/1.1.38/lib/libexslt.#{$LIBEXT}")
+      assert_includes(libflags, "-lz") # from `--static`
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/test_recipe.rb new/test/test_recipe.rb
--- old/test/test_recipe.rb     1970-01-01 01:00:00.000000000 +0100
+++ new/test/test_recipe.rb     2023-10-22 17:13:47.000000000 +0200
@@ -0,0 +1,18 @@
+require File.expand_path('../helper', __FILE__)
+
+class TestRecipe < TestCase
+  def test_path
+    recipe = MiniPortile.new("libfoo", "1.0.0")
+    assert_equal(File.expand_path(File.join(recipe.target, recipe.host, 
recipe.name, recipe.version)), recipe.path)
+  end
+
+  def test_lib_path
+    recipe = MiniPortile.new("libfoo", "1.0.0")
+    assert_equal(File.join(recipe.path, "lib"), recipe.lib_path)
+  end
+
+  def test_include_path
+    recipe = MiniPortile.new("libfoo", "1.0.0")
+    assert_equal(File.join(recipe.path, "include"), recipe.include_path)
+  end
+end

Reply via email to