rcee_precompiled 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 057d5aabd8a8648f1381e6d95d8d7312adc7e325a53e91910debbfd2664d0e20
4
- data.tar.gz: 772f3c5ad74b9365076024189e352793f493e101834e8517d5ff60ac4065d32d
3
+ metadata.gz: 1433303a861ccdca59314c39762f30c11817241057c5deceb1fd90a192119c2f
4
+ data.tar.gz: aa0690709c7d77f1517714e323d1cbd627febebbb29952b1c9e1ecf3e8e3bfd5
5
5
  SHA512:
6
- metadata.gz: e490327174f9ad601bf9e150bcdf448a5be74059bee3e728c86524359c3b3efffa876bcb441f089faaae779321559d6ead84451ece12f03f42bdae4e57172cd6
7
- data.tar.gz: f53d5117f4b0d9e9b1ab8f577aeb0d35aad7743fbd027ed24e8a75c4e5c47a8b3d05f4dfaecbf859745b8d432960a4fe97771cddcb7a638fdcf8d892df551d6c
6
+ metadata.gz: 62422e6214c2d6f7c025a7474a46a8fe42d3244125f23b9e1b44c7a4546540860ea0e7a58892dd97627f9854882f87da8e384f540be269966d2676541c170215
7
+ data.tar.gz: 1ea4fe394233270e1f362b9849189e400726379448472275ce547614d4db5c76e0532ea0e00d807dd50012319623342ce97ae69408237c8690746eae2b3f9301
data/README.md CHANGED
@@ -93,7 +93,7 @@ This makes sure that the cross-compiler is the compiler used within the guest co
93
93
  cross_build_p = enable_config("cross-build")
94
94
  ```
95
95
 
96
- We don't need this for `libyaml`, but the technique is useful: the cross-compile rake task signals to `extconf.rb` that it's cross-compiling by using a commandline flag that we can inspect. As an example, `extconf.rb` may need to set specific configuration options on the third-party library when cross-compiling.
96
+ The cross-compile rake task signals to `extconf.rb` that it's cross-compiling by using a commandline flag that we can inspect. We'll need this for `libyaml` to make sure that set the appropriate flags during precompilation (flags which shouldn't be set when compiling natively).
97
97
 
98
98
  ``` ruby
99
99
  MiniPortile.new("yaml", "0.2.5").tap do |recipe|
@@ -150,6 +150,24 @@ end
150
150
  Go ahead and try it! `gem install rcee_precompiled`. If you're on windows, linux, or macos you should get a precompiled version that installs in under a second. Everyone else (hello FreeBSD people!) it'll take a few more seconds to build the vanilla gem's packaged tarball.
151
151
 
152
152
 
153
+ ## Testing
154
+
155
+ See [.github/workflows/precompiled.yml](../.github/workflows/precompiled.yml)
156
+
157
+ Key things to note:
158
+
159
+ - matrix across all supported Rubies and platforms (for compile-from-source installation testing)
160
+ - test native gems for a variety of platforms
161
+ - use rake-compiler-dock images to build the gems
162
+ - then install on native platforms and verify that it passes tests
163
+
164
+ Note that there's additional complexity because of how we test:
165
+
166
+ - see new script bin/test-gem-build which artificially bumps the VERSION string to double-check we're testing the packaged version of the gem (which the tests output)
167
+ - see new script bin/test-gem-install which installs the gem, deletes the local source code, and runs the tests against the installed gem
168
+ - the gemspec handles a missing version file (because we delete the local source code during testing)
169
+
170
+
153
171
  ## What Can Go Wrong
154
172
 
155
173
  This strategy isn't perfect. Remember what I said earlier, that a compiled C extension is specific to
@@ -158,8 +176,8 @@ This strategy isn't perfect. Remember what I said earlier, that a compiled C ext
158
176
  - the machine architecture (e.g., x86_64)
159
177
  - the system libraries
160
178
 
161
- The precompiled strategy mostly takes care of the first two, but there are still edge cases for system libraries. The big gotcha is that linux libc is not the same as linux musl, and we've had to work around this a few times in Nokogiri.
179
+ The precompiled strategy mostly takes care of the first two, but there are still edge cases for system libraries. The big gotcha is that linux libc is not the same as linux musl, and we've had to work around this a few times in Nokogiri. Note also that we're unable to easily test `musl` systems on Github Actions because of limitations in the `download-artifact` action.
162
180
 
