You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+47-7Lines changed: 47 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,43 @@ This is kind of successor of [rake-compiler-dev-box](https://github.com/tjschuck
10
10
It is wrapped as a gem for easier setup, usage and integration and is based on lightweight Docker containers.
11
11
It is also more reliable, since the underlying docker images are versioned and immutable.
12
12
13
+
## Supported platforms
14
+
15
+
The following platforms are supported for cross-compilation by rake-compiler-dock:
16
+
17
+
-`aarch64-linux` and `aarch64-linux-gnu`
18
+
-`aarch64-linux-musl`
19
+
-`arm-linux` and `arm-linux-gnu`
20
+
-`arm-linux-musl`
21
+
-`arm64-darwin`
22
+
-`jruby`
23
+
-`x64-mingw-ucrt`
24
+
-`x64-mingw32`
25
+
-`x86-linux` and `x86-linux-gnu`
26
+
-`x86-linux-musl`
27
+
-`x86-mingw32`
28
+
-`x86_64-darwin`
29
+
-`x86_64-linux` and `x86_64-linux-gnu`
30
+
-`x86_64-linux-musl`
31
+
32
+
### Windows
33
+
34
+
`x64-mingw-ucrt` should be used for Ruby 3.1 and later on windows. `x64-mingw32` should be used for Ruby 3.0 and earlier. This is to match the [changed platform of RubyInstaller-3.1](https://rubyinstaller.org/2021/12/31/rubyinstaller-3.1.0-1-released.html).
35
+
36
+
### GNU and Musl
37
+
38
+
Platform names with a `*-linux` suffix are aliases for `*-linux-gnu`, since the Rubygems default is to assume `gnu` if no libc is specified.
39
+
40
+
Some C extensions may not require separate GNU and Musl builds, in which case it's acceptable to ship a single `*-linux` gem to cover both platforms.
41
+
42
+
The `*-linux-gnu` and `*-linux-musl` platform name suffixes require Rubygems 3.3.22 or later (or Bundler 2.3.21 or later) at installation time. Ruby version 3.0 and later ship with a sufficient Rubygems version, but versions compatible with earlier Rubies are:
43
+
44
+
- ruby: "2.7", rubygems: "3.4.22"
45
+
- ruby: "2.6", rubygems: "3.4.22"
46
+
- ruby: "2.5", rubygems: "3.3.26"
47
+
- ruby: "2.4", rubygems: "3.3.26"
48
+
49
+
13
50
## Installation
14
51
15
52
Install docker [following the instructions on the docker website](https://docs.docker.com/engine/install/) ... or install [docker-toolbox for Windows and OSX](https://github.com/docker/toolbox/releases) or boot2docker on [Windows](https://github.com/boot2docker/windows-installer/releases) or [OS X](https://github.com/boot2docker/osx-installer/releases) .
@@ -33,20 +70,19 @@ Your Rakefile should enable cross compilation like so:
33
70
```ruby
34
71
exttask =Rake::ExtensionTask.new('my_extension', my_gem_spec) do |ext|
where you should choose your platforms from the list in the "Supported platforms" section.
78
+
40
79
See below, how to invoke cross builds in your Rakefile.
41
80
42
81
Additionally it may also be used to build ffi based binary gems like [libusb](https://github.com/larskanis/libusb), but currently doesn't provide any additional build helpers for this use case, beyond docker invocation and cross compilers.
43
82
44
83
### Interactive Usage
45
84
46
85
Rake-compiler-dock offers the shell command `rake-compiler-dock` and a [ruby API](http://www.rubydoc.info/gems/rake-compiler-dock/RakeCompilerDock) for issuing commands within the docker image, described below.
47
-
There are dedicated images for targets: `aarch64-linux-gnu`, `arm-linux-gnu`, `arm64-darwin`, `x64-mingw-ucrt`, `x64-mingw32`, `x86-linux-gnu`, `x86-mingw32`, `x86_64-darwin`, `x86_64-linux-gnu`, and `jruby`.
48
-
The images contain all supported cross ruby versions, with the exception of `x64-mingw32`, which has versions before 3.1 only, and `x64-mingw-ucrt`, which has only ruby-3.1+.
49
-
This is to match the [changed platform of RubyInstaller-3.1](https://rubyinstaller.org/2021/12/31/rubyinstaller-3.1.0-1-released.html).
50
86
51
87
`rake-compiler-dock` without arguments starts an interactive shell session.
52
88
This is best suited to try out and debug a build.
@@ -68,7 +104,7 @@ To build x86 Windows and x86_64 Linux binary gems interactively, it can be calle
68
104
user@host:$ ls pkg/*.gem
69
105
your-gem-1.0.0.gem your-gem-1.0.0-x86-mingw32.gem
70
106
71
-
user@host:$ RCD_PLATFORM=x86_64-linux-gnu rake-compiler-dock # this enters a container for amd64 Linux target
107
+
user@host:$ RCD_PLATFORM=x86_64-linux-gnu rake-compiler-dock # this enters a container for amd64 Linux GNU target
72
108
user@adc55b2b92a9:$ bundle
73
109
user@adc55b2b92a9:$ rake cross native gem
74
110
user@adc55b2b92a9:$ exit
@@ -120,14 +156,18 @@ This can be done like this:
120
156
```ruby
121
157
PLATFORMS=%w[
122
158
aarch64-linux-gnu
159
+
aarch64-linux-musl
123
160
arm-linux-gnu
161
+
arm-linux-musl
124
162
arm64-darwin
125
163
x64-mingw-ucrt
126
164
x64-mingw32
127
165
x86-linux-gnu
166
+
x86-linux-musl
128
167
x86-mingw32
129
168
x86_64-darwin
130
169
x86_64-linux-gnu
170
+
x86_64-linux-musl
131
171
]
132
172
task 'gem:native'do
133
173
require'rake_compiler_dock'
@@ -212,7 +252,7 @@ jobs:
212
252
Where the referenced rake task might be defined by something like:
@@ -248,7 +288,7 @@ The following variables are recognized by rake-compiler-dock:
248
288
*`RCD_RUBYVM` - The ruby VM and toolchain to be used.
249
289
Must be one of `mri`, `jruby`.
250
290
*`RCD_PLATFORM` - The target rubygems platform.
251
-
Must be a space separated list out of `aarch64-linux-gnu`, `arm-linux-gnu`, `arm64-darwin`, `x64-mingw-ucrt`, `x64-mingw32`, `x86-linux-gnu`, `x86-mingw32`, `x86_64-darwin`, `x86_64-linux-gnu`.
291
+
Must be a space separated list out of the platforms listed under "Supported platforms" above.
252
292
It is ignored when `rubyvm` is set to `:jruby`.
253
293
*`RCD_IMAGE` - The docker image that is downloaded and started.
254
294
Defaults to "ghcr.io/rake-compiler/rake-compiler-dock-image:IMAGE_VERSION-PLATFORM" with an image version that is determined by the gem version.
0 commit comments