Skip to content

Commit 67cad94

Browse files
authored
Merge pull request #83 from rake-compiler/flavorjones-update-rubygems-and-gems
update rubygems and gems, and general cleanup
2 parents 145266e + c60da99 commit 67cad94

File tree

6 files changed

+109
-95
lines changed

6 files changed

+109
-95
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/Dockerfile.mri.arm-linux
55
/Dockerfile.mri.arm64-darwin
66
/Dockerfile.mri.arm64-linux
7+
/Dockerfile.mri.x64-mingw-ucrt
78
/Dockerfile.mri.x64-mingw32
89
/Dockerfile.mri.x86-linux
910
/Dockerfile.mri.x86-mingw32

Dockerfile.mri.erb

Lines changed: 68 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ manylinux = !!(image =~ /manylinux/)
88
%>
99
FROM <%= image %>
1010

11+
##
12+
## RVM and native rubies
13+
##
14+
# Install packages which rvm will require
1115
<% if manylinux %>
12-
# install packages which rvm will require
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
1417

1518
# Prepare sudo and delete sudo as alias to gosu
1619
RUN rm -f /usr/local/bin/sudo && \
@@ -19,7 +22,7 @@ RUN rm -f /usr/local/bin/sudo && \
1922
<% else %>
2023
ENV DEBIAN_FRONTEND noninteractive
2124
RUN apt-get -y update && \
22-
apt-get install -y curl git-core xz-utils build-essential zlib1g-dev libreadline-dev libssl-dev wget unzip sudo gnupg2 dirmngr cmake pkg-config autoconf && \
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 && \
2326
rm -rf /var/lib/apt/lists/*
2427
<% end %>
2528

@@ -42,38 +45,31 @@ RUN mkdir ~/.gnupg && \
4245
RUN gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB && \
4346
(curl -L http://get.rvm.io | sudo bash) && \
4447
bash -c " \
45-
source /etc/rubybashrc && \
46-
rvm autolibs disable && \
47-
rvmsudo rvm cleanup all "
48+
source /etc/rubybashrc && \
49+
rvm autolibs disable && \
50+
rvmsudo rvm cleanup all \
51+
"
4852

49-
# Import patch files for ruby and gems
53+
# Install native rubies and fix permissions
5054
COPY build/patches /home/rvm/patches/
51-
52-
# install rubies and fix permissions on
5355
ENV RVM_RUBIES 2.5.9 3.1.0
5456
RUN bash -c " \
55-
export CFLAGS='-s -O3 -fno-fast-math -fPIC' && \
56-
for v in ${RVM_RUBIES} ; do \
57+
export CFLAGS='-s -O3 -fno-fast-math -fPIC' && \
58+
for v in ${RVM_RUBIES} ; do \
5759
rvm install \$v --patch \$(echo ~/patches/ruby-\$v/* | tr ' ' ','); \
58-
done && \
59-
rvm cleanup all && \
60-
find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
61-
62-
# Install rake-compiler and typical gems in all Rubies
63-
# do not generate documentation for gems
64-
# TODO: stop pinning rubygems to 3.3.20 once https://github.com/rake-compiler/rake-compiler/pull/209 is merged
65-
RUN echo "gem: --no-ri --no-rdoc" >> ~/.gemrc && \
66-
bash -c " \
67-
rvm all do gem update --system=3.3.20 --no-document && \
68-
rvm all do gem install --no-document bundler 'bundler:~>1.16' 'rake-compiler:1.1.6' hoe mini_portile rubygems-tasks mini_portile2 && \
69-
find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
70-
71-
# Install rake-compiler's cross rubies in global dir instead of /root
72-
RUN sudo mkdir -p /usr/local/rake-compiler && \
73-
sudo chown rvm.rvm /usr/local/rake-compiler && \
74-
ln -s /usr/local/rake-compiler ~/.rake-compiler
60+
done && \
61+
rvm cleanup all \
62+
"
7563

76-
# Add cross compilers for Windows and Linux
64+
RUN bash -c " \
65+
rvm all do gem update --system --no-document && \
66+
rvm all do gem update --no-document && \
67+
rvm all do gem install bundler --no-document \
68+
"
69+
70+
##
71+
## Cross compilers
72+
##
7773
USER root
7874

7975
<% if platform=~/x64-mingw-ucrt/ %>
@@ -98,77 +94,46 @@ if platform=~/x64-mingw32/ %> gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 <% end
9894
rm -rf /var/lib/apt/lists/*
9995
<% end %>
10096

101-
RUN bash -c " \
102-
rvm alias create default 3.1.0 && \
103-
rvm use default "
104-
10597
<% if manylinux %>
10698
# Create dev tools x86-linux-*
10799
COPY build/mk_i686.rb /root/
108-
RUN bash -c " \
109-
ruby /root/mk_i686.rb "
100+
RUN /root/mk_i686.rb
110101
<% end %>
111102

112103
<% if platform=~/darwin/ %>
113-
RUN git clone -q --depth=1 https://github.com/tpoechtrager/osxcross.git /opt/osxcross && rm -rf /opt/osxcross/.git && \
114-
cd /opt/osxcross/tarballs && \
115-
curl -L -o MacOSX11.1.sdk.tar.xz https://github.com/larskanis/MacOSX-SDKs/releases/download/11.1/MacOSX11.1.sdk.tar.xz && \
116-
tar -xf MacOSX11.1.sdk.tar.xz -C . && \
117-
cp -rf /usr/lib/llvm-10/include/c++ MacOSX11.1.sdk/usr/include/c++ && \
118-
cp -rf /usr/include/x86_64-linux-gnu/c++/9/bits/ MacOSX11.1.sdk/usr/include/c++/v1/bits && \
119-
tar -cJf MacOSX11.1.sdk.tar.xz MacOSX11.1.sdk && \
120-
cd /opt/osxcross && \
121-
UNATTENDED=1 SDK_VERSION=11.1 OSX_VERSION_MIN=10.13 USE_CLANG_AS=1 ./build.sh && \
122-
ln -s /usr/bin/llvm-config-10 /usr/bin/llvm-config && \
123-
ENABLE_COMPILER_RT_INSTALL=1 SDK_VERSION=11.1 ./build_compiler_rt.sh && \
124-
rm -rf *~ build tarballs/*
125-
126-
RUN echo "export PATH=/opt/osxcross/target/bin:\$PATH" >> /etc/rubybashrc && \
127-
echo "export MACOSX_DEPLOYMENT_TARGET=10.13" >> /etc/rubybashrc && \
128-
echo "export OSXCROSS_MP_INC=1" >> /etc/rubybashrc
129-
130-
# Add links to build tools without target version kind of:
131-
# arm64-apple-darwin-clang => arm64-apple-darwin20.1-clang
132-
RUN rm /opt/osxcross/target/bin/*-apple-darwin-* ; \
133-
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
134-
135-
# There's no objdump in osxcross but we can use llvm's
136-
RUN ln -s /usr/lib/llvm-10/bin/llvm-objdump /opt/osxcross/target/bin/x86_64-apple-darwin-objdump && \
137-
ln -s /usr/lib/llvm-10/bin/llvm-objdump /opt/osxcross/target/bin/aarch64-apple-darwin-objdump
138-
104+
COPY build/mk_osxcross.sh /home/rvm
105+
RUN /home/rvm/mk_osxcross.sh
139106
<% end %>
140107

141-
# Patch rake-compiler to build and install static libraries for Linux rubies
108+
109+
##
110+
## Cross-compile rubies
111+
##
142112
USER rvm
113+
114+
RUN bash -c "rvm all do gem install --no-document rake-compiler:1.2.1"
115+
116+
# Install rake-compiler's cross rubies in global dir instead of /root
117+
RUN sudo mkdir -p /usr/local/rake-compiler && \
118+
sudo chown rvm.rvm /usr/local/rake-compiler && \
119+
ln -s /usr/local/rake-compiler ~/.rake-compiler
120+
121+
# Patch rake-compiler to build and install static libraries for Linux rubies
143122
COPY build/patches2 /home/rvm/patches/
144123
RUN bash -c " \
145-
for v in ${RVM_RUBIES} ; do \
146-
cd /usr/local/rvm/gems/ruby-\$v/gems/rake-compiler-1.1.6 && \
147-
echo applying patches to ruby-\$v /home/rvm/patches/rake-compiler-1.1.6/*.patch && \
148-
( git apply /home/rvm/patches/rake-compiler-1.1.6/*.patch || true ) \
149-
done "
150-
151-
# Patch rubies for cross build
152-
#USER root
153-
#RUN bash -c " \
154-
# for v in 2.7.0 3.0.0 3.1.0 ; do \
155-
# curl -SL http://cache.ruby-lang.org/pub/ruby/\${v:0:3}/ruby-\$v.tar.xz | tar -xJC /root/ && \
156-
# cd /root/ruby-\$v && \
157-
# git apply /home/rvm/patches/ruby-\$v/*.patch && \
158-
# cd .. && \
159-
# mkdir -p /usr/local/rake-compiler/sources/ && \
160-
# tar cjf /usr/local/rake-compiler/sources/ruby-\$v.tar.bz2 ruby-\$v && \
161-
# chown rvm /usr/local/rake-compiler -R && \
162-
# rm -rf /root/ruby-\$v ; \
163-
# done "
164-
#USER rvm
124+
for v in ${RVM_RUBIES} ; do \
125+
cd /usr/local/rvm/gems/ruby-\$v/gems/rake-compiler-1.2.1 && \
126+
echo applying patches to ruby-\$v /home/rvm/patches/rake-compiler-1.2.1/*.patch && \
127+
( git apply /home/rvm/patches/rake-compiler-1.2.1/*.patch || true ) \
128+
done \
129+
"
165130

166131
<%
167132
axrubies = if platform =~ /x64-mingw-ucrt/
168133
[
169134
# Rubyinstaller-3.1.0+ is platform x64-mingw-ucrt
170-
["3.2.0-rc1", "3.1.0", true],
171-
["3.1.0", "3.1.0", true],
135+
# parallel=false because 3.2.0-rc1 has undefined references when using a high -j arg
136+
["3.2.0-rc1:3.1.0", "3.1.0", false],
172137
]
173138
elsif platform =~ /x64-mingw32/
174139
[
@@ -192,16 +157,16 @@ ENV XRUBIES <%= xrubies %>
192157
# Build xruby versions in parallel
193158
# Then cleanup all build artifacts
194159
RUN bash -c " \
195-
rvm use <%= rvm %> && \
196-
export CPPFLAGS='<%= "-D__USE_MINGW_ANSI_STDIO=1" if platform=~/x64-mingw-ucrt/ %>' && \
197-
export CFLAGS='-O1 -fno-omit-frame-pointer -fno-fast-math -fstack-protector-strong <%= strip %>' && \
198-
export LDFLAGS='-pipe <%= strip %>' && \
199-
<%= "export LIBS='-l:libssp.a' &&" if platform =~ /mingw/ %> \
200-
<%= "export CC=#{target}-clang &&" if platform =~ /darwin/ %> \
201-
export MAKE='make V=1 <%= "-j`nproc`" if parallel %>' && \
202-
rake-compiler cross-ruby VERSION=$XRUBIES HOST=<%= target %> && \
203-
rm -rf ~/.rake-compiler/builds ~/.rake-compiler/sources && \
204-
find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
160+
rvm use <%= rvm %> && \
161+
export CPPFLAGS='<%= "-D__USE_MINGW_ANSI_STDIO=1" if platform=~/x64-mingw-ucrt/ %>' && \
162+
export CFLAGS='-O1 -fno-omit-frame-pointer -fno-fast-math -fstack-protector-strong <%= strip %>' && \
163+
export LDFLAGS='-pipe <%= strip %>' && \
164+
<%= "export LIBS='-l:libssp.a' &&" if platform =~ /mingw/ %> \
165+
<%= "export CC=#{target}-clang &&" if platform =~ /darwin/ %> \
166+
export MAKE='make V=1 <%= "-j`nproc`" if parallel %>' && \
167+
rake-compiler cross-ruby VERSION=$XRUBIES HOST=<%= target %> && \
168+
rm -rf ~/.rake-compiler/builds ~/.rake-compiler/sources \
169+
"
205170
<% end %>
206171

207172
<% if platform=~/linux/ %>
@@ -222,12 +187,14 @@ RUN find /usr/local/rake-compiler/ruby -name rbconfig.rb | while read f ; do sed
222187
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
223188
<% end %>
224189

190+
##
191+
## Final adjustments
192+
##
225193
USER root
226194

227195
# Fix paths in rake-compiler/config.yml
228196
RUN sed -i -- "s:/root/.rake-compiler:/usr/local/rake-compiler:g" /usr/local/rake-compiler/config.yml
229197

230-
231198
<% if platform=~/mingw/ %>
232199
# Install wrappers for strip commands as a workaround for "Protocol error" in boot2docker.
233200
COPY build/strip_wrapper /root/
@@ -274,6 +241,12 @@ RUN echo "source /etc/profile.d/rcd-env.sh" >> /etc/rubybashrc
274241
# Install sudoers configuration
275242
COPY build/sudoers /etc/sudoers.d/rake-compiler-dock
276243

244+
RUN find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw
245+
RUN bash -c " \
246+
rvm alias create default 3.1.0 && \
247+
rvm use default \
248+
"
249+
277250
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
278251

279252
CMD bash

build/mk_i686.rb

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#! /usr/bin/env ruby
2+
13
require "fileutils"
24

35
Dir["/usr/bin/x86_64-linux-gnu-*"].each do |file|

build/mk_osxcross.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)