rb_sys 0.9.30 → 0.9.31

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: cfb92c4965e75453786520f0fb761d7431f219ff506dd3508a8e097ff2e1c07e
4
- data.tar.gz: fabbc5bfefd9f18697e7a4de16a903c2cf81efd6c8c380d9664ad4c7ef772bab
3
+ metadata.gz: f2fbb213df6fbefbf7d3092fc838dd2319055ca539083dc74600dad2341b6b2d
4
+ data.tar.gz: cd8f1e38419a5d4ef11cbd81720a679b82719f3366ff37e0a77b3478346764c2
5
5
  SHA512:
6
- metadata.gz: be115dce5d54c80f53d63b10f01d5d15ad27b8a37b2c505f020d3c0631d2fa7310dc2c605ee90fee5c569d210db433e59d5583a543feb934ffff22f181a9d166
7
- data.tar.gz: 70ac9e78c941eaa864ef47cd6810cd466130a0837b83cf789355fae88c400fa79ce3e85e1ca1c8ab861bfad513dacb234c924df1b76f3aae81511896a64c8a4d
6
+ metadata.gz: cd38f96f8e8cf54d2ef39c7d6570c2344ac4a1da7dcb721e5ddf9a5a7a62fb5f61e9d5d2f603051998de4ff05c2353b3be61adb72a4f56ca9d2348e704bd7536
7
+ data.tar.gz: 4ccbb106c216cc3b9df021dfb5bc586b4c9e20f674a5dcf050081a36926d4482c8917c633324cc9efc2ed6f7f7cc3308302ba26b8b229e1f8ca762e3cf1bd5c1
checksums.yaml.gz.sig CHANGED
Binary file
@@ -132,9 +132,16 @@ module RbSys
132
132
  linker = cc_flag.shift
133
133
  link_args = cc_flag.flat_map { |a| ["-C", "link-arg=#{a}"] }
134
134
 
135
+ return mswin_link_args if linker == "cl"
136
+
135
137
  ["-C", "linker=#{linker}", *link_args]
136
138
  end
137
139
 
140
+ def mswin_link_args
141
+ libruby = ruby_static? ? makefile_config("LIBRUBY_A") : makefile_config("LIBRUBY")
142
+ ["-C", "link-arg=#{libruby}"]
143
+ end
144
+
138
145
  def libruby_args(dest_dir)
139
146
  libs = makefile_config(ruby_static? ? "LIBRUBYARG_STATIC" : "LIBRUBYARG_SHARED")
140
147
  raw_libs = Shellwords.split(libs)
data/lib/rb_sys/mkmf.rb CHANGED
@@ -5,6 +5,7 @@ require "shellwords"
5
5
  require_relative "cargo_builder"
6
6
  require_relative "mkmf/config"
7
7
 
8
+ # rubocop:disable Style/GlobalVars
8
9
  # Root module
9
10
  module RbSys
10
11
  # Helper class for creating Rust Makefiles
@@ -48,42 +49,41 @@ module RbSys
48
49
 
49
50
  full_cargo_command = cargo_command(srcdir, builder)
50
51
 
51
- # rubocop:disable Style/GlobalVars
52
52
  make_install = +<<~MAKE
53
- RB_SYS_BUILD_DIR ?= #{File.join(Dir.pwd, ".rb-sys")}
54
- CARGO ?= cargo
55
- CARGO_BUILD_TARGET ?= #{builder.target}
56
- SOEXT ?= #{builder.so_ext}
53
+ #{conditional_assign("RB_SYS_BUILD_DIR", File.join(Dir.pwd, ".rb-sys"))}
54
+ #{conditional_assign("CARGO", "cargo")}
55
+ #{conditional_assign("CARGO_BUILD_TARGET", builder.target)}
56
+ #{conditional_assign("SOEXT", builder.so_ext)}
57
57
 
58
58
  # Determine the prefix Cargo uses for the lib.
59
- ifneq ($(SOEXT),dll)
60
- SOEXT_PREFIX ?= lib
61
- endif
59
+ #{if_neq_stmt("$(SOEXT)", "dll")}
60
+ #{conditional_assign("SOEXT_PREFIX", "lib", indent: 1)}
61
+ #{endif_stmt}
62
62
 
63
- RB_SYS_CARGO_PROFILE ?= #{builder.profile}
64
- RB_SYS_CARGO_FEATURES ?= #{builder.features.join(",")}
65
- RB_SYS_EXTRA_RUSTFLAGS ?= #{builder.extra_rustflags.join(" ")}
63
+ #{conditional_assign("RB_SYS_CARGO_PROFILE", builder.profile)}
64
+ #{conditional_assign("RB_SYS_CARGO_FEATURES", builder.features.join(","))}
65
+ #{conditional_assign("RB_SYS_EXTRA_RUSTFLAGS", builder.extra_rustflags.join(" "))}
66
66
 
