rpremote 0.1.0 → 0.2.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 +4 -4
- data/CHANGELOG.md +21 -17
- data/README.ja.md +43 -33
- data/README.md +41 -32
- data/RELEASING.md +23 -23
- data/THIRD_PARTY_NOTICES.md +4 -18
- data/lib/rpremote/builder.rb +9 -2
- data/lib/rpremote/cli.rb +26 -17
- data/lib/rpremote/config.rb +1 -0
- data/lib/rpremote/config_show.rb +91 -0
- data/lib/rpremote/dfu_command.rb +4 -4
- data/lib/rpremote/flash_command.rb +5 -2
- data/lib/rpremote/flasher.rb +1 -1
- data/lib/rpremote/help.rb +253 -26
- data/lib/rpremote/language_source.rb +4 -1
- data/lib/rpremote/picomodem.rb +3 -7
- data/lib/rpremote/picoruby_source_patch.rb +32 -0
- data/lib/rpremote/resetter.rb +1 -1
- data/lib/rpremote/runner.rb +2 -2
- data/lib/rpremote/shell.rb +38 -7
- data/lib/rpremote/version.rb +1 -1
- data/lib/rpremote.rb +1 -0
- data/patches/picoruby-3.4.5-ruby-exception-status.patch +59 -0
- data/patches/picoruby-4.0.3-ruby-exception-status.patch +59 -0
- data/sig/rpremote.rbs +17 -3
- data/tasks/firmware_build.rb +2 -8
- data/tasks/release_check.rb +3 -7
- metadata +5 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
diff --git a/mrbgems/picoruby-shell/mrblib/job.rb b/mrbgems/picoruby-shell/mrblib/job.rb
|
|
2
|
+
index 9351ee0..91e7e74 100644
|
|
3
|
+
--- a/mrbgems/picoruby-shell/mrblib/job.rb
|
|
4
|
+
+++ b/mrbgems/picoruby-shell/mrblib/job.rb
|
|
5
|
+
@@ -1,5 +1,7 @@
|
|
6
|
+
class Shell
|
|
7
|
+
class Job
|
|
8
|
+
+ RUBY_EXCEPTION_STATUS = "\x1eR2P2:RUBY_EXCEPTION\x1f"
|
|
9
|
+
+
|
|
10
|
+
def initialize(*params)
|
|
11
|
+
if params.empty?
|
|
12
|
+
raise ArgumentError, "Job requires at least one parameter"
|
|
13
|
+
@@ -24,12 +26,11 @@ class Shell
|
|
14
|
+
@sandbox.resume
|
|
15
|
+
@sandbox.wait(timeout: nil)
|
|
16
|
+
if error = @sandbox.error
|
|
17
|
+
- puts "#{error.message} (#{error.class})"
|
|
18
|
+
+ return report_ruby_exception(error)
|
|
19
|
+
end
|
|
20
|
+
return true
|
|
21
|
+
rescue Exception => e
|
|
22
|
+
- puts "#{e.message} (#{e.class})"
|
|
23
|
+
- return false
|
|
24
|
+
+ return report_ruby_exception(e)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def state
|
|
28
|
+
@@ -46,22 +47,28 @@ class Shell
|
|
29
|
+
trap
|
|
30
|
+
@sandbox.load_file(@exefile)
|
|
31
|
+
if error = @sandbox.error
|
|
32
|
+
- puts "\n#{error.message} (#{error.class})"
|
|
33
|
+
+ return report_ruby_exception(error, true)
|
|
34
|
+
end
|
|
35
|
+
return true
|
|
36
|
+
rescue Exception => e
|
|
37
|
+
- puts "#{e.message} (#{e.class})"
|
|
38
|
+
# backtrace uses a lot of memory
|
|
39
|
+
#if e.respond_to?(:backtrace)
|
|
40
|
+
# e.backtrace.each do |line|
|
|
41
|
+
# puts " #{line}"
|
|
42
|
+
# end
|
|
43
|
+
#end
|
|
44
|
+
- return false
|
|
45
|
+
+ return report_ruby_exception(e)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
+ def report_ruby_exception(error, leading_newline = false)
|
|
51
|
+
+ print "\n" if leading_newline
|
|
52
|
+
+ puts "#{error.message} (#{error.class})"
|
|
53
|
+
+ print RUBY_EXCEPTION_STATUS
|
|
54
|
+
+ false
|
|
55
|
+
+ end
|
|
56
|
+
+
|
|
57
|
+
def trap
|
|
58
|
+
Signal.trap(:TSTP) do
|
|
59
|
+
@sandbox.suspend
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
diff --git a/mrbgems/picoruby-shell/mrblib/job.rb b/mrbgems/picoruby-shell/mrblib/job.rb
|
|
2
|
+
index f650cce..225c944 100644
|
|
3
|
+
--- a/mrbgems/picoruby-shell/mrblib/job.rb
|
|
4
|
+
+++ b/mrbgems/picoruby-shell/mrblib/job.rb
|
|
5
|
+
@@ -1,5 +1,7 @@
|
|
6
|
+
class Shell
|
|
7
|
+
class Job
|
|
8
|
+
+ RUBY_EXCEPTION_STATUS = "\x1eR2P2:RUBY_EXCEPTION\x1f"
|
|
9
|
+
+
|
|
10
|
+
def initialize(*params)
|
|
11
|
+
if params.empty?
|
|
12
|
+
raise ArgumentError, "Job requires at least one parameter"
|
|
13
|
+
@@ -24,12 +26,11 @@ class Shell
|
|
14
|
+
@sandbox.resume
|
|
15
|
+
@sandbox.wait(timeout: nil)
|
|
16
|
+
if error = @sandbox.error
|
|
17
|
+
- puts "#{error.message} (#{error.class})"
|
|
18
|
+
+ return report_ruby_exception(error)
|
|
19
|
+
end
|
|
20
|
+
return true
|
|
21
|
+
rescue Exception => e
|
|
22
|
+
- puts "#{e.message} (#{e.class})"
|
|
23
|
+
- return false
|
|
24
|
+
+ return report_ruby_exception(e)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def state
|
|
28
|
+
@@ -60,22 +61,28 @@ class Shell
|
|
29
|
+
end
|
|
30
|
+
if error = @sandbox.error
|
|
31
|
+
reap(before)
|
|
32
|
+
- puts "\n#{error.message} (#{error.class})"
|
|
33
|
+
+ return report_ruby_exception(error, true)
|
|
34
|
+
end
|
|
35
|
+
return true
|
|
36
|
+
rescue Exception => e
|
|
37
|
+
- puts "#{e.message} (#{e.class})"
|
|
38
|
+
# backtrace uses a lot of memory
|
|
39
|
+
#if e.respond_to?(:backtrace)
|
|
40
|
+
# e.backtrace.each do |line|
|
|
41
|
+
# puts " #{line}"
|
|
42
|
+
# end
|
|
43
|
+
#end
|
|
44
|
+
- return false
|
|
45
|
+
+ return report_ruby_exception(e)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
+ def report_ruby_exception(error, leading_newline = false)
|
|
51
|
+
+ print "\n" if leading_newline
|
|
52
|
+
+ puts "#{error.message} (#{error.class})"
|
|
53
|
+
+ print RUBY_EXCEPTION_STATUS
|
|
54
|
+
+ false
|
|
55
|
+
+ end
|
|
56
|
+
+
|
|
57
|
+
# Terminate tasks the job started but left behind, and ONLY when the
|
|
58
|
+
# job died: a script killed by e.g. NoMemoryError never reaches the
|
|
59
|
+
# code that would stop its own tasks, and such an orphan keeps running
|
data/sig/rpremote.rbs
CHANGED
|
@@ -166,11 +166,24 @@ module Rpremote
|
|
|
166
166
|
def source_dir: () -> String
|
|
167
167
|
end
|
|
168
168
|
|
|
169
|
+
class PicoRubySourcePatch
|
|
170
|
+
JOB_PATH: String
|
|
171
|
+
PATCH_ALIASES: Hash[String, String]
|
|
172
|
+
|
|
173
|
+
class Error < Rpremote::Error
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
attr_reader version: String
|
|
177
|
+
|
|
178
|
+
def initialize: (version: String) -> void
|
|
179
|
+
def apply: (String source) -> void
|
|
180
|
+
end
|
|
181
|
+
|
|
169
182
|
class Builder
|
|
170
183
|
class Error < Rpremote::Error
|
|
171
184
|
end
|
|
172
185
|
|
|
173
|
-
def initialize: (?root: String, ?runner: untyped, ?mrbgems_class: untyped) -> void
|
|
186
|
+
def initialize: (?root: String, ?runner: untyped, ?mrbgems_class: untyped, ?source_patcher: untyped) -> void
|
|
174
187
|
def build: (
|
|
175
188
|
?language: String,
|
|
176
189
|
?language_version: String,
|
|
@@ -240,6 +253,7 @@ module Rpremote
|
|
|
240
253
|
PROMPT_END: String
|
|
241
254
|
CURSOR_POSITION_QUERY: String
|
|
242
255
|
CURSOR_POSITION_RESPONSE: String
|
|
256
|
+
RUBY_EXCEPTION_STATUS: String
|
|
243
257
|
|
|
244
258
|
class Error < Rpremote::Error
|
|
245
259
|
end
|
|
@@ -260,7 +274,7 @@ module Rpremote
|
|
|
260
274
|
def initialize: (untyped io, ?timeout: Float) -> void
|
|
261
275
|
def synchronize!: () -> nil
|
|
262
276
|
def send_command: (String command) -> nil
|
|
263
|
-
def execute: (String command) -> String
|
|
277
|
+
def execute: (String command, ?output: IO?) -> String
|
|
264
278
|
end
|
|
265
279
|
|
|
266
280
|
class Terminal
|
|
@@ -293,7 +307,7 @@ module Rpremote
|
|
|
293
307
|
?shell_class: untyped,
|
|
294
308
|
?path_factory: untyped
|
|
295
309
|
) -> void
|
|
296
|
-
def run: (String data) -> String
|
|
310
|
+
def run: (String data, ?output: IO?) -> String
|
|
297
311
|
end
|
|
298
312
|
|
|
299
313
|
class Resetter
|
data/tasks/firmware_build.rb
CHANGED
|
@@ -32,9 +32,7 @@ output_dir = File.join(REPOSITORY_ROOT, "build", build_name)
|
|
|
32
32
|
mruby_build_dir = File.join(picoruby_root, "build", config_name)
|
|
33
33
|
cmake_source_dir = File.join(r2p2_gem_dir, "cmake")
|
|
34
34
|
|
|
35
|
-
unless File.file?(File.join(picoruby_root, "Rakefile"))
|
|
36
|
-
abort "PicoRuby source not found: #{picoruby_root}\nSet PICORUBY_DIR to a PicoRuby checkout."
|
|
37
|
-
end
|
|
35
|
+
abort "PicoRuby source not found: #{picoruby_root}\nSet PICORUBY_DIR to a PicoRuby checkout." unless File.file?(File.join(picoruby_root, "Rakefile"))
|
|
38
36
|
abort "Build config not found: #{base_config_path}" unless File.file?(base_config_path)
|
|
39
37
|
abort "Generated build config not found: #{config_path}" unless File.file?(config_path)
|
|
40
38
|
build_config = File.read(base_config_path)
|
|
@@ -60,11 +58,7 @@ build_env = {
|
|
|
60
58
|
"PICO_EXTRAS_PATH" => pico_extras_path
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
# PicoRuby
|
|
64
|
-
# A generated overlay therefore shares the base target's objects. In particular,
|
|
65
|
-
# mrblib.c includes picogem_init.c, but Make does not track that generated include
|
|
66
|
-
# as a dependency. Reusing the directory can leave a removed or added local
|
|
67
|
-
# mrbgem out of libmruby.a. Custom mrbgems must start from a fresh target build.
|
|
61
|
+
# PicoRuby keys build output by target, so an overlay can reuse stale objects; fresh builds keep changed local mrbgems in libmruby.a.
|
|
68
62
|
if fingerprint && File.directory?(mruby_build_dir)
|
|
69
63
|
puts "Removing stale PicoRuby build output: #{mruby_build_dir}"
|
|
70
64
|
FileUtils.rm_rf(mruby_build_dir)
|
data/tasks/release_check.rb
CHANGED
|
@@ -34,14 +34,10 @@ module Rpremote
|
|
|
34
34
|
package = Gem::Package.new(gem_file)
|
|
35
35
|
specification = package.spec
|
|
36
36
|
missing_files = EXPECTED_FILES - package.contents
|
|
37
|
-
changelog_entry =
|
|
37
|
+
changelog_entry = /^## #{Regexp.escape(Rpremote::VERSION)} - \d{4}-\d{2}-\d{2}$/
|
|
38
38
|
|
|
39
|
-
unless specification.version.to_s == Rpremote::VERSION
|
|
40
|
-
|
|
41
|
-
end
|
|
42
|
-
unless File.read("CHANGELOG.md").include?(changelog_entry)
|
|
43
|
-
abort "CHANGELOG.md has no entry for #{Rpremote::VERSION}"
|
|
44
|
-
end
|
|
39
|
+
abort "built gem version does not match #{Rpremote::VERSION}" unless specification.version.to_s == Rpremote::VERSION
|
|
40
|
+
abort "CHANGELOG.md has no entry for #{Rpremote::VERSION}" unless File.read("CHANGELOG.md").match?(changelog_entry)
|
|
45
41
|
abort "built gem is missing: #{missing_files.join(", ")}" unless missing_files.empty?
|
|
46
42
|
abort "built gem does not require MFA" unless specification.metadata["rubygems_mfa_required"] == "true"
|
|
47
43
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rpremote
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ogom
|
|
@@ -31,6 +31,7 @@ files:
|
|
|
31
31
|
- lib/rpremote/checksum.rb
|
|
32
32
|
- lib/rpremote/cli.rb
|
|
33
33
|
- lib/rpremote/config.rb
|
|
34
|
+
- lib/rpremote/config_show.rb
|
|
34
35
|
- lib/rpremote/device.rb
|
|
35
36
|
- lib/rpremote/dfu_command.rb
|
|
36
37
|
- lib/rpremote/dfu_compiler.rb
|
|
@@ -42,6 +43,7 @@ files:
|
|
|
42
43
|
- lib/rpremote/mrbgems.rb
|
|
43
44
|
- lib/rpremote/mrbgems_command.rb
|
|
44
45
|
- lib/rpremote/picomodem.rb
|
|
46
|
+
- lib/rpremote/picoruby_source_patch.rb
|
|
45
47
|
- lib/rpremote/remote_path.rb
|
|
46
48
|
- lib/rpremote/resetter.rb
|
|
47
49
|
- lib/rpremote/runner.rb
|
|
@@ -51,6 +53,8 @@ files:
|
|
|
51
53
|
- lib/rpremote/target.rb
|
|
52
54
|
- lib/rpremote/terminal.rb
|
|
53
55
|
- lib/rpremote/version.rb
|
|
56
|
+
- patches/picoruby-3.4.5-ruby-exception-status.patch
|
|
57
|
+
- patches/picoruby-4.0.3-ruby-exception-status.patch
|
|
54
58
|
- sig/rpremote.rbs
|
|
55
59
|
- tasks/firmware_build.rb
|
|
56
60
|
- tasks/release.rake
|