rake-compiler-dock 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,7 +27,7 @@ namespace "gem" do
27
27
  task 'prepare' do
28
28
  require 'rake_compiler_dock'
29
29
  require 'io/console'
30
- sh "bundle package --all"
30
+ sh "bundle package"
31
31
  sh "mkdir -p tmp/gem"
32
32
  sh "cp ~/.gem/gem-*.pem tmp/gem/ || true"
33
33
  unless ENV['CI']
@@ -42,11 +42,13 @@ namespace "gem" do
42
42
  desc "Build the native gem for #{plat}"
43
43
  task plat => 'prepare' do
44
44
  config = "-- #{ENV['RCD_TEST_CONFIG']}"
45
- # Set mountdir of the directory where .git resides, so that git ls-files in the gemspec works
46
- RakeCompilerDock.sh <<-EOT, platform: plat, mountdir: Dir.pwd + "/../.."
45
+ # Set mountdir of the directory where .git resides,
46
+ # - so that git ls-files in the gemspec works
47
+ # - and to bundle the rake-compiler-dock under test
48
+ RakeCompilerDock.sh <<-EOT, platform: plat, mountdir: Dir.pwd + "/../..", verbose: true
47
49
  (cp tmp/gem/gem-*.pem ~/.gem/ || true) &&
48
50
  bundle --local &&
49
- rake native:#{plat} pkg/#{exttask.gem_spec.full_name}-#{plat}.gem #{config}
51
+ rake native:#{plat} pkg/#{exttask.gem_spec.full_name}-#{plat}.gem "MAKE=make V=1" #{config}
50
52
  EOT
51
53
  end
52
54
  end
@@ -55,8 +57,8 @@ namespace "gem" do
55
57
  desc "Build a jruby gem"
56
58
  task "jruby" do
57
59
  require 'rake_compiler_dock'
58
- sh "bundle package --all"
59
- RakeCompilerDock.sh <<-EOT, rubyvm: "jruby", platform: "jruby", mountdir: Dir.pwd + "/../.."
60
+ sh "bundle package"
61
+ RakeCompilerDock.sh <<-EOT, rubyvm: "jruby", platform: "jruby", mountdir: Dir.pwd + "/../..", verbose: true
60
62
  mvn archetype:generate -DartifactId=test -DarchetypeVersion=1.4 -DinteractiveMode=false -DgroupId=test -Dpackage=test &&
61
63
  bundle --local &&
62
64
  bundle exec rake java gem
@@ -11,9 +11,11 @@ else
11
11
  puts "-"*70
12
12
  puts "CONFIG['arch']: #{CONFIG['arch'].inspect}"
13
13
  puts "CONFIG['sitearch']: #{CONFIG['sitearch'].inspect}"
14
+ puts "CONFIG['host']: #{CONFIG['host'].inspect}"
14
15
  puts "CONFIG['RUBY_SO_NAME']: #{CONFIG['RUBY_SO_NAME'].inspect}"
15
16
  puts "RUBY_PLATFORM: #{RUBY_PLATFORM.inspect}"
16
17
  puts "Gem::Platform.local.to_s: #{Gem::Platform.local.to_s.inspect}"
18
+ puts "cc --version: #{ %x[#{CONFIG['CC']} --version].lines.first}"
17
19
  puts "-"*70
18
20
 
19
21
  have_func('rb_thread_call_without_gvl', 'ruby/thread.h') ||
@@ -23,6 +25,70 @@ else
23
25
  # https://github.com/rake-compiler/rake-compiler-dock/issues/69
24
26
  puts "Linking with '-static' flag"
25
27
  $LDFLAGS << ' -static'
