rb_sys 0.9.18 → 0.9.21

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: 87a77ec921cf8f55b614bc5f9cdca97ab6c70ab665844872f75854acc9b9b661
4
- data.tar.gz: bdc868687c0b8b6981ab736b39e392656d5b77f8ad0331b076d5a99abacdcb56
3
+ metadata.gz: 1ef1de2cec5dcbbaaa9d8cc147b9bf727ce66c3beeb03ac6966549677a58a666
4
+ data.tar.gz: 5a693be7f33111e218293d7f6ff1e1ed8b4b3f1e238384a7c5f2d29ee654e713
5
5
  SHA512:
6
- metadata.gz: d1a4dd01534046638cf54bf50eff4a8725d5987265f3fe71fb08ec9406bd30938b48de5a4e7efde70cc44ebec0d1be8afe004fe6ed3f85631b0abab46986f48a
7
- data.tar.gz: f9b949fc7a3476917607a3ac7b9aca1d69c7be54b149cc877002ea49e2e4417939b1c0ae7b85685274e19d1b5a2745027b373d65c1997462176650f0c0af1866
6
+ metadata.gz: c3b0b95982617b6df58a1e78359858fce84510559386f537de606781bbb4d1e9431c349830ac1655140b373ec57f29b48b26705d715056d1a50b30233b362775
7
+ data.tar.gz: 2fc14bb752c42481d37de6b6f5e12fbcd43f55b580ddd9dc7ef158ee836fce241a990fc1b96dfa8b5babb055df5cdf828824f1983bf76a0cebddaec99442565c
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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}
@@ -152,6 +159,7 @@ module RbSys
152
159
  def env_vars(builder)
153
160
  lines = builder.build_env.map { |k, v| env_line(k, v) }
154
161
  lines << env_line("CC", env_or_makefile_config("CC"))
162
+ lines << env_line("CXX", env_or_makefile_config("CXX"))
155
163
  lines << env_line("AR", env_or_makefile_config("AR")) unless env_or_makefile_config("AR") == "libtool -static"
156
164
  lines.compact.join("\n")
157
165
  end
@@ -173,6 +181,45 @@ module RbSys
173
181
  cargo_command.gsub!(%r{/#{target_dir}/[^/]+}, "/$(RB_SYS_CARGO_BUILD_TARGET_DIR)/$(RB_SYS_CARGO_PROFILE_DIR)")
174
182
  cargo_command
175
183
  end
184
+
185
+ def optional_rust_toolchain(builder)
186
+ <<~MAKE
187
+ RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN ?= #{builder.force_install_rust_toolchain}
188
+
189
+ # Only run if the we are told to explicitly install the Rust toolchain
190
+ ifneq ($(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN),false)
191
+ RB_SYS_RUSTUP_PROFILE ?= minimal
192
+
193
+ # If the user passed true, we assume stable Rust. Otherwise, use what
194
+ # was specified (i.e. RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN=beta)
195
+ ifeq ($(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN),true)
196
+ RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN = stable
197
+ endif
198
+
199
+ # If a $RUST_TARGET is specified (i.e. for rake-compiler-dock), append
200
+ # that to the profile.
201
+ ifeq ($(RUST_TARGET),)
202
+ RB_SYS_DEFAULT_TOOLCHAIN = $(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN)
203
+ else
204
+ RB_SYS_DEFAULT_TOOLCHAIN = $(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN)-$(RUST_TARGET)
205
+ endif
206
+
207
+ export CARGO_HOME ?= $(RB_SYS_BUILD_DIR)/$(RB_SYS_DEFAULT_TOOLCHAIN)/cargo
208
+ export RUSTUP_HOME ?= $(RB_SYS_BUILD_DIR)/$(RB_SYS_DEFAULT_TOOLCHAIN)/rustup
209
+ export PATH := $(CARGO_HOME)/bin:$(RUSTUP_HOME)/bin:$(PATH)
210
+ export RUSTUP_TOOLCHAIN := $(RB_SYS_DEFAULT_TOOLCHAIN)
211
+ export CARGO := $(CARGO_HOME)/bin/cargo
212
+
213
+ $(CARGO):
214
+ \t$(Q) $(MAKEDIRS) $(CARGO_HOME) $(RUSTUP_HOME)
215
+ \tcurl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
216
+ \trustup toolchain install $(RB_SYS_DEFAULT_TOOLCHAIN) --profile $(RB_SYS_RUSTUP_PROFILE)
217
+ \trustup default $(RB_SYS_DEFAULT_TOOLCHAIN)
218
+
219
+ $(DLLIB): $(CARGO)
220
+ endif
221
+ MAKE
222
+ end
176
223
  end
177
224
  end
178
225
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbSys
4
- VERSION = "0.9.18"
4
+ VERSION = "0.9.21"
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.18
4
+ version: 0.9.21
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-06-30 00:00:00.000000000 Z
33
+ date: 2022-07-19 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
@@ -62,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
63
  requirements:
63
64
  - - ">="
64
65
  - !ruby/object:Gem::Version
65
- version: 2.4.0
66
+ version: 2.3.0
66
67
  required_rubygems_version: !ruby/object:Gem::Requirement
67
68
  requirements:
68
69
  - - ">="
metadata.gz.sig CHANGED
Binary file