diff --git a/.github/platforms.json b/.github/platforms.json index 9ac6597..de87059 100644 --- a/.github/platforms.json +++ b/.github/platforms.json @@ -56,7 +56,7 @@ "linux_x86_64": [ { "platform": "x86_64-linux", - "os": "ubuntu-latest", + "os": "ubuntu-22.04", "ruby": "3.4", "description": "Linux x86_64 (generic)", "build": true, @@ -65,7 +65,7 @@ }, { "platform": "x86_64-linux-gnu", - "os": "ubuntu-latest", + "os": "ubuntu-22.04", "ruby": "3.4", "description": "Linux x86_64 GNU libc", "build": true, @@ -83,7 +83,7 @@ "linux_aarch64": [ { "platform": "aarch64-linux", - "os": "ubuntu-latest", + "os": "ubuntu-22.04", "ruby": "3.4", "description": "Linux ARM64 (generic)", "build": true, @@ -93,7 +93,7 @@ }, { "platform": "aarch64-linux-gnu", - "os": "ubuntu-latest", + "os": "ubuntu-22.04", "ruby": "3.4", "description": "Linux ARM64 GNU libc", "build": true, diff --git a/.github/workflows/gem-build.yml b/.github/workflows/gem-build.yml index e44eac9..bb9bfaa 100644 --- a/.github/workflows/gem-build.yml +++ b/.github/workflows/gem-build.yml @@ -88,18 +88,32 @@ jobs: - run: bundle exec rake gem:native:${{ matrix.platform }} - # Display compiled libraries for debugging + # Display compiled libraries for debugging - MUST FAIL if none found - name: Inspect built libraries if: matrix.platform != 'any' shell: bash run: | echo "=== Platform: ${{ matrix.platform }} ===" echo "=== Compiled libraries ===" - ls lib/ffi-libarchive-binary/*.dll lib/ffi-libarchive-binary/*.so lib/ffi-libarchive-binary/*.dylib 2>/dev/null || echo "No compiled libraries found" + FOUND=0 + for ext in dll so dylib; do + for f in lib/ffi-libarchive-binary/*.$ext; do + if [ -f "$f" ]; then + echo "$f" + FOUND=1 + fi + done + done + if [ "$FOUND" -eq 0 ]; then + echo "ERROR: No compiled libraries found!" + echo "=== Library directory contents ===" + ls -la lib/ffi-libarchive-binary/ 2>/dev/null || echo "Directory not found" + exit 1 + fi echo "=== Library directory contents ===" - ls -la lib/ffi-libarchive-binary/ 2>/dev/null || echo "Directory not found" + ls -la lib/ffi-libarchive-binary/ - # Unpack gem and display contents + # Unpack gem and verify it contains compiled libraries - MUST FAIL if none found - name: Inspect gem contents shell: bash run: | @@ -108,7 +122,17 @@ jobs: echo "=== Files in gem ===" ls -R */lib/ 2>/dev/null | head -50 echo "=== Compiled libraries in gem ===" - ls */lib/ffi-libarchive-binary/*.dll */lib/ffi-libarchive-binary/*.so */lib/ffi-libarchive-binary/*.dylib 2>/dev/null || echo "No compiled libraries found in gem" + FOUND=0 + for ext in dll so dylib; do + for f in $(find . -name "*.$ext" 2>/dev/null); do + echo "$f" + FOUND=1 + done + done + if [ "$FOUND" -eq 0 ] && [ "${{ matrix.platform }}" != "any" ]; then + echo "ERROR: No compiled libraries found in gem!" + exit 1 + fi - uses: actions/upload-artifact@v6 if: failure() diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2d78b55..d1ecc77 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,7 +77,7 @@ jobs: name: ${{ github.run_number }}-${{ matrix.platform }}-pkg path: pkg - # Unpack gem and display compiled libraries for debugging + # Unpack gem and display compiled libraries for debugging - MUST FAIL if none found - name: Inspect gem contents shell: bash run: | @@ -85,9 +85,21 @@ jobs: gem unpack ffi-libarchive-binary-*.gem echo "=== Platform: ${{ matrix.platform }} ===" echo "=== Compiled libraries in gem ===" - ls */lib/ffi-libarchive-binary/*.dll */lib/ffi-libarchive-binary/*.so */lib/ffi-libarchive-binary/*.dylib 2>/dev/null || echo "No compiled libraries found in gem" + FOUND=0 + for ext in dll so dylib; do + for f in $(find . -name "*.$ext" 2>/dev/null); do + echo "$f" + FOUND=1 + done + done + if [ "$FOUND" -eq 0 ]; then + echo "ERROR: No compiled libraries found in gem!" + echo "=== Full lib directory contents ===" + ls -la */lib/ffi-libarchive-binary/ 2>/dev/null || echo "Directory not found" + exit 1 + fi echo "=== Full lib directory contents ===" - ls -la */lib/ffi-libarchive-binary/ 2>/dev/null || echo "Directory not found" + ls -la */lib/ffi-libarchive-binary/ # Install the native gem - name: Install native gem diff --git a/ext/configuration.yml b/ext/configuration.yml index f7ba5a4..6ca3ab0 100644 --- a/ext/configuration.yml +++ b/ext/configuration.yml @@ -4,6 +4,11 @@ libraries: # - OpenSSL uses version 1.1.1w for Windows x64 (more stable for x86_64) # - xz uses version 5.2.4 for all Windows platforms (MinGW compatibility) # - Other libraries use cross-platform versions under 'all' + libiconv: + all: + version: "1.18" + url: "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.18.tar.gz" + sha256: "3b08f5f4f9b4eb82f151a7040bfd6fe6c6fb922efe4b1659c66ea933276965e8" zlib: all: version: "1.3.2" diff --git a/lib/ffi-libarchive-binary/configuration.rb b/lib/ffi-libarchive-binary/configuration.rb index 35393dd..1d093be 100644 --- a/lib/ffi-libarchive-binary/configuration.rb +++ b/lib/ffi-libarchive-binary/configuration.rb @@ -20,7 +20,7 @@ def self.libraries def self.library_for(libname) if MiniPortile::windows? # Detect Windows ARM64 - if RUBY_PLATFORM =~ /aarch64|arm64/i + if RUBY_PLATFORM.match?(/aarch64|arm64/i) libraries[libname]["windows-arm64"] || libraries[libname]["windows"] || libraries[libname]["all"] else libraries[libname]["windows-x64"] || libraries[libname]["windows"] || libraries[libname]["all"] diff --git a/lib/ffi-libarchive-binary/libarchive_recipe.rb b/lib/ffi-libarchive-binary/libarchive_recipe.rb index 747d2c8..78835f6 100644 --- a/lib/ffi-libarchive-binary/libarchive_recipe.rb +++ b/lib/ffi-libarchive-binary/libarchive_recipe.rb @@ -7,6 +7,7 @@ require_relative "base_recipe" require_relative "zlib_recipe" require_relative "libexpat_recipe" +require_relative "libiconv_recipe" require_relative "openssl_recipe" require_relative "xz_recipe" @@ -32,6 +33,7 @@ def initialize def create_dependencies @zlib_recipe = ZLibRecipe.new @expat_recipe = LibexpatRecipe.new + @iconv_recipe = LibiconvRecipe.new @openssl_recipe = OpensslRecipe.new @xz_recipe = XZRecipe.new end @@ -42,10 +44,10 @@ def generator_flags def default_flags [ - "-DENABLE_OPENSSL:BOOL=ON", "-DENABLE_LIBB2:BOOL=OFF", "-DENABLE_LZ4:BOOL=OFF", - "-DENABLE_LZO::BOOL=OFF", "-DENABLE_LZMA:BOOL=ON", "-DENABLE_ZSTD:BOOL=OFF", - "-DENABLE_ZLIB::BOOL=ON", "-DENABLE_BZip2:BOOL=OFF", "-DENABLE_LIBXML2:BOOL=OFF", - "-DENABLE_EXPAT::BOOL=ON", "-DENABLE_TAR:BOOL=OFF", "-DENABLE_CPIO::BOOL=OFF", + "-DENABLE_OPENSSL:BOOL=ON", "-DENABLE_LIBB2:BOOL=OFF", "-DENABLE_LZ4:BOOL=OFF", + "-DENABLE_LZO:BOOL=OFF", "-DENABLE_LZMA:BOOL=ON", "-DENABLE_ZSTD:BOOL=OFF", + "-DENABLE_ZLIB:BOOL=ON", "-DENABLE_BZip2:BOOL=OFF", "-DENABLE_LIBXML2:BOOL=OFF", + "-DENABLE_EXPAT:BOOL=ON", "-DENABLE_TAR:BOOL=OFF", "-DENABLE_CPIO:BOOL=OFF", "-DENABLE_CAT:BOOL=OFF", "-DENABLE_ACL:BOOL=OFF", "-DENABLE_TEST:BOOL=OFF", "-DENABLE_UNZIP:BOOL=OFF", "-DOPENSSL_USE_STATIC_LIBS=ON", "-DENABLE_XAR:BOOL=ON", @@ -53,7 +55,11 @@ def default_flags "-DOPENSSL_ROOT_DIR:PATH=#{@openssl_recipe.path}", # Add include paths to C flags so CMake's header detection can find them - "-DCMAKE_C_FLAGS=-I#{@expat_recipe.path}/include -I#{@openssl_recipe.path}/include -I#{@xz_recipe.path}/include -I#{@zlib_recipe.path}/include", + "-DCMAKE_C_FLAGS=-I#{@expat_recipe.path}/include " \ + "-I#{@iconv_recipe.path}/include " \ + "-I#{@openssl_recipe.path}/include " \ + "-I#{@xz_recipe.path}/include " \ + "-I#{@zlib_recipe.path}/include", # Provide search paths for CMake to find libraries "-DCMAKE_INCLUDE_PATH:STRING=#{include_path}", @@ -71,18 +77,19 @@ def configure_defaults end def include_path - paths = [@zlib_recipe.path, @expat_recipe.path, @openssl_recipe.path, @xz_recipe.path] + paths = [@zlib_recipe.path, @expat_recipe.path, @iconv_recipe.path, @openssl_recipe.path, @xz_recipe.path] paths.map { |k| "#{k}/include" }.join(";") end def library_path - paths = [@zlib_recipe.path, @expat_recipe.path, @openssl_recipe.path, @xz_recipe.path] + paths = [@zlib_recipe.path, @expat_recipe.path, @iconv_recipe.path, @openssl_recipe.path, @xz_recipe.path] paths.map { |k| "#{k}/lib;#{k}/lib64" }.join(";") end def activate @zlib_recipe.activate @expat_recipe.activate + @iconv_recipe.activate @openssl_recipe.activate @xz_recipe.activate @@ -100,6 +107,9 @@ def cook @expat_recipe.host = @host if @host @expat_recipe.cook_if_not + @iconv_recipe.host = @host if @host + @iconv_recipe.cook_if_not + @openssl_recipe.host = @host if @host @openssl_recipe.cook_if_not @@ -107,8 +117,8 @@ def cook @xz_recipe.cook_if_not # Set explicit LZMA environment variables for libarchive configure - ENV['LIBLZMA_CFLAGS'] = "-I#{@xz_recipe.path}/include" - ENV['LIBLZMA_LIBS'] = "-L#{@xz_recipe.path}/lib -llzma" + ENV["LIBLZMA_CFLAGS"] = "-I#{@xz_recipe.path}/include" + ENV["LIBLZMA_LIBS"] = "-L#{@xz_recipe.path}/lib -llzma" super diff --git a/lib/ffi-libarchive-binary/libexpat_recipe.rb b/lib/ffi-libarchive-binary/libexpat_recipe.rb index 07a60e6..45dfb47 100644 --- a/lib/ffi-libarchive-binary/libexpat_recipe.rb +++ b/lib/ffi-libarchive-binary/libexpat_recipe.rb @@ -21,7 +21,7 @@ def configure # Set cross-compiler environment variables for aarch64 env_vars = cross_compiler_env(host) cmd = ["env"] + env_vars.map { |k, v| "#{k}=#{v}" } + - [cflags(host), ldflags(host), "./configure"] + computed_options + [cflags(host), ldflags(host), "./configure"] + computed_options execute("configure", cmd) end diff --git a/lib/ffi-libarchive-binary/libiconv_recipe.rb b/lib/ffi-libarchive-binary/libiconv_recipe.rb new file mode 100644 index 0000000..dfbab7c --- /dev/null +++ b/lib/ffi-libarchive-binary/libiconv_recipe.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require_relative "base_recipe" + +module LibarchiveBinary + class LibiconvRecipe < BaseRecipe + def initialize + super("libiconv") + + @target = ROOT.join(@target).to_s + end + + def configure_defaults + [ + "--host=#{@host}", + "--disable-shared", + "--enable-static", + "--disable-nls", + ] + end + + def configure + # Set cross-compiler environment variables for aarch64 + env_vars = cross_compiler_env(host) + cmd = ["env"] + env_vars.map { |k, v| "#{k}=#{v}" } + + [cflags(host), ldflags(host), "./configure"] + computed_options + execute("configure", cmd) + end + + def checkpoint + File.join(@target, "#{name}-#{version}-#{host}.installed") + end + + def cook_if_not + cook unless File.exist?(checkpoint) + end + + def cook + super + + FileUtils.touch(checkpoint) + end + end +end diff --git a/lib/ffi-libarchive-binary/libxml2_recipe.rb b/lib/ffi-libarchive-binary/libxml2_recipe.rb index 639a638..491b9b4 100644 --- a/lib/ffi-libarchive-binary/libxml2_recipe.rb +++ b/lib/ffi-libarchive-binary/libxml2_recipe.rb @@ -28,7 +28,7 @@ def configure_defaults "--without-http", "--without-ftp", "--enable-static", - "--disable-shared" + "--disable-shared", ] end @@ -52,4 +52,4 @@ def cook FileUtils.touch(checkpoint) end end -end \ No newline at end of file +end diff --git a/lib/ffi-libarchive-binary/xz_recipe.rb b/lib/ffi-libarchive-binary/xz_recipe.rb index 14fb2cd..0e725f2 100644 --- a/lib/ffi-libarchive-binary/xz_recipe.rb +++ b/lib/ffi-libarchive-binary/xz_recipe.rb @@ -21,7 +21,7 @@ def configure # Set cross-compiler environment variables for aarch64 env_vars = cross_compiler_env(host) cmd = ["env"] + env_vars.map { |k, v| "#{k}=#{v}" } + - [cflags(host), ldflags(host), "./configure"] + computed_options + [cflags(host), ldflags(host), "./configure"] + computed_options execute("configure", cmd) end diff --git a/lib/ffi-libarchive-binary/zlib_recipe.rb b/lib/ffi-libarchive-binary/zlib_recipe.rb index 902761e..dd9e9bd 100644 --- a/lib/ffi-libarchive-binary/zlib_recipe.rb +++ b/lib/ffi-libarchive-binary/zlib_recipe.rb @@ -36,7 +36,7 @@ def configure # Set cross-compiler environment variables for aarch64 env_vars = cross_compiler_env(host) cmd = ["env"] + env_vars.map { |k, v| "#{k}=#{v}" } + - [cflags(host), ldflags(host), "./configure"] + computed_options + [cflags(host), ldflags(host), "./configure"] + computed_options execute("configure", cmd) end end