rb_sys 0.9.19 → 0.9.20

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48b3782a3c2bd7804f9f0a1c42f4bbb1181173525c63011e77fa9a122b93bfe3
4
- data.tar.gz: 04acd400f1997b1d1a981a148a7f9e7027d3b7af4c23fb924b97a5b3831f4115
3
+ metadata.gz: 8268ca6121f3fc20fd5f5247b8bbfbe1ce93de3b57f025d11087b77da0e49aa3
4
+ data.tar.gz: f5ad91cce6a8543d13ae8fd9d269bc6f3bab43d41afb02af20b0edc1152a7cd7
5
5
  SHA512:
6
- metadata.gz: 706f56f3d6ee988b4216481d0bdbe90ba5a57e25304a07b7e790f9bc3c50adf91a76b2b12097747c4be4148b5e2a8bb1374f8c5d9dc9dd6e4318ab8bbee2ae25
7
- data.tar.gz: 247aa3d5cf43aa9dd83775617ca2a2c60a68f15083a3502e05c9ad76aa8beaa0f2d725d846983e84f1b4af1b0503714d26fde921b14c3ea2e972f8fe19c2f1d3
6
+ metadata.gz: 5334cc57dea7b85b73bd3807d521823992ef5d96fd52e25a7afe56df447912c17311d707be731ea6540db71c0284bbdb3ba943c2fe2fbadb5141fb698b0a5731
7
+ data.tar.gz: 8bfd5734a29819031e1523f4f6c63c0840471932757d97f31c41d0606145c997a4812a92c331625781259eeb34a0821620f8963477ee851d61cfbecf377f3043
checksums.yaml.gz.sig CHANGED
@@ -1,3 +1,2 @@
1
- q���j��tbn��9 ��("eI��M�9!C�IP� `0��h�F�'@CL���+�
2
- cHg���
3
- ���.o�>��JImp �+lt�>>�YW ws�E��c�`�x����Y�՚��d.�+���*Մ��+?���P򱬙L�Xտ�"��Z�dS������r7�\=%4�<)<4���ћ5"$ B�Ǚ�y#U��A�5�]��K6�͎ϔ˫d�
1
+ D�K�v3u8WQ�eAn(�(�U�/y4���
2
+ ��O��#�8Y6�HQ�Q}\�p�� �����V}aP����֪U�$�.�Q*ȼ-����Eǖ���iI�1�:�
@@ -1,6 +1,6 @@
1
1
  module RbSys
2
2
  class CargoBuilder < Gem::Ext::Builder
3
- attr_accessor :spec, :runner, :profile, :env, :features, :target, :extra_rustc_args, :dry_run, :ext_dir
3
+ attr_accessor :spec, :runner, :profile, :env, :features, :target, :extra_rustc_args, :dry_run, :ext_dir, :extra_rustflags
4
4
 
5
5
  def initialize(spec)
6
6
  require "rubygems/command"
@@ -15,6 +15,7 @@ module RbSys
15
15
  @extra_rustc_args = []
16
16
  @dry_run = true
17
17
  @ext_dir = nil
18
+ @extra_rustflags = []
18
19
  end
19
20
 
20
21
  def build(_extension, dest_path, results, args = [], lib_dir = nil, cargo_dir = Dir.pwd)
@@ -0,0 +1,23 @@
1
+ # Root module
2
+ module RbSys
3
+ # Helper class for creating Rust Makefiles
4
+ module Mkmf
5
+ # Config that delegates to CargoBuilder if needded
6
+ class Config
7
+ attr_accessor :force_install_rust_toolchain
8
+
9
+ def initialize(builder)
10
+ @builder = builder
11
+ @force_install_rust_toolchain = false
12
+ end
13
+
14
+ def method_missing(name, *args, &blk)
15
+ @builder.send(name, *args, &blk)
16
+ end
17
+
18
+ def respond_to_missing?(name, include_private = false)
19
+ @builder.respond_to?(name) || super
20
+ end
21
+ end
22
+ end
23
+ end
data/lib/rb_sys/mkmf.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require "rubygems/ext"
4
4
  require "shellwords"
5
5
  require_relative "cargo_builder"
6
+ require_relative "mkmf/config"
6
7
 
7
8
  # Root module
8
9
  module RbSys
@@ -37,7 +38,8 @@ module RbSys
37
38
  end
38
39
 
39
40
  spec = Struct.new(:name, :metadata).new(target, {})
40
- builder = CargoBuilder.new(spec)
41
+ cargo_builder = CargoBuilder.new(spec)
42
+ builder = Config.new(cargo_builder)
41
43
 
42
44
  yield builder if blk
43
45
 
@@ -48,6 +50,7 @@ module RbSys
48
50
 
49
51
  # rubocop:disable Style/GlobalVars
50
52
  make_install = +<<~MAKE
53
+ RB_SYS_BUILD_DIR ?= #{File.join(Dir.pwd, ".rb-sys")}
51
54
  CARGO ?= cargo
52
55
  CARGO_BUILD_TARGET ?= #{builder.target}
53
56
  SOEXT ?= #{builder.so_ext}
@@ -59,6 +62,7 @@ module RbSys
59
62
 
60
63
  RB_SYS_CARGO_PROFILE ?= #{builder.profile}
61
64
  RB_SYS_CARGO_FEATURES ?= #{builder.features.join(",")}
65
+ RB_SYS_EXTRA_RUSTFLAGS ?= #{builder.extra_rustflags.join(" ")}
62
66
 
63
67
  # Set dirname for the profile, since the profiles do not directly map to target dir (i.e. dev -> debug)
64
68
  ifeq ($(RB_SYS_CARGO_PROFILE),dev)
@@ -91,7 +95,7 @@ module RbSys
91
95
  TARGET_DIR = #{Dir.pwd}/$(RB_SYS_CARGO_BUILD_TARGET_DIR)/$(RB_SYS_CARGO_PROFILE_DIR)
92
96
  RUSTLIB = $(TARGET_DIR)/$(SOEXT_PREFIX)$(TARGET_NAME).$(SOEXT)
93
97
 
94
- DISTCLEANDIRS = $(TARGET_DIR)
98
+ DISTCLEANDIRS = $(TARGET_DIR) $(RB_SYS_BUILD_DIR)
95
99
  DEFFILE = $(TARGET_DIR)/$(TARGET)-$(arch).def
96
100
  #{base_makefile(srcdir)}
97
101
 
@@ -100,6 +104,7 @@ module RbSys
100
104
  endif
101
105
 
102
106
  #{env_vars(builder)}
107
+ $(DLLIB): export RUSTFLAGS := $(RUSTFLAGS) $(RB_SYS_EXTRA_RUSTFLAGS)
103
108
 
104
109
  FORCE: ;
105
110
 
@@ -111,6 +116,8 @@ module RbSys
111
116
  \t$(ECHO) generating $(@)
112
117
  \t$(Q) ($(COPY) $(srcdir)/$(TARGET).def $@ 2> /dev/null) || (echo EXPORTS && echo $(TARGET_ENTRY)) > $@
113
118
 
119
+ #{optional_rust_toolchain(builder)}
120
+
114
121
  $(DLLIB): $(DEFFILE) FORCE
115
122
  \t$(ECHO) generating $(@) \\("$(RB_SYS_CARGO_PROFILE)"\\)
116
123
  \t$(Q) #{full_cargo_command}
@@ -173,6 +180,45 @@ module RbSys
173
180
  cargo_command.gsub!(%r{/#{target_dir}/[^/]+}, "/$(RB_SYS_CARGO_BUILD_TARGET_DIR)/$(RB_SYS_CARGO_PROFILE_DIR)")
174
181
  cargo_command
175
182
  end
183
+
184
+ def optional_rust_toolchain(builder)
185
+ <<~MAKE
186
+ RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN ?= #{builder.force_install_rust_toolchain}
187
+
188
+ # Only run if the we are told to explicitly install the Rust toolchain
189
+ ifneq ($(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN),false)
190
+ RB_SYS_RUSTUP_PROFILE ?= minimal
191
+
192
+ # If the user passed true, we assume stable Rust. Otherwise, use what
193
+ # was specified (i.e. RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN=beta)
194
+ ifeq ($(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN),true)
195
+ RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN = stable
196
+ endif
197
+
198
+ # If a $RUST_TARGET is specified (i.e. for rake-compiler-dock), append
199
+ # that to the profile.
200
+ ifeq ($(RUST_TARGET),)
201
+ RB_SYS_DEFAULT_TOOLCHAIN = $(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN)
202
+ else
203
+ RB_SYS_DEFAULT_TOOLCHAIN = $(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN)-$(RUST_TARGET)
204
+ endif
205
+
206
+ export CARGO_HOME ?= $(RB_SYS_BUILD_DIR)/$(RB_SYS_DEFAULT_TOOLCHAIN)/cargo
207
+ export RUSTUP_HOME ?= $(RB_SYS_BUILD_DIR)/$(RB_SYS_DEFAULT_TOOLCHAIN)/rustup
208
+ export PATH := $(CARGO_HOME)/bin:$(RUSTUP_HOME)/bin:$(PATH)
209
+ export RUSTUP_TOOLCHAIN := $(RB_SYS_DEFAULT_TOOLCHAIN)
210
+ export CARGO := $(CARGO_HOME)/bin/cargo
211
+
212
+ $(CARGO):
213
+ \t$(Q) $(MAKEDIRS) $(CARGO_HOME) $(RUSTUP_HOME)
214
+ \tcurl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
215
+ \trustup toolchain install $(RB_SYS_DEFAULT_TOOLCHAIN) --profile $(RB_SYS_RUSTUP_PROFILE)
216
+ \trustup default $(RB_SYS_DEFAULT_TOOLCHAIN)
217
+
218
+ $(DLLIB): $(CARGO)
219
+ endif
220
+ MAKE
221
+ end
176
222
  end
177
223
  end
178
224
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbSys
4
- VERSION = "0.9.19"
4
+ VERSION = "0.9.20"
5
5
  end
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.19
4
+ version: 0.9.20
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-07-05 00:00:00.000000000 Z
33
+ date: 2022-07-16 00:00:00.000000000 Z
34
34
  dependencies: []
35
35
  description:
36
36
  email:
@@ -46,6 +46,7 @@ files:
46
46
  - lib/rb_sys/cargo_builder.rb
47
47
  - lib/rb_sys/cargo_builder/link_flag_converter.rb
48
48
  - lib/rb_sys/mkmf.rb
49
+ - lib/rb_sys/mkmf/config.rb
49
50
  - lib/rb_sys/version.rb
50
51
  - sig/rb_sys.rbs
51
52
  homepage: https://github.com/oxidize-rb/rb-sys
metadata.gz.sig CHANGED
Binary file