28
+ else
29
+ if RbConfig::CONFIG["target_os"].include?("darwin")
30
+ ## In ruby 3.2, symbol resolution changed on Darwin, to introduce the `-bundle_loader` flag.
31
+ ##
32
+ ## See https://github.com/rake-compiler/rake-compiler-dock/issues/87 for a lot of context, but
33
+ ## I'll try to summarize here.
34
+ ##
35
+ ## > -bundle_loader executable
36
+ ## > This specifies the executable that will be loading the bundle output file being linked.
37
+ ## > Undefined symbols from the bundle are checked against the specified executable like it
38
+ ## > was one of the dynamic libraries the bundle was linked with.
39
+ ##
40
+ ## There are good reasons to do this, including faster initialiation/loading as the Darwin
41
+ ## toolchain gets improved over time.
42
+ ##
43
+ ## Unfortunately, this flag prevents us from building a shared object that works with both a
44
+ ## Ruby compiled with `--enable-shared` and one compiled with `--disabled-shared`. The result
45
+ ## is usually an "Symbol not found" error about `_rb_cObject`, or a "dyld: missing symbol
46
+ ## called" error.
47
+ ##
48
+ ## There are two workarounds that I know of (there may be others I don't know of), and
49
+ ## they are ...
50
+
51
+ ## ----------------------------------------
52
+ ## SOLUTION 1, the `-flat_namespace` flag
53
+ ##
54
+ ## > Two-level namespace
55
+ ## > By default all references resolved to a dynamic library record the library to which
56
+ ## > they were resolved. At runtime, dyld uses that information to directly resolve symbols.
57
+ ## > The alternative is to use the -flat_namespace option. With flat namespace, the library
58
+ ## > is not recorded. At runtime, dyld will search each dynamic library in load order when
59
+ ## > resolving symbols. This is slower, but more like how other operating systems resolve
60
+ ## > symbols.
61
+ ##
62
+ #
63
+ # puts "Adding '-flat_namespace'"
64
+ # $LDFLAGS << ' -flat_namespace'
65
+ #
66
+ ## This solution unfortunately introduces new behavior that any symbols statically linked into
67
+ ## the shared object (e.g., libxml2 in nokogiri.bundle) may not be resolved locally from the
68
+ ## shared object, but instead resolved from a shared object loaded in the main process.
69
+ ##
70
+ ## This solution might be good for you if:
71
+ ## - you don't statically link things into your bundle,
72
+ ## - or you don't export those symbols,
73
+ ## - or you can avoid exporting those symbols (e.g., by using `-load_hidden`, or
74
+ ## `-exported_symbols_list` or some other mechanism)
75
+ ##
76
+
77
+ ## ----------------------------------------
78
+ ## BUT ... if that is a problem, try SOLUTION 2, remove the `-bundle-loader` flag
79
+ ##
80
+ ## This returns us to the symbol resolution we had in previous Rubies. It feels gross but may
81
+ ## be a workaround for gem maintainers until we all figure out a better way to deal with this.
82
+ #
83
+ # extdldflags = RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"].split
84
+ # if found = extdldflags.index("-bundle_loader")
85
+ # removed_1 = extdldflags.delete_at(found) # flag
86
+ # removed_2 = extdldflags.delete_at(found) # and its argument
87
+ # puts "Removing '#{removed_1} #{removed_2}' from EXTDLDFLAGS"
88
+ # end
89
+ # RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"] = extdldflags.join(" ")
90
+ #
91
+ end
26
92
  end
27
93
 
28
94
  create_makefile("rcd_test/rcd_test_ext")
@@ -8,7 +8,13 @@ end
8
8
 
9
9
  class TestEnvironmentVariables
10
10
  module Common
11
- IMAGE_NAME = "larskanis/rake-compiler-dock-mri-x86-mingw32:#{RakeCompilerDock::IMAGE_VERSION}"
11
+ TEST_PLATFORM = ENV["TEST_PLATFORM"] || "x64-mingw-ucrt"
12
+ IS_JRUBY = TEST_PLATFORM.to_s == "jruby"
13
+ TEST_IMAGE_NAME = if IS_JRUBY
14
+ RakeCompilerDock::Starter.container_image_name(rubyvm: "jruby")
15
+ else
16
+ RakeCompilerDock::Starter.container_image_name(platform: TEST_PLATFORM)
17
+ end
12
18
 
13
19
  def rcd_env
14
20
  self.class.instance_variable_get("@rcd_env") || begin
