Skip to content
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
24 changes: 8 additions & 16 deletions .github/workflows/build-gems.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,20 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Add LLVM apt Repo
run: |-
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-21 main"
sudo apt update

- name: Install APT dependencies
run: xargs sudo apt-get install -y --no-install-recommends < Aptfile

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: false

- name: bundle install
run: bundle install
ruby-version: '3.4'
bundler-cache: true

- name: Render Templates
run: bundle exec rake templates

- name: Compile Herb
run: bundle exec rake make
- name: Vendor Prism
run: bundle exec rake prism:vendor

- name: Setup Cross-Ruby Configs
run: bundle exec rake gem:prepare

- name: Build gem
run: |
Expand Down Expand Up @@ -128,7 +120,7 @@ jobs:
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
bundler-cache: false
bundler-cache: true

- name: Download gem artifacts
uses: actions/download-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ gem "maxitest"
gem "minitest-difftastic", "~> 0.2"
gem "rake", "~> 13.2"
gem "rake-compiler", "~> 1.3"
gem "rake-compiler-dock", "1.11.0.rc1"
gem "rake-cross-compiler", github: "marcoroth/rake-cross-compiler"
gem "reline", "~> 0.6"
gem "rubocop", "~> 1.71"

Expand Down
10 changes: 8 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
GIT
remote: https://github.com/marcoroth/rake-cross-compiler.git
revision: 0e6070af00050ce0fcb580e5478f92661dfe23e0
specs:
rake-cross-compiler (0.0.1)
rake (>= 13.0)

GIT
remote: https://github.com/ruby/prism.git
revision: df554035afb63c754b9edbe531ff48e6569eaf07
Expand Down Expand Up @@ -110,7 +117,6 @@ GEM
rake (13.3.1)
rake-compiler (1.3.1)
rake
rake-compiler-dock (1.11.0.rc1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
Expand Down Expand Up @@ -192,7 +198,7 @@ DEPENDENCIES
prism!
rake (~> 13.2)
rake-compiler (~> 1.3)
rake-compiler-dock (= 1.11.0.rc1)
rake-cross-compiler!
rbs-inline (~> 0.12)
reline (~> 0.6)
rubocop (~> 1.71)
Expand Down
28 changes: 12 additions & 16 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,34 +58,29 @@ begin
end

task "gem:native" do
require "rake_compiler_dock"
require "rake/cross/compiler"
sh "bundle config set cache_all true"

PLATFORMS.each do |platform|
RakeCompilerDock.sh "bundle --local && rake native:#{platform} gem", platform: platform
Rake::Cross::Compiler.sh "bundle --local && rake native:#{platform} gem", platform: platform
end

RakeCompilerDock.sh "bundle --local && rake java gem", rubyvm: :jruby
# RakeCompilerDock.sh "bundle --local && rake java gem", rubyvm: :jruby
rescue LoadError
abort "rake_compiler_dock is required to build native gems"
abort "rake-cross-compiler is required to build native gems"
end

namespace "gem" do
task "prepare" do
require "rake_compiler_dock"
require "io/console"

sh "bundle config set cache_all true"
sh "cp ~/.gem/gem-*.pem build/gem/ || true"
require "rake/cross/compiler"

gemspec_path = File.expand_path("./herb.gemspec", __dir__)
spec = eval(File.read(gemspec_path), binding, gemspec_path)

RakeCompilerDock.set_ruby_cc_version(spec.required_ruby_version.as_list)

# ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
Rake::Cross::Compiler.set_ruby_cc_version(spec.required_ruby_version, platforms: PLATFORMS)
Rake::Cross::Compiler.setup_cross_ruby(platforms: PLATFORMS)
rescue LoadError
abort "rake_compiler_dock is required for this task"
abort "rake-cross-compiler is required for this task"
end

exttask.cross_platform.each do |platform|
Expand All @@ -94,9 +89,10 @@ begin

desc "Build the native gem for #{platform}"
task platform => "prepare" do
RakeCompilerDock.sh(
"bundle --local && rake native:#{platform} gem RUBY_CC_VERSION='#{ENV.fetch("RUBY_CC_VERSION", nil)}'",
platform: platform
Rake::Cross::Compiler.sh(
"bundle --local && rake native:#{platform} gem",
platform: platform,
ruby_cc_version: ENV.fetch("RUBY_CC_VERSION", nil)
)
end
end
Expand Down
12 changes: 7 additions & 5 deletions ext/herb/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@

puts "Sources to be compiled: #{$srcs.inspect}"

abort("could not find prism.h") unless find_header("prism.h")
abort("could not find herb.h") unless find_header("herb.h")
unless defined?(CROSS_COMPILING) && CROSS_COMPILING
abort("could not find prism.h") unless find_header("prism.h")
abort("could not find herb.h") unless find_header("herb.h")

abort("could not find nodes.h (run `ruby templates/template.rb` to generate the file)") unless find_header("nodes.h")
abort("could not find extension.h") unless find_header("extension.h")
abort("could not find extension_helpers.h") unless find_header("extension_helpers.h")
abort("could not find nodes.h (run `ruby templates/template.rb` to generate the file)") unless find_header("nodes.h")
abort("could not find extension.h") unless find_header("extension.h")
abort("could not find extension_helpers.h") unless find_header("extension_helpers.h")
end

create_header
create_makefile("#{extension_name}/#{extension_name}")
Loading