Skip to content

Commit

Permalink
Merge pull request #6 from ZhongRuoyu/portable-formula-aarch64-linux
Browse files Browse the repository at this point in the history
portable-formula: update dependencies for aarch64 Linux
  • Loading branch information
ZhongRuoyu committed Apr 25, 2024
2 parents 2662124 + 89ac157 commit 48f3d13
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 16 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/build-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ jobs:
name: bottles_${{matrix.arch}}
path: bottle

- name: Post cleanup
if: always()
run: |
brew test-bot --only-cleanup-after
rm -rvf bottle portable-ruby
- name: Stop container
if: always()
run: |
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,14 @@ jobs:

- name: Test Portable Ruby
run: |
cd
mkdir -p portable-ruby/
tar --strip-components 2 -C portable-ruby -xf bottle/portable-ruby--*.tar.gz
tar --strip-components 2 -C portable-ruby -xf '${{github.workspace}}'/bottle/portable-ruby--*.tar.gz
export PATH="${PWD}/portable-ruby/bin:${PATH}"
export HOMEBREW_USE_RUBY_FROM_PATH=1
rm -rf "$(brew --repo)/Library/Homebrew/vendor/portable-ruby"
brew config | awk -v s="${PWD}/portable-ruby/bin/ruby" '$0~s{r=1} 1; END{exit(!r)}'
- name: Post cleanup
if: always()
run: |
brew test-bot --only-cleanup-after
rm -rvf bottle portable-ruby
- name: Stop container
if: always()
run: |
Expand Down
50 changes: 48 additions & 2 deletions Abstract/portable-formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,33 @@ def portable_configure_args
end
end

def portable_cflags
@portable_cflags ||= if OS.linux? && Hardware::CPU.arm?
gcc = "/usr/bin/gcc"
gcc_include_dir = Utils.safe_popen_read(gcc, "--print-file-name=include").chomp
gcc_include_fixed_dir = Utils.safe_popen_read(gcc, "--print-file-name=include-fixed").chomp
%W[
-nostdinc
-isystem#{gcc_include_dir}
-isystem#{gcc_include_fixed_dir}
].join(" ")
else
""
end
end

def portable_ldflags
@portable_ldflags ||= if OS.linux? && Hardware::CPU.arm?
glibc = Formula["zhongruoyu/portable-ruby-aarch64-linux/glibc@2.17"]
%W[
-B#{glibc.opt_lib}
-Wl,-rpath-link=#{glibc.opt_lib}
].join(" ")
else
""
end
end

def install
if OS.mac?
if OS::Mac.version > TARGET_MACOS
Expand Down Expand Up @@ -60,7 +87,19 @@ def install
ENV.append_to_cflags "-fPIC"
end

ENV.append_to_cflags portable_cflags if portable_cflags.present?
ENV.append "LDFLAGS", portable_ldflags if portable_ldflags.present?

super

return if name != "portable-ruby"

abi_version = `#{bin}/ruby -rrbconfig -e 'print RbConfig::CONFIG["ruby_version"]'`
abi_arch = `#{bin}/ruby -rrbconfig -e 'print RbConfig::CONFIG["arch"]'`
inreplace lib/"ruby/#{abi_version}/#{abi_arch}/rbconfig.rb" do |s|
s.gsub! portable_cflags, "" if portable_cflags.present?
s.gsub! portable_ldflags, "" if portable_ldflags.present?
end
end

def test
Expand All @@ -82,8 +121,15 @@ def self.inherited(subclass)
keg_only "portable formulae are keg-only"

on_linux do
depends_on "glibc@2.13" => :build
depends_on "linux-headers@4.4" => :build
on_arm do
depends_on "zhongruoyu/portable-ruby-aarch64-linux/glibc@2.17" => :build
depends_on "zhongruoyu/portable-ruby-aarch64-linux/linux-headers@4.4" => :build
end

on_intel do
depends_on "glibc@2.13" => :build
depends_on "linux-headers@4.4" => :build
end
end

prepend PortableFormulaMixin
Expand Down
11 changes: 10 additions & 1 deletion Formula/portable-openssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ def configure_args
]
end

def test_args
if OS.linux? && Hardware::CPU.arm?
# https://github.com/openssl/openssl/issues/17900
%w[TESTS=-test_afalg]
else
[]
end
end

def install
# OpenSSL is not fully portable and certificate paths are backed into the library.
# We therefore need to set the certificate path at runtime via an environment variable.
Expand All @@ -57,7 +66,7 @@ def install
openssldir.mkpath
system "perl", "./Configure", *(configure_args + arch_args)
system "make"
system "make", "test"
system "make", "test", *test_args

system "make", "install_dev"

Expand Down

0 comments on commit 48f3d13

Please sign in to comment.