rb_sys 0.9.1 → 0.9.4

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: b22b7aeab8b1c9d4e6ad7225f110ad9274594ac53bf1b6284421bb9728d6cdb2
4
- data.tar.gz: d14f49223946ead201af5b97ab3bf872924da318427762db28939201cca10248
3
+ metadata.gz: 5f361cdc09e131225d1dc35bfd79a391df71665264e674da09b4122a0bee7096
4
+ data.tar.gz: b2bcbcf45a0f555aaee12136e79b756a3ab12d6daf8504d8a571d3382c1483b5
5
5
  SHA512:
6
- metadata.gz: '049e3e24630545530e01983ab43288e992e73cfcc74e8b2f070735ece4aa3b1e5488a5fc473410c6539f00d162e8366c0b7aebde3bbda2cdf57f579a6d684f18'
7
- data.tar.gz: 979ba1c4c4faf11316f576ea1ec103c244bb20dcca42a13e0e23cf7b886e5f249bb8169a14b6bcf2cf22aedf121b53a9e96a6068e6e6432e873924714f6368ae
6
+ metadata.gz: 7277d6b439a9d319d6b380118544f65706c858f54504922014990c68763c77407cd05310453266c945e6db18efa0827322b1721575d01f32f1b80074bd58339d
7
+ data.tar.gz: 7c2454a9bb3ccf632a696b2ad92c28d7cbda213946fbab32addc87b8237e9f317d2d4ddddb31b024d4a721bf59d1d07e286f0341709b6f24cf813da67d4db36a
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
3
+ attr_accessor :spec, :runner, :profile, :env, :features, :target, :extra_rustc_args, :dry_run
4
4
 
5
5
  def initialize(spec)
6
6
  require "rubygems/command"
@@ -13,6 +13,7 @@ module RbSys
13
13
  @features = []
14
14
  @target = ENV["CARGO_BUILD_TARGET"]
15
15
  @extra_rustc_args = []
16
+ @dry_run = true
16
17
  end
17
18
 
18
19
  def build(_extension, dest_path, results, args = [], lib_dir = nil, cargo_dir = Dir.pwd)
@@ -52,7 +53,6 @@ module RbSys
52
53
  cmd += ["--manifest-path", manifest]
53
54
  cmd += ["--lib"]
54
55
  cmd += ["--profile", profile.to_s]
55
- cmd += ["--locked"] if profile.to_s == "release"
56
56
  cmd += Gem::Command.build_args
57
57
  cmd += args
58
58
  cmd += ["--"]
@@ -217,9 +217,11 @@ module RbSys
217
217
  deffile_path = File.join(dest_dir, "#{spec.name}-#{RbConfig::CONFIG["arch"]}.def")
218
218
  export_prefix = makefile_config("EXPORT_PREFIX") || ""
219
219
 
220
- File.open(deffile_path, "w") do |f|
221
- f.puts "EXPORTS"
222
- f.puts "#{export_prefix.strip}Init_#{spec.name}"
220
+ unless dry_run
221
+ File.open(deffile_path, "w") do |f|
222
+ f.puts "EXPORTS"
223
+ f.puts "#{export_prefix.strip}Init_#{spec.name}"
224
+ end
223
225
  end
224
226
 
225
227
  deffile_path
data/lib/rb_sys/mkmf.rb CHANGED
@@ -25,7 +25,7 @@ module RbSys
25
25
  # . create_rust_makefile("my_extension") do |r|
26
26
  # . # All of these are optional
27
27
  # . r.env = { 'FOO' => 'bar' }
28
- # . r.profile = ENV.fetch('CARGO_BUILD_PROFILE', :dev).to_sym
28
+ # . r.profile = ENV.fetch('RB_SYS_CARGO_PROFILE', :dev).to_sym
29
29
  # . r.features = %w[some_cargo_feature]
30
30
  # . end
31
31
  def create_rust_makefile(target, srcprefix = nil, &blk)
@@ -45,36 +45,58 @@ module RbSys
45
45
  RbConfig.expand(srcdir = srcprefix.dup)
46
46
 
47
47
  full_cargo_command = cargo_command(srcdir, builder)
48
- gsub_cargo_command!(full_cargo_command, builder: builder)
49
48
 
50
49
  # rubocop:disable Style/GlobalVars
51
- make_install = <<~MAKE
50
+ make_install = +<<~MAKE
52
51
  RB_SYS_CARGO_PROFILE ?= #{builder.profile}
53
52
  RB_SYS_CARGO_FEATURES ?= #{builder.features.join(",")}
53
+ CARGO ?= cargo
54
+
55
+ ifeq ($(RB_SYS_CARGO_PROFILE),dev)
56
+ RB_SYS_TARGET_DIR ?= debug
57
+ else
58
+ RB_SYS_TARGET_DIR ?= $(RB_SYS_CARGO_PROFILE)
59
+ endif
60
+
54
61
  target_prefix = #{target_prefix}
