kar 5 → 6

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: a7d4c9f840a7c81a217588a739049b7088d613bfecb47db8e9c015fa2fa3ad85
4
- data.tar.gz: 26f82de197f880d8c5d8092059edeb995b8572b7fdd621b2627ae62ff2133f98
3
+ metadata.gz: 370a71b352efdc345562491f694552d0450a7eb7bb3b73f4e2f70d89f8ead35d
4
+ data.tar.gz: 04d19c674fdd8afc2d7c588429642c641ec2ea0c431855d1ebc877d7f06f80b4
5
5
  SHA512:
6
- metadata.gz: d8e2ef380327503237a243d1401e262b7f149f6314f56675d02292052487313ab502d7b5a5637cb2a6666cecb33a4c75567ab4707f8f5b4d2e0413aa4ad75e92
7
- data.tar.gz: dc8c7dcd9301f1d6394c934c404df765299e0b3585620f821f8eee096c0f366d58b13a70b8feb12cff16af9bb10aa393c244cf721e69e5bac6223dadf6c273a9
6
+ metadata.gz: ccc1f62a586e54a7d3c4b65181cbee1dac9752c6a59e47379e552da7230913db46f3ff9f6090e16004850898adf0efc1b37f6c06d26cbc37044b84462f8eef1a
7
+ data.tar.gz: f21722ed42367ddb8be79c63bf1b528f1c80fd9cf84fe2e763dc2f7f9df18efffa153afe9d6dfb9adcec80119ad92f53f5609826784b26c610f0427e9492de22
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ # [6] - 2025-11-16
4
+
5
+ * Don't remove compiled files in CargoTask
6
+
3
7
  # [5] - 2025-11-14
4
8
 
5
9
  * Use open-uri for URITask
data/kar.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "kar"
3
- spec.version = "5"
3
+ spec.version = "6"
4
4
  spec.authors = ["Kitaiti Makoto"]
5
5
  spec.email = ["KitaitiMakoto@gmail.com"]
6
6
 
data/lib/kar/cargotask.rb CHANGED
@@ -23,7 +23,7 @@ module Kar
23
23
  file dl_path => [lock_file] + src do |t|
24
24
  results = Results.new
25
25
  begin
26
- Gem::Ext::CargoBuilder.new.build t.source, ".", results, [], lib_dir, File.expand_path(ext_dir)
26
+ CargoBuilder.new.build t.source, ext_dir, results, [], lib_dir, File.expand_path(ext_dir)
27
27
  rescue => error
28
28
  $stderr.puts results unless verbose?
29
29
  fail
@@ -111,5 +111,56 @@ module Kar
111
111
  Rake.verbose == true
112
112
  end
113
113
  end
114
+
115
+ class CargoBuilder < Gem::Ext::CargoBuilder
116
+ # Original Gem::Ext::CargoBuilder removes compiled files after installation.
117
+ # It is ideal for installation, but not for development.
118
+ # We override the behavior to keep the compiled files.
119
+ def build(extension, dest_path, results, args = [], lib_dir = nil, cargo_dir = Dir.pwd,
120
+ target_rbconfig=Gem.target_rbconfig)
121
+ require "tempfile"
122
+ require "fileutils"
123
+
124
+ if target_rbconfig.path
125
+ warn "--target-rbconfig is not yet supported for Rust extensions. Ignoring"
126
+ end
127
+
128
+ # Where's the Cargo.toml of the crate we're building
129
+ cargo_toml = File.join(cargo_dir, "Cargo.toml")
130
+ # What's the crate's name
131
+ crate_name = cargo_crate_name(cargo_dir, cargo_toml, results)
132
+
133
+ # Run the build
134
+ cmd = cargo_command(cargo_toml, cargo_dir, args, crate_name)
135
+ runner.call(cmd, results, "cargo", cargo_dir, build_env)
136
+
137
+ # Where do we expect Cargo to write the compiled library
138
+ dylib_path = cargo_dylib_path(cargo_dir, crate_name)
139
+
140
+ # Helpful error if we didn't find the compiled library
141
+ raise DylibNotFoundError, cargo_dir unless File.exist?(dylib_path)
142
+
143
+ # Cargo and Ruby differ on how the library should be named, rename from
144
+ # what Cargo outputs to what Ruby expects
145
+ dlext_name = "#{crate_name}.#{makefile_config("DLEXT")}"
146
+ dlext_path = File.join(File.dirname(dylib_path), dlext_name)
147
+ FileUtils.cp(dylib_path, dlext_path)
148
+
149
+ nesting = extension_nesting(extension)
150
+
151
+ if Gem.install_extension_in_lib && lib_dir
152
+ nested_lib_dir = File.join(lib_dir, nesting)
153
+ FileUtils.mkdir_p nested_lib_dir
154
+ FileUtils.cp_r dlext_path, nested_lib_dir, remove_destination: true
155
+ end
156
+
157
+ # move to final destination
158
+ nested_dest_path = File.join(dest_path, nesting)
159
+ FileUtils.mkdir_p nested_dest_path
160
+ FileUtils.cp_r dlext_path, nested_dest_path, remove_destination: true
161
+
162
+ results
163
+ end
164
+ end
114
165
  end
115
166
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kar
3
3
  version: !ruby/object:Gem::Version
4
- version: '5'
4
+ version: '6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kitaiti Makoto