rb_sys 0.9.42 → 0.9.44

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb891270e825b41d12d8ef69ebf94c9eac8862d6cf1649d23af775bc84f394d2
4
- data.tar.gz: 3cf455c0df0e6498c4117d3c063bd4ccaa05cb6f566fe51d36b7898b552f8aec
3
+ metadata.gz: 7dc7cda8ec0b4b84fe72eafee24aa48c69a8bcded5713fa586baf7b3c076bf31
4
+ data.tar.gz: c714b3f4b84eb780fe1a57315e3d9546ed9202369c880c4fe983f3b435298c4e
5
5
  SHA512:
6
- metadata.gz: f84a703e4194b91120cbeb0968680d8bacd8d4eeabb0f770f94ed00d3056d765b621d46cd89134b1077e72e54bb360594f9df62bab7a2bc676efb07f4931eaa4
7
- data.tar.gz: 5cf5177fd5833d9eba38fc53529b0321d9109b772f59daa84a7d38dc447468c3aade4d8a919488a1a345164ed9589801287a0e4e02513ee9967f219f44bc0457
6
+ metadata.gz: dcb91faa9279bf86c4e057c235a8dcea72faa7870d694441d9dcd35614f5cb4979df1967ca1a8ea49dfc9662daf03799239cf549854ea174eec70f506500c4ab
7
+ data.tar.gz: f92e5fcb836a6b7acf483e5c4afde4809ec1bdd02e57f8d02c97cacfaa8d75423a83c6ebc4fc952449b750f59a886c215482fff389d766ff2b0c9aa91aa97a24
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,7 +1,8 @@
1
1
  module RbSys
2
2
  # A class to build a Ruby gem Cargo. Extracted from `rubygems` gem, with some modifications.
3
3
  class CargoBuilder < Gem::Ext::Builder
4
- attr_accessor :spec, :runner, :profile, :env, :features, :target, :extra_rustc_args, :dry_run, :ext_dir, :extra_rustflags
4
+ attr_accessor :spec, :runner, :env, :features, :target, :extra_rustc_args, :dry_run, :ext_dir, :extra_rustflags
5
+ attr_writer :profile
5
6
 
6
7
  def initialize(spec)
7
8
  require "rubygems/command"
@@ -9,7 +10,7 @@ module RbSys
9
10
 
10
11
  @spec = spec
11
12
  @runner = self.class.method(:run)
12
- @profile = ENV.fetch("RB_SYS_CARGO_BUILD_PROFILE", :release).to_sym
13
+ @profile = ENV.fetch("RB_SYS_CARGO_PROFILE", :release).to_sym
13
14
  @env = {}
14
15
  @features = []
15
16
  @target = ENV["CARGO_BUILD_TARGET"] || ENV["RUST_TARGET"]
@@ -19,6 +20,12 @@ module RbSys
19
20
  @extra_rustflags = []
20
21
  end
21
22
 
23
+ def profile
24
+ return :release if rubygems_invoked?
25
+
26
+ @profile
27
+ end
28
+
22
29
  def build(_extension, dest_path, results, args = [], lib_dir = nil, cargo_dir = Dir.pwd)
23
30
  require "fileutils"
24
31
  require "shellwords"
@@ -243,12 +250,12 @@ module RbSys
243
250
  end
244
251
 
245
252
  def write_deffile(dest_path)
246
- dest_dir = File.dirname(final_extension_path(dest_path))
247
- FileUtils.mkdir_p(dest_dir)
248
- deffile_path = File.join(dest_dir, "#{spec.name}-#{RbConfig::CONFIG["arch"]}.def")
249
- export_prefix = makefile_config("EXPORT_PREFIX") || ""
253
+ deffile_path = File.join(dest_path, "#{spec.name}-#{RbConfig::CONFIG["arch"]}.def")
250
254
 
251
255
  unless dry_run
256
+ FileUtils.mkdir_p(dest_dir)
257
+ export_prefix = makefile_config("EXPORT_PREFIX") || ""
258
+
252
259
  File.open(deffile_path, "w") do |f|
253
260
  f.puts "EXPORTS"
254
261
  f.puts "#{export_prefix.strip}Init_#{spec.name}"
@@ -324,6 +331,10 @@ module RbSys
324
331
  end
325
332
  end
326
333
 
