rcee_precompiled 0.2.0-x64-mingw32 → 0.3.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -3
- data/Rakefile +23 -0
- data/ext/precompiled/extconf.rb +8 -7
- data/lib/rcee/precompiled/2.5/precompiled.so +0 -0
- data/lib/rcee/precompiled/2.6/precompiled.so +0 -0
- data/lib/rcee/precompiled/2.7/precompiled.so +0 -0
- data/lib/rcee/precompiled/3.0/precompiled.so +0 -0
- data/lib/rcee/precompiled/version.rb +1 -1
- data/rcee_precompiled.gemspec +6 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e522487dd90054bbf854665b626b4bdaa1394365493cc4ac6c6e6795358d4038
|
4
|
+
data.tar.gz: 543833fa552e66deedae625148821af9eead12eb151bd85a2ed9d808a02d840d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10f7d02ab0fe278d6076018e0257abe8379622edfe0771866ffb8d05ee442ba4ac9c1f0f70230b2e53f7761f6fb4ecaab0633bdc83d24b5cd220b63c3a54eace
|
7
|
+
data.tar.gz: 1a036c3b3ddc5accd9c1529cc78eecf7454a16401db065b9385e6e1a05ee991396f6aa9391eed82d1f7b9f5f057391d4156de62cbf28bd55f59c4db963b28b0b
|
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
|
-
|
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")
|
data/ext/precompiled/extconf.rb
CHANGED
@@ -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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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))
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/rcee_precompiled.gemspec
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: x64-mingw32
|
6
6
|
authors:
|
7
7
|
- Mike Dalessio
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
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.
|
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.
|