rake-compiler-dock 0.7.2 → 1.2.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
- checksums.yaml.gz.sig +4 -0
- data/.github/workflows/ci.yml +168 -0
- data/.gitignore +14 -0
- data/Dockerfile.jruby +12 -7
- data/Dockerfile.mri.erb +271 -0
- data/History.md +63 -0
- data/README.md +138 -27
- data/Rakefile +71 -4
- data/{lib/rake_compiler_dock → build}/gem_helper.rb +0 -15
- data/build/parallel_docker_build.rb +106 -0
- data/build/patches/{ruby-2.5.3 → ruby-2.5.9}/no_sendfile.patch +1 -1
- data/build/patches/ruby-3.1.0/no_sendfile.patch +24 -0
- data/build/patches2/rake-compiler-1.1.6/0004-Enable-build-of-static-libruby.patch +28 -0
- data/build/rcd-env.sh +6 -0
- data/build/runas +1 -6
- data/build/sudoers +1 -1
- data/lib/rake_compiler_dock/docker_check.rb +12 -6
- data/lib/rake_compiler_dock/starter.rb +69 -53
- data/lib/rake_compiler_dock/version.rb +2 -2
- data/lib/rake_compiler_dock.rb +10 -0
- data/mingw64-ucrt/Dockerfile +62 -0
- data/mingw64-ucrt/binutils-mingw-w64-ignore-check-errors.patch +13 -0
- data/mingw64-ucrt/gcc-mingw-w64-only-c-c++.patch +13 -0
- data/mingw64-ucrt/mingw-w64-enable-ucrt.patch +22 -0
- data/rake-compiler-dock.gemspec +2 -2
- data/test/env/Dockerfile.alpine +17 -0
- data/test/env/Dockerfile.centos +17 -0
- data/test/env/Dockerfile.debian +24 -0
- data/test/rcd_test/Gemfile +11 -0
- data/test/rcd_test/Rakefile +74 -0
- data/test/rcd_test/ext/java/RcdTestExtService.java +19 -0
- data/test/rcd_test/ext/java/RubyRcdTest.java +16 -0
- data/test/rcd_test/ext/mri/extconf.rb +20 -0
- data/test/rcd_test/ext/mri/rcd_test_ext.c +35 -0
- data/test/rcd_test/ext/mri/rcd_test_ext.h +6 -0
- data/test/rcd_test/lib/rcd_test.rb +6 -0
- data/test/rcd_test/rcd_test.gemspec +27 -0
- data/test/rcd_test/test/test_basic.rb +22 -0
- data/test/test_environment_variables.rb +56 -31
- data/test/test_parallel_docker_build.rb +70 -0
- data.tar.gz.sig +1 -0
- metadata +83 -14
- metadata.gz.sig +0 -0
- data/Dockerfile.mri +0 -122
- data/build/patches/rake-compiler-1.0.7/enable-static.diff +0 -13
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require "shellwords"
|
|
2
2
|
require "etc"
|
|
3
|
+
require "io/console"
|
|
3
4
|
require "rake_compiler_dock/version"
|
|
4
5
|
|
|
5
6
|
module RakeCompilerDock
|
|
@@ -9,15 +10,15 @@ module RakeCompilerDock
|
|
|
9
10
|
class Starter
|
|
10
11
|
class << self
|
|
11
12
|
def sh(cmd, options={}, &block)
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
begin
|
|
14
|
+
exec('bash', '-c', cmd, options, &block)
|
|
15
|
+
ensure
|
|
16
|
+
STDIN.cooked! if STDIN.tty?
|
|
14
17
|
end
|
|
15
|
-
exec('bash', '-c', cmd, options, &block)
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
def exec(*args)
|
|
19
21
|
options = (Hash === args.last) ? args.pop : {}
|
|
20
|
-
runargs = args.dup
|
|
21
22
|
|
|
22
23
|
mountdir = options.fetch(:mountdir){ ENV['RCD_MOUNTDIR'] || Dir.pwd }
|
|
23
24
|
workdir = options.fetch(:workdir){ ENV['RCD_WORKDIR'] || Dir.pwd }
|
|
@@ -40,49 +41,62 @@ module RakeCompilerDock
|
|
|
40
41
|
user = options.fetch(:username){ current_user }
|
|
41
42
|
group = options.fetch(:groupname){ current_group }
|
|
42
43
|
rubyvm = options.fetch(:rubyvm){ ENV['RCD_RUBYVM'] } || "mri"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
jrubyvm = rubyvm.to_s == "jruby"
|
|
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
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
opts
|
|
56
|
-
end
|
|
55
|
+
check = check_docker(mountdir) if options.fetch(:check_docker){ true }
|
|
56
|
+
docker_opts = options.fetch(:options) do
|
|
57
|
+
opts = ["--rm", "-i"]
|
|
58
|
+
opts << "-t" if $stdin.tty?
|
|
59
|
+
opts
|
|
60
|
+
end
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
"-
|
|
60
|
-
|
|
61
|
-
"-e", "GID=#{gid}",
|
|
62
|
-
"-e", "USER=#{user}",
|
|
63
|
-
"-e", "GROUP=#{group}",
|
|
64
|
-
"-e", "ftp_proxy=#{ENV['ftp_proxy']}",
|
|
65
|
-
"-e", "http_proxy=#{ENV['http_proxy']}",
|
|
66
|
-
"-e", "https_proxy=#{ENV['https_proxy']}",
|
|
67
|
-
"-e", "RCD_HOST_RUBY_PLATFORM=#{RUBY_PLATFORM}",
|
|
68
|
-
"-e", "RCD_HOST_RUBY_VERSION=#{RUBY_VERSION}",
|
|
69
|
-
"-e", "RCD_IMAGE=#{image_name}",
|
|
70
|
-
"-w", make_valid_path(workdir),
|
|
71
|
-
*docker_opts,
|
|
72
|
-
image_name,
|
|
73
|
-
*runargs]
|
|
74
|
-
|
|
75
|
-
cmdline = Shellwords.join(cmd)
|
|
76
|
-
if verbose_flag(options) == true
|
|
77
|
-
$stderr.puts cmdline
|
|
78
|
-
end
|
|
62
|
+
if verbose_flag(options) && args.size == 3 && args[0] == "bash" && args[1] == "-c"
|
|
63
|
+
$stderr.puts "rake-compiler-dock bash -c #{ args[2].inspect }"
|
|
64
|
+
end
|
|
79
65
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
runargs = args.dup
|
|
67
|
+
runargs.unshift("sigfw") if options.fetch(:sigfw){ true }
|
|
68
|
+
runargs.unshift("runas") if options.fetch(:runas){ true }
|
|
69
|
+
|
|
70
|
+
cmd = [check.docker_command, "run",
|
|
71
|
+
"-v", "#{mountdir}:#{make_valid_path(mountdir)}",
|
|
72
|
+
"-e", "UID=#{uid}",
|
|
73
|
+
"-e", "GID=#{gid}",
|
|
74
|
+
"-e", "USER=#{user}",
|
|
75
|
+
"-e", "GROUP=#{group}",
|
|
76
|
+
"-e", "GEM_PRIVATE_KEY_PASSPHRASE",
|
|
77
|
+
"-e", "ftp_proxy",
|
|
78
|
+
"-e", "http_proxy",
|
|
79
|
+
"-e", "https_proxy",
|
|
80
|
+
"-e", "RCD_HOST_RUBY_PLATFORM=#{RUBY_PLATFORM}",
|
|
81
|
+
"-e", "RCD_HOST_RUBY_VERSION=#{RUBY_VERSION}",
|
|
82
|
+
"-e", "RCD_IMAGE=#{image_name}",
|
|
83
|
+
"-w", make_valid_path(workdir),
|
|
84
|
+
*docker_opts,
|
|
85
|
+
image_name,
|
|
86
|
+
*runargs]
|
|
87
|
+
|
|
88
|
+
cmdline = Shellwords.join(cmd)
|
|
89
|
+
if verbose_flag(options) == true
|
|
90
|
+
$stderr.puts cmdline
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
ok = system(*cmd)
|
|
94
|
+
if block_given?
|
|
95
|
+
yield(ok, $?)
|
|
96
|
+
elsif !ok
|
|
97
|
+
fail "Command failed with status (#{$?.exitstatus}): " +
|
|
98
|
+
"[#{cmdline}]"
|
|
99
|
+
end
|
|
86
100
|
end
|
|
87
101
|
end
|
|
88
102
|
|
|
@@ -130,20 +144,22 @@ module RakeCompilerDock
|
|
|
130
144
|
name = name.gsub(/[ ]/i, "_")
|
|
131
145
|
end
|
|
132
146
|
|
|
147
|
+
@@docker_checked_lock = Mutex.new
|
|
133
148
|
@@docker_checked = {}
|
|
134
149
|
|
|
135
150
|
def check_docker(pwd)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
151
|
+
@@docker_checked_lock.synchronize do
|
|
152
|
+
@@docker_checked[pwd] ||= begin
|
|
153
|
+
check = DockerCheck.new($stderr, pwd)
|
|
154
|
+
unless check.ok?
|
|
155
|
+
at_exit do
|
|
156
|
+
check.print_help_text
|
|
157
|
+
end
|
|
158
|
+
raise DockerIsNotAvailable, "Docker is not available"
|
|
159
|
+
end
|
|
160
|
+
check
|
|
142
161
|
end
|
|
143
|
-
raise DockerIsNotAvailable, "Docker is not available"
|
|
144
162
|
end
|
|
145
|
-
|
|
146
|
-
@@docker_checked[pwd] = check
|
|
147
163
|
end
|
|
148
164
|
|
|
149
165
|
# Change Path from "C:\Path" to "/c/Path" as used by boot2docker
|
data/lib/rake_compiler_dock.rb
CHANGED
|
@@ -21,6 +21,16 @@ module RakeCompilerDock
|
|
|
21
21
|
# Option +:verbose+ can be set to enable printing of the command line.
|
|
22
22
|
# If not set, rake's verbose flag is used.
|
|
23
23
|
#
|
|
24
|
+
# Option +:rubyvm+ can be set to +:mri+ or +:jruby+ .
|
|
25
|
+
# It selects the docker image with an appropriate toolchain.
|
|
26
|
+
#
|
|
27
|
+
# Option +:platform+ can be set to a list of space separated values.
|
|
28
|
+
# It selects the docker image(s) with an appropriate toolchain.
|
|
29
|
+
# Allowed values are +:x86-mingw32+, +x64-mingw32+, +x86-linux+ or +x86_64-linux+.
|
|
30
|
+
# If the list contains multiple values, +cmd+ is consecutively executed in each of the docker images,
|
|
31
|
+
# Option +:platform+ is ignored when +:rubyvm+ is set to +:jruby+.
|
|
32
|
+
# Default is "x86-mingw32 x64-mingw32" .
|
|
33
|
+
#
|
|
24
34
|
# Examples:
|
|
25
35
|
#
|
|
26
36
|
# RakeCompilerDock.sh 'bundle && rake cross native gem'
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
FROM ubuntu:20.04
|
|
2
|
+
|
|
3
|
+
ARG DEBIAN_FRONTEND=noninteractive
|
|
4
|
+
|
|
5
|
+
RUN set -ex \
|
|
6
|
+
&& sed -i -- 's/# deb-src/deb-src/g' /etc/apt/sources.list \
|
|
7
|
+
&& apt-get update \
|
|
8
|
+
&& apt-get install -y --no-install-recommends \
|
|
9
|
+
build-essential \
|
|
10
|
+
cdbs \
|
|
11
|
+
devscripts \
|
|
12
|
+
equivs \
|
|
13
|
+
fakeroot \
|
|
14
|
+
pkg-config \
|
|
15
|
+
&& apt-get clean \
|
|
16
|
+
&& rm -rf /tmp/* /var/tmp/*
|
|
17
|
+
|
|
18
|
+
WORKDIR /build
|
|
19
|
+
|
|
20
|
+
# Download mingw sources
|
|
21
|
+
RUN apt-get source mingw-w64-common && \
|
|
22
|
+
cd mingw-w64-* && \
|
|
23
|
+
mk-build-deps -ir -t "apt-get -o Debug::pkgProblemResolver=yes -y --no-install-recommends"
|
|
24
|
+
|
|
25
|
+
# Patch build for UCRT and build UCRT enabled deb-packages
|
|
26
|
+
ADD mingw-w64-*.patch ./
|
|
27
|
+
RUN cd mingw-w64-* && \
|
|
28
|
+
cat debian/rules && \
|
|
29
|
+
ls ../mingw-w64-*.patch | xargs -n1 patch --verbose -p1 -i && \
|
|
30
|
+
dpkg-buildpackage -b && \
|
|
31
|
+
rm -rf ../*.ddeb ../*i686* `pwd`
|
|
32
|
+
|
|
33
|
+
# Install UCRT enabled deb-packages
|
|
34
|
+
RUN dpkg -i mingw-w64-common_7.0.0-2_all.deb \
|
|
35
|
+
mingw-w64-tools_7.0.0-2_amd64.deb \
|
|
36
|
+
mingw-w64-x86-64-dev_7.0.0-2_all.deb
|
|
37
|
+
|
|
38
|
+
# Download gcc-binutils sources for mingw
|
|
39
|
+
RUN apt-get source binutils-mingw-w64 && \
|
|
40
|
+
cd binutils-mingw-w64-* && \
|
|
41
|
+
mk-build-deps -ir -t "apt-get -o Debug::pkgProblemResolver=yes -y --no-install-recommends"
|
|
42
|
+
|
|
43
|
+
# Build gcc-binutils based on UCRT headers and crt
|
|
44
|
+
ADD binutils-mingw-w64-*.patch ./
|
|
45
|
+
RUN cd binutils-mingw-w64-* && \
|
|
46
|
+
ls ../binutils-mingw-w64-*.patch | xargs -n1 patch --verbose -p1 -i && \
|
|
47
|
+
dpkg-buildpackage -b --jobs=auto && \
|
|
48
|
+
rm -rf ../*.ddeb ../*i686* `pwd`
|
|
49
|
+
|
|
50
|
+
# Download gcc sources for mingw
|
|
51
|
+
RUN apt-get source gcc-mingw-w64 && \
|
|
52
|
+
cd gcc-mingw-w64-* && \
|
|
53
|
+
mk-build-deps -ir -t "apt-get -o Debug::pkgProblemResolver=yes -y --no-install-recommends"
|
|
54
|
+
|
|
55
|
+
# Build gcc (only C and C++) based on UCRT headers and crt
|
|
56
|
+
ADD gcc-mingw-w64-*.patch ./
|
|
57
|
+
RUN cd gcc-mingw-w64-* && \
|
|
58
|
+
ls ../gcc-mingw-w64-*.patch | xargs -n1 patch --verbose -p1 -i && \
|
|
59
|
+
dpkg-buildpackage -b --jobs=auto && \
|
|
60
|
+
rm -rf ../*.ddeb ../*i686* `pwd`
|
|
61
|
+
|
|
62
|
+
RUN ls -l *.deb
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
diff --git a/debian/rules b/debian/rules
|
|
2
|
+
index 4401493..62c8fe4 100755
|
|
3
|
+
--- a/debian/rules
|
|
4
|
+
+++ b/debian/rules
|
|
5
|
+
@@ -91,7 +91,7 @@ override_dh_auto_test-arch:
|
|
6
|
+
unset CFLAGS CPPFLAGS LDFLAGS; \
|
|
7
|
+
env > $(build_dir)/env; \
|
|
8
|
+
for target in $(targets); do \
|
|
9
|
+
- dh_auto_test -B$(build_dir)/$$target; \
|
|
10
|
+
+ dh_auto_test -B$(build_dir)/$$target || true; \
|
|
11
|
+
done
|
|
12
|
+
|
|
13
|
+
override_dh_auto_install-arch:
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
diff --git a/debian/rules b/debian/rules
|
|
2
|
+
index 9e7e40c..fa9a8a2 100755
|
|
3
|
+
--- a/debian/rules
|
|
4
|
+
+++ b/debian/rules
|
|
5
|
+
@@ -58,7 +58,7 @@ ifneq ($(filter stage1,$(DEB_BUILD_PROFILES)),)
|
|
6
|
+
INSTALL_TARGET := install-gcc
|
|
7
|
+
else
|
|
8
|
+
# Build the full GCC.
|
|
9
|
+
- languages := c,c++,fortran,objc,obj-c++,ada
|
|
10
|
+
+ languages := c,c++
|
|
11
|
+
BUILD_TARGET :=
|
|
12
|
+
INSTALL_TARGET := install install-lto-plugin
|
|
13
|
+
endif
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
diff --git a/debian/rules b/debian/rules
|
|
2
|
+
index 9fb970c..5473839 100755
|
|
3
|
+
--- a/debian/rules
|
|
4
|
+
+++ b/debian/rules
|
|
5
|
+
@@ -94,7 +94,7 @@ build-arch-stamp: $(patsubst %,$(host)~$(host)~tools-%-install-stamp,$(HOST_TOOL
|
|
6
|
+
%~headers-configure-stamp: autoreconf-stamp
|
|
7
|
+
mkdir -p $(call buildfolder,$*~headers) && \
|
|
8
|
+
cd $(call buildfolder,$*~headers) && \
|
|
9
|
+
- $(call sourcefolder,$*~headers)/configure --prefix=/usr/$(call ruletarget,$*~headers) --host=$(call rulehost,$*~headers) --enable-sdk=all --enable-secure-api
|
|
10
|
+
+ $(call sourcefolder,$*~headers)/configure --prefix=/usr/$(call ruletarget,$*~headers) --host=$(call rulehost,$*~headers) --enable-sdk=all --with-default-msvcrt=ucrt
|
|
11
|
+
touch $*-headers-configure-stamp
|
|
12
|
+
|
|
13
|
+
# Override CRT configuration to avoid multilib builds
|
|
14
|
+
@@ -108,7 +108,7 @@ target64crt := $(target64)~$(target64)~crt
|
|
15
|
+
$(target64crt)-configure-stamp: $(target64)~$(target64)~headers-install-stamp autoreconf-stamp
|
|
16
|
+
mkdir -p $(call buildfolder,$(target64crt)) && \
|
|
17
|
+
cd $(call buildfolder,$(target64crt)) && \
|
|
18
|
+
- $(call sourcefolder,$(target64crt))/configure --prefix=/usr/$(call ruletarget,$(target64crt)) --host=$(call rulehost,$(target64crt)) --target=$(call ruletarget,$(target64crt)) --disable-lib32 --enable-lib64 CPPFLAGS="$(CPPFLAGS) -I$(top_dir)/debian/tmp/usr/$(call ruletarget,$(target64crt))/include"
|
|
19
|
+
+ $(call sourcefolder,$(target64crt))/configure --prefix=/usr/$(call ruletarget,$(target64crt)) --host=$(call rulehost,$(target64crt)) --target=$(call ruletarget,$(target64crt)) --disable-lib32 --enable-lib64 --with-default-msvcrt=ucrt CPPFLAGS="$(CPPFLAGS) -I$(top_dir)/debian/tmp/usr/$(call ruletarget,$(target64crt))/include"
|
|
20
|
+
touch $@
|
|
21
|
+
|
|
22
|
+
build-indep-stamp: $(foreach target,$(targets),$(patsubst %,$(target)~$(target)~%-install-stamp,$(TARGET_PROJECTS))) $(patsubst %,$(target32)~$(target32)~%-install-stamp,$(TARGET32_PROJECTS))
|
data/rake-compiler-dock.gemspec
CHANGED
|
@@ -22,7 +22,7 @@ Use rake-compiler-dock to enter an interactive shell session or add a task to yo
|
|
|
22
22
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
23
23
|
spec.require_paths = ["lib"]
|
|
24
24
|
|
|
25
|
-
spec.add_development_dependency "bundler", "
|
|
26
|
-
spec.add_development_dependency "rake", "
|
|
25
|
+
spec.add_development_dependency "bundler", ">= 1.7", "< 3.0"
|
|
26
|
+
spec.add_development_dependency "rake", ">= 12"
|
|
27
27
|
spec.add_development_dependency "test-unit", "~> 3.0"
|
|
28
28
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
ARG from_image
|
|
2
|
+
FROM ${from_image}
|
|
3
|
+
|
|
4
|
+
RUN uname -a
|
|
5
|
+
RUN apk add ruby ruby-etc ruby-rake git
|
|
6
|
+
|
|
7
|
+
RUN ruby --version
|
|
8
|
+
RUN gem env
|
|
9
|
+
RUN gem inst bundler
|
|
10
|
+
|
|
11
|
+
WORKDIR /build
|
|
12
|
+
|
|
13
|
+
CMD ruby -e "puts Gem::Platform.local.to_s" && \
|
|
14
|
+
gem install --local *.gem --verbose --no-document && \
|
|
15
|
+
cd test/rcd_test/ && \
|
|
16
|
+
bundle install && \
|
|
17
|
+
rake test
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
ARG from_image
|
|
2
|
+
FROM ${from_image}
|
|
3
|
+
|
|
4
|
+
RUN uname -a
|
|
5
|
+
RUN yum install -y ruby git
|
|
6
|
+
|
|
7
|
+
RUN ruby --version
|
|
8
|
+
RUN gem env
|
|
9
|
+
RUN gem inst bundler
|
|
10
|
+
|
|
11
|
+
WORKDIR /build
|
|
12
|
+
|
|
13
|
+
CMD ruby -e "puts Gem::Platform.local.to_s" && \
|
|
14
|
+
gem install --local *.gem --verbose --no-document && \
|
|
15
|
+
cd test/rcd_test/ && \
|
|
16
|
+
bundle install && \
|
|
17
|
+
rake test
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
ARG from_image
|
|
2
|
+
FROM ${from_image}
|
|
3
|
+
|
|
4
|
+
# To prevent installed tzdata deb package to show interactive dialog.
|
|
5
|
+
ENV DEBIAN_FRONTEND noninteractive
|
|
6
|
+
|
|
7
|
+
RUN uname -a
|
|
8
|
+
RUN apt-get update -qq && \
|
|
9
|
+
apt-get install -yq \
|
|
10
|
+
-o Dpkg::Options::='--force-confnew' \
|
|
11
|
+
ruby \
|
|
12
|
+
git
|
|
13
|
+
|
|
14
|
+
RUN ruby --version
|
|
15
|
+
RUN gem env
|
|
16
|
+
RUN gem inst bundler
|
|
17
|
+
|
|
18
|
+
WORKDIR /build
|
|
19
|
+
|
|
20
|
+
CMD ruby -e "puts Gem::Platform.local.to_s" && \
|
|
21
|
+
gem install --local *.gem --verbose --no-document && \
|
|
22
|
+
cd test/rcd_test/ && \
|
|
23
|
+
bundle install && \
|
|
24
|
+
rake test
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
require "rubygems/package_task"
|
|
3
|
+
require "rake/testtask"
|
|
4
|
+
|
|
5
|
+
rcd_test_spec = Bundler.load_gemspec("rcd_test.gemspec")
|
|
6
|
+
|
|
7
|
+
if RUBY_ENGINE == "jruby"
|
|
8
|
+
require "rake/javaextensiontask"
|
|
9
|
+
|
|
10
|
+
Rake::JavaExtensionTask.new("rcd_test_ext", rcd_test_spec) do |ext|
|
|
11
|
+
ext.ext_dir = 'ext/java'
|
|
12
|
+
ext.lib_dir = 'lib/rcd_test'
|
|
13
|
+
end
|
|
14
|
+
else
|
|
15
|
+
require "rake/extensiontask"
|
|
16
|
+
|
|
17
|
+
exttask = Rake::ExtensionTask.new('rcd_test_ext', rcd_test_spec) do |ext|
|
|
18
|
+
ext.ext_dir = 'ext/mri'
|
|
19
|
+
ext.lib_dir = 'lib/rcd_test'
|
|
20
|
+
ext.cross_compile = true
|
|
21
|
+
ext.cross_platform = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32 x86-linux x86_64-linux aarch64-linux arm-linux x86_64-darwin arm64-darwin]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
namespace "gem" do
|
|
26
|
+
if exttask
|
|
27
|
+
task 'prepare' do
|
|
28
|
+
require 'rake_compiler_dock'
|
|
29
|
+
require 'io/console'
|
|
30
|
+
sh "bundle package --all"
|
|
31
|
+
sh "mkdir -p tmp/gem"
|
|
32
|
+
sh "cp ~/.gem/gem-*.pem tmp/gem/ || true"
|
|
33
|
+
unless ENV['CI']
|
|
34
|
+
ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
exttask.cross_platform.each do |plat|
|
|
39
|
+
desc "Build all native binary gems"
|
|
40
|
+
multitask 'native' => plat
|
|
41
|
+
|
|
42
|
+
desc "Build the native gem for #{plat}"
|
|
43
|
+
task plat => 'prepare' do
|
|
44
|
+
# Set mountdir of the directory where .git resides, so that git ls-files in the gemspec works
|
|
45
|
+
RakeCompilerDock.sh <<-EOT, platform: plat, mountdir: Dir.pwd + "/../.."
|
|
46
|
+
(cp tmp/gem/gem-*.pem ~/.gem/ || true) &&
|
|
47
|
+
bundle --local &&
|
|
48
|
+
rake native:#{plat} pkg/#{exttask.gem_spec.full_name}-#{plat}.gem
|
|
49
|
+
EOT
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
desc "Build a jruby gem"
|
|
55
|
+
task "jruby" do
|
|
56
|
+
require 'rake_compiler_dock'
|
|
57
|
+
sh "bundle package --all"
|
|
58
|
+
RakeCompilerDock.sh <<-EOT, rubyvm: "jruby", platform: "jruby", mountdir: Dir.pwd + "/../.."
|
|
59
|
+
bundle --local &&
|
|
60
|
+
bundle exec rake java gem
|
|
61
|
+
EOT
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
Rake::TestTask.new(:test) do |t|
|
|
66
|
+
t.libs << "test"
|
|
67
|
+
t.libs << "lib"
|
|
68
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
task default: [:clobber, :compile, :test]
|
|
72
|
+
task gem: :build
|
|
73
|
+
|
|
74
|
+
CLEAN.add("{ext,lib}/**/*.{o,so}", "pkg", "tmp")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package rcd_test;
|
|
2
|
+
|
|
3
|
+
import org.jruby.Ruby;
|
|
4
|
+
import org.jruby.RubyClass;
|
|
5
|
+
import org.jruby.RubyModule;
|
|
6
|
+
import org.jruby.runtime.ObjectAllocator;
|
|
7
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
|
8
|
+
import org.jruby.runtime.load.BasicLibraryService;
|
|
9
|
+
|
|
10
|
+
import java.io.IOException;
|
|
11
|
+
|
|
12
|
+
public class RcdTestExtService implements BasicLibraryService {
|
|
13
|
+
@Override
|
|
14
|
+
public boolean basicLoad(final Ruby ruby) throws IOException {
|
|
15
|
+
RubyModule rb_mRcdTest = ruby.defineModule("RcdTest");
|
|
16
|
+
rb_mRcdTest.defineAnnotatedMethods(RubyRcdTest.class);
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package rcd_test;
|
|
2
|
+
|
|
3
|
+
import org.jruby.Ruby;
|
|
4
|
+
import org.jruby.anno.JRubyMethod;
|
|
5
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
|
6
|
+
import org.jruby.anno.JRubyModule;
|
|
7
|
+
import org.jruby.runtime.ThreadContext;
|
|
8
|
+
|
|
9
|
+
@JRubyModule(name = "RcdTest")
|
|
10
|
+
public class RubyRcdTest {
|
|
11
|
+
@JRubyMethod(name = "do_something", module = true, meta = true)
|
|
12
|
+
public static IRubyObject buildSelfString(ThreadContext context, IRubyObject recv) {
|
|
13
|
+
Ruby runtime = context.getRuntime();
|
|
14
|
+
return runtime.newString("something has been done");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
if RUBY_ENGINE == "jruby"
|
|
2
|
+
File.open("Makefile", "w") do |mf|
|
|
3
|
+
mf.puts "# Dummy makefile for JRuby"
|
|
4
|
+
mf.puts "all install::\n"
|
|
5
|
+
end
|
|
6
|
+
else
|
|
7
|
+
require "mkmf"
|
|
8
|
+
|
|
9
|
+
include RbConfig
|
|
10
|
+
|
|
11
|
+
puts "-"*70
|
|
12
|
+
puts "CONFIG['arch']: #{CONFIG['arch'].inspect}"
|
|
13
|
+
puts "CONFIG['sitearch']: #{CONFIG['sitearch'].inspect}"
|
|
14
|
+
puts "CONFIG['RUBY_SO_NAME']: #{CONFIG['RUBY_SO_NAME'].inspect}"
|
|
15
|
+
puts "RUBY_PLATFORM: #{RUBY_PLATFORM.inspect}"
|
|
16
|
+
puts "Gem::Platform.local.to_s: #{Gem::Platform.local.to_s.inspect}"
|
|
17
|
+
puts "-"*70
|
|
18
|
+
|
|
19
|
+
create_makefile("rcd_test/rcd_test_ext")
|
|
20
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#include "rcd_test_ext.h"
|
|
2
|
+
|
|
3
|
+
#ifndef __has_builtin
|
|
4
|
+
#define __has_builtin(x) 0
|
|
5
|
+
#endif
|
|
6
|
+
|
|
7
|
+
VALUE rb_mRcdTest;
|
|
8
|
+
|
|
9
|
+
static VALUE
|
|
10
|
+
rcdt_do_something(VALUE self)
|
|
11
|
+
{
|
|
12
|
+
return rb_str_new_cstr("something has been done");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static VALUE
|
|
16
|
+
rcdt_darwin_builtin_available_eh(VALUE self)
|
|
17
|
+
{
|
|
18
|
+
#if __has_builtin(__builtin_available)
|
|
19
|
+
// This version must be higher than MACOSX_DEPLOYMENT_TARGET to prevent clang from optimizing it away
|
|
20
|
+
if (__builtin_available(macOS 10.14, *)) {
|
|
21
|
+
return Qtrue;
|
|
22
|
+
}
|
|
23
|
+
return Qfalse;
|
|
24
|
+
#else
|
|
25
|
+
rb_raise(rb_eRuntimeError, "__builtin_available is not defined");
|
|
26
|
+
#endif
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
void
|
|
30
|
+
Init_rcd_test_ext(void)
|
|
31
|
+
{
|
|
32
|
+
rb_mRcdTest = rb_define_module("RcdTest");
|
|
33
|
+
rb_define_singleton_method(rb_mRcdTest, "do_something", rcdt_do_something, 0);
|
|
34
|
+
rb_define_singleton_method(rb_mRcdTest, "darwin_builtin_available?", rcdt_darwin_builtin_available_eh, 0);
|
|
35
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "rcd_test"
|
|
5
|
+
spec.version = "1.0.0"
|
|
6
|
+
spec.authors = ["Lars Kanis"]
|
|
7
|
+
spec.email = ["lars@greiz-reinsdorf.de"]
|
|
8
|
+
|
|
9
|
+
spec.summary = "C extension for testing rake-compiler-dock"
|
|
10
|
+
spec.description = "This gem has no real use other than testing builds of binary gems."
|
|
11
|
+
spec.homepage = "https://github.com/rake-compiler/rake-compiler-dock"
|
|
12
|
+
spec.required_ruby_version = ">= 2.0.0"
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
|
|
15
|
+
# Specify which files should be added to the gem when it is released.
|
|
16
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
17
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
|
19
|
+
end
|
|
20
|
+
spec.bindir = "exe"
|
|
21
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
22
|
+
spec.require_paths = ["lib"]
|
|
23
|
+
spec.extensions = ["ext/mri/extconf.rb"]
|
|
24
|
+
|
|
25
|
+
# Uncomment to register a new dependency of your gem
|
|
26
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
|
27
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "minitest/autorun"
|
|
4
|
+
require "rcd_test"
|
|
5
|
+
|
|
6
|
+
class TestBasic < Minitest::Test
|
|
7
|
+
|
|
8
|
+
def test_do_something
|
|
9
|
+
assert_equal "something has been done", RcdTest.do_something
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_check_darwin_compiler_rt_symbol_resolution
|
|
13
|
+
skip("jruby should not run libc-specific tests") if RUBY_ENGINE == "jruby"
|
|
14
|
+
|
|
15
|
+
if RUBY_PLATFORM.include?("darwin")
|
|
16
|
+
assert(RcdTest.darwin_builtin_available?)
|
|
17
|
+
else
|
|
18
|
+
e = assert_raises(RuntimeError) { RcdTest.darwin_builtin_available? }
|
|
19
|
+
assert_equal("__builtin_available is not defined", e.message)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|