334
+ def rubygems_invoked?
335
+ ENV.key?("SOURCE_DATE_EPOCH")
336
+ end
337
+
327
338
  # Error raised when no cdylib artifact was created
328
339
  class DylibNotFoundError < StandardError
329
340
  def initialize(dir)
data/lib/rb_sys/mkmf.rb CHANGED
@@ -64,7 +64,7 @@ module RbSys
64
64
  #{conditional_assign("SOEXT_PREFIX", "lib", indent: 1)}
65
65
  #{endif_stmt}
66
66
 
67
- #{conditional_assign("RB_SYS_CARGO_PROFILE", builder.profile)}
67
+ #{set_cargo_profile(builder)}
68
68
  #{conditional_assign("RB_SYS_CARGO_FEATURES", builder.features.join(","))}
69
69
  #{conditional_assign("RB_SYS_GLOBAL_RUSTFLAGS", GLOBAL_RUSTFLAGS.join(" "))}
70
70
  #{conditional_assign("RB_SYS_EXTRA_RUSTFLAGS", builder.extra_rustflags.join(" "))}
@@ -84,28 +84,30 @@ module RbSys
84
84
  #{endif_stmt}
85
85
 
86
86
  # Account for sub-directories when using `--target` argument with Cargo
87
+ #{conditional_assign("RB_SYS_CARGO_TARGET_DIR", "target")}
87
88
  #{if_neq_stmt("$(CARGO_BUILD_TARGET)", "")}
88
- #{assign_stmt("RB_SYS_CARGO_BUILD_TARGET_DIR", "target/$(CARGO_BUILD_TARGET)", indent: 1)}
89
+ #{assign_stmt("RB_SYS_FULL_TARGET_DIR", "$(RB_SYS_CARGO_TARGET_DIR)/$(CARGO_BUILD_TARGET)", indent: 1)}
89
90
  #{else_stmt}
90
- #{assign_stmt("RB_SYS_CARGO_BUILD_TARGET_DIR", "target", indent: 1)}
91
+ #{assign_stmt("RB_SYS_FULL_TARGET_DIR", "$(RB_SYS_CARGO_TARGET_DIR)", indent: 1)}
91
92
  #{endif_stmt}
92
93
 
93
94
  target_prefix = #{target_prefix}
94
95
  TARGET_NAME = #{target[/\A\w+/]}
95
96
  TARGET_ENTRY = #{RbConfig::CONFIG["EXPORT_PREFIX"]}Init_$(TARGET_NAME)
96
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
97
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
97
98
  TARGET = #{target}
98
99
  DLLIB = $(TARGET).#{RbConfig::CONFIG["DLEXT"]}
99
- #{conditional_assign("TARGET_DIR", "$(RB_SYS_CARGO_BUILD_TARGET_DIR)")}
100
- RUSTLIBDIR = $(TARGET_DIR)/$(RB_SYS_CARGO_PROFILE_DIR)
100
+ RUSTLIBDIR = $(RB_SYS_FULL_TARGET_DIR)/$(RB_SYS_CARGO_PROFILE_DIR)
101
101
  RUSTLIB = $(RUSTLIBDIR)/$(SOEXT_PREFIX)$(TARGET_NAME).$(SOEXT)
102
102
 
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
103
+ CLEANOBJS = $(RUSTLIBDIR) $(RB_SYS_BUILD_DIR)
104
+ DEFFILE = $(RB_SYS_CARGO_TARGET_DIR)/$(TARGET)-$(arch).def
105
105
  CLEANLIBS = $(DLLIB) $(RUSTLIB) $(DEFFILE)
106
106
 
107
107
  #{base_makefile(srcdir)}
108
108
 
109
+ .PHONY: gemclean
110
+
109
111
  #{if_neq_stmt("$(RB_SYS_VERBOSE)", "")}
110
112
  #{assign_stmt("Q", "$(0=@)", indent: 1)}
111
113
  #{endif_stmt}
@@ -115,10 +117,6 @@ module RbSys
115
117
 
116
118
  FORCE: ;
117
119
 
118
- $(RUSTLIBDIR):
119
- \t$(ECHO) creating target directory \\($(@)\\)
120
- \t$(Q) $(MAKEDIRS) $(RUSTLIBDIR)
121
-
122
120
  #{deffile_definition}
123
121
 
124
122
  #{optional_rust_toolchain(builder)}
@@ -135,7 +133,10 @@ module RbSys
135
133
  \t$(Q) $(MAKEDIRS) $(RUBYARCHDIR)
