Skip to content
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

Update extconf #22

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/rake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: rake

on:
push:
branches: [ master, main ]
tags: [ v* ]
pull_request:

permissions:
contents: write

jobs:
rake-alpine:
name: Test on Ruby ${{ matrix.ruby.version }} ${{ matrix.os }}-${{ matrix.env.CC }}
runs-on: ubuntu-latest
env: ${{ matrix.env }}
container:
image: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- alpine:3.18
- alpine:3.16
env:
- CC: gcc
CXX: g++
- CC: clang
CXX: clang++

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Ruby
run: |
apk --no-cache --upgrade add build-base cmake git bash \
autoconf make binutils-dev pkgconfig tar ruby-dev clang

- name: Install Bundler
run: |
gem install bundler
bundle install

- run: bundle exec rake

rake:
needs: rake-alpine
uses: fontist/support/.github/workflows/rake.yml@main
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: release

on:
workflow_dispatch:
inputs:
next_version:
description: |
Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
required: true
default: 'skip'
repository_dispatch:
types: [ do-release ]

jobs:
release:
uses: fontist/support/.github/workflows/release.yml@main
with:
next_version: ${{ github.event.inputs.next_version }}
secrets:
rubygems-api-key: ${{ secrets.FONTIST_CI_RUBYGEMS_API_KEY }}
73 changes: 0 additions & 73 deletions .github/workflows/test-and-release.yml

This file was deleted.

2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@ task :copy_binary do
FileUtils.cp(src, dest) if (File.exist?(src))
end
end

task default: %i[build_local spec]
17 changes: 17 additions & 0 deletions ext/p7zip/makefile.macosx_arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
OPTFLAGS=-O2

ALLFLAGS=-arch arm64 ${OPTFLAGS} \
-DENV_MACOSX \
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
-D_REENTRANT -DENV_UNIX \
$(LOCAL_FLAGS)

CXX=clang++
CC=clang

LINK_SHARED=-bundle

LOCAL_LIBS=-framework CoreFoundation
LOCAL_LIBS_DLL=$(LOCAL_LIBS)

OBJ_CRC32=$(OBJ_CRC32_C)
3 changes: 1 addition & 2 deletions ext/p7zip/makefile.macosx_llvm_64bits
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ALLFLAGS=-m64 ${OPTFLAGS} \
# CC=/Developer/usr/bin/llvm-gcc

# For new Mac OS X :
XX=/usr/bin/llvm-g++
CXX=/usr/bin/llvm-g++
CC=/usr/bin/llvm-gcc

LINK_SHARED=-bundle
Expand All @@ -24,4 +24,3 @@ LOCAL_LIBS_DLL=$(LOCAL_LIBS)

OBJ_CRC32=$(OBJ_CRC32_C)
OBJ_AES=

21 changes: 17 additions & 4 deletions ext/seven_zip_ruby/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@
def create_p7zip_makefile(type)
config = RbConfig::CONFIG

allflags = config["ARCH_FLAG"] + ' -O -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_REENTRANT -DENV_UNIX '
allflags = config["ARCH_FLAG"] + ' -O -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_REENTRANT -DENV_UNIX -v '
case(type)
when :macosx
allflags += ' -DENV_MACOSX '
# Add explicit arch flag and deployment target for arm64 support
if RUBY_PLATFORM.include?('arm64')
allflags += ' -arch arm64 '
# Set minimum deployment target to ensure arm64 compatibility
ENV['MACOSX_DEPLOYMENT_TARGET'] = '11.0'
end
cc_shared = nil
link_shared = "-bundle"
local_libs = "-framework CoreFoundation"
Expand All @@ -30,8 +36,8 @@ def create_p7zip_makefile(type)

makefile_content = <<"EOS"
ALLFLAGS=#{allflags} $(LOCAL_FLAGS)
CXX=#{config['CXX']} $(ALLFLAGS)
CC=#{config['CC']} $(ALLFLAGS)
CXX=#{config['CXX']} $(ALLFLAGS) -Wall -Wextra
CC=#{config['CC']} $(ALLFLAGS) -Wall -Wextra
#{cc_shared_content}
LINK_SHARED=#{link_shared}

Expand All @@ -47,11 +53,13 @@ def create_p7zip_makefile(type)

def check_ostype
if (RUBY_PLATFORM.include?("darwin"))
# Ensure proper flags are set for macOS compilation
ENV['SDKROOT'] = `xcrun --show-sdk-path`.chomp
return :macosx
elsif (RUBY_PLATFORM.include?("linux"))
return :linux
elsif (RUBY_PLATFORM.include?("freebsd"))
return :freebsd
return :freebsd
else
raise "Unsupported platform"
end
Expand Down Expand Up @@ -184,6 +192,11 @@ def main
Dir.chdir(File.expand_path("../../p7zip", __FILE__)) do
create_p7zip_makefile(ostype)

# Use ARM64-specific makefile for macOS arm64
if RUBY_PLATFORM.include?('darwin') && RUBY_PLATFORM.include?('arm64')
system("cp makefile.macosx_arm64 makefile.machine")
end

make_success = system("make common7z")
raise "Failed to make p7zip" unless (make_success)

Expand Down
2 changes: 1 addition & 1 deletion lib/seven_zip_ruby/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module SevenZipRuby
VERSION = "1.6.2"
VERSION = "1.7.0.rc1"
end
Loading