67
67
  # Set dirname for the profile, since the profiles do not directly map to target dir (i.e. dev -> debug)
68
- ifeq ($(RB_SYS_CARGO_PROFILE),dev)
69
- RB_SYS_CARGO_PROFILE_DIR ?= debug
70
- else
71
- RB_SYS_CARGO_PROFILE_DIR ?= $(RB_SYS_CARGO_PROFILE)
72
- endif
68
+ #{if_eq_stmt("$(RB_SYS_CARGO_PROFILE)", "dev")}
69
+ #{conditional_assign("RB_SYS_CARGO_PROFILE_DIR", "debug", indent: 1)}
70
+ #{else_stmt}
71
+ #{conditional_assign("RB_SYS_CARGO_PROFILE_DIR", "$(RB_SYS_CARGO_PROFILE)", indent: 1)}
72
+ #{endif_stmt}
73
73
 
74
74
  # Set the build profile (dev, release, etc.) Compat with Rust 1.51.
75
- ifeq ($(RB_SYS_CARGO_PROFILE),release)
76
- RB_SYS_CARGO_PROFILE_FLAG = --release
77
- else
78
- RB_SYS_CARGO_PROFILE_FLAG = --profile $(RB_SYS_CARGO_PROFILE)
79
- endif
75
+ #{if_eq_stmt("$(RB_SYS_CARGO_PROFILE)", "release")}
76
+ #{assign_stmt("RB_SYS_CARGO_PROFILE_FLAG", "--release", indent: 1)}
77
+ #{else_stmt}
78
+ #{assign_stmt("RB_SYS_CARGO_PROFILE_FLAG", "--profile $(RB_SYS_CARGO_PROFILE)", indent: 1)}
79
+ #{endif_stmt}
80
80
 
81
81
  # Account for sub-directories when using `--target` argument with Cargo
82
- ifneq ($(CARGO_BUILD_TARGET),)
83
- RB_SYS_CARGO_BUILD_TARGET_DIR ?= target/$(CARGO_BUILD_TARGET)
84
- else
85
- RB_SYS_CARGO_BUILD_TARGET_DIR ?= target
86
- endif
82
+ #{if_neq_stmt("$(CARGO_BUILD_TARGET)", "")}
83
+ #{assign_stmt("RB_SYS_CARGO_BUILD_TARGET_DIR", "target/$(CARGO_BUILD_TARGET)", indent: 1)}
84
+ #{else_stmt}
85
+ #{assign_stmt("RB_SYS_CARGO_BUILD_TARGET_DIR", "target", indent: 1)}
86
+ #{endif_stmt}
87
87
 
88
88
  target_prefix = #{target_prefix}
89
89
  TARGET_NAME = #{target[/\A\w+/]}
@@ -100,12 +100,12 @@ module RbSys
100
100
 
101
101
  #{base_makefile(srcdir)}
102
102
 
103
- ifneq ($(RB_SYS_VERBOSE),)
104
- Q = $(0=@)
105
- endif
103
+ #{if_neq_stmt("$(RB_SYS_VERBOSE)", "")}
104
+ #{assign_stmt("Q", "$(0=@)", indent: 1)}
105
+ #{endif_stmt}
106
106
 
107
107
  #{env_vars(builder)}
108
- $(RUSTLIB): export RUSTFLAGS := $(RUSTFLAGS) $(RB_SYS_EXTRA_RUSTFLAGS)
108
+ #{export_env("RUSTFLAGS", "$(RUSTFLAGS) $(RB_SYS_EXTRA_RUSTFLAGS)")}
109
109
 
110
110
  FORCE: ;
111
111
 
@@ -140,7 +140,6 @@ module RbSys
140
140
 
141
141
  File.write("Makefile", make_install)
142
142
  end
143
- # rubocop:enable Style/GlobalVars
144
143
 
145
144
  private
146
145
 
@@ -170,7 +169,7 @@ module RbSys
170
169
 
171
170
  def env_line(k, v)
172
171
  return unless v
