rake-compiler-dock 1.2.2 → 1.3.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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +74 -23
- data/.github/workflows/publish-images.yml +67 -0
- data/.gitignore +2 -0
- data/CONTRIBUTING.md +38 -0
- data/Dockerfile.jruby +17 -14
- data/Dockerfile.mri.erb +83 -100
- data/History.md +24 -0
- data/README.md +12 -2
- data/Rakefile +21 -14
- data/build/mk_i686.rb +2 -0
- data/build/mk_osxcross.sh +38 -0
- data/build/parallel_docker_build.rb +21 -6
- data/build/patches/{ruby-3.1.0 → ruby-3.1.3}/no_sendfile.patch +0 -0
- data/build/patches2/{rake-compiler-1.1.6 → rake-compiler-1.2.1}/0004-Enable-build-of-static-libruby.patch +0 -0
- data/build/patches2/rake-compiler-1.2.1/0005-make-miniruby.patch +19 -0
- data/lib/rake_compiler_dock/starter.rb +35 -11
- data/lib/rake_compiler_dock/version.rb +2 -2
- data/test/env/Dockerfile.centos +3 -1
- data/test/rcd_test/Gemfile +1 -1
- data/test/rcd_test/Rakefile +8 -6
- data/test/rcd_test/ext/mri/extconf.rb +66 -0
- data/test/test_environment_variables.rb +27 -19
- data/test/test_parallel_docker_build.rb +1 -1
- data/test/test_starter.rb +119 -0
- metadata +10 -33
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -2
data/Dockerfile.mri.erb
CHANGED
@@ -8,9 +8,12 @@ manylinux = !!(image =~ /manylinux/)
|
|
8
8
|
%>
|
9
9
|
FROM <%= image %>
|
10
10
|
|
11
|
+
##
|
12
|
+
## RVM and native rubies
|
13
|
+
##
|
14
|
+
# Install packages which rvm will require
|
11
15
|
<% if manylinux %>
|
12
|
-
|
13
|
-
RUN yum install -y autoconf gcc-c++ libtool readline-devel sqlite-devel ruby openssl-devel xz cmake sudo less libffi-devel git wget
|
16
|
+
RUN yum install -y sudo ruby less git wget curl autoconf libtool cmake gcc-c++ xz readline-devel sqlite-devel openssl-devel libffi-devel libyaml-devel
|
14
17
|
|
15
18
|
# Prepare sudo and delete sudo as alias to gosu
|
16
19
|
RUN rm -f /usr/local/bin/sudo && \
|
@@ -19,7 +22,7 @@ RUN rm -f /usr/local/bin/sudo && \
|
|
19
22
|
<% else %>
|
20
23
|
ENV DEBIAN_FRONTEND noninteractive
|
21
24
|
RUN apt-get -y update && \
|
22
|
-
apt-get install -y curl git-core
|
25
|
+
apt-get install -y sudo wget autoconf cmake curl git-core pkg-config build-essential xz-utils unzip gnupg2 dirmngr zlib1g-dev libreadline-dev libsqlite0-dev libssl-dev libyaml-dev libffi-dev && \
|
23
26
|
rm -rf /var/lib/apt/lists/*
|
24
27
|
<% end %>
|
25
28
|
|
@@ -42,37 +45,34 @@ RUN mkdir ~/.gnupg && \
|
|
42
45
|
RUN gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB && \
|
43
46
|
(curl -L http://get.rvm.io | sudo bash) && \
|
44
47
|
bash -c " \
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
+
source /etc/rubybashrc && \
|
49
|
+
rvm autolibs disable && \
|
50
|
+
rvmsudo rvm cleanup all \
|
51
|
+
"
|
48
52
|
|
49
|
-
#
|
53
|
+
# Install native rubies and fix permissions
|
50
54
|
COPY build/patches /home/rvm/patches/
|
51
|
-
|
52
|
-
# install rubies and fix permissions on
|
53
|
-
ENV RVM_RUBIES 2.5.9 3.1.0
|
55
|
+
ENV RVM_RUBIES 2.5.9 3.1.3
|
54
56
|
RUN bash -c " \
|
55
|
-
|
56
|
-
|
57
|
+
export CFLAGS='-s -O3 -fno-fast-math -fPIC' && \
|
58
|
+
for v in ${RVM_RUBIES} ; do \
|
57
59
|
rvm install \$v --patch \$(echo ~/patches/ruby-\$v/* | tr ' ' ','); \
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
# Install rake-compiler and typical gems in all Rubies
|
63
|
-
# do not generate documentation for gems
|
64
|
-
RUN echo "gem: --no-ri --no-rdoc" >> ~/.gemrc && \
|
65
|
-
bash -c " \
|
66
|
-
rvm all do gem update --system --no-document && \
|
67
|
-
rvm all do gem install --no-document bundler 'bundler:~>1.16' 'rake-compiler:1.1.6' hoe mini_portile rubygems-tasks mini_portile2 && \
|
68
|
-
find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
|
60
|
+
done && \
|
61
|
+
rvm cleanup all && \
|
62
|
+
find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw \
|
63
|
+
"
|
69
64
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
65
|
+
RUN bash -c " \
|
66
|
+
echo "gem: --no-ri --no-rdoc" >> ~/.gemrc && \
|
67
|
+
rvm all do gem update --system --no-document && \
|
68
|
+
rvm all do gem update --no-document && \
|
69
|
+
rvm all do gem install bundler --no-document && \
|
70
|
+
find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw \
|
71
|
+
"
|
72
|
+
|
73
|
+
##
|
74
|
+
## Cross compilers
|
75
|
+
##
|
76
76
|
USER root
|
77
77
|
|
78
78
|
<% if platform=~/x64-mingw-ucrt/ %>
|
@@ -97,89 +97,58 @@ if platform=~/x64-mingw32/ %> gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 <% end
|
|
97
97
|
rm -rf /var/lib/apt/lists/*
|
98
98
|
<% end %>
|
99
99
|
|
100
|
-
RUN bash -c " \
|
101
|
-
rvm alias create default 3.1.0 && \
|
102
|
-
rvm use default "
|
103
|
-
|
104
100
|
<% if manylinux %>
|
105
101
|
# Create dev tools x86-linux-*
|
106
102
|
COPY build/mk_i686.rb /root/
|
107
|
-
RUN
|
108
|
-
ruby /root/mk_i686.rb "
|
103
|
+
RUN /root/mk_i686.rb
|
109
104
|
<% end %>
|
110
105
|
|
111
106
|
<% if platform=~/darwin/ %>
|
112
|
-
|
113
|
-
|
114
|
-
curl -L -o MacOSX11.1.sdk.tar.xz https://github.com/larskanis/MacOSX-SDKs/releases/download/11.1/MacOSX11.1.sdk.tar.xz && \
|
115
|
-
tar -xf MacOSX11.1.sdk.tar.xz -C . && \
|
116
|
-
cp -rf /usr/lib/llvm-10/include/c++ MacOSX11.1.sdk/usr/include/c++ && \
|
117
|
-
cp -rf /usr/include/x86_64-linux-gnu/c++/9/bits/ MacOSX11.1.sdk/usr/include/c++/v1/bits && \
|
118
|
-
tar -cJf MacOSX11.1.sdk.tar.xz MacOSX11.1.sdk && \
|
119
|
-
cd /opt/osxcross && \
|
120
|
-
UNATTENDED=1 SDK_VERSION=11.1 OSX_VERSION_MIN=10.13 USE_CLANG_AS=1 ./build.sh && \
|
121
|
-
ln -s /usr/bin/llvm-config-10 /usr/bin/llvm-config && \
|
122
|
-
ENABLE_COMPILER_RT_INSTALL=1 SDK_VERSION=11.1 ./build_compiler_rt.sh && \
|
123
|
-
rm -rf *~ build tarballs/*
|
124
|
-
|
125
|
-
RUN echo "export PATH=/opt/osxcross/target/bin:\$PATH" >> /etc/rubybashrc && \
|
126
|
-
echo "export MACOSX_DEPLOYMENT_TARGET=10.13" >> /etc/rubybashrc && \
|
127
|
-
echo "export OSXCROSS_MP_INC=1" >> /etc/rubybashrc
|
128
|
-
|
129
|
-
# Add links to build tools without target version kind of:
|
130
|
-
# arm64-apple-darwin-clang => arm64-apple-darwin20.1-clang
|
131
|
-
RUN rm /opt/osxcross/target/bin/*-apple-darwin-* ; \
|
132
|
-
find /opt/osxcross/target/bin/ -name '*-apple-darwin[0-9]*' | sort | while read f ; do d=`echo $f | sed s/darwin[0-9\.]*/darwin/`; echo $f '"$@"' | tee $d && chmod +x $d ; done
|
133
|
-
|
134
|
-
# There's no objdump in osxcross but we can use llvm's
|
135
|
-
RUN ln -s /usr/lib/llvm-10/bin/llvm-objdump /opt/osxcross/target/bin/x86_64-apple-darwin-objdump && \
|
136
|
-
ln -s /usr/lib/llvm-10/bin/llvm-objdump /opt/osxcross/target/bin/aarch64-apple-darwin-objdump
|
137
|
-
|
107
|
+
COPY build/mk_osxcross.sh /home/rvm
|
108
|
+
RUN /home/rvm/mk_osxcross.sh
|
138
109
|
<% end %>
|
139
110
|
|
140
|
-
|
111
|
+
|
112
|
+
##
|
113
|
+
## Cross-compile rubies
|
114
|
+
##
|
141
115
|
USER rvm
|
116
|
+
|
117
|
+
RUN bash -c "rvm all do gem install --no-document rake-compiler:1.2.1"
|
118
|
+
|
119
|
+
# Install rake-compiler's cross rubies in global dir instead of /root
|
120
|
+
RUN sudo mkdir -p /usr/local/rake-compiler && \
|
121
|
+
sudo chown rvm.rvm /usr/local/rake-compiler && \
|
122
|
+
ln -s /usr/local/rake-compiler ~/.rake-compiler
|
123
|
+
|
124
|
+
# Patch rake-compiler to build and install static libraries for Linux rubies
|
142
125
|
COPY build/patches2 /home/rvm/patches/
|
143
126
|
RUN bash -c " \
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
# Patch rubies for cross build
|
151
|
-
#USER root
|
152
|
-
#RUN bash -c " \
|
153
|
-
# for v in 2.7.0 3.0.0 3.1.0 ; do \
|
154
|
-
# curl -SL http://cache.ruby-lang.org/pub/ruby/\${v:0:3}/ruby-\$v.tar.xz | tar -xJC /root/ && \
|
155
|
-
# cd /root/ruby-\$v && \
|
156
|
-
# git apply /home/rvm/patches/ruby-\$v/*.patch && \
|
157
|
-
# cd .. && \
|
158
|
-
# mkdir -p /usr/local/rake-compiler/sources/ && \
|
159
|
-
# tar cjf /usr/local/rake-compiler/sources/ruby-\$v.tar.bz2 ruby-\$v && \
|
160
|
-
# chown rvm /usr/local/rake-compiler -R && \
|
161
|
-
# rm -rf /root/ruby-\$v ; \
|
162
|
-
# done "
|
163
|
-
#USER rvm
|
127
|
+
for v in ${RVM_RUBIES} ; do \
|
128
|
+
cd /usr/local/rvm/gems/ruby-\$v/gems/rake-compiler-1.2.1 && \
|
129
|
+
echo applying patches to ruby-\$v /home/rvm/patches/rake-compiler-1.2.1/*.patch && \
|
130
|
+
( git apply /home/rvm/patches/rake-compiler-1.2.1/*.patch || true ) \
|
131
|
+
done \
|
132
|
+
"
|
164
133
|
|
165
134
|
<%
|
166
135
|
axrubies = if platform =~ /x64-mingw-ucrt/
|
167
136
|
[
|
168
137
|
# Rubyinstaller-3.1.0+ is platform x64-mingw-ucrt
|
169
|
-
["3.1.0", "3.1.
|
138
|
+
["3.2.0:3.1.0", "3.1.3", true],
|
170
139
|
]
|
171
140
|
elsif platform =~ /x64-mingw32/
|
172
141
|
[
|
173
142
|
# Rubyinstaller prior to 3.1.0 is platform x64-mingw32
|
174
143
|
["2.6.0:2.5.0:2.4.0", "2.5.9", false],
|
175
|
-
["3.0.0:2.7.0", "3.1.
|
144
|
+
["3.0.0:2.7.0", "3.1.3", true],
|
176
145
|
]
|
177
146
|
else
|
178
147
|
[
|
179
148
|
# Build xruby versions prior ruby2_keywords in parallel using ruby-2.5
|
180
149
|
["2.6.0:2.5.0:2.4.0", "2.5.9", false],
|
181
150
|
# Build xruby versions with ruby2_keywords in parallel using ruby-3.x
|
182
|
-
["3.1.0:3.0.0:2.7.0", "3.1.
|
151
|
+
["3.2.0:3.1.0:3.0.0:2.7.0", "3.1.3", true],
|
183
152
|
]
|
184
153
|
end
|
185
154
|
|
@@ -190,16 +159,17 @@ ENV XRUBIES <%= xrubies %>
|
|
190
159
|
# Build xruby versions in parallel
|
191
160
|
# Then cleanup all build artifacts
|
192
161
|
RUN bash -c " \
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
162
|
+
rvm use <%= rvm %> && \
|
163
|
+
export CPPFLAGS='<%= "-D__USE_MINGW_ANSI_STDIO=1" if platform=~/x64-mingw-ucrt/ %>' && \
|
164
|
+
export CFLAGS='-O1 -fno-omit-frame-pointer -fno-fast-math -fstack-protector-strong <%= strip %>' && \
|
165
|
+
export LDFLAGS='-pipe <%= strip %>' && \
|
166
|
+
<%= "export LIBS='-l:libssp.a' &&" if platform =~ /mingw/ %> \
|
167
|
+
<%= "export CC=#{target}-clang &&" if platform =~ /darwin/ %> \
|
168
|
+
export MAKE='make V=1 <%= "-j`nproc`" if parallel %>' && \
|
169
|
+
rake-compiler cross-ruby VERSION=$XRUBIES HOST=<%= target %> && \
|
170
|
+
rm -rf ~/.rake-compiler/builds ~/.rake-compiler/sources && \
|
171
|
+
find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw \
|
172
|
+
"
|
203
173
|
<% end %>
|
204
174
|
|
205
175
|
<% if platform=~/linux/ %>
|
@@ -220,12 +190,23 @@ RUN find /usr/local/rake-compiler/ruby -name rbconfig.rb | while read f ; do sed
|
|
220
190
|
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
|
221
191
|
<% end %>
|
222
192
|
|
193
|
+
# ruby-2.5 links to libcrypt, which isn't necessary for extensions
|
194
|
+
RUN find /usr/local/rake-compiler/ruby -name rbconfig.rb | while read f ; do sed -i 's/-lcrypt//' $f ; done
|
195
|
+
|
196
|
+
<% if platform=~/darwin/ %>
|
197
|
+
# ruby-3.2 on darwin links with `-bundle_loader`, see https://github.com/rake-compiler/rake-compiler-dock/issues/87
|
198
|
+
RUN find /usr/local/rake-compiler/ruby/*/*/lib/ruby/3.2.0 -name rbconfig.rb | \
|
199
|
+
while read f ; do sed -i 's/\["EXTDLDFLAGS"\] = "/&-Wl,-flat_namespace /' $f ; done
|
200
|
+
<% end %>
|
201
|
+
|
202
|
+
##
|
203
|
+
## Final adjustments
|
204
|
+
##
|
223
205
|
USER root
|
224
206
|
|
225
207
|
# Fix paths in rake-compiler/config.yml
|
226
208
|
RUN sed -i -- "s:/root/.rake-compiler:/usr/local/rake-compiler:g" /usr/local/rake-compiler/config.yml
|
227
209
|
|
228
|
-
|
229
210
|
<% if platform=~/mingw/ %>
|
230
211
|
# Install wrappers for strip commands as a workaround for "Protocol error" in boot2docker.
|
231
212
|
COPY build/strip_wrapper /root/
|
@@ -246,9 +227,6 @@ RUN echo "export PATH=\$DEVTOOLSET_ROOTPATH/usr/bin:\$PATH" >> /etc/rubybashrc
|
|
246
227
|
# Add prefixed versions of compiler tools
|
247
228
|
RUN for f in addr2line gcc gcov-tool ranlib ar dwp gcc-ranlib nm readelf as elfedit gcc-ar gprof objcopy size c++filt g++ gcov ld objdump strings cpp gcc-nm pkg-config strip ; do ln -sf $DEVTOOLSET_ROOTPATH/usr/bin/$f $DEVTOOLSET_ROOTPATH/usr/bin/<%= target %>-$f ; done
|
248
229
|
|
249
|
-
# ruby-2.5 links to libcrypt, which isn't necessary for extensions
|
250
|
-
RUN find /usr/local/rake-compiler/ruby -name rbconfig.rb | while read f ; do sed -i 's/-lcrypt//' $f ; done
|
251
|
-
|
252
230
|
# Use builtin functions of newer gcc to avoid linker issues on Musl based Linux
|
253
231
|
COPY build/math_h.patch /root/
|
254
232
|
RUN cd /usr/include/ && \
|
@@ -272,6 +250,11 @@ RUN echo "source /etc/profile.d/rcd-env.sh" >> /etc/rubybashrc
|
|
272
250
|
# Install sudoers configuration
|
273
251
|
COPY build/sudoers /etc/sudoers.d/rake-compiler-dock
|
274
252
|
|
275
|
-
|
253
|
+
RUN bash -c " \
|
254
|
+
rvm alias create default 3.1.3 && \
|
255
|
+
rvm use default \
|
256
|
+
"
|
257
|
+
|
258
|
+
ENV RUBY_CC_VERSION 3.2.0:3.1.0:3.0.0:2.7.0:2.6.0:2.5.0:2.4.0
|
276
259
|
|
277
260
|
CMD bash
|
data/History.md
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
1.3.0 / 2022-01-11
|
2
|
+
------------------
|
3
|
+
|
4
|
+
* Add Ruby 3.2 cross-compilation support.
|
5
|
+
* Update RVM installations to latest rubygems.
|
6
|
+
* Update to rake-compiler 1.2.1.
|
7
|
+
* Reduce pre-installed gems to only rake-compiler and bundler.
|
8
|
+
* Install yaml and ffi development headers in the base images, for psych and ffi gem compilation.
|
9
|
+
* Ensure autoconf is installed in the base iamges.
|
10
|
+
* Bump JRuby to 9.4.0.0
|
11
|
+
* Move docker images to ghcr.io/rake-compiler:
|
12
|
+
* `ghcr.io/rake-compiler/rake-compiler-dock-image:1.3.0-jruby`
|
13
|
+
* `ghcr.io/rake-compiler/rake-compiler-dock-image:1.3.0-mri-aarch64-linux`
|
14
|
+
* `ghcr.io/rake-compiler/rake-compiler-dock-image:1.3.0-mri-arm-linux`
|
15
|
+
* `ghcr.io/rake-compiler/rake-compiler-dock-image:1.3.0-mri-arm64-darwin`
|
16
|
+
* `ghcr.io/rake-compiler/rake-compiler-dock-image:1.3.0-mri-x64-mingw-ucrt`
|
17
|
+
* `ghcr.io/rake-compiler/rake-compiler-dock-image:1.3.0-mri-x64-mingw32`
|
18
|
+
* `ghcr.io/rake-compiler/rake-compiler-dock-image:1.3.0-mri-x86-linux`
|
19
|
+
* `ghcr.io/rake-compiler/rake-compiler-dock-image:1.3.0-mri-x86-mingw32`
|
20
|
+
* `ghcr.io/rake-compiler/rake-compiler-dock-image:1.3.0-mri-x86_64-darwin`
|
21
|
+
* `ghcr.io/rake-compiler/rake-compiler-dock-image:1.3.0-mri-x86_64-linux`
|
22
|
+
* Start publishing weekly image snapshots.
|
23
|
+
|
24
|
+
|
1
25
|
1.2.2 / 2022-06-27
|
2
26
|
------------------
|
3
27
|
|
data/README.md
CHANGED
@@ -187,7 +187,7 @@ jobs:
|
|
187
187
|
name: "native-gem"
|
188
188
|
runs-on: ubuntu-latest
|
189
189
|
container:
|
190
|
-
image: "
|
190
|
+
image: "ghcr.io/rake-compiler/rake-compiler-dock-image:1.2.2-mri-x86_64-linux"
|
191
191
|
steps:
|
192
192
|
- uses: actions/checkout@v2
|
193
193
|
- run: bundle install && bundle exec rake gem:x86_64-linux:rcd
|
@@ -218,6 +218,16 @@ end
|
|
218
218
|
|
219
219
|
For an example of rake tasks that support this style of invocation, visit https://github.com/flavorjones/ruby-c-extensions-explained/tree/main/precompiled
|
220
220
|
|
221
|
+
|
222
|
+
### Living on the edge: using weekly snapshots
|
223
|
+
|
224
|
+
OCI images snapshotted from `master` are published weekly to Github Container Registry with the string "snapshot" in place of the version number in the tag name, e.g.:
|
225
|
+
|
226
|
+
- `ghcr.io/rake-compiler/rake-compiler-dock-image:snapshot-mri-x86_64-linux`
|
227
|
+
|
228
|
+
These images are intended for integration testing. They may not work properly and should not be considered production ready.
|
229
|
+
|
230
|
+
|
221
231
|
## Environment Variables
|
222
232
|
|
223
233
|
Rake-compiler-dock makes use of several environment variables.
|
@@ -230,7 +240,7 @@ The following variables are recognized by rake-compiler-dock:
|
|
230
240
|
Must be a space separated list out of `x86-mingw32`, `x64-mingw-ucrt`, `x64-mingw32`, `x86-linux`, `x86_64-linux`, `arm-linux`, `aarch64-linux`, `x86_64-darwin` and `arm64-darwin`.
|
231
241
|
It is ignored when `rubyvm` is set to `:jruby`.
|
232
242
|
* `RCD_IMAGE` - The docker image that is downloaded and started.
|
233
|
-
Defaults to "
|
243
|
+
Defaults to "ghcr.io/rake-compiler/rake-compiler-dock-image:IMAGE_VERSION-PLATFORM" with an image version that is determined by the gem version.
|
234
244
|
|
235
245
|
The following variables are passed through to the docker container without modification:
|
236
246
|
|
data/Rakefile
CHANGED
@@ -6,9 +6,6 @@ require_relative "build/parallel_docker_build"
|
|
6
6
|
|
7
7
|
RakeCompilerDock::GemHelper.install_tasks
|
8
8
|
|
9
|
-
DOCKERHUB_USER = ENV['DOCKERHUB_USER'] || "larskanis"
|
10
|
-
docker_build_cmd = Shellwords.split(ENV['RCD_DOCKER_BUILD'] || "docker build")
|
11
|
-
|
12
9
|
platforms = [
|
13
10
|
["x86-mingw32", "i686-w64-mingw32"],
|
14
11
|
["x64-mingw32", "x86_64-w64-mingw32"],
|
@@ -29,7 +26,8 @@ namespace :build do
|
|
29
26
|
desc "Build image for platform #{platform}"
|
30
27
|
task platform => sdf
|
31
28
|
task sdf do
|
32
|
-
|
29
|
+
image_name = RakeCompilerDock::Starter.container_image_name(platform: platform)
|
30
|
+
sh(*RakeCompilerDock.docker_build_cmd(platform), "-t", image_name, "-f", "Dockerfile.mri.#{platform}", ".")
|
33
31
|
end
|
34
32
|
|
35
33
|
df = ERB.new(File.read("Dockerfile.mri.erb"), trim_mode: ">").result(binding)
|
@@ -40,16 +38,25 @@ namespace :build do
|
|
40
38
|
desc "Build image for JRuby"
|
41
39
|
task :jruby => "Dockerfile.jruby"
|
42
40
|
task "Dockerfile.jruby" do
|
43
|
-
|
41
|
+
image_name = RakeCompilerDock::Starter.container_image_name(rubyvm: "jruby")
|
42
|
+
sh(*RakeCompilerDock.docker_build_cmd("jruby"), "-t", image_name, "-f", "Dockerfile.jruby", ".")
|
44
43
|
end
|
45
44
|
|
46
|
-
RakeCompilerDock::ParallelDockerBuild.new(platforms.map{|pl, _| "Dockerfile.mri.#{pl}" } + ["Dockerfile.jruby"], workdir: "tmp/docker"
|
45
|
+
RakeCompilerDock::ParallelDockerBuild.new(platforms.map{|pl, _| "Dockerfile.mri.#{pl}" } + ["Dockerfile.jruby"], workdir: "tmp/docker")
|
47
46
|
|
48
47
|
desc "Build images for all MRI platforms in parallel"
|
49
|
-
|
48
|
+
if ENV['RCD_USE_BUILDX_CACHE']
|
49
|
+
task :mri => platforms.map(&:first)
|
50
|
+
else
|
51
|
+
multitask :mri => platforms.map(&:first)
|
52
|
+
end
|
50
53
|
|
51
54
|
desc "Build images for all platforms in parallel"
|
52
|
-
|
55
|
+
if ENV['RCD_USE_BUILDX_CACHE']
|
56
|
+
task :all => platforms.map(&:first) + ["jruby"]
|
57
|
+
else
|
58
|
+
multitask :all => platforms.map(&:first) + ["jruby"]
|
59
|
+
end
|
53
60
|
end
|
54
61
|
|
55
62
|
task :build => "build:all"
|
@@ -57,14 +64,14 @@ task :build => "build:all"
|
|
57
64
|
namespace :prepare do
|
58
65
|
desc "Build cross compiler for x64-mingw-ucrt aka RubyInstaller-3.1+"
|
59
66
|
task "mingw64-ucrt" do
|
60
|
-
sh(*docker_build_cmd, "-t", "
|
67
|
+
sh(*RakeCompilerDock.docker_build_cmd, "-t", "larskanis/mingw64-ucrt:20.04", ".",
|
61
68
|
chdir: "mingw64-ucrt")
|
62
69
|
end
|
63
70
|
end
|
64
71
|
|
65
72
|
desc "Run tests"
|
66
73
|
task :test do
|
67
|
-
sh
|
74
|
+
sh %Q{ruby -w -W2 -I. -Ilib -e "#{Dir["test/test_*.rb"].map{|f| "require '#{f}';"}.join}" -- -v #{ENV['TESTOPTS']}}
|
68
75
|
end
|
69
76
|
|
70
77
|
desc "Update predefined_user_group.rb"
|
@@ -92,12 +99,12 @@ end
|
|
92
99
|
namespace :release do
|
93
100
|
desc "push all docker images"
|
94
101
|
task :images do
|
95
|
-
|
96
|
-
sh
|
102
|
+
image_name = RakeCompilerDock::Starter.container_image_name(rubyvm: "jruby")
|
103
|
+
sh("docker", "push", image_name)
|
97
104
|
|
98
105
|
platforms.each do |platform, _|
|
99
|
-
|
100
|
-
sh
|
106
|
+
image_name = RakeCompilerDock::Starter.container_image_name(platform: platform)
|
107
|
+
sh("docker", "push", image_name)
|
101
108
|
end
|
102
109
|
end
|
103
110
|
end
|
data/build/mk_i686.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
#! /usr/bin/env bash
|
2
|
+
|
3
|
+
set -o errexit
|
4
|
+
set -o pipefail
|
5
|
+
set -x
|
6
|
+
|
7
|
+
git clone -q --depth=1 https://github.com/tpoechtrager/osxcross.git /opt/osxcross
|
8
|
+
rm -rf /opt/osxcross/.git
|
9
|
+
|
10
|
+
set +x
|
11
|
+
cd /opt/osxcross/tarballs
|
12
|
+
set -x
|
13
|
+
curl -L -o MacOSX11.1.sdk.tar.xz https://github.com/larskanis/MacOSX-SDKs/releases/download/11.1/MacOSX11.1.sdk.tar.xz
|
14
|
+
tar -xf MacOSX11.1.sdk.tar.xz -C .
|
15
|
+
cp -rf /usr/lib/llvm-10/include/c++ MacOSX11.1.sdk/usr/include/c++
|
16
|
+
cp -rf /usr/include/x86_64-linux-gnu/c++/9/bits/ MacOSX11.1.sdk/usr/include/c++/v1/bits
|
17
|
+
tar -cJf MacOSX11.1.sdk.tar.xz MacOSX11.1.sdk
|
18
|
+
|
19
|
+
set +x
|
20
|
+
cd /opt/osxcross
|
21
|
+
set -x
|
22
|
+
UNATTENDED=1 SDK_VERSION=11.1 OSX_VERSION_MIN=10.13 USE_CLANG_AS=1 ./build.sh
|
23
|
+
ln -s /usr/bin/llvm-config-10 /usr/bin/llvm-config
|
24
|
+
ENABLE_COMPILER_RT_INSTALL=1 SDK_VERSION=11.1 ./build_compiler_rt.sh
|
25
|
+
rm -rf *~ build tarballs/*
|
26
|
+
|
27
|
+
echo "export PATH=/opt/osxcross/target/bin:\$PATH" >> /etc/rubybashrc
|
28
|
+
echo "export MACOSX_DEPLOYMENT_TARGET=10.13" >> /etc/rubybashrc
|
29
|
+
echo "export OSXCROSS_MP_INC=1" >> /etc/rubybashrc
|
30
|
+
|
31
|
+
# Add links to build tools without target version kind of:
|
32
|
+
# arm64-apple-darwin-clang => arm64-apple-darwin20.1-clang
|
33
|
+
rm -f /opt/osxcross/target/bin/*-apple-darwin-*
|
34
|
+
find /opt/osxcross/target/bin/ -name '*-apple-darwin[0-9]*' | sort | while read f ; do d=`echo $f | sed s/darwin[0-9\.]*/darwin/`; echo $f '"$@"' | tee $d && chmod +x $d ; done
|
35
|
+
|
36
|
+
# There's no objdump in osxcross but we can use llvm's
|
37
|
+
ln -s /usr/lib/llvm-10/bin/llvm-objdump /opt/osxcross/target/bin/x86_64-apple-darwin-objdump
|
38
|
+
ln -s /usr/lib/llvm-10/bin/llvm-objdump /opt/osxcross/target/bin/aarch64-apple-darwin-objdump
|
@@ -2,15 +2,28 @@ require "fileutils"
|
|
2
2
|
require "rake"
|
3
3
|
|
4
4
|
module RakeCompilerDock
|
5
|
+
class << self
|
6
|
+
def docker_build_cmd(platform=nil)
|
7
|
+
cmd = if ENV['RCD_USE_BUILDX_CACHE']
|
8
|
+
if platform
|
9
|
+
cache_version = RakeCompilerDock::IMAGE_VERSION.split(".").take(2).join(".")
|
10
|
+
cache = File.join("cache", cache_version, platform)
|
11
|
+
"docker buildx build --cache-to=type=local,dest=#{cache},mode=max --cache-from=type=local,src=#{cache} --load"
|
12
|
+
else
|
13
|
+
return nil
|
14
|
+
end
|
15
|
+
else
|
16
|
+
ENV['RCD_DOCKER_BUILD'] || "docker build"
|
17
|
+
end
|
18
|
+
Shellwords.split(cmd)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
5
22
|
# Run docker builds in parallel, but ensure that common docker layers are reused
|
6
23
|
class ParallelDockerBuild
|
7
24
|
include Rake::DSL
|
8
25
|
|
9
|
-
|
10
|
-
|
11
|
-
def initialize(dockerfiles, workdir: "tmp/docker", inputdir: ".", task_prefix: "common-",
|
12
|
-
docker_build_cmd: %w["docker", "build"])
|
13
|
-
@docker_build_cmd = docker_build_cmd
|
26
|
+
def initialize(dockerfiles, workdir: "tmp/docker", inputdir: ".", task_prefix: "common-")
|
14
27
|
FileUtils.mkdir_p(workdir)
|
15
28
|
|
16
29
|
files = parse_dockerfiles(dockerfiles, inputdir)
|
@@ -100,7 +113,9 @@ module RakeCompilerDock
|
|
100
113
|
#
|
101
114
|
# The layers will be reused in subsequent builds, even if they run in parallel.
|
102
115
|
def docker_build(filename, workdir)
|
103
|
-
|
116
|
+
cmd = RakeCompilerDock.docker_build_cmd
|
117
|
+
return if cmd.nil?
|
118
|
+
sh(*RakeCompilerDock.docker_build_cmd, "-f", File.join(workdir, filename), ".")
|
104
119
|
end
|
105
120
|
end
|
106
121
|
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
fix(temp): rake-compiler explicitly builds miniruby first
|
2
|
+
|
3
|
+
See https://bugs.ruby-lang.org/issues/19239 for the upstream bug
|
4
|
+
report.
|
5
|
+
|
6
|
+
TODO: This patch can be removed if that's fixed in a 3.2.0 final release.
|
7
|
+
|
8
|
+
diff --git a/tasks/bin/cross-ruby.rake b/tasks/bin/cross-ruby.rake
|
9
|
+
index 8317a2a..d9bfe4c 100644
|
10
|
+
--- a/tasks/bin/cross-ruby.rake
|
11
|
+
+++ b/tasks/bin/cross-ruby.rake
|
12
|
+
@@ -129,6 +129,7 @@
|
13
|
+
|
14
|
+
# make
|
15
|
+
file "#{build_dir}/ruby.exe" => ["#{build_dir}/Makefile"] do |t|
|
16
|
+
+ sh "#{MAKE} miniruby", chdir: File.dirname(t.prerequisites.first)
|
17
|
+
sh MAKE, chdir: File.dirname(t.prerequisites.first)
|
18
|
+
end
|
19
|
+
|
@@ -40,17 +40,9 @@ module RakeCompilerDock
|
|
40
40
|
end
|
41
41
|
user = options.fetch(:username){ current_user }
|
42
42
|
group = options.fetch(:groupname){ current_group }
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
platforms = options.fetch(:platform){ ENV['RCD_PLATFORM'] } || (jrubyvm ? "jruby" : "x86-mingw32 x64-mingw32")
|
47
|
-
platforms.split(" ").each do |platform|
|
48
|
-
image_name = options.fetch(:image) do
|
49
|
-
platform_postfix = jrubyvm ? "" : "-#{platform}"
|
50
|
-
ENV['RCD_IMAGE'] ||
|
51
|
-
ENV['RAKE_COMPILER_DOCK_IMAGE'] ||
|
52
|
-
"larskanis/rake-compiler-dock-#{rubyvm}#{platform_postfix}:#{IMAGE_VERSION}"
|
53
|
-
end
|
43
|
+
|
44
|
+
platforms(options).split(" ").each do |platform|
|
45
|
+
image_name = container_image_name(options.merge(platform: platform))
|
54
46
|
|
55
47
|
check = check_docker(mountdir) if options.fetch(:check_docker){ true }
|
56
48
|
docker_opts = options.fetch(:options) do
|
@@ -166,6 +158,38 @@ module RakeCompilerDock
|
|
166
158
|
def sanitize_windows_path(path)
|
167
159
|
path.gsub(/^([a-z]):/i){ "/#{$1.downcase}" }
|
168
160
|
end
|
161
|
+
|
162
|
+
def container_image_name(options={})
|
163
|
+
options.fetch(:image) do
|
164
|
+
image_name = ENV['RCD_IMAGE'] || ENV['RAKE_COMPILER_DOCK_IMAGE']
|
165
|
+
return image_name unless image_name.nil?
|
166
|
+
|
167
|
+
"%s/rake-compiler-dock-image:%s-%s%s" % [
|
168
|
+
container_registry,
|
169
|
+
options.fetch(:version) { IMAGE_VERSION },
|
170
|
+
container_rubyvm(options),
|
171
|
+
container_jrubyvm?(options) ? "" : "-#{options.fetch(:platform)}",
|
172
|
+
]
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def container_registry
|
177
|
+
ENV['CONTAINER_REGISTRY'] || "ghcr.io/rake-compiler"
|
178
|
+
end
|
179
|
+
|
180
|
+
def container_rubyvm(options={})
|
181
|
+
return "jruby" if options[:platform] == "jruby"
|
182
|
+
options.fetch(:rubyvm) { ENV['RCD_RUBYVM'] } || "mri"
|
183
|
+
end
|
184
|
+
|
185
|
+
def container_jrubyvm?(options={})
|
186
|
+
container_rubyvm(options).to_s == "jruby"
|
187
|
+
end
|
188
|
+
|
189
|
+
def platforms(options={})
|
190
|
+
options.fetch(:platform) { ENV['RCD_PLATFORM'] } ||
|
191
|
+
(container_jrubyvm?(options) ? "jruby" : "x86-mingw32 x64-mingw32")
|
192
|
+
end
|
169
193
|
end
|
170
194
|
end
|
171
195
|
end
|
data/test/env/Dockerfile.centos
CHANGED
data/test/rcd_test/Gemfile
CHANGED