136
134
  \t$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
137
135
 
138
- install: #{builder.clean_after_install ? "install-so realclean" : "install-so"}
136
+ gemclean:
137
+ \t-$(Q)$(RM_RF) $(CLEANOBJS) $(CLEANFILES) 2> /dev/null || true
138
+
139
+ install: #{builder.clean_after_install ? "install-so gemclean" : "install-so"}
139
140
 
140
141
  all: #{$extout ? "install" : "$(DLLIB)"}
141
142
  MAKE
@@ -184,7 +185,7 @@ module RbSys
184
185
  cargo_command.gsub!(/--profile \w+/, "$(RB_SYS_CARGO_PROFILE_FLAG)")
185
186
  cargo_command.gsub!(%r{--features \S+}, "--features $(RB_SYS_CARGO_FEATURES)")
186
187
  cargo_command.gsub!(%r{--target \S+}, "--target $(CARGO_BUILD_TARGET)")
187
- cargo_command.gsub!(/--target-dir (?:(?!--).)+/, "--target-dir $(TARGET_DIR) ")
188
+ cargo_command.gsub!(/--target-dir (?:(?!--).)+/, "--target-dir $(RB_SYS_CARGO_TARGET_DIR) ")
188
189
  cargo_command
189
190
  end
190
191
 
@@ -194,9 +195,12 @@ module RbSys
194
195
  return unless defined?(EXPORT_PREFIX) && EXPORT_PREFIX
195
196
 
196
197
  @deffile_definition ||= <<~MAKE
197
- $(DEFFILE): $(RUSTLIBDIR)
198
+ $(DEFFILE):
199
+ \t$(ECHO) creating target directory \\($(RUSTLIBDIR)\\)
200
+ \t$(Q) $(MAKEDIRS) $(RUSTLIBDIR)
198
201
  \t$(ECHO) generating $(@)
199
- \t$(Q) ($(COPY) $(srcdir)/$(TARGET).def $@ 2> /dev/null) || (echo EXPORTS && echo $(TARGET_ENTRY)) > $@
202
+ \t$(ECHO) EXPORTS > $@
203
+ \t$(ECHO) $(TARGET_ENTRY) >> $@
200
204
  MAKE
201
205
  end
202
206
 
@@ -238,9 +242,10 @@ module RbSys
238
242
 
239
243
  $(CARGO):
240
244
  \t$(Q) $(MAKEDIRS) $(CARGO_HOME) $(RUSTUP_HOME)
241
- \tcurl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --no-modify-path --profile $(RB_SYS_RUSTUP_PROFILE) --default-toolchain none -y
242
- \trustup toolchain install $(RB_SYS_DEFAULT_TOOLCHAIN) --profile $(RB_SYS_RUSTUP_PROFILE)
243
- \trustup default $(RB_SYS_DEFAULT_TOOLCHAIN)
245
+ \t$(Q) curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --no-modify-path --profile $(RB_SYS_RUSTUP_PROFILE) --default-toolchain none -y
246
+ \t$(Q) rustup toolchain install $(RB_SYS_DEFAULT_TOOLCHAIN) --profile $(RB_SYS_RUSTUP_PROFILE)
247
+ \t$(Q) rustup default $(RB_SYS_DEFAULT_TOOLCHAIN)
248
+ \t$(Q) rustup component add rustfmt
244
249
 
245
250
  $(RUSTLIB): $(CARGO)
246
251
  #{endif_stmt}
@@ -311,6 +316,12 @@ module RbSys
311
316
  "export #{k} := #{v}"
312
317
  end
313
318
  end
319
+
320
+ def set_cargo_profile(builder)
321
+ return assign_stmt("RB_SYS_CARGO_PROFILE", "release") if builder.rubygems_invoked?
322
+
323
+ conditional_assign("RB_SYS_CARGO_PROFILE", builder.profile)
324
+ end
314
325
  end
315
326
  end
316
327
  # rubocop:enable Style/GlobalVars
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbSys
4
- VERSION = "0.9.42"
4
+ VERSION = "0.9.44"
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.42
4
+ version: 0.9.44
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-16 00:00:00.000000000 Z
33
+ date: 2022-11-18 00:00:00.000000000 Z
34
34
  dependencies: []
35
35
  description:
36
36
  email:
metadata.gz.sig CHANGED
Binary file