173
- %($(RUSTLIB): export #{k} = #{v.gsub("\n", '\n')})
172
+ export_env(k, v.gsub("\n", '\n'))
174
173
  end
175
174
 
176
175
  def env_or_makefile_config(key)
@@ -188,31 +187,31 @@ module RbSys
188
187
 
189
188
  def optional_rust_toolchain(builder)
190
189
  <<~MAKE
191
- RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN ?= #{builder.force_install_rust_toolchain}
190
+ #{conditional_assign("RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN", builder.force_install_rust_toolchain)}
192
191
 
193
192
  # Only run if the we are told to explicitly install the Rust toolchain
194
- ifneq ($(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN),false)
195
- RB_SYS_RUSTUP_PROFILE ?= minimal
193
+ #{if_neq_stmt("$(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN)", "false")}
194
+ #{conditional_assign("RB_SYS_RUSTUP_PROFILE", "minimal")}
196
195
 
197
196
  # If the user passed true, we assume stable Rust. Otherwise, use what
198
197
  # was specified (i.e. RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN=beta)
199
- ifeq ($(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN),true)
198
+ #{if_eq_stmt("$(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN)", "true")}
200
199
  RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN = stable
201
- endif
200
+ #{endif_stmt}
202
201
 
203
202
  # If a $RUST_TARGET is specified (i.e. for rake-compiler-dock), append
204
203
  # that to the profile.
205
- ifeq ($(RUST_TARGET),)
204
+ #{if_eq_stmt("$(RUST_TARGET)", "")}
206
205
  RB_SYS_DEFAULT_TOOLCHAIN = $(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN)
207
- else
206
+ #{else_stmt}
208
207
  RB_SYS_DEFAULT_TOOLCHAIN = $(RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN)-$(RUST_TARGET)
209
- endif
208
+ #{endif_stmt}
210
209
 
211
- export CARGO_HOME ?= $(RB_SYS_BUILD_DIR)/$(RB_SYS_DEFAULT_TOOLCHAIN)/cargo
212
- export RUSTUP_HOME ?= $(RB_SYS_BUILD_DIR)/$(RB_SYS_DEFAULT_TOOLCHAIN)/rustup
213
- export PATH := $(CARGO_HOME)/bin:$(RUSTUP_HOME)/bin:$(PATH)
214
- export RUSTUP_TOOLCHAIN := $(RB_SYS_DEFAULT_TOOLCHAIN)
215
- export CARGO := $(CARGO_HOME)/bin/cargo
210
+ #{conditional_assign("CARGO_HOME", "$(RB_SYS_BUILD_DIR)/$(RB_SYS_DEFAULT_TOOLCHAIN)/cargo", export: true)}
211
+ #{conditional_assign("RUSTUP_HOME", "$(RB_SYS_BUILD_DIR)/$(RB_SYS_DEFAULT_TOOLCHAIN)/rustup", export: true)}
212
+ #{export_env("PATH", "$(CARGO_HOME)/bin:$(RUSTUP_HOME)/bin:$(PATH)")}
213
+ #{export_env("RUSTUP_TOOLCHAIN", "$(RB_SYS_DEFAULT_TOOLCHAIN)")}
214
+ #{export_env("CARGO", "$(CARGO_HOME)/bin/cargo")}
216
215
 
217
216
  $(CARGO):
218
217
  \t$(Q) $(MAKEDIRS) $(CARGO_HOME) $(RUSTUP_HOME)
@@ -221,10 +220,69 @@ module RbSys
221
220
  \trustup default $(RB_SYS_DEFAULT_TOOLCHAIN)
222
221
 
223
222
  $(RUSTLIB): $(CARGO)
224
- endif
223
+ #{endif_stmt}
225
224
  MAKE
226
225
  end
226
+
227
+ def if_eq_stmt(a, b)
228
+ if $nmake
229
+ "!IF #{a.inspect} == #{b.inspect}"
230
+ else
231
+ "ifeq (#{a},#{b})"
232
+ end
233
+ end
234
+
235
+ def if_neq_stmt(a, b)
236
+ if $nmake
237
+ "!IF #{a.inspect} != #{b.inspect}"
238
+ else
239
+ "ifneq (#{a},#{b})"
240
+ end
241
+ end
242
+
243
+ def else_stmt
244
+ if $nmake
245
+ "!ELSE"
246
+ else
247
+ "else"
248
+ end
249
+ end
250
+
251
+ def endif_stmt
252
+ if $nmake
253
+ "!ENDIF"
254
+ else
255
+ "endif"
256
+ end
257
+ end
258
+
259
+ def conditional_assign(a, b, export: false, indent: 0)
260
+ if $nmake
261
+ result = +"!IFNDEF #{a}\n#{a} = #{b}\n!ENDIF\n"
262
+ result << export_env(a, b) if export
263
+ result
264
+ else
265
+ "#{"\t" * indent}#{export ? "export " : ""}#{a} ?= #{b}"
266
+ end
267
+ end
268
+
269
+ def assign_stmt(a, b, indent: 0)
270
+ if $nmake
271
+ "#{a} = #{b}"
272
+ else
273
+ "#{"\t" * indent}#{a} = #{b}"
274
+ end
275
+ end
276
+
277
+ def export_env(k, v)
278
+ if $nmake
279
+ "!if [set #{k}=#{v}]\n!endif"
280
+ else
281
+ "export #{k} := #{v}"
282
+ end
283
+ end
227
284
  end
228
285
  end
286
+ # rubocop:enable Style/GlobalVars
229
287
 
230
288
  include RbSys::Mkmf # rubocop:disable Style/MixinUsage
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbSys
4
- VERSION = "0.9.30"
4
+ VERSION = "0.9.31"
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.30
4
+ version: 0.9.31
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-08-18 00:00:00.000000000 Z
33
+ date: 2022-09-30 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.7
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