kar 0.1.1 → 0.1.3
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 +9 -0
- data/README.md +32 -7
- data/kar.gemspec +1 -5
- data/lib/kar/cargotask.rb +110 -0
- data/lib/kar/dsl.rb +25 -0
- metadata +2 -2
- data/lib/kar/version.rb +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4e88a860068093597ff4434adfe3ff6f5f7f3db2576b66708e0e57d0dc0bb96d
|
|
4
|
+
data.tar.gz: 1949ce09fc44920dbe98c61f2214ee7d81323f60e6a7f22b082068ecaf25b52e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 892276c83f0431711faaf1569154b9ec04e06b7689e34eca638dd55c3d69da91dda5720f9af844f8794755c01e0f3b1dacee5064e00e182a00a8a2e0533607fc
|
|
7
|
+
data.tar.gz: a135684469b46c1b14896faa8f3abdff6a364edde5ec006864bb8bd9bbffac62bacaae26acc8d4cf79e913a91cb09fbd3ef6ae373d237920c005cf2afffe1bf9
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.1.3] - 2025-10-26
|
|
4
|
+
|
|
5
|
+
- Make cargo task to be dependent on Rust source files
|
|
6
|
+
- cargo:validate -> cargo:check
|
|
7
|
+
|
|
8
|
+
## [0.1.2] - 2025-10-26
|
|
9
|
+
|
|
10
|
+
- CargoTask, build extension in Rust
|
|
11
|
+
|
|
3
12
|
## [0.1.1] - 2025-10-24
|
|
4
13
|
|
|
5
14
|
- URITask, handle redirection
|
data/README.md
CHANGED
|
@@ -19,22 +19,47 @@ Usage
|
|
|
19
19
|
|
|
20
20
|
# Rakefile
|
|
21
21
|
require "kar/dsl"
|
|
22
|
+
|
|
23
|
+
### Download task ###
|
|
24
|
+
|
|
25
|
+
It downloads a file and declares file task.
|
|
22
26
|
|
|
23
27
|
download "local/path/to/file" => "https://example.net/remote/path/to/file"
|
|
28
|
+
|
|
29
|
+
### Multiple files task ###
|
|
30
|
+
|
|
31
|
+
It declares multiple file tasks at a time.
|
|
32
|
+
|
|
33
|
+
# Rakefile
|
|
24
34
|
FILES = FileList["fileA", "fileB", "fileC"]
|
|
25
35
|
files FILES
|
|
26
36
|
|
|
37
|
+
### Cargo task ###
|
|
38
|
+
|
|
39
|
+
It declares a cargo task which builds extensions in Rust.
|
|
40
|
+
|
|
41
|
+
# Rakefile
|
|
42
|
+
cargo "my_gem"
|
|
43
|
+
|
|
44
|
+
Run the task:
|
|
45
|
+
|
|
46
|
+
% rake cargo
|
|
47
|
+
|
|
48
|
+
And cargo:check task which checks Rust source files and is useful for dependency of build task.
|
|
49
|
+
|
|
50
|
+
# Rakefile
|
|
51
|
+
task build: "cargo:check"
|
|
52
|
+
|
|
53
|
+
Run the task:
|
|
54
|
+
|
|
55
|
+
% rake build # invokes cargo:checks
|
|
56
|
+
|
|
27
57
|
Development
|
|
28
58
|
-----------
|
|
29
59
|
|
|
30
|
-
To install this gem onto your local machine, run `
|
|
60
|
+
To install this gem onto your local machine, run `rake install`. To release a new version, update the version number in `kar.gemspec`, and then run `rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
31
61
|
|
|
32
62
|
Contributing
|
|
33
63
|
------------
|
|
34
64
|
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://gitlab.com/KitaitiMakoto/kar. This project is intended to be a safe, welcoming space for collaboration
|
|
36
|
-
|
|
37
|
-
Code of Conduct
|
|
38
|
-
---------------
|
|
39
|
-
|
|
40
|
-
Everyone interacting in the Kar project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/KitaitiMakoto/kar/blob/main/CODE_OF_CONDUCT.md).
|
|
65
|
+
Bug reports and pull requests are welcome on GitHub at https://gitlab.com/KitaitiMakoto/kar. This project is intended to be a safe, welcoming space for collaboration.
|
data/kar.gemspec
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "lib/kar/version"
|
|
4
|
-
|
|
5
1
|
Gem::Specification.new do |spec|
|
|
6
2
|
spec.name = "kar"
|
|
7
|
-
spec.version =
|
|
3
|
+
spec.version = "0.1.3"
|
|
8
4
|
spec.authors = ["Kitaiti Makoto"]
|
|
9
5
|
spec.email = ["KitaitiMakoto@gmail.com"]
|
|
10
6
|
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
require "rake/clean"
|
|
2
|
+
require "rubygems/ext"
|
|
3
|
+
require "json"
|
|
4
|
+
require "shellwords"
|
|
5
|
+
require "stringio"
|
|
6
|
+
|
|
7
|
+
module Kar
|
|
8
|
+
class CargoTask < Rake::TaskLib
|
|
9
|
+
def initialize(target)
|
|
10
|
+
@target = target
|
|
11
|
+
|
|
12
|
+
define
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def verbose?
|
|
18
|
+
Rake.verbose == true
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def define
|
|
22
|
+
file dl_path => [manifest, lock_file] + src do |t|
|
|
23
|
+
results = Results.new
|
|
24
|
+
begin
|
|
25
|
+
Gem::Ext::CargoBuilder.new.build t.source, ".", results, [], lib_dir, File.expand_path(ext_dir)
|
|
26
|
+
rescue => error
|
|
27
|
+
$stderr.puts results unless verbose?
|
|
28
|
+
fail
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
CLEAN.include dl_name, dl_path
|
|
32
|
+
|
|
33
|
+
namespace :cargo do
|
|
34
|
+
task @target => dl_path
|
|
35
|
+
|
|
36
|
+
# TODO: Consider the case `target` is "check"
|
|
37
|
+
namespace :check do
|
|
38
|
+
task @target => manifest do |t|
|
|
39
|
+
sh "cargo", "check", "--manifest-path", manifest.shellescape, "--locked", "--quiet"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
desc "Check Rust sources and manifests"
|
|
44
|
+
task check: "cargo:check:#{@target}"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
desc "Build all extensions in Rust"
|
|
48
|
+
task cargo: "cargo:#{@target}"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def gemspec
|
|
52
|
+
@gemspec ||= Gem::Specification.load("#{@target}.gemspec")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def manifest
|
|
56
|
+
@manifest ||= gemspec.extensions.first
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def lock_file
|
|
60
|
+
@lock_file ||= manifest.ext(".lock")
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def ext_dir
|
|
64
|
+
@ext_dir ||= File.dirname(manifest)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def lib_dir
|
|
68
|
+
# When a gem include an extension, the first element of require_paths is the directory for extensions and the second is for Ruby files.
|
|
69
|
+
@lib_dir ||= gemspec.require_paths[1]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def dl_name
|
|
73
|
+
@dl_name ||= "#{gemspec.name}.#{RbConfig::CONFIG["DLEXT"]}"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def dl_path
|
|
77
|
+
@dl_path ||= File.join(lib_dir, dl_name)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def src
|
|
81
|
+
@src ||= FileList["#{ext_dir}/src/**/*.rs"]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
class Results
|
|
85
|
+
def initialize
|
|
86
|
+
@io = verbose? ? $stdout : StringIO.new
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def <<(output)
|
|
90
|
+
# Always break a line even when output isn't terminated by a line break
|
|
91
|
+
@io.puts output
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def to_s
|
|
95
|
+
if verbose?
|
|
96
|
+
""
|
|
97
|
+
else
|
|
98
|
+
@io.rewind
|
|
99
|
+
@io.read
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
private
|
|
104
|
+
|
|
105
|
+
def verbose?
|
|
106
|
+
Rake.verbose == true
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
data/lib/kar/dsl.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "kar/uritask"
|
|
2
|
+
require "kar/cargotask"
|
|
2
3
|
|
|
3
4
|
module Kar
|
|
4
5
|
# DSLs you can use in your Rakefiles
|
|
@@ -18,6 +19,9 @@ module Kar
|
|
|
18
19
|
#
|
|
19
20
|
# # Downloads file from https://example.com/remote/file and save to local/file
|
|
20
21
|
# download "local/file" => "https://example.org/remote/file"
|
|
22
|
+
#
|
|
23
|
+
# # Build extension in Rust
|
|
24
|
+
# cargo "my_gem"
|
|
21
25
|
module DSL
|
|
22
26
|
def files(file_list)
|
|
23
27
|
file_list.each do |file_name|
|
|
@@ -46,6 +50,27 @@ module Kar
|
|
|
46
50
|
URITask.new args
|
|
47
51
|
end
|
|
48
52
|
|
|
53
|
+
# Declare a cargo task which builds extension in Rust by Cargo.
|
|
54
|
+
#
|
|
55
|
+
# @example
|
|
56
|
+
# # Rakefile
|
|
57
|
+
# cargo "my_gem"
|
|
58
|
+
#
|
|
59
|
+
# task build: "cargo:check"
|
|
60
|
+
#
|
|
61
|
+
# # shell
|
|
62
|
+
# % rake cargo
|
|
63
|
+
#
|
|
64
|
+
# Also defines a cargo:check task which check sources and manifests.
|
|
65
|
+
# It's useful to add them to the dependency of build task and prevent building invalid gem package.
|
|
66
|
+
#
|
|
67
|
+
# Uses {https://docs.ruby-lang.org/en/master/Gem/Ext/CargoBuilder.html Gem::Ext::CargoBuilder} internally unlike {https://oxidize-rb.org/docs/api-reference/rb-sys-gem-config#rbsysextensiontask RbSys::ExtensionTask}
|
|
68
|
+
# in order to build in the same way as `gem install` command, even though the output might be less usefull.
|
|
69
|
+
# When `RbSys::Extension` uses the same way, this function may be deprecated.
|
|
70
|
+
def cargo(target)
|
|
71
|
+
CargoTask.new target
|
|
72
|
+
end
|
|
73
|
+
|
|
49
74
|
Rake::DSL.prepend self
|
|
50
75
|
end
|
|
51
76
|
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: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kitaiti Makoto
|
|
@@ -80,9 +80,9 @@ files:
|
|
|
80
80
|
- agpl-3.0.txt
|
|
81
81
|
- kar.gemspec
|
|
82
82
|
- lib/kar.rb
|
|
83
|
+
- lib/kar/cargotask.rb
|
|
83
84
|
- lib/kar/dsl.rb
|
|
84
85
|
- lib/kar/uritask.rb
|
|
85
|
-
- lib/kar/version.rb
|
|
86
86
|
- sig/kar.rbs
|
|
87
87
|
homepage: https://gitlab.com/KitaitiMakoto/kar
|
|
88
88
|
licenses:
|