steep-picoruby 0.1.0
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 +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +138 -0
- data/Rakefile +12 -0
- data/lib/steep/picoruby/dependency_checker.rb +37 -0
- data/lib/steep/picoruby/library_options_ext.rb +37 -0
- data/lib/steep/picoruby/version.rb +7 -0
- data/lib/steep/picoruby.rb +17 -0
- data/sig/steep/picoruby.rbs +6 -0
- metadata +65 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 86e760b6bf31ec9ddc4b5f2d9d7b5cf59c7739bcf27d1492c4bf227dd2642072
|
|
4
|
+
data.tar.gz: ece76834cb7d7c6cff20b03ba3ae6054c81c73675fb745e0f0d01c0017cbe71a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a0241d499f8714dd265c132c397db1c3811ca5f52e80f15d8956c751c18161b903ee6d235c60b10016511bfcc53e14a071cf640ab4055ea40cf1d38075798d07
|
|
7
|
+
data.tar.gz: 8bfa5443f41cda24c320d59ca2528d5abb2a64d7097fffd38045d0e4d3713655d9b3788b3adb90be2dc83921595791e017d20526bbc42c2bcd15465f98c6581c
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Masataka Pocke Kuwabara
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Steep::PicoRuby
|
|
2
|
+
|
|
3
|
+
A Steep extension to load RBS files for PicoRuby gems.
|
|
4
|
+
|
|
5
|
+
This gem supports introducing Steep into an application written in PicoRuby.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install the gem and add to the application's Gemfile by executing:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bundle add steep-picoruby
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
gem install steep-picoruby
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
This gem adds `picoruby_library` method for `Steepfile`.
|
|
24
|
+
|
|
25
|
+
It requires the [picoruby/picoruby](https://github.com/picoruby/picoruby) repository and a build config file that determines what gems your application depends on.
|
|
26
|
+
Execute the following commands if you haven't downloaded the PicoRuby repository yet.
|
|
27
|
+
|
|
28
|
+
```console
|
|
29
|
+
$ mkdir lib
|
|
30
|
+
$ git clone --recurse-submodules https://github.com/picoruby/picoruby lib/picoruby
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
# Steepfile
|
|
35
|
+
|
|
36
|
+
require 'steep/picoruby'
|
|
37
|
+
|
|
38
|
+
target :lib do
|
|
39
|
+
picoruby_library(
|
|
40
|
+
target: 'my_app',
|
|
41
|
+
picoruby_root: 'path/to/picoruby/picoruby',
|
|
42
|
+
build_config: 'path/to/your/build_config/my_app.rb',
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# General type checking settings
|
|
46
|
+
check 'mrblib'
|
|
47
|
+
signature 'sig'
|
|
48
|
+
end
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The arguments of `picoruby_library`:
|
|
52
|
+
|
|
53
|
+
| name | type | description | default |
|
|
54
|
+
| --- | --- | --- | --- |
|
|
55
|
+
| `target` | `String | Array[String]` | The build name defined in the build config file | All existing targets |
|
|
56
|
+
| `picoruby_root` | `String | Pathname` | The file path of PicoRuby repository | `"lib/picoruby"` |
|
|
57
|
+
| `build_config` | `String | Pathname | Array[String | Pathname]` | The file path of your build config | `Pathname.glob("build_config/*.rb")` |
|
|
58
|
+
|
|
59
|
+
## Examples
|
|
60
|
+
|
|
61
|
+
These examples require that PicoRuby repository is cloned into `lib/picoruby/`.
|
|
62
|
+
|
|
63
|
+
### For app on R2P2
|
|
64
|
+
|
|
65
|
+
```ruby
|
|
66
|
+
# Steepfile
|
|
67
|
+
|
|
68
|
+
require 'steep/picoruby'
|
|
69
|
+
|
|
70
|
+
target :lib do
|
|
71
|
+
picoruby_library(
|
|
72
|
+
target: 'r2p2-picoruby-pico2',
|
|
73
|
+
build_config: 'lib/picoruby/build_config/r2p2-picoruby-pico2.rb',
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
# General type checking settings
|
|
77
|
+
check 'mrblib'
|
|
78
|
+
signature 'sig'
|
|
79
|
+
end
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
You need to change the setting if your app assumes a different environment, such as FemtoRuby or Pico W.
|
|
83
|
+
|
|
84
|
+
### Several targets
|
|
85
|
+
|
|
86
|
+
You can use several RBS environments. For example: application code and test code.
|
|
87
|
+
|
|
88
|
+
This example requires the following `build_config` files.
|
|
89
|
+
|
|
90
|
+
```console
|
|
91
|
+
$ cat build_config/my-app.rb
|
|
92
|
+
MRuby::CrossBuild.new("my-app") do |conf|
|
|
93
|
+
# ...
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
$ cat build_config/picotest-host.rb
|
|
97
|
+
MRuby::Build.new do |conf|
|
|
98
|
+
# ...
|
|
99
|
+
end
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```ruby
|
|
103
|
+
# Steepfile
|
|
104
|
+
|
|
105
|
+
require 'steep/picoruby'
|
|
106
|
+
|
|
107
|
+
target :lib do
|
|
108
|
+
# It only loads type signatures for application code
|
|
109
|
+
picoruby_library target: 'my_app'
|
|
110
|
+
|
|
111
|
+
signature "sig"
|
|
112
|
+
check 'mrblib'
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
target :test do
|
|
116
|
+
# It loads both dependencies of app and test.
|
|
117
|
+
picoruby_library
|
|
118
|
+
|
|
119
|
+
signature "sig"
|
|
120
|
+
check 'test'
|
|
121
|
+
end
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Note that if you specify `picoruby_library target: 'host'`, it loads RBS files only for test dependencies. But it does not work well in most cases because RBS files under `sig/` depend on gems that the test dependencies do not include.
|
|
125
|
+
|
|
126
|
+
## Development
|
|
127
|
+
|
|
128
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
129
|
+
|
|
130
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec 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).
|
|
131
|
+
|
|
132
|
+
## Contributing
|
|
133
|
+
|
|
134
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/pocke/steep-picoruby.
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This file is evaluated in a separated environment from Steep.
|
|
2
|
+
# Therefore it does NOT loaded by `require 'picoruby/steep'`.
|
|
3
|
+
|
|
4
|
+
stdout = $stdout.dup
|
|
5
|
+
$stdout.reopen File::NULL
|
|
6
|
+
|
|
7
|
+
require "rake"
|
|
8
|
+
require 'json'
|
|
9
|
+
|
|
10
|
+
picoruby_root = ARGV[0] or raise
|
|
11
|
+
config_paths = ARGV[1..]
|
|
12
|
+
|
|
13
|
+
MRUBY_ROOT = File.expand_path(picoruby_root)
|
|
14
|
+
$LOAD_PATH << "#{MRUBY_ROOT}/lib"
|
|
15
|
+
|
|
16
|
+
require "mruby/core_ext"
|
|
17
|
+
require "mruby/build"
|
|
18
|
+
require "picoruby/build"
|
|
19
|
+
|
|
20
|
+
MRUBY_CONFIG = MRuby::Build.mruby_config_path
|
|
21
|
+
load MRUBY_CONFIG
|
|
22
|
+
|
|
23
|
+
config_paths.each do |path|
|
|
24
|
+
load path
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
MRuby.each_target do
|
|
28
|
+
gems.each(&:setup)
|
|
29
|
+
gems.check self
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
map = MRuby.each_target.to_h do |t|
|
|
33
|
+
[t.name, t.gems.map { |g| g.dir }]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
$stdout.reopen stdout
|
|
37
|
+
puts JSON.generate(map)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Steep
|
|
4
|
+
module PicoRuby
|
|
5
|
+
module LibraryOptionsExt
|
|
6
|
+
NONE = Object.new.freeze
|
|
7
|
+
|
|
8
|
+
def picoruby_library(picoruby_root: 'lib/picoruby', build_config: NONE, target: NONE)
|
|
9
|
+
pwd = Pathname.pwd
|
|
10
|
+
|
|
11
|
+
if build_config == NONE
|
|
12
|
+
build_config = pwd.glob('build_config/*.rb')
|
|
13
|
+
end
|
|
14
|
+
build_config = Array(build_config).map(&:to_s)
|
|
15
|
+
raise "No build_config exists" if build_config.empty?
|
|
16
|
+
|
|
17
|
+
out, err, st = Open3.capture3('ruby', DEPENDENCY_CHECKER_PATH, picoruby_root.to_s, *build_config)
|
|
18
|
+
raise "dependency checker failed.\n\n#{out}\n\n#{err}" unless st.success?
|
|
19
|
+
|
|
20
|
+
hash = JSON.parse(out)
|
|
21
|
+
keys = target == NONE ? hash.keys : Array(target)
|
|
22
|
+
unless (not_exists = keys - hash.keys).empty?
|
|
23
|
+
raise "#{not_exists.join(',')} are unknown targets. target should be in #{hash.keys.join(',')}"
|
|
24
|
+
end
|
|
25
|
+
paths = keys
|
|
26
|
+
.flat_map { |key| hash[key] }.uniq
|
|
27
|
+
.map { |path|
|
|
28
|
+
path = Pathname(path) / 'sig/'
|
|
29
|
+
path.relative_path_from(pwd)
|
|
30
|
+
}
|
|
31
|
+
paths.each do |path|
|
|
32
|
+
signature path.to_s if path.exist?
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'open3'
|
|
4
|
+
require 'pathname'
|
|
5
|
+
require 'json'
|
|
6
|
+
require 'steep'
|
|
7
|
+
|
|
8
|
+
require_relative "picoruby/version"
|
|
9
|
+
require_relative "picoruby/library_options_ext"
|
|
10
|
+
|
|
11
|
+
module Steep
|
|
12
|
+
module PicoRuby
|
|
13
|
+
DEPENDENCY_CHECKER_PATH = File.join(__dir__, 'picoruby/dependency_checker.rb')
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Steep::Project::DSL::LibraryOptions.include Steep::PicoRuby::LibraryOptionsExt
|
metadata
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: steep-picoruby
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Masataka Pocke Kuwabara
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: rake
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
description: Load PicoRuby libraries from Steep
|
|
27
|
+
email:
|
|
28
|
+
- kuwabara@pocke.me
|
|
29
|
+
executables: []
|
|
30
|
+
extensions: []
|
|
31
|
+
extra_rdoc_files: []
|
|
32
|
+
files:
|
|
33
|
+
- LICENSE.txt
|
|
34
|
+
- README.md
|
|
35
|
+
- Rakefile
|
|
36
|
+
- lib/steep/picoruby.rb
|
|
37
|
+
- lib/steep/picoruby/dependency_checker.rb
|
|
38
|
+
- lib/steep/picoruby/library_options_ext.rb
|
|
39
|
+
- lib/steep/picoruby/version.rb
|
|
40
|
+
- sig/steep/picoruby.rbs
|
|
41
|
+
homepage: https://github.com/pocke/steep-picoruby
|
|
42
|
+
licenses:
|
|
43
|
+
- MIT
|
|
44
|
+
metadata:
|
|
45
|
+
homepage_uri: https://github.com/pocke/steep-picoruby
|
|
46
|
+
source_code_uri: https://github.com/pocke/steep-picoruby
|
|
47
|
+
rubygems_mfa_required: 'true'
|
|
48
|
+
rdoc_options: []
|
|
49
|
+
require_paths:
|
|
50
|
+
- lib
|
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: 3.2.0
|
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
requirements: []
|
|
62
|
+
rubygems_version: 4.0.3
|
|
63
|
+
specification_version: 4
|
|
64
|
+
summary: Load PicoRuby libraries from Steep
|
|
65
|
+
test_files: []
|