kar 6 → 7

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: 370a71b352efdc345562491f694552d0450a7eb7bb3b73f4e2f70d89f8ead35d
4
- data.tar.gz: 04d19c674fdd8afc2d7c588429642c641ec2ea0c431855d1ebc877d7f06f80b4
3
+ metadata.gz: c6cc9802cffd2ecc1ca9fc94c7ebabf115c71d22132a8bb94c1c39bd84f0900f
4
+ data.tar.gz: bd16c3e09c21a9fdb9237522b545a20c54b848e466bac889223bdfb0e8ccfd50
5
5
  SHA512:
6
- metadata.gz: ccc1f62a586e54a7d3c4b65181cbee1dac9752c6a59e47379e552da7230913db46f3ff9f6090e16004850898adf0efc1b37f6c06d26cbc37044b84462f8eef1a
7
- data.tar.gz: f21722ed42367ddb8be79c63bf1b528f1c80fd9cf84fe2e763dc2f7f9df18efffa153afe9d6dfb9adcec80119ad92f53f5609826784b26c610f0427e9492de22
6
+ metadata.gz: 43aba430a63678a560a0a454cc405b74b0d7d67e41bc986b7c94423cf51963c8831c32792cdd35f006ca9fc3cbe38a4ed470eebf69eef652ea0c3ea012c4cb9d
7
+ data.tar.gz: 5c71e60f1dc1fab01e00093e56025072757817aac1bbe33cde21e9be677770034bfcee5fb06871172cff37be73d5e45d2414d0ebac3f7d092782dfe87f35dca7
data/CHANGELOG.md CHANGED
@@ -1,10 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
- # [6] - 2025-11-16
3
+ ## [7] - 2026-08-11
4
+
5
+ * Fix installation path of Cargo built file of CargoTask
6
+
7
+ ## [6] - 2025-11-16
4
8
 
5
9
  * Don't remove compiled files in CargoTask
6
10
 
7
- # [5] - 2025-11-14
11
+ ## [5] - 2025-11-14
8
12
 
9
13
  * Use open-uri for URITask
10
14
  * Add Cargo.lock generate task in CargoTask
data/kar.gemspec CHANGED
@@ -1,11 +1,11 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "kar"
3
- spec.version = "6"
3
+ spec.version = "7"
4
4
  spec.authors = ["Kitaiti Makoto"]
5
5
  spec.email = ["KitaitiMakoto@gmail.com"]
6
6
 
7
7
  spec.summary = "Rake utilities"
8
- spec.description = "Rake utilities such as task to download, DSL to define multiple tasks at onece, etc."
8
+ spec.description = "Rake utilities such as task to download, DSL to define multiple tasks at once, etc."
9
9
  spec.homepage = "https://gitlab.com/KitaitiMakoto/kar"
10
10
  spec.required_ruby_version = ">= 2.6.0"
11
11
  spec.license = "AGPL-3.0-or-later"
@@ -0,0 +1,67 @@
1
+ class Kar::CargoTask::CargoBuilder < Gem::Ext::CargoBuilder
2
+ # Original Gem::Ext::CargoBuilder removes compiled files after installation.
3
+ # It is ideal for installation, but not for development.
4
+ # We override the behavior to keep the compiled files.
5
+ def build(extension, dest_path, results, args = [], lib_dir = nil, cargo_dir = Dir.pwd,
6
+ target_rbconfig = Gem.target_rbconfig, n_jobs: nil)
7
+ require "tempfile"
8
+ require "fileutils"
9
+
10
+ if target_rbconfig.path
11
+ warn "--target-rbconfig is not yet supported for Rust extensions. Ignoring"
12
+ end
13
+
14
+ # Where's the Cargo.toml of the crate we're building
15
+ cargo_toml = File.join(cargo_dir, "Cargo.toml")
16
+ # What's the crate's name
17
+ crate_name = cargo_crate_name(cargo_dir, cargo_toml, results)
18
+
19
+ begin
20
+ # Mimic tmp_dest to make diff with superclass's #build clean
21
+ tmp_dest = cargo_dir
22
+
23
+ # Run the build
24
+ cmd = cargo_command(cargo_toml, tmp_dest, args, crate_name)
25
+ runner.call(cmd, results, "cargo", cargo_dir, build_env)
26
+
27
+ # Where do we expect Cargo to write the compiled library
28
+ dylib_path = cargo_dylib_path(tmp_dest, crate_name)
29
+
30
+ # Helpful error if we didn't find the compiled library
31
+ raise DylibNotFoundError, tmp_dest unless File.exist?(dylib_path)
32
+
33
+ # Cargo and Ruby differ on how the library should be named, rename from
34
+ # what Cargo outputs to what Ruby expects
35
+ dlext_name = "#{crate_name}.#{makefile_config("DLEXT")}"
36
+ dlext_path = File.join(File.dirname(dylib_path), dlext_name)
37
+ FileUtils.cp(dylib_path, dlext_path)
38
+
39
+ nesting = extension_nesting(extension)
40
+
41
+ if Gem.install_extension_in_lib && lib_dir
42
+ nested_lib_dir = File.join(lib_dir, nesting)
43
+ FileUtils.mkdir_p nested_lib_dir
44
+ FileUtils.cp_r dlext_path, nested_lib_dir, remove_destination: true
45
+ end
46
+
47
+ # move to final destination
48
+ nested_dest_path = File.join(dest_path, nesting)
49
+ FileUtils.mkdir_p nested_dest_path
50
+ FileUtils.cp_r dlext_path, nested_dest_path, remove_destination: true
51
+ ensure
52
+ #noop
53
+ end
54
+
55
+ results
56
+ end
57
+
58
+ # This intentionally duplicates part of #build to keep that method close to
59
+ # the upstream CargoBuilder implementation and make updates easy to review with diff.
60
+ def dl_path(extension, dest_path, cargo_dir)
61
+ cargo_toml = File.join(cargo_dir, "Cargo.toml")
62
+ crate_name = cargo_crate_name(cargo_dir, cargo_toml, [])
63
+ dlext_name = "#{crate_name}.#{makefile_config("DLEXT")}"
64
+ nesting = extension_nesting(extension)
65
+ File.join(dest_path, nesting, dlext_name)
66
+ end
67
+ end
data/lib/kar/cargotask.rb CHANGED
@@ -23,13 +23,13 @@ module Kar
23
23
  file dl_path => [lock_file] + src do |t|
