rb_sys 0.9.41 → 0.9.42
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 +2 -1
- data/lib/rb_sys/cargo_builder.rb +1 -0
- data/lib/rb_sys/mkmf/config.rb +6 -3
- data/lib/rb_sys/mkmf.rb +40 -25
- data/lib/rb_sys/toolchain_info.rb +7 -0
- data/lib/rb_sys/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eb891270e825b41d12d8ef69ebf94c9eac8862d6cf1649d23af775bc84f394d2
|
|
4
|
+
data.tar.gz: 3cf455c0df0e6498c4117d3c063bd4ccaa05cb6f566fe51d36b7898b552f8aec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f84a703e4194b91120cbeb0968680d8bacd8d4eeabb0f770f94ed00d3056d765b621d46cd89134b1077e72e54bb360594f9df62bab7a2bc676efb07f4931eaa4
|
|
7
|
+
data.tar.gz: 5cf5177fd5833d9eba38fc53529b0321d9109b772f59daa84a7d38dc447468c3aade4d8a919488a1a345164ed9589801287a0e4e02513ee9967f219f44bc0457
|
checksums.yaml.gz.sig
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
99��
|
|
2
|
+
�Jќ9a��,��*��t�E����
|
data/lib/rb_sys/cargo_builder.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
module RbSys
|
|
2
|
+
# A class to build a Ruby gem Cargo. Extracted from `rubygems` gem, with some modifications.
|
|
2
3
|
class CargoBuilder < Gem::Ext::Builder
|
|
3
4
|
attr_accessor :spec, :runner, :profile, :env, :features, :target, :extra_rustc_args, :dry_run, :ext_dir, :extra_rustflags
|
|
4
5
|
|
data/lib/rb_sys/mkmf/config.rb
CHANGED
|
@@ -4,14 +4,19 @@ module RbSys
|
|
|
4
4
|
module Mkmf
|
|
5
5
|
# Config that delegates to CargoBuilder if needded
|
|
6
6
|
class Config
|
|
7
|
-
attr_accessor :force_install_rust_toolchain, :clean_after_install
|
|
7
|
+
attr_accessor :force_install_rust_toolchain, :clean_after_install, :target_dir, :auto_install_rust_toolchain
|
|
8
8
|
|
|
9
9
|
def initialize(builder)
|
|
10
10
|
@builder = builder
|
|
11
11
|
@force_install_rust_toolchain = false
|
|
12
|
+
@auto_install_rust_toolchain = true
|
|
12
13
|
@clean_after_install = rubygems_invoked?
|
|
13
14
|
end
|
|
14
15
|
|
|
16
|
+
def cross_compiling?
|
|
17
|
+
RbConfig::CONFIG["CROSS_COMPILING"] == "yes"
|
|
18
|
+
end
|
|
19
|
+
|
|
15
20
|
def method_missing(name, *args, &blk)
|
|
16
21
|
@builder.send(name, *args, &blk)
|
|
17
22
|
end
|
|
@@ -20,8 +25,6 @@ module RbSys
|
|
|
20
25
|
@builder.respond_to?(name) || super
|
|
21
26
|
end
|
|
22
27
|
|
|
23
|
-
private
|
|
24
|
-
|
|
25
28
|
# Seems to be the only way to reliably know if we were invoked by Rubygems.
|
|
26
29
|
# We want to know this so we can cleanup the target directory after an
|
|
27
30
|
# install, to remove bloat.
|
data/lib/rb_sys/mkmf.rb
CHANGED
|
@@ -18,20 +18,22 @@ module RbSys
|
|
|
18
18
|
#
|
|
19
19
|
# @example Basic
|
|
20
20
|
# require 'mkmf'
|
|
21
|
-
#
|
|
21
|
+
# require 'rb_sys/mkmf'
|
|
22
22
|
#
|
|
23
|
-
#
|
|
23
|
+
# create_rust_makefile("my_extension") #=> Generate a Makefile in the current directory
|
|
24
24
|
#
|
|
25
25
|
# @example Configure a custom build profile
|
|
26
26
|
# require 'mkmf'
|
|
27
|
-
#
|
|
27
|
+
# require 'rb_sys/mkmf'
|
|
28
28
|
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
29
|
+
# create_rust_makefile("my_extension") do |r|
|
|
30
|
+
# # All of these are optional
|
|
31
|
+
# r.env = { 'FOO' => 'bar' }
|
|
32
|
+
# r.profile = ENV.fetch('RB_SYS_CARGO_PROFILE', :dev).to_sym
|
|
33
|
+
# r.features = %w[some_cargo_feature]
|
|
34
|
+
# r.rustflags = %w[--cfg=foo]
|
|
35
|
+
# r.target_dir = "some/target/dir"
|
|
36
|
+
# end
|
|
35
37
|
def create_rust_makefile(target, &blk)
|
|
36
38
|
if target.include?("/")
|
|
37
39
|
target_prefix, target = File.split(target)
|
|
@@ -94,11 +96,12 @@ module RbSys
|
|
|
94
96
|
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
|
95
97
|
TARGET = #{target}
|
|
96
98
|
DLLIB = $(TARGET).#{RbConfig::CONFIG["DLEXT"]}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
#{conditional_assign("TARGET_DIR", "$(RB_SYS_CARGO_BUILD_TARGET_DIR)")}
|
|
100
|
+
RUSTLIBDIR = $(TARGET_DIR)/$(RB_SYS_CARGO_PROFILE_DIR)
|
|
101
|
+
RUSTLIB = $(RUSTLIBDIR)/$(SOEXT_PREFIX)$(TARGET_NAME).$(SOEXT)
|
|
99
102
|
|
|
100
|
-
CLEANOBJS = $(
|
|
101
|
-
DEFFILE = $(
|
|
103
|
+
CLEANOBJS = $(RUSTLIBDIR)/.fingerprint $(RUSTLIBDIR)/incremental $(RUSTLIBDIR)/examples $(RUSTLIBDIR)/deps $(RUSTLIBDIR)/build $(RUSTLIBDIR)/.cargo-lock $(RUSTLIBDIR)/*.d $(RUSTLIBDIR)/*.rlib $(RB_SYS_BUILD_DIR)
|
|
104
|
+
DEFFILE = $(RUSTLIBDIR)/$(TARGET)-$(arch).def
|
|
102
105
|
CLEANLIBS = $(DLLIB) $(RUSTLIB) $(DEFFILE)
|
|
103
106
|
|
|
104
107
|
#{base_makefile(srcdir)}
|
|
@@ -112,9 +115,9 @@ module RbSys
|
|
|
112
115
|
|
|
113
116
|
FORCE: ;
|
|
114
117
|
|
|
115
|
-
$(
|
|
118
|
+
$(RUSTLIBDIR):
|
|
116
119
|
\t$(ECHO) creating target directory \\($(@)\\)
|
|
117
|
-
\t$(Q) $(MAKEDIRS) $(
|
|
120
|
+
\t$(Q) $(MAKEDIRS) $(RUSTLIBDIR)
|
|
118
121
|
|
|
119
122
|
#{deffile_definition}
|
|
120
123
|
|
|
@@ -122,7 +125,7 @@ module RbSys
|
|
|
122
125
|
|
|
123
126
|
$(RUSTLIB): #{deffile_definition ? "$(DEFFILE) " : nil}FORCE
|
|
124
127
|
\t$(ECHO) generating $(@) \\("$(RB_SYS_CARGO_PROFILE)"\\)
|
|
125
|
-
\t
|
|
128
|
+
\t#{full_cargo_command}
|
|
126
129
|
|
|
127
130
|
$(DLLIB): $(RUSTLIB)
|
|
128
131
|
\t$(Q) $(COPY) "$(RUSTLIB)" $@
|
|
@@ -153,7 +156,7 @@ module RbSys
|
|
|
153
156
|
|
|
154
157
|
def cargo_command(cargo_dir, builder)
|
|
155
158
|
builder.ext_dir = cargo_dir
|
|
156
|
-
dest_path = File.join(Dir.pwd, "target")
|
|
159
|
+
dest_path = builder.target_dir || File.join(Dir.pwd, "target")
|
|
157
160
|
args = ARGV.dup
|
|
158
161
|
args.shift if args.first == "--"
|
|
159
162
|
cargo_cmd = builder.cargo_command(dest_path, args)
|
|
@@ -181,8 +184,7 @@ module RbSys
|
|
|
181
184
|
cargo_command.gsub!(/--profile \w+/, "$(RB_SYS_CARGO_PROFILE_FLAG)")
|
|
182
185
|
cargo_command.gsub!(%r{--features \S+}, "--features $(RB_SYS_CARGO_FEATURES)")
|
|
183
186
|
cargo_command.gsub!(%r{--target \S+}, "--target $(CARGO_BUILD_TARGET)")
|
|
184
|
-
|
|
185
|
-
cargo_command.gsub!(%r{/#{target_dir}/[^/]+}, "/$(RB_SYS_CARGO_BUILD_TARGET_DIR)/$(RB_SYS_CARGO_PROFILE_DIR)")
|
|
187
|
+
cargo_command.gsub!(/--target-dir (?:(?!--).)+/, "--target-dir $(TARGET_DIR) ")
|
|
186
188
|
cargo_command
|
|
187
189
|
end
|
|
188
190
|
|
|
@@ -192,18 +194,14 @@ module RbSys
|
|
|
192
194
|
return unless defined?(EXPORT_PREFIX) && EXPORT_PREFIX
|
|
193
195
|
|
|
194
196
|
@deffile_definition ||= <<~MAKE
|
|
195
|
-
$(DEFFILE): $(
|
|
197
|
+
$(DEFFILE): $(RUSTLIBDIR)
|
|
196
198
|
\t$(ECHO) generating $(@)
|
|
197
199
|
\t$(Q) ($(COPY) $(srcdir)/$(TARGET).def $@ 2> /dev/null) || (echo EXPORTS && echo $(TARGET_ENTRY)) > $@
|
|
198
200
|
MAKE
|
|
199
201
|
end
|
|
200
202
|
|
|
201
|
-
def
|
|
203
|
+
def rust_toolchain_env(builder)
|
|
202
204
|
<<~MAKE
|
|
203
|
-
#{conditional_assign("RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN", builder.force_install_rust_toolchain)}
|
|
204
|
-
|
|
205
|
-
# Only run if the we are told to explicitly install the Rust toolchain
|
|
206
|
-
#{if_neq_stmt("$(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN)", "false")}
|
|
207
205
|
#{conditional_assign("RB_SYS_RUSTUP_PROFILE", "minimal")}
|
|
208
206
|
|
|
209
207
|
# If the user passed true, we assume stable Rust. Otherwise, use what
|
|
@@ -227,6 +225,16 @@ module RbSys
|
|
|
227
225
|
#{export_env("PATH", "$(CARGO_HOME)/bin:$(RUSTUP_HOME)/bin:$(PATH)")}
|
|
228
226
|
#{export_env("RUSTUP_TOOLCHAIN", "$(RB_SYS_DEFAULT_TOOLCHAIN)")}
|
|
229
227
|
#{export_env("CARGO", "$(CARGO_HOME)/bin/cargo")}
|
|
228
|
+
MAKE
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def optional_rust_toolchain(builder)
|
|
232
|
+
<<~MAKE
|
|
233
|
+
#{conditional_assign("RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN", force_install_rust_toolchain?(builder))}
|
|
234
|
+
|
|
235
|
+
# Only run if the we are told to explicitly install the Rust toolchain
|
|
236
|
+
#{if_neq_stmt("$(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN)", "false")}
|
|
237
|
+
#{rust_toolchain_env(builder)}
|
|
230
238
|
|
|
231
239
|
$(CARGO):
|
|
232
240
|
\t$(Q) $(MAKEDIRS) $(CARGO_HOME) $(RUSTUP_HOME)
|
|
@@ -239,6 +247,13 @@ module RbSys
|
|
|
239
247
|
MAKE
|
|
240
248
|
end
|
|
241
249
|
|
|
250
|
+
def force_install_rust_toolchain?(builder)
|
|
251
|
+
return builder.force_install_rust_toolchain if builder.force_install_rust_toolchain
|
|
252
|
+
return false unless builder.rubygems_invoked? && builder.auto_install_rust_toolchain
|
|
253
|
+
|
|
254
|
+
find_executable("cargo").nil?
|
|
255
|
+
end
|
|
256
|
+
|
|
242
257
|
def if_eq_stmt(a, b)
|
|
243
258
|
if $nmake
|
|
244
259
|
"!IF #{a.inspect} == #{b.inspect}"
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
require_relative "toolchain_info/data"
|
|
4
4
|
|
|
5
5
|
module RbSys
|
|
6
|
+
# A class to get information about the Rust toolchains, and how they map to
|
|
7
|
+
# Ruby platforms.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# RbSys::ToolchainInfo.new("x86_64-unknown-linux-gnu").ruby_platform # => "x86_64-linux"
|
|
11
|
+
# RbSys::ToolchainInfo.new("x86_64-unknown-linux-gnu").supported? # => true
|
|
12
|
+
# RbSys::ToolchainInfo.new("x86_64-unknown-linux-gnu")
|
|
6
13
|
class ToolchainInfo
|
|
7
14
|
attr_reader :platform, :gem_platform, :rust_target, :rake_compiler_dock_cc, :supported, :rake_compiler_dock_image, :docker_platform
|
|
8
15
|
|
data/lib/rb_sys/version.rb
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rb_sys
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.42
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ian Ker-Seymer
|
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
|
30
30
|
Rl+ASkq2/1i07TkBpCf+2hq66+h/hx+/Y/KrUzXfe0jtvil0WESkJT2kqRqHWNhD
|
|
31
31
|
9GKBxaQlXokNDtWCm1/gl6cD8WRZ0N5S4ZGJT1FLLsA=
|
|
32
32
|
-----END CERTIFICATE-----
|
|
33
|
-
date: 2022-11-
|
|
33
|
+
date: 2022-11-16 00:00:00.000000000 Z
|
|
34
34
|
dependencies: []
|
|
35
35
|
description:
|
|
36
36
|
email:
|
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
73
|
version: '0'
|
|
74
74
|
requirements: []
|
|
75
|
-
rubygems_version: 3.3.
|
|
75
|
+
rubygems_version: 3.3.22
|
|
76
76
|
signing_key:
|
|
77
77
|
specification_version: 4
|
|
78
78
|
summary: Helpers for compiling Rust extensions for ruby
|
metadata.gz.sig
CHANGED
|
Binary file
|