@@ -23,24 +29,26 @@ class TestEnvironmentVariables
23
29
  end
24
30
  end
25
31
 
26
- def test_RUBY_CC_VERSION
27
- df = File.read(File.expand_path("../../Dockerfile.mri.erb", __FILE__))
28
- df =~ /^ENV RUBY_CC_VERSION\s+(.*)\s+$/
29
- assert_equal $1, rcd_env['RUBY_CC_VERSION']
30
- end
32
+ unless IS_JRUBY
33
+ def test_RUBY_CC_VERSION
34
+ df = File.read(File.expand_path("../../Dockerfile.mri.erb", __FILE__))
35
+ df =~ /^ENV RUBY_CC_VERSION\s+(.*)\s+$/
36
+ assert_equal $1, rcd_env['RUBY_CC_VERSION']
37
+ end
31
38
 
32
- def test_RAKE_EXTENSION_TASK_NO_NATIVE
33
- assert_equal "true", rcd_env['RAKE_EXTENSION_TASK_NO_NATIVE']
34
- end
39
+ def test_RAKE_EXTENSION_TASK_NO_NATIVE
40
+ assert_equal "true", rcd_env['RAKE_EXTENSION_TASK_NO_NATIVE']
41
+ end
35
42
 
36
- def test_symlink_rake_compiler
37
- cmd = invocation("if test -h $HOME/.rake-compiler ; then echo yes ; else echo no ; fi")
38
- assert_equal("yes", %x(#{cmd}).strip)
39
- end
43
+ def test_symlink_rake_compiler
44
+ cmd = invocation("if test -h $HOME/.rake-compiler ; then echo yes ; else echo no ; fi")
45
+ assert_equal("yes", %x(#{cmd}).strip)
46
+ end
40
47
 
41
- def test_gem_directory
42
- cmd = invocation("if test -d $HOME/.gem ; then echo yes ; else echo no ; fi")
43
- assert_equal("yes", %x(#{cmd}).strip)
48
+ def test_gem_directory
49
+ cmd = invocation("if test -d $HOME/.gem ; then echo yes ; else echo no ; fi")
50
+ assert_equal("yes", %x(#{cmd}).strip)
51
+ end
44
52
  end
45
53
  end
46
54
 
@@ -49,7 +57,7 @@ class TestEnvironmentVariables
49
57
 
50
58
  def invocation(command)
51
59
  idir = File.join(File.dirname(__FILE__), '../lib')
52
- "#{RbConfig::CONFIG['RUBY_INSTALL_NAME']} -I#{idir.inspect} bin/rake-compiler-dock bash -c '#{command}'"
60
+ "RCD_PLATFORM=#{TEST_PLATFORM} RCD_RUBYVM=#{IS_JRUBY ? 'jruby' : 'mri'} #{RbConfig::CONFIG['RUBY_INSTALL_NAME']} -I#{idir.inspect} bin/rake-compiler-dock bash -c '#{command}'"
53
61
  end
54
62
 
55
63
  def test_HOST_RUBY_PLATFORM
@@ -61,7 +69,7 @@ class TestEnvironmentVariables
61
69
  end
62
70
 
63
71
  def test_IMAGE
64
- assert_equal IMAGE_NAME, rcd_env['RCD_IMAGE']
72
+ assert_equal TEST_IMAGE_NAME, rcd_env['RCD_IMAGE']
65
73
  end
66
74
 
67
75
  def test_PWD
@@ -73,7 +81,7 @@ class TestEnvironmentVariables
73
81
  include Common
74
82
 
75
83
  def invocation(command)
76
- "docker run -it #{IMAGE_NAME} bash -c '#{command}'"
84
+ "docker run --rm #{TEST_IMAGE_NAME} bash -c '#{command}'"
77
85
  end
78
86
  end
79
87
  end
@@ -65,6 +65,6 @@ class TestParallelDockerBuild < Test::Unit::TestCase
65
65
  end
66
66
 
67
67
  def read_df(fn)
68
- File.read("tmp/docker/#{fn}").each_line.map(&:lstrip).join
68
+ File.read(File.join(@tmpdir, "/tmp/docker", fn)).each_line.map(&:lstrip).join
69
69
  end
70
70
  end
data/test/test_starter.rb CHANGED
@@ -30,4 +30,123 @@ class TestStarter < Test::Unit::TestCase
30
30
  assert_equal "_", Starter.make_valid_group_name(nil)
31
31
  end
32
32
 
33
+ def test_container_image_name
34
+ # with env vars
35
+ with_env({"RCD_IMAGE" => "env-var-value"}) do
36
+ assert_equal("env-var-value", Starter.container_image_name)
37
+ end
38
+ with_env({"RAKE_COMPILER_DOCK_IMAGE" => "env-var-value"}) do
39
+ assert_equal("env-var-value", Starter.container_image_name)
40
+ end
41
+
42
+ # with image option
43
+ assert_equal("option-value", Starter.container_image_name({:image => "option-value"}))
44
+
45
+ # with env var and image option, image option wins
46
+ with_env({"RCD_IMAGE" => "env-var-value"}) do
47
+ assert_equal("option-value", Starter.container_image_name({:image => "option-value"}))
48
+ end
49
+
50
+ # mri platform arg
51
+ assert_equal(
52
+ "ghcr.io/rake-compiler/rake-compiler-dock-image:#{IMAGE_VERSION}-mri-platform-option-value",
53
+ Starter.container_image_name({:platform => "platform-option-value"}),
54
+ )
55
+
56
+ # jruby rubyvm arg
57
+ assert_equal(
58
+ "ghcr.io/rake-compiler/rake-compiler-dock-image:#{IMAGE_VERSION}-jruby",
59
+ Starter.container_image_name({:rubyvm => "jruby"}),
60
+ )
61
+
62
+ # jruby platform arg
63
+ assert_equal(
64
+ "ghcr.io/rake-compiler/rake-compiler-dock-image:#{IMAGE_VERSION}-jruby",
65
+ Starter.container_image_name({:platform => "jruby"}),
66
+ )
67
+
68
+ # container registry env var
69
+ with_env({"CONTAINER_REGISTRY" => "registry-value"}) do
70
+ assert_equal(
71
+ "registry-value/rake-compiler-dock-image:#{IMAGE_VERSION}-mri-x86_64-darwin",
72
+ Starter.container_image_name({:platform => "x86_64-darwin"}),
73
+ )
74
+ end
75
+
76
+ # snapshots
77
+ assert_equal(
78
+ "ghcr.io/rake-compiler/rake-compiler-dock-image:snapshot-mri-x86_64-darwin",
79
+ Starter.container_image_name({:platform =>"x86_64-darwin", :version => "snapshot"}),
80
+ )
81
+ end
82
+
83
+ def test_container_registry
84
+ assert_equal("ghcr.io/rake-compiler", Starter.container_registry)
85
+
86
+ with_env({"CONTAINER_REGISTRY" => "env-var-value"}) do
87
+ assert_equal("env-var-value", Starter.container_registry)
88
+ end
89
+ end
90
+
91
+ def test_container_rubyvm
92
+ # no args
93
+ assert_equal("mri", Starter.container_rubyvm)
94
+
95
+ # with env var
96
+ with_env({"RCD_RUBYVM" => "env-var-value"}) do
97
+ assert_equal("env-var-value", Starter.container_rubyvm)
98
+ end
99
+
100
+ # with rubyvm option
101
+ assert_equal("option-value", Starter.container_rubyvm({:rubyvm => "option-value"}))
102
+
103
+ # with rubyvm option and env var, rubyvm option wins
104
+ with_env({"RCD_RUBYVM" => "env-var-value"}) do
105
+ assert_equal("option-value", Starter.container_rubyvm({:rubyvm => "option-value"}))
106
+ end
107
+
108
+ # with jruby platform option
109
+ assert_equal("jruby", Starter.container_rubyvm({:platform => "jruby"}))
110
+ end
111
+
112
+ def test_container_jrubyvm?
113
+ assert(Starter.container_jrubyvm?({:rubyvm => "jruby"}))
114
+ assert(Starter.container_jrubyvm?({:platform => "jruby"}))
115
+ refute(Starter.container_jrubyvm?({:rubyvm => "mri"}))
116
+ refute(Starter.container_jrubyvm?({:platform => "x86_64-linux"}))
117
+ end
118
+
119
+ def test_platforms
120
+ # no args
121
+ assert_equal("x86-mingw32 x64-mingw32", Starter.platforms)
122
+
123
+ # with env var
124
+ with_env({"RCD_PLATFORM" => "env-var-value"}) do
125
+ assert_equal("env-var-value", Starter.platforms)
126
+ end
127
+
128
+ # with platform option
129
+ assert_equal("option-value", Starter.platforms({:platform => "option-value"}))
130
+
131
+ # with platform option and env var, platform option wins
132
+ with_env({"RCD_PLATFORM" => "arm64-darwin"}) do
133
+ assert_equal("option-value", Starter.platforms({:platform => "option-value"}))
134
+ end
135
+
136
+ # when options rubyvm is set to jruby
137
+ assert_equal("jruby", Starter.platforms({:rubyvm => "jruby"}))
138
+ end
139
+
140
+ def with_env(env = {})
141
+ original_env = {}
142
+ env.each do |k, v|
143
+ original_env[k] = ENV[k]
144
+ ENV[k] = v
145
+ end
146
+ yield
147
+ ensure
148
+ original_env.each do |k, v|
149
+ ENV[k] = v
150
+ end
151
+ end
33
152
  end
metadata CHANGED
@@ -1,41 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-compiler-dock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Kanis
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIETTCCArWgAwIBAgIBATANBgkqhkiG9w0BAQsFADAoMSYwJAYDVQQDDB1sYXJz
14
- L0RDPWdyZWl6LXJlaW5zZG9yZi9EQz1kZTAeFw0yMjAyMTQxMzMwNTZaFw0yMzAy
15
- MTQxMzMwNTZaMCgxJjAkBgNVBAMMHWxhcnMvREM9Z3JlaXotcmVpbnNkb3JmL0RD
16
- PWRlMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAwum6Y1KznfpzXOT/
17
- mZgJTBbxZuuZF49Fq3K0WA67YBzNlDv95qzSp7V/7Ek3NCcnT7G+2kSuhNo1FhdN
18
- eSDO/moYebZNAcu3iqLsuzuULXPLuoU0GsMnVMqV9DZPh7cQHE5EBZ7hlzDBK7k/
19
- 8nBMvR0mHo77kIkapHc26UzVq/G0nKLfDsIHXVylto3PjzOumjG6GhmFN4r3cP6e
20
- SDfl1FSeRYVpt4kmQULz/zdSaOH3AjAq7PM2Z91iGwQvoUXMANH2v89OWjQO/NHe
21
- JMNDFsmHK/6Ji4Kk48Z3TyscHQnipAID5GhS1oD21/WePdj7GhmbF5gBzkV5uepd
22
- eJQPgWGwrQW/Z2oPjRuJrRofzWfrMWqbOahj9uth6WSxhNexUtbjk6P8emmXOJi5
23
- chQPnWX+N3Gj+jjYxqTFdwT7Mj3pv1VHa+aNUbqSPpvJeDyxRIuo9hvzDaBHb/Cg
24
- 9qRVcm8a96n4t7y2lrX1oookY6bkBaxWOMtWlqIprq8JZXM9AgMBAAGjgYEwfzAJ
25
- BgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUOIdbSMr3VFrTCO9/cTM0
26
- 0exHzBcwIgYDVR0RBBswGYEXbGFyc0BncmVpei1yZWluc2RvcmYuZGUwIgYDVR0S
27
- BBswGYEXbGFyc0BncmVpei1yZWluc2RvcmYuZGUwDQYJKoZIhvcNAQELBQADggGB
28
- AFWP7F/y3Oq3NgrqUOnjKOeDaBa7AqNhHS+PZg+C90lnJzMgOs4KKgZYxqSQVSab
29
- SCEmzIO/StkXY4NpJ4fYLrHemf/fJy1wPyu+fNdp5SEEUwEo+2toRFlzTe4u4LdS
30
- QC636nPPTMt8H3xz2wf/lUIUeo2Qc95Qt2BQM465ibbG9kmA3c7Sopx6yOabYOAl
31
- KPRbOSEPiWYcF9Suuz8Gdf8jxEtPlnZiwRvnYJ+IHMq3XQCJWPpMzdDMbtlgHbXE
32
- vq1zOTLMSYAS0UB3uionR4yo1hLz60odwkCm7qf0o2Ci/5OjtB0a89VuyqRU2vUJ
33
- QH95WBjDJ6lCCW7J0mrMPnJQSUFTmufsU6jOChvPaCeAzW1YwrsP/YKnvwueG7ip
34
- VOdW6RitjtFxhS7evRL0201+KUvLz12zZWWjOcujlQs64QprxOtiv/MiisKb1Ng+
35
- oL1mUdzB8KrZL4/WbG5YNX6UTtJbIOu9qEFbBAy4/jtIkJX+dlNoFwd4GXQW1YNO
36
- nA==
37
- -----END CERTIFICATE-----
38
- date: 2022-06-27 00:00:00.000000000 Z
10
+ cert_chain: []
11
+ date: 2023-01-12 00:00:00.000000000 Z
39
12
  dependencies:
40
13
  - !ruby/object:Gem::Dependency
41
14
  name: bundler
@@ -96,7 +69,9 @@ extensions: []
96
69
  extra_rdoc_files: []
97
70
  files:
98
71
  - ".github/workflows/ci.yml"
72
+ - ".github/workflows/publish-images.yml"
99
73
  - ".gitignore"
74
+ - CONTRIBUTING.md
100
75
  - Dockerfile.jruby
101
76
  - Dockerfile.mri.erb
102
77
  - Gemfile
@@ -108,10 +83,12 @@ files:
108
83
  - build/gem_helper.rb
109
84
  - build/math_h.patch
110
85
  - build/mk_i686.rb
86
+ - build/mk_osxcross.sh
111
87
  - build/parallel_docker_build.rb
112
88
  - build/patches/ruby-2.5.9/no_sendfile.patch
113
- - build/patches/ruby-3.1.0/no_sendfile.patch
114
- - build/patches2/rake-compiler-1.1.6/0004-Enable-build-of-static-libruby.patch
89
+ - build/patches/ruby-3.1.3/no_sendfile.patch
90
+ - build/patches2/rake-compiler-1.2.1/0004-Enable-build-of-static-libruby.patch
91
+ - build/patches2/rake-compiler-1.2.1/0005-make-miniruby.patch
115
92
  - build/rcd-env.sh
116
93
  - build/runas
117
94
  - build/sigfw.c
@@ -163,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
140
  - !ruby/object:Gem::Version
164
141
  version: '0'
165
142
  requirements: []
166
- rubygems_version: 3.2.22
143
+ rubygems_version: 3.4.2
167
144
  signing_key:
168
145
  specification_version: 4
169
146
  summary: Easy to use and reliable cross compiler environment for building Windows
checksums.yaml.gz.sig DELETED
Binary file
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- ,1o�0����o����ɂl��4.y��ƖǙ^(���/�F^P�A��F��"M2��0����3O�tY ��?��AYͨ\:L�4��M�QZͩY&~�w�����#t܆-�;鼍_�>�J06܉���X#E�M+� ����K�;0-�I(N@*���M��J���2�2h�(cS�+��+L�C���6���/����Kr��N�2Kz����Ց��(����e� �R�D��߬ªRɲ��j��2[j���.P֭�OE���Op:z�zP�ɀ=�y�%Y飗^�MRjo�8b9�~W�#Uq�=�p�
2
- \��AP�"�e(�3�\�2Xm���n��$����¼jU��c7����).�f|��y�v��mH��M�LՍ��