rcee_precompiled 0.2.0-x86_64-linux → 0.3.0-x86_64-linux

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: '0818480101cccae68bf8c0864bcfe3a2bcb834c6109a2ea0de8fb20b0b857839'
4
- data.tar.gz: 2c5895c09102a334bd504bafff4ea219cff158b4a59eb7206c113ff9a706d951
3
+ metadata.gz: 5261c6c48fb6b1025adc0390308aaf8c975735476d0bc3c43a941444762de992
4
+ data.tar.gz: 9c6b37821d80801f440716cceb12434e2beaf35e891f38fab622d3470df4bb65
5
5
  SHA512:
6
- metadata.gz: 00efa25e3e7109ea75c6e163d2ff59d6b5d55278b0f35b888cfe9befd1bd965cc4697146766ab740bd4a8942f4d3b56b7daeb33165b4fe3c9073fe58c84798da
7
- data.tar.gz: b7d2027f2b8673254ab8ae573c641f954756d8ad7a8a649890f3bc9d5d1f0db5197e063494c5fd839d1a3021ecf0f53ae9b47b3cafa4c96344d10af0d0f6a186
6
+ metadata.gz: a54d29615c7c6ac381ae0b98024a6c90133302223a7f9f1687509227cd5feb7d2251764662e61a7945ba84d1c290e2c089c4c469682aa85e08f9e3fc89adccec
7
+ data.tar.gz: fecf4625695af77b0904dea142c3dec7860574b70724e78cccbe2e7083dc1d5b7d35e4bb03d482f30be47d4c031e73c380fbb7268d6415e4b713c7f683a489ee
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: x86_64-linux
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
  description: Part of a project to explain how Ruby C extensions work.
14
14
  email:
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  requirements: []
56
- rubygems_version: 3.2.3
56
+ rubygems_version: 3.2.30
57
57
  signing_key:
58
58
  specification_version: 4
59
59
  summary: Example gem demonstrating a basic C extension.