24
24
  results = Results.new
25
25
  begin
26
- CargoBuilder.new.build t.source, ext_dir, results, [], lib_dir, File.expand_path(ext_dir)
26
+ builder.build manifest, lib_dir, results, [], nil, cargo_dir
27
27
  rescue => error
28
28
  $stderr.puts results unless verbose?
29
29
  fail
30
30
  end
31
31
  end
32
- CLEAN.include dl_name, dl_path
32
+ CLEAN.include dl_path
33
33
 
34
34
  file lock_file => manifest do |t|
35
35
  sh "cargo", "generate-lockfile", "--manifest-path", t.source
@@ -53,6 +53,10 @@ module Kar
53
53
  task cargo: "cargo:#{@target}"
54
54
  end
55
55
 
56
+ def builder
57
+ @builder ||= CargoBuilder.new
58
+ end
59
+
56
60
  def gemspec
57
61
  @gemspec ||= Gem::Specification.load("#{@target}.gemspec")
58
62
  end
@@ -65,6 +69,10 @@ module Kar
65
69
  @lock_file ||= manifest.ext(".lock")
66
70
  end
67
71
 
72
+ def cargo_dir
73
+ @cargo_dir ||= File.expand_path(ext_dir)
74
+ end
75
+
68
76
  def ext_dir
69
77
  @ext_dir ||= File.dirname(manifest)
70
78
  end
@@ -74,16 +82,12 @@ module Kar
74
82
  @lib_dir ||= gemspec.require_paths[1]
75
83
  end
76
84
 
77
- def dl_name
78
- @dl_name ||= "#{gemspec.name}.#{RbConfig::CONFIG["DLEXT"]}"
79
- end
80
-
81
85
  def dl_path
82
- @dl_path ||= File.join(lib_dir, dl_name)
86
+ @dl_path ||= builder.dl_path(manifest, lib_dir, cargo_dir)
83
87
  end
84
88
 
85
89
  def src
86
- @src ||= FileList["#{ext_dir}/src/**/*.rs"]
90
+ @src ||= FileList["#{ext_dir}/src/**/*.rs", "#{ext_dir}/build.rs"]
87
91
  end
88
92
 
89
93
  class Results
@@ -111,56 +115,7 @@ module Kar
111
115
  Rake.verbose == true
112
116
  end
113
117
  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
165
118
  end
166
119
  end
120
+
121
+ require_relative "cargotask/cargo_builder"
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: '6'
4
+ version: '7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kitaiti Makoto
@@ -66,7 +66,7 @@ dependencies:
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  description: Rake utilities such as task to download, DSL to define multiple tasks
69
- at onece, etc.
69
+ at once, etc.
70
70
  email:
71
71
  - KitaitiMakoto@gmail.com
72
72
  executables: []
@@ -80,6 +80,7 @@ files:
80
80
  - kar.gemspec
81
81
  - lib/kar.rb
82
82
  - lib/kar/cargotask.rb
83
+ - lib/kar/cargotask/cargo_builder.rb
83
84
  - lib/kar/dsl.rb
84
85
  - lib/kar/uritask.rb
85
86
  - sig/kar.rbs
@@ -104,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  - !ruby/object:Gem::Version
105
106
  version: '0'
106
107
  requirements: []
107
- rubygems_version: 3.7.2
108
+ rubygems_version: 4.0.16
108
109
  specification_version: 4
109
110
  summary: Rake utilities
110
111
  test_files: []