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 +4 -4
- data/CHANGELOG.md +4 -0
- data/kar.gemspec +1 -1
- data/lib/kar/cargotask.rb +52 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 370a71b352efdc345562491f694552d0450a7eb7bb3b73f4e2f70d89f8ead35d
|
|
4
|
+
data.tar.gz: 04d19c674fdd8afc2d7c588429642c641ec2ea0c431855d1ebc877d7f06f80b4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ccc1f62a586e54a7d3c4b65181cbee1dac9752c6a59e47379e552da7230913db46f3ff9f6090e16004850898adf0efc1b37f6c06d26cbc37044b84462f8eef1a
|
|
7
|
+
data.tar.gz: f21722ed42367ddb8be79c63bf1b528f1c80fd9cf84fe2e763dc2f7f9df18efffa153afe9d6dfb9adcec80119ad92f53f5609826784b26c610f0427e9492de22
|
data/CHANGELOG.md
CHANGED
data/kar.gemspec
CHANGED
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
|
-
|
|
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
|