rake-compiler-dock 1.9.1 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Dockerfile.mri.erb CHANGED
@@ -1,6 +1,8 @@
1
1
  <% image = "ubuntu:20.04" %>
2
2
  FROM <%= image %>
3
3
 
4
+ ARG TARGETPLATFORM
5
+
4
6
  ##
5
7
  ## Install required base packages for compiling ruby
6
8
  ##
@@ -24,6 +26,24 @@ COPY --from=larskanis/mingw64-ucrt:20.04 \
24
26
  /debs/
25
27
  RUN dpkg -i /debs/*.deb
26
28
 
29
+ <% elsif platform =~ /aarch64-mingw-ucrt/ %>
30
+
31
+ RUN <<EOF
32
+ if [ "$TARGETPLATFORM" = "linux/amd64" ]; then
33
+ DOWNLOAD_PLATFORM="x86_64";
34
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then
35
+ DOWNLOAD_PLATFORM="aarch64";
36
+ else
37
+ echo "Unsupported platform $TARGETPLATFORM";
38
+ exit 1;
39
+ fi &&
40
+ wget https://github.com/mstorsjo/llvm-mingw/releases/download/20250114/llvm-mingw-20250114-ucrt-ubuntu-20.04-$DOWNLOAD_PLATFORM.tar.xz &&
41
+ tar xf llvm-mingw*.tar.xz &&
42
+ mv `ls -d llvm-mingw-*/` /llvm-mingw &&
43
+ echo "export PATH=/llvm-mingw/bin:\$PATH" >> /etc/rubybashrc &&
44
+ rm -r /llvm-mingw/bin/i686-w64* /llvm-mingw/bin/armv7-w64* /llvm-mingw/bin/x86_64-w64* /llvm-mingw/i686-w64* /llvm-mingw/armv7-w64* /llvm-mingw/x86_64-w64*
45
+ EOF
46
+
27
47
  <% elsif platform =~ /linux-musl/ %>
28
48
  COPY build/mk_musl_cross.sh /tmp
29
49
  RUN /tmp/mk_musl_cross.sh <%= target %>
@@ -44,6 +64,20 @@ if platform =~ /x64-mingw32/ %> gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64
44
64
  <% if platform =~ /darwin/ %>
45
65
  COPY build/mk_osxcross.sh /tmp
46
66
  RUN /tmp/mk_osxcross.sh
67
+
68
+ # Install mig which is a Macos specific RPC code generator, which is part of xcode
69
+ RUN apt-get -y update && \
70
+ apt-get install -y bison flex && \
71
+ rm -rf /var/lib/apt/lists/*
72
+ RUN git clone --branch=cross_platform https://github.com/markmentovai/bootstrap_cmds && \
73
+ cd bootstrap_cmds && \
74
+ autoreconf --install && \
75
+ sh configure && \
76
+ make && \
77
+ sed -E -i 's/^cppflags=(.*)/cppflags=(\1 "-D<%= platform =~ /arm64/ ? "__arm64__" : "__x86_64__" %>" "-I\/opt\/osxcross\/target\/SDK\/MacOSX11.1.sdk\/usr\/include")/' migcom.tproj/mig.sh && \
78
+ sudo make install && \
79
+ cd .. && \
80
+ rm -rf bootstrap_cmds
47
81
  <% end %>
48
82
 
49
83
 
@@ -74,7 +108,7 @@ ENV BASH_ENV=/etc/rubybashrc
74
108
  ##
75
109
  USER rubyuser
76
110
 
77
- ENV RBENV_RUBIES="2.5.9 3.1.6 3.4.1"
111
+ ENV RBENV_RUBIES="3.1.7 3.4.5"
78
112
 
79
113
  # Install the bootstrap rubies
80
114
  RUN bash -c " \
@@ -106,7 +140,6 @@ RUN sudo mkdir -p /usr/local/rake-compiler && \
106
140
 
107
141
  <%
108
142
  #
109
- # Build ruby versions prior to ruby2_keywords using ruby-2.5
110
143
  # Build ruby versions with ruby2_keywords using ruby-3.x
111
144
  #
112
145
  # Note that parallel builds of ruby with make flag `-j` are often flaky, see
@@ -115,23 +148,25 @@ RUN sudo mkdir -p /usr/local/rake-compiler && \
115
148
  xrubies_build_plan = if platform =~ /x64-mingw-ucrt/
116
149
  [
117
150
  # Rubyinstaller-3.1+ is platform x64-mingw-ucrt
118
- ["3.4.1:3.3.7:3.2.6:3.1.6", "3.4.1"],
151
+ ["3.4.5:3.3.9:3.2.9:3.1.7", "3.4.5"],
152
+ ]
153
+ elsif platform =~ /aarch64-mingw-ucrt/
154
+ [
155
+ ["3.4.5", "3.1.7"],
119
156
  ]
120
157
  elsif platform =~ /x64-mingw32/
121
158
  [
122
159
  # Rubyinstaller prior to 3.1 is platform x64-mingw32
123
- ["2.6.10:2.5.9:2.4.10", "2.5.9"],
124
- ["3.0.7:2.7.8", "3.1.6"],
160
+ ["3.0.7:2.7.8", "3.1.7"],
125
161
  ]
126
162
  else
127
163
  [
128
- ["2.6.10:2.5.9:2.4.10", "2.5.9"],
129
- ["2.7.8", "3.1.6"],
130
- ["3.4.1:3.3.7:3.2.6:3.1.6:3.0.7", "3.4.1"],
164
+ ["2.7.8", "3.1.7"],
165
+ ["3.4.5:3.3.9:3.2.9:3.1.7:3.0.7", "3.4.5"],
131
166
  ]
132
167
  end
133
168
 
134
- strip = '-s' if platform !~ /darwin/
169
+ strip = '-s' if platform !~ /darwin|aarch64-mingw/
135
170
 
136
171
  xrubies_build_plan.each do |xrubies, bootstrap_ruby_version| %>
137
172
  RUN bash -c " \
@@ -139,7 +174,7 @@ RUN bash -c " \
139
174
  export CPPFLAGS='<%= "-D__USE_MINGW_ANSI_STDIO=1" if platform =~ /x64-mingw-ucrt/ %>' && \
140
175
  export CFLAGS='-O1 -fno-omit-frame-pointer -fno-fast-math -fstack-protector-strong <%= strip %>' && \
141
176
  export LDFLAGS='-pipe <%= strip %>' && \
142
- <%= "export LIBS='-l:libssp.a' &&" if platform =~ /mingw/ %> \
177
+ <%= "export LIBS='-l:libssp.a -lpthread' &&" if platform =~ /mingw/ %> \
143
178
  <%= "export CC=#{target}-clang &&" if platform =~ /darwin/ %> \
144
179
  export MAKE='make V=1' && \
145
180
  rake-compiler cross-ruby VERSION=<%= xrubies %> HOST=<%= target %> && \
@@ -160,15 +195,10 @@ RUN find /usr/local/rake-compiler/ruby/*linux*/ -name mkmf.rb | while read f ; d
160
195
  <% if platform =~ /mingw/ %>
161
196
  # RubyInstaller doesn't install libgcc -> link it static.
162
197
  RUN find /usr/local/rake-compiler/ruby/*mingw*/ -name rbconfig.rb | while read f ; do sed -i 's/."LDFLAGS". = "/&-static-libgcc /' $f ; done
163
- # Raise Windows-API to Vista (affects ruby < 2.6 only)
164
- RUN find /usr/local/rake-compiler/ruby -name rbconfig.rb | while read f ; do sed -i 's/0x0501/0x0600/' $f ; done
165
198
  # Don't link to static libruby
166
199
  RUN find /usr/local/rake-compiler/ruby -name lib*-ruby*.dll.a | while read f ; do n=`echo $f | sed s/.dll//` ; mv $f $n ; done
