Skip to content

Commit f85155b

Browse files
authored
Merge pull request #5 from paulgoetze/feature/precompiled-binaries
Set up GitHub action to cross-compile the gem
2 parents cfa65b1 + 68e4084 commit f85155b

File tree

4 files changed

+93
-47
lines changed

4 files changed

+93
-47
lines changed

.github/workflows/cross-compile.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: Cross Compile
3+
4+
on:
5+
push:
6+
tags:
7+
- "v*"
8+
9+
jobs:
10+
ci-data:
11+
name: Fetch CI data
12+
runs-on: ubuntu-latest
13+
outputs:
14+
result: ${{ steps.fetch.outputs.result }}
15+
steps:
16+
- uses: oxidize-rb/actions/fetch-ci-data@v1
17+
id: fetch
18+
with:
19+
supported-ruby-platforms: true
20+
stable-ruby-versions: |
21+
exclude: [head]
22+
cross-gem:
23+
name: Compile native gem for ${{ matrix.platform }}
24+
runs-on: ubuntu-latest
25+
needs: ci-data
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }}
30+
steps:
31+
- uses: actions/checkout@v3
32+
33+
- uses: ruby/setup-ruby@v1
34+
with:
35+
ruby-version: "3.2"
36+
37+
- uses: oxidize-rb/actions/cross-gem@v1
38+
id: cross-gem
39+
with:
40+
platform: ${{ matrix.platform }}
41+
ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }}
42+
43+
- uses: actions/upload-artifact@v3
44+
with:
45+
name: cross-gem
46+
path: ${{ steps.cross-gem.outputs.gem-path }}

ext/mrml/Cargo.lock renamed to Cargo.lock

Lines changed: 35 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[workspace]
2+
members = ["ext/mrml"]

Rakefile

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,22 @@
33
require 'bundler/gem_tasks'
44
require 'rake/testtask'
55
require 'rake/extensiontask'
6+
require 'rb_sys/extensiontask'
67

7-
PLATFORM = %w[
8-
x86-linux x86_64-linux aarch64-linux
9-
x86-mingw32 x64-mingw-ucrt x64-mingw32
10-
x86_64-darwin arm64-darwin
11-
]
8+
GEMSPEC = Gem::Specification.load('mrml.gemspec')
9+
10+
RbSys::ExtensionTask.new('mrml', GEMSPEC) do |ext|
11+
ext.lib_dir = 'lib/mrml'
12+
end
13+
14+
task :native, [:platform] do |_t, platform:|
15+
sh 'bundle', 'exec', 'rb-sys-dock', '--platform', platform, '--build'
16+
end
1217

1318
Rake::TestTask.new(:test) do |t|
1419
t.libs << 'test'
1520
t.libs << 'lib'
1621
t.test_files = FileList['test/**/*_test.rb']
1722
end
1823

19-
Rake::ExtensionTask.new('mrml') do |ext|
20-
ext.lib_dir = 'lib/mrml'
21-
ext.source_pattern = '*.{rs,toml}'
22-
ext.cross_compile = true
23-
ext.cross_platform = PLATFORM
24-
end
25-
2624
task default: %i[clobber compile test]

0 commit comments

Comments
 (0)