55
- CLEANLIBS = $(RUSTLIB) $(DLLIB)
62
+ TARGET_NAME = #{target[/\A\w+/]}
63
+ TARGET_ENTRY = #{RbConfig::CONFIG["EXPORT_PREFIX"]}Init_$(TARGET_NAME)
64
+ CLEANLIBS = $(RUSTLIB) $(DLLIB) $(DEFFILE)
56
65
  DISTCLEANDIRS = target/
57
66
  RUBYARCHDIR = $(sitearchdir)$(target_prefix)
58
67
  RUSTLIB = #{dllib_path(builder)}
59
68
  TARGET = #{target}
60
69
  DLLIB = $(TARGET).#{RbConfig::CONFIG["DLEXT"]}
61
-
70
+ TARGET_DIR = #{Dir.pwd}/target/$(RB_SYS_TARGET_DIR)
71
+ DEFFILE = $(TARGET_DIR)/$(TARGET)-$(arch).def
62
72
  #{base_makefile(srcdir)}
63
-
64
73
  #{env_vars(builder)}
65
74
 
66
75
  FORCE: ;
67
76
 
68
- $(DLLIB): FORCE
69
- \t#{full_cargo_command}
70
- \t$(COPY) "$(RUSTLIB)" $@
77
+ $(TARGET_DIR):
78
+ \t$(ECHO) creating target directory \\($(@)\\)
79
+ \t$(Q) $(MAKEDIRS) $(TARGET_DIR)
80
+
81
+ $(DEFFILE): $(TARGET_DIR)
82
+ \t$(ECHO) generating $(@)
83
+ \t$(Q) ($(COPY) $(srcdir)/$(TARGET).def $@ 2> /dev/null) || (echo EXPORTS && echo $(TARGET_ENTRY)) > $@
84
+
85
+ $(DLLIB): $(DEFFILE) FORCE
86
+ \t$(ECHO) generating $(@) \\("$(RB_SYS_CARGO_PROFILE)"\\)
87
+ \t$(Q) #{full_cargo_command}
88
+ \t$(Q) $(COPY) "$(RUSTLIB)" $@
71
89
 
72
90
  install: $(DLLIB) Makefile
73
- \t$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
91
+ \t$(ECHO) installing $(DLLIB)
92
+ \t$(Q) $(MAKEDIRS) $(RUBYARCHDIR)
93
+ \t$(Q) $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
74
94
 
75
95
  all: #{$extout ? "install" : "$(DLLIB)"}
76
96
  MAKE
77
97
 
98
+ gsub_cargo_command!(make_install, builder: builder)
99
+
78
100
  File.write("Makefile", make_install)
79
101
  end
80
102
  # rubocop:enable Style/GlobalVars
@@ -93,7 +115,7 @@ module RbSys
93
115
  dest_path = File.join(Dir.pwd, "target")
94
116
  args = []
95
117
  cargo_cmd = builder.cargo_command(cargo_dir, dest_path, args)
96
- Shellwords.join(cargo_cmd).gsub("\\=", "=")
118
+ Shellwords.join(cargo_cmd).gsub("\\=", "=").gsub(/\Acargo/, "$(CARGO)")
97
119
  end
98
120
 
99
121
  def env_vars(builder)
@@ -119,6 +141,7 @@ module RbSys
119
141
  def gsub_cargo_command!(cargo_command, builder:)
120
142
  cargo_command.gsub!("--profile #{builder.profile}", "--profile $(RB_SYS_CARGO_PROFILE)")
121
143
  cargo_command.gsub!(%r{--features \S+}, "--features $(RB_SYS_CARGO_FEATURES)")
144
+ cargo_command.gsub!(%r{/target/\w+/}, "/target/$(RB_SYS_TARGET_DIR)/")
122
145
  cargo_command
123
146
  end
124
147
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbSys
4
- VERSION = "0.9.1"
4
+ VERSION = "0.9.4"
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.1
4
+ version: 0.9.4
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-01 00:00:00.000000000 Z
33
+ date: 2022-06-07 00:00:00.000000000 Z
34
34
  dependencies: []
35
35
  description:
36
36
  email:
metadata.gz.sig CHANGED
@@ -1 +1,2 @@
1
- �I�g6J[��c��}����i���S1�*���Ո��Q�u�I�ڴ�ȴ��k�����|�� ˍ�(��H����årqJ��fT����KN��gs�����7�#��++�C{/nЃ2%JA�o���Ä�O 2F�I0�e �$2���<����W � ΁�G�L��I�0�w[l+@��Ż���s�� �7̹= �Oɜ5��W�_��Y�Oyd��[�|)D,���m��#SF���eo;A++���B�
1
+ ��YP%+Y(�'!��MY�@}(���BmT�A���,݃%X:6 ��ݼ���X����30|
2
+ ��/M�S>@9�;���@��r�+-��+f����Fݠ�[.�!��,�ڃ#���N'X�y py�p�mE��2Μ�e �H����#�;�ȫ�D�r��K)�v�Ƨ�@��&n7fw�;��q���SĻ�^���y(�n)��m$�A�����c����|7�!�g�t����R?mi�+�B�#rf�(CAq�E��sI