163
- I'm positive that there are more edge cases that will be found as users add more platforms and as more gems start precompiling. I'm willing to bet money that you can break this by setting some Ruby compile-time flags on your system. I'm honestly surprised it works as well as it has.
181
+ I'm positive that there are more edge cases that will be found as users add more platforms and as more gems start precompiling. I'm willing to bet money that you can break this by setting some Ruby compile-time flags on your system. I'm honestly surprised it works as well as it has. (Worth noting: the `sassc` gem stopped shipping native gems for linux because of the musl incompatibilities.)
164
182
 
165
183
  So the lesson here is: make sure you have an automated test pipeline that will build a gem and test it on the target platform! This takes time to set up, but it will save you time and effort in the long run.
data/Rakefile CHANGED
@@ -57,6 +57,29 @@ namespace "gem" do
57
57
  multitask "all" => [cross_platforms, "gem"].flatten
58
58
  end
59
59
 
60
+ desc "Temporarily set VERSION to a unique timestamp"
61
+ task "set-version-to-timestamp" do
62
+ # this task is used by bin/test-gem-build
63
+ # to test building, packaging, and installing a precompiled gem
64
+ version_constant_re = /^\s*VERSION\s*=\s*["'](.*)["']$/
65
+
66
+ version_file_path = File.join(__dir__, "lib/rcee/precompiled/version.rb")
67
+ version_file_contents = File.read(version_file_path)
68
+
69
+ current_version_string = version_constant_re.match(version_file_contents)[1]
70
+ current_version = Gem::Version.new(current_version_string)
71
+
72
+ fake_version = Gem::Version.new(format("%s.test.%s", current_version.bump, Time.now.strftime("%Y.%m%d.%H%M")))
73
+
74
+ unless version_file_contents.gsub!(version_constant_re, " VERSION = \"#{fake_version}\"")
75
+ raise("Could not hack the VERSION constant")
76
+ end
77
+
78
+ File.open(version_file_path, "w") { |f| f.write(version_file_contents) }
79
+
80
+ puts "NOTE: wrote version as \"#{fake_version}\""
81
+ end
82
+
60
83
  task default: [:clobber, :compile, :test]
61
84
 
62
85
  CLEAN.add("{ext,lib}/**/*.{o,so}", "pkg")
@@ -6,7 +6,6 @@ package_root_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."
6
6
  RbConfig::CONFIG["CC"] = RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
7
7
  ENV["CC"] = RbConfig::CONFIG["CC"]
8
8
 
9
- # not needed for libyaml, but generally useful to know whether we're cross-compiling
10
9
  cross_build_p = enable_config("cross-build")
11
10
 
12
11
  MiniPortile.new("yaml", "0.2.5").tap do |recipe|
@@ -17,12 +16,14 @@ MiniPortile.new("yaml", "0.2.5").tap do |recipe|
17
16
  recipe.target = File.join(package_root_dir, "ports")
18
17
 
19
18
  # configure the environment that MiniPortile will use for subshells
20
- ENV.to_h.dup.tap do |env|
21
- # -fPIC is necessary for linking into a shared library
22
- env["CFLAGS"] = [env["CFLAGS"], "-fPIC"].join(" ")
23
- env["SUBDIRS"] = "include src" # libyaml: skip tests
24
-
25
- recipe.configure_options += env.map { |key, value| "#{key}=#{value.strip}" }
19
+ if cross_build_p
20
+ ENV.to_h.tap do |env|
21
+ # -fPIC is necessary for linking into a shared library
22
+ env["CFLAGS"] = [env["CFLAGS"], "-fPIC"].join(" ")
23
+ env["SUBDIRS"] = "include src" # libyaml: skip tests
24
+
25
+ recipe.configure_options += env.map { |key, value| "#{key}=#{value.strip}" }
26
+ end
26
27
  end
27
28
 
28
29
  unless File.exist?(File.join(recipe.target, recipe.host, recipe.name, recipe.version))
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RCEE
4
4
  module Precompiled
5
- VERSION = "0.2.0"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
@@ -1,10 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/rcee/precompiled/version"
3
+ begin
4
+ require_relative "lib/rcee/precompiled/version"
5
+ rescue LoadError
6
+ puts "WARNING: Could not load RCEE::Precompiled::VERSION"
7
+ end
4
8
 
5
9
  Gem::Specification.new do |spec|
6
10
  spec.name = "rcee_precompiled"
7
- spec.version = RCEE::Precompiled::VERSION
11
+ spec.version = defined?(RCEE::Precompiled::VERSION) ? RCEE::Precompiled::VERSION : "0.0.0"
8
12
  spec.authors = ["Mike Dalessio"]
9
13
  spec.email = ["mike.dalessio@gmail.com"]
10
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcee_precompiled
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Dalessio
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-10 00:00:00.000000000 Z
11
+ date: 2021-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_portile2