167
200
  <% end %>
168
201
 
169
- # ruby-2.5 links to libcrypt, which isn't necessary for extensions
170
- RUN find /usr/local/rake-compiler/ruby -name rbconfig.rb | while read f ; do sed -i 's/-lcrypt//' $f ; done
171
-
172
202
  <% if platform =~ /darwin/ %>
173
203
  # for rubies which use `-bundle_loader` on darwin
174
204
  # - the upstream change: https://github.com/ruby/ruby/pull/6193
@@ -187,7 +217,7 @@ RUN find /usr/local/rake-compiler/ruby/*/*/lib/ruby -name rbconfig.rb | while re
187
217
  ##
188
218
  USER root
189
219
 
190
- <% if platform =~ /mingw/ %>
220
+ <% if platform =~ /(x64|x86)-mingw/ %>
191
221
  # Install wrappers for strip commands as a workaround for "Protocol error" in boot2docker.
192
222
  COPY build/strip_wrapper_vbox /root/
193
223
  RUN mv /usr/bin/<%= target %>-strip /usr/bin/<%= target %>-strip.bin && \
@@ -200,6 +230,16 @@ RUN printf "1\n" | update-alternatives --config <%= target %>-gcc && \
200
230
  printf "1\n" | update-alternatives --config <%= target %>-g++
201
231
  <% end %>
202
232
 
233
+ <% if platform =~ /aarch64-mingw/ %>
234
+ # Fool libtool to allow building a shared library although linking to libclang_rt.builtins-aarch64.a
235
+ #
236
+ # Linker option "-llibclang_rt.builtins-aarch64.a" is required on Windows on ARM when compiling C++ and when clang is called with -nostdlib (due to be invoked by libtool).
237
+ # Unfortunately libtool then forces a static build.
238
+ # This is a ugly hack to make libtool beleave that the library is a DLL instead of an archive and to allow building a DLL instand.
239
+ #
240
+ RUN sudo cp /llvm-mingw/aarch64-w64-mingw32/bin/libc++.dll /llvm-mingw/aarch64-w64-mingw32/lib/libclang_rt.builtins-aarch64.0
241
+ <% end %>
242
+
203
243
  <% if platform =~ /darwin/ %>
204
244
  # Install wrapper around strip to re-sign binaries (ad-hoc signature)
205
245
  COPY build/strip_wrapper_codesign /root/
@@ -224,8 +264,8 @@ RUN echo 'source /etc/profile.d/rcd-env.sh' >> /etc/rubybashrc
224
264
  # Install sudoers configuration
225
265
  COPY build/sudoers /etc/sudoers.d/rake-compiler-dock
226
266
 
227
- RUN bash -c "rbenv global 3.4.1"
267
+ RUN bash -c "rbenv global 3.4.5"
228
268
 
229
- ENV RUBY_CC_VERSION=3.4.1:3.3.7:3.2.6:3.1.6:3.0.7:2.7.8:2.6.10:2.5.9:2.4.10
269
+ ENV RUBY_CC_VERSION=3.4.5:3.3.9:3.2.9:3.1.7:3.0.7:2.7.8
230
270
 
231
271
  CMD bash
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Easy to use and reliable cross compiler environment for building Windows, Linux, Mac and JRuby binary gems.**
4
4
 
5
- It provides cross compilers and Ruby environments for 2.4 and newer versions of the [RubyInstaller](http://rubyinstaller.org/) and Linux runtime environments.
5
+ It provides cross compilers and Ruby environments for 2.6 and newer versions of the [RubyInstaller](http://rubyinstaller.org/) and Linux runtime environments.
6
6
  They are prepared for use with [rake-compiler](https://github.com/rake-compiler/rake-compiler).
7
7
  It is used by [many gems with C or JRuby extentions](https://github.com/rake-compiler/rake-compiler-dock/wiki/Projects-using-rake-compiler-dock).
8
8
 
@@ -16,6 +16,7 @@ The following platforms are supported for cross-compilation by rake-compiler-doc
16
16
 
17
17
  - `aarch64-linux` and `aarch64-linux-gnu`
18
18
  - `aarch64-linux-musl`
19
+ - `aarch64-mingw-ucrt`
19
20
  - `arm-linux` and `arm-linux-gnu`
20
21
  - `arm-linux-musl`
21
22
  - `arm64-darwin`
@@ -72,8 +73,6 @@ Ruby version 3.1 and later ship with a sufficient Rubygems version. For earlier
72
73
  - ruby: "3.0", rubygems: "3.5.5" # or possibly higher
73
74
  - ruby: "2.7", rubygems: "3.4.22"
74
75
  - ruby: "2.6", rubygems: "3.4.22"
75
- - ruby: "2.5", rubygems: "3.3.26"
76
- - ruby: "2.4", rubygems: "3.3.26"
77
76
 
78
77
  **It's strongly suggested that you use rake-compiler v1.2.7 or later to build `linux-musl` and/or `linux-gnu` native gems.** That version of rake-compiler sets `required_rubygems_version` automatically in the native platform gems' gemspecs.
79
78
 
@@ -193,6 +192,7 @@ This can be done like this:
193
192
  PLATFORMS = %w[
194
193
  aarch64-linux-gnu
195
194
  aarch64-linux-musl
195
+ aarch64-mingw-ucrt
196
196
  arm-linux-gnu
197
197
  arm-linux-musl
198
198
  arm64-darwin
@@ -207,7 +207,8 @@ PLATFORMS = %w[
207
207
  ]
208
208
  task 'gem:native' do
209
209
  require 'rake_compiler_dock'
210
- sh "bundle package --all" # Avoid repeated downloads of gems by using gem files from the host.
210
+ sh "bundle config set cache_all true" # Avoid repeated downloads of gems by using gem files from the host.
211
+ sh "bundle package"
211
212
  PLATFORMS.each do |plat|
212
213
  RakeCompilerDock.sh "bundle --local && rake native:#{plat} gem", platform: plat
213
214
  end
@@ -231,7 +232,8 @@ Please note, that parallel builds only work reliable, if the specific platform g
231
232
  task 'prepare' do
232
233
  require 'rake_compiler_dock'
233
234
  require 'io/console'
234
- sh "bundle package --all"
235
+ sh "bundle config set cache_all true"
236
+ sh "bundle package"
235
237
  sh "cp ~/.gem/gem-*.pem build/gem/ || true"
236
238
  ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
237
239
  end
@@ -313,6 +315,7 @@ OCI images snapshotted from `main` are published weekly to Github Container Regi
313
315
  - `ghcr.io/rake-compiler/rake-compiler-dock-image:snapshot-mri-x86_64-linux-gnu`
314
316
 
315
317
  These images are intended for integration testing. They may not work properly and should not be considered production ready.
318
+ Snapshot images can be used by setting `RCD_IMAGE_VERSION` environment variable.
316
319
 
317
320
 
318
321
  ## Environment Variables
@@ -328,6 +331,9 @@ The following variables are recognized by rake-compiler-dock:
328
331
  It is ignored when `rubyvm` is set to `:jruby`.
329
332
  * `RCD_IMAGE` - The docker image that is downloaded and started.
330
333
  Defaults to "ghcr.io/rake-compiler/rake-compiler-dock-image:IMAGE_VERSION-PLATFORM" with an image version that is determined by the gem version.
334
+ * `RCD_IMAGE_VERSION` - The docker image version that is downloaded and started.
335
+ Defaults to the version of the rake-compiler-dock gem in use.
336
+ Can be set to `snapshot` in order to use the latest images from main branch.
331
337
 
332
338
  The following variables are passed through to the docker container without modification:
333
339
 
@@ -352,6 +358,42 @@ Other environment variables can be set or passed through to the container like t
352
358
  RakeCompilerDock.sh "rake cross native gem OPENSSL_VERSION=#{ENV['OPENSSL_VERSION']}"
353
359
  ```
354
360
 
361
+ ### Choosing the version of ruby to run in the build container
362
+
363
+ There are [multiple versions of Ruby installed in the build container](https://github.com/rake-compiler/rake-compiler-dock/blob/d3e6b44916d9d63d4c431b8c749a2c58bf1fe8e8/Dockerfile.mri.erb#L77). The latest version will be the default, but you may need to choose a different version to run during your build process.
364
+
365
+ You can do this by passing a `ruby:` keyword argument to `RakeCompilerDock.sh`:
366
+
367
+ ```ruby
368
+ RakeCompilerDock.sh "ruby -v"
369
+ # => ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
370
+
371
+ RakeCompilerDock.sh "ruby -v", ruby: "3.1.6"
372
+ # => ruby 3.1.6p260 (2024-05-29 revision a777087be6) [x86_64-linux]48d4efcb85) +PRISM [x86_64-linux]
373
+ ```
374
+
375
+ Or by setting the environment variable `RCD_RUBY_VERSION`:
376
+
377
+ ``` sh
378
+ $ rake-compiler-dock bash -c "ruby -v"
379
+ ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
380
+
381
+ $ RCD_RUBY_VERSION=3.1.6 rake-compiler-dock bash -c "ruby -v"
382
+ ruby 3.1.6p260 (2024-05-29 revision a777087be6) [x86_64-linux]
383
+ ```
384
+
385
+ Or by running `rbenv shell` in the command:
386
+
387
+ ``` ruby
388
+ RakeCompilerDock.sh "rbenv shell 3.1.6 && ruby -v", platform: "x86_64-linux-gnu"
389
+ # => ruby 3.1.6p260 (2024-05-29 revision a777087be6) [x86_64-linux]
390
+ ```
391
+
392
+ ``` sh
393
+ $ rake-compiler-dock bash -c "rbenv shell 3.1.6 && ruby -v"
394
+ ruby 3.1.6p260 (2024-05-29 revision a777087be6) [x86_64-linux]
395
+ ```
396
+
355
397
  ### Choosing specific Ruby versions to support
356
398
 
357
399
  If you only want to precompile for certain Ruby versions, you can specify those versions by overwriting the `RUBY_CC_VERSION` environment variable.
@@ -362,7 +404,7 @@ For example, if you wanted to only support Ruby 3.4 and 3.3, you might set this
362
404
  ENV["RUBY_CC_VERSION"] = "3.4.1:3.3.7"
363
405
  ```
364
406
 
365
- In practice, though, hardcoding these versions is brittle because the patch versions in the container may very from release to release.
407
+ In practice, though, hardcoding these versions is brittle because the patch versions in the container may vary from release to release.
366
408
 
367
409
  A more robust way to do this is to use `RakeCompilerDock.ruby_cc_version` which accepts an array of Ruby minor versions or patch version requirements.
368
410
 
data/Rakefile CHANGED
@@ -8,10 +8,32 @@ CLEAN.include("tmp")
8
8
 
9
9
  RakeCompilerDock::GemHelper.install_tasks
10
10
 
11
+ def build_mri_images(platforms, host_platforms, output: )
12
+ plats = host_platforms.map(&:first).join(",")
13
+ platforms.each do |platform, _|
14
+ sdf = "tmp/docker/Dockerfile.mri.#{platform}.#{host_platforms.first[1]}"
15
+ image_name = RakeCompilerDock::Starter.container_image_name(platform: platform)
16
+
17
+ RakeCompilerDock.docker_build(sdf, tag: image_name, platform: plats, output: output)
18
+
19
+ if image_name.include?("linux-gnu")
20
+ RakeCompilerDock.docker_build(sdf, tag: image_name.sub("linux-gnu", "linux"), platform: plats, output: output)
21
+ end
22
+ end
23
+ end
24
+
25
+ def build_jruby_images(host_platforms, output: )
26
+ image_name = RakeCompilerDock::Starter.container_image_name(rubyvm: "jruby")
27
+ plats = host_platforms.map(&:first).join(",")
28
+ sdf = "tmp/docker/Dockerfile.jruby.#{host_platforms.first[1]}"
29
+ RakeCompilerDock.docker_build(sdf, tag: image_name, platform: plats, output: output)
30
+ end
31
+
11
32
  platforms = [
12
33
  # tuple is [platform, target]
13
34
  ["aarch64-linux-gnu", "aarch64-linux-gnu"],
14
35
  ["aarch64-linux-musl", "aarch64-linux-musl"],
36
+ ["aarch64-mingw-ucrt", "aarch64-w64-mingw32"],
15
37
  ["arm-linux-gnu", "arm-linux-gnueabihf"],
16
38
  ["arm-linux-musl", "arm-linux-musleabihf"],
17
39
  ["arm64-darwin", "aarch64-apple-darwin"],
@@ -25,52 +47,91 @@ platforms = [
25
47
  ["x86_64-linux-musl", "x86_64-unknown-linux-musl"],
26
48
  ]
27
49
 
50
+ host_platforms = [
51
+ # tuple is [docker platform, rake task, RUBY_PLATFORM matcher]
52
+ ["linux/amd64", "x86", /^x86_64|^x64|^amd64/],
53
+ ["linux/arm64", "arm", /^aarch64|arm64/],
54
+ ]
55
+ local_platform = host_platforms.find { |_,_,reg| reg =~ RUBY_PLATFORM } or
56
+ raise("RUBY_PLATFORM #{RUBY_PLATFORM} is not supported as host")
57
+
28
58
  namespace :build do
29
59
 
30
- platforms.each do |platform, target|
31
- sdf = "Dockerfile.mri.#{platform}"
32
-
33
- desc "Build image for platform #{platform}"
34
- task platform => sdf
35
- task sdf do
36
- image_name = RakeCompilerDock::Starter.container_image_name(platform: platform)
37
- sh(*RakeCompilerDock.docker_build_cmd(platform), "-t", image_name, "-f", "Dockerfile.mri.#{platform}", ".")
38
- if image_name.include?("linux-gnu")
39
- sh("docker", "tag", image_name, image_name.sub("linux-gnu", "linux"))
40
- end
41
- end
60
+ mkdir_p "tmp/docker"
42
61
 
62
+ docker_platform, rake_platform, _ = local_platform
63
+ platforms.each do |platform, target|
64
+ sdf = "tmp/docker/Dockerfile.mri.#{platform}.#{rake_platform}"
43
65
  df = ERB.new(File.read("Dockerfile.mri.erb"), trim_mode: ">").result(binding)
44
66
  File.write(sdf, df)
45
67
  CLEAN.include(sdf)
46
68
  end
69
+ sdf = "tmp/docker/Dockerfile.jruby.#{rake_platform}"
70
+ df = File.read("Dockerfile.jruby")
71
+ File.write(sdf, df)
72
+
73
+ RakeCompilerDock::ParallelDockerBuild.new(platforms.map{|pl, _| "tmp/docker/Dockerfile.mri.#{pl}.#{rake_platform}" } + ["tmp/docker/Dockerfile.jruby.#{rake_platform}"], workdir: "tmp/docker", task_prefix: "common-#{rake_platform}-", platform: docker_platform)
47
74
 
48
- desc "Build image for JRuby"
49
- task :jruby => "Dockerfile.jruby"
50
- task "Dockerfile.jruby" do
51
- image_name = RakeCompilerDock::Starter.container_image_name(rubyvm: "jruby")
52
- sh(*RakeCompilerDock.docker_build_cmd("jruby"), "-t", image_name, "-f", "Dockerfile.jruby", ".")
75
+ platforms.each do |platform, target|
76
+ sdf = "tmp/docker/Dockerfile.mri.#{platform}.#{rake_platform}"
77
+
78
+ # Load image after build on local platform only
79
+ desc "Build and load image for platform #{platform} on #{docker_platform}"
80
+ task platform => sdf do
81
+ build_mri_images([platform], [local_platform], output: 'load')
82
+ end
83
+ multitask :all => platform
53
84
  end
54
85
 
55
- RakeCompilerDock::ParallelDockerBuild.new(platforms.map{|pl, _| "Dockerfile.mri.#{pl}" } + ["Dockerfile.jruby"], workdir: "tmp/docker")
86
+ sdf = "tmp/docker/Dockerfile.jruby.#{rake_platform}"
87
+ # Load image after build on local platform only
88
+ desc "Build and load image for JRuby on #{docker_platform}"
89
+ task :jruby => sdf do
90
+ build_jruby_images([local_platform], output: 'load')
91
+ end
92
+ multitask :all => :jruby
56
93
 
94
+ all_mri_images = platforms.map(&:first)
57
95
  desc "Build images for all MRI platforms in parallel"
58
96
  if ENV['RCD_USE_BUILDX_CACHE']
59
- task :mri => platforms.map(&:first)
97
+ task :mri => all_mri_images
60
98
  else
61
- multitask :mri => platforms.map(&:first)
99
+ multitask :mri => all_mri_images
62
100
  end
63
101
 
102
+ all_images = all_mri_images + ["jruby"]
64
103
  desc "Build images for all platforms in parallel"
65
104
  if ENV['RCD_USE_BUILDX_CACHE']
66
- task :all => platforms.map(&:first) + ["jruby"]
105
+ task :all => all_images
67
106
  else
68
- multitask :all => platforms.map(&:first) + ["jruby"]
107
+ multitask :all => all_images
69
108
  end
70
109
  end
71
110
 
72
111
  task :build => "build:all"
73
112
 
113
+ namespace :release do
114
+ host_pl = host_platforms.map(&:first).join(",")
115
+
116
+ desc "Push image for JRuby on #{host_pl}"
117
+ task :jruby do
118
+ build_jruby_images(host_platforms, output: 'push')
119
+ end
120
+
121
+ desc "Push all docker images on #{host_pl}"
122
+ multitask :images => :jruby
123
+
124
+ platforms.each do |platform, target|
125
+ desc "Push image for platform #{platform} on #{host_pl}"
126
+ task platform do
127
+ build_mri_images([platform], host_platforms, output: 'push')
128
+ end
129
+
130
+ desc "Push all docker images on #{host_pl}"
131
+ multitask :images => platform
132
+ end
133
+ end
134
+
74
135
  namespace :prepare do
75
136
  desc "Build cross compiler for x64-mingw-ucrt aka RubyInstaller-3.1+"
76
137
  task "mingw64-ucrt" do
@@ -113,20 +174,3 @@ task :update_lists do
113
174
  EOT
114
175
  end
115
176
  end
116
-
117
- namespace :release do
118
- desc "push all docker images"
119
- task :images do
120
- image_name = RakeCompilerDock::Starter.container_image_name(rubyvm: "jruby")
121
- sh("docker", "push", image_name)
122
-
123
- platforms.each do |platform, _|
124
- image_name = RakeCompilerDock::Starter.container_image_name(platform: platform)
125
- sh("docker", "push", image_name)
126
-
127
- if image_name.include?("linux-gnu")
128
- sh("docker", "push", image_name.sub("linux-gnu", "linux"))
129
- end
130
- end
131
- end
132
- end
@@ -0,0 +1,2 @@
1
+ [worker.oci]
2
+ gc = false
data/build/gem_helper.rb CHANGED
@@ -13,7 +13,7 @@ module RakeCompilerDock
13
13
  end
14
14
 
15
15
  def hfile
16
- "History.md"
16
+ "CHANGELOG.md"
17
17
  end
18
18
 
19
19
  def headline
@@ -29,7 +29,7 @@ GCC_CONFIG += --disable-libquadmath --disable-decimal-float
29
29
  GCC_CONFIG += --disable-multilib
30
30
  EOF
31
31
 
32
- make -j$(nproc) install
32
+ make -j$(nproc) install LINUX_HEADERS_SITE=http://mirrors.2f30.org/sabotage/tarballs/
33
33
 
34
34
  popd
35
35
 
@@ -9,22 +9,34 @@ module RakeCompilerDock
9
9
  if platform
10
10
  cache_version = RakeCompilerDock::IMAGE_VERSION.split(".").take(2).join(".")
11
11
  cache = File.join("cache", cache_version, platform)
12
- "docker buildx build --cache-to=type=local,dest=#{cache},mode=max --cache-from=type=local,src=#{cache} --load"
12
+ "docker buildx build --cache-to=type=local,dest=#{cache},mode=max --cache-from=type=local,src=#{cache} --progress=plain"
13
13
  else
14
14
  return nil
15
15
  end
16
16
  else
17
- ENV['RCD_DOCKER_BUILD'] || "docker build"
17
+ ENV['RCD_DOCKER_BUILD'] || "docker buildx build --progress=plain"
18
18
  end
19
19
  Shellwords.split(cmd)
20
20
  end
21
+
22
+ # Run an intermediate dockerfile without tag
23
+ #
24
+ # The layers will be reused in subsequent builds, even if they run in parallel.
25
+ def docker_build(filename, tag: nil, output: false, platform: )
26
+ cmd = docker_build_cmd(platform)
27
+ return if cmd.nil?
28
+ tag_args = ["-t", tag] if tag
29
+ push_args = ["--push"] if output == 'push'
30
+ push_args = ["--load"] if output == 'load'
31
+ Class.new.extend(FileUtils).sh(*cmd, "-f", filename, ".", "--platform", platform, *tag_args, *push_args)
32
+ end
21
33
  end
22
34
 
23
35
  # Run docker builds in parallel, but ensure that common docker layers are reused
24
36
  class ParallelDockerBuild
25
37
  include Rake::DSL
26
38
 
27
- def initialize(dockerfiles, workdir: "tmp/docker", inputdir: ".", task_prefix: "common-")
39
+ def initialize(dockerfiles, workdir: "tmp/docker", inputdir: ".", task_prefix: "common-", platform: "local")
28
40
  FileUtils.mkdir_p(workdir)
29
41
 
30
42
  files = parse_dockerfiles(dockerfiles, inputdir)
@@ -34,6 +46,7 @@ module RakeCompilerDock
34
46
  # pp vcs
35
47
 
36
48
  define_common_tasks(vcs, workdir, task_prefix)
49
+ @platform = platform
37
50
  end
38
51
 
39
52
  # Read given dockerfiles from inputdir and split into a list of commands.
@@ -96,7 +109,7 @@ module RakeCompilerDock
96
109
  fn = "#{task_prefix}#{Digest::SHA1.hexdigest(files.join)}"
97
110
  File.write(File.join(workdir, fn), (plines + lines).join)
98
111
  task fn do
99
- docker_build(fn, workdir)
112
+ RakeCompilerDock.docker_build(File.join(workdir, fn), platform: @platform)
100
113
  end
101
114
 
102
115
  nfn = define_common_tasks(nvcs, workdir, task_prefix, plines + lines)
@@ -109,14 +122,5 @@ module RakeCompilerDock
109
122
  fn
110
123
  end
111
124
  end
112
-
113
- # Run an intermediate dockerfile without tag
114
- #
115
- # The layers will be reused in subsequent builds, even if they run in parallel.
116
- def docker_build(filename, workdir)
117
- cmd = RakeCompilerDock.docker_build_cmd
118
- return if cmd.nil?
119
- sh(*RakeCompilerDock.docker_build_cmd, "-f", File.join(workdir, filename), ".")
120
- end
121
125
  end
122
126
  end
@@ -2,16 +2,18 @@ diff --git a/tasks/bin/cross-ruby.rake b/tasks/bin/cross-ruby.rake
2
2
  index 8317a2a3..8ed21718 100644
3
3
  --- a/tasks/bin/cross-ruby.rake
4
4
  +++ b/tasks/bin/cross-ruby.rake
5
- @@ -116,11 +116,30 @@
5
+ @@ -116,11 +116,32 @@
6
6
  "--host=#{mingw_host}",
7
7
  "--target=#{mingw_target}",
8
8
  "--build=#{RUBY_BUILD}",
9
9
  - '--enable-shared',
10
10
  + '--enable-install-static-library',
11
11
  + '--disable-jit-support',
12
+ + '--disable-rpath',
12
13
  + 'ac_cv_lib_z_uncompress=no',
13
14
  + 'ac_cv_lib_crypt_crypt=no',
14
15
  + 'ac_cv_func_crypt_r=no',
16
+ + 'extra_warnflags=-Wno-shorten-64-to-32 -Wno-dll-attribute-on-redeclaration',
15
17
  '--disable-install-doc',
16
18
  '--with-ext=',
17
19
  ]
data/build/sudoers CHANGED
@@ -1 +1 @@
1
- Defaults env_keep += "http_proxy https_proxy ftp_proxy GEM_PRIVATE_KEY_PASSPHRASE RCD_HOST_RUBY_PLATFORM RCD_HOST_RUBY_VERSION RCD_IMAGE RUBY_CC_VERSION LD_LIBRARY_PATH DEVTOOLSET_ROOTPATH SOURCE_DATE_EPOCH"
1
+ Defaults env_keep += "http_proxy https_proxy ftp_proxy GEM_PRIVATE_KEY_PASSPHRASE RCD_HOST_RUBY_PLATFORM RCD_HOST_RUBY_VERSION RCD_IMAGE RUBY_CC_VERSION LD_LIBRARY_PATH DEVTOOLSET_ROOTPATH SOURCE_DATE_EPOCH RBENV_VERSION"
@@ -41,6 +41,11 @@ module RakeCompilerDock
41
41
  user = options.fetch(:username){ current_user }
42
42
  group = options.fetch(:groupname){ current_group }
43
43
 
44
+ ruby_version = options[:ruby] || ENV['RCD_RUBY_VERSION']
45
+ rbenv_opts = if ruby_version
46
+ ["-e", "RBENV_VERSION=#{ruby_version}"]
47
+ end
48
+
44
49
  platforms(options).split(" ").each do |platform|
45
50
  image_name = container_image_name(options.merge(platform: platform))
46
51
 
@@ -73,6 +78,7 @@ module RakeCompilerDock
73
78
  "-e", "RCD_HOST_RUBY_PLATFORM=#{RUBY_PLATFORM}",
74
79
  "-e", "RCD_HOST_RUBY_VERSION=#{RUBY_VERSION}",
75
80
  "-e", "RCD_IMAGE=#{image_name}",
81
+ *rbenv_opts,
76
82
  "-w", make_valid_path(workdir),
77
83
  *docker_opts,
78
84
  image_name,
@@ -167,7 +173,7 @@ module RakeCompilerDock
167
173
 
168
174
  "%s/rake-compiler-dock-image:%s-%s%s" % [
169
175
  container_registry,
170
- options.fetch(:version) { IMAGE_VERSION },
176
+ options.fetch(:version) { image_version },
171
177
  container_rubyvm(options),
172
178
  container_jrubyvm?(options) ? "" : "-#{options.fetch(:platform)}",
173
179
  ]
@@ -178,6 +184,10 @@ module RakeCompilerDock
178
184
  ENV['CONTAINER_REGISTRY'] || "ghcr.io/rake-compiler"
179
185
  end
180
186
 
187
+ def image_version
188
+ ENV['RCD_IMAGE_VERSION'] || IMAGE_VERSION
189
+ end
190
+
181
191
  def container_rubyvm(options={})
182
192
  return "jruby" if options[:platform] == "jruby"
183
193
  options.fetch(:rubyvm) { ENV['RCD_RUBYVM'] } || "mri"
@@ -1,4 +1,4 @@
1
1
  module RakeCompilerDock
2
- VERSION = "1.9.1"
3
- IMAGE_VERSION = "1.9.1"
2
+ VERSION = "1.10.0"
3
+ IMAGE_VERSION = "1.10.0"
4
4
  end