arduino_ci 0.2.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +49 -20
  3. data/REFERENCE.md +636 -0
  4. data/cpp/arduino/Arduino.h +1 -1
  5. data/cpp/arduino/AvrMath.h +117 -17
  6. data/cpp/arduino/Client.h +27 -0
  7. data/cpp/arduino/EEPROM.h +64 -0
  8. data/cpp/arduino/Godmode.cpp +11 -0
  9. data/cpp/arduino/Godmode.h +58 -9
  10. data/cpp/arduino/HardwareSerial.h +9 -28
  11. data/cpp/arduino/IPAddress.h +59 -0
  12. data/cpp/arduino/Print.h +9 -12
  13. data/cpp/arduino/Printable.h +8 -0
  14. data/cpp/arduino/SPI.h +11 -3
  15. data/cpp/arduino/Server.h +5 -0
  16. data/cpp/arduino/Udp.h +27 -0
  17. data/cpp/arduino/Wire.h +234 -0
  18. data/cpp/arduino/avr/io.h +10 -1
  19. data/cpp/arduino/avr/pgmspace.h +76 -46
  20. data/cpp/arduino/ci/StreamTape.h +36 -0
  21. data/cpp/unittest/OstreamHelpers.h +4 -0
  22. data/exe/arduino_ci.rb +427 -0
  23. data/exe/arduino_ci_remote.rb +2 -385
  24. data/exe/arduino_library_location.rb +2 -2
  25. data/exe/ensure_arduino_installation.rb +7 -1
  26. data/lib/arduino_ci.rb +1 -0
  27. data/lib/arduino_ci/arduino_backend.rb +222 -0
  28. data/lib/arduino_ci/arduino_downloader.rb +43 -73
  29. data/lib/arduino_ci/arduino_downloader_linux.rb +17 -55
  30. data/lib/arduino_ci/arduino_downloader_osx.rb +21 -33
  31. data/lib/arduino_ci/arduino_downloader_windows.rb +11 -53
  32. data/lib/arduino_ci/arduino_installation.rb +18 -80
  33. data/lib/arduino_ci/ci_config.rb +15 -9
  34. data/lib/arduino_ci/cpp_library.rb +266 -48
  35. data/lib/arduino_ci/host.rb +59 -4
  36. data/lib/arduino_ci/library_properties.rb +96 -0
  37. data/lib/arduino_ci/version.rb +1 -1
  38. data/misc/default.yml +55 -4
  39. metadata +21 -87
  40. data/cpp/arduino/Arduino.h.orig +0 -143
  41. data/exe/libasan.rb +0 -29
  42. data/lib/arduino_ci/arduino_cmd.rb +0 -328
  43. data/lib/arduino_ci/arduino_cmd_linux.rb +0 -17
  44. data/lib/arduino_ci/arduino_cmd_linux_builder.rb +0 -19
  45. data/lib/arduino_ci/arduino_cmd_osx.rb +0 -17
  46. data/lib/arduino_ci/arduino_cmd_windows.rb +0 -17
@@ -6,6 +6,13 @@ module ArduinoCI
6
6
 
7
7
  # Tools for interacting with the host machine
8
8
  class Host
9
+ # TODO: this came from https://stackoverflow.com/a/22716582/2063546
10
+ # and I'm not sure if it can be replaced by self.os == :windows
11
+ WINDOWS_VARIANT_REGEX = /mswin32|cygwin|mingw|bccwin/.freeze
12
+
13
+ # e.g. 11/27/2020 01:02 AM <SYMLINKD> ExcludeSomething [C:\projects\arduino-ci\SampleProjects\ExcludeSomething]
14
+ DIR_SYMLINK_REGEX = %r{\d+/\d+/\d+\s+[^<]+<SYMLINKD?>\s+(.*) \[([^\]]+)\]}.freeze
15
+
9
16
  # Cross-platform way of finding an executable in the $PATH.
10
17
  # via https://stackoverflow.com/a/5471032/2063546
11
18
  # which('ruby') #=> /usr/bin/ruby
@@ -38,21 +45,69 @@ module ArduinoCI
38
45
  return :windows if OS.windows?
39
46
  end
40
47
 
48
+ # Cross-platform symlinking
41
49
  # if on windows, call mklink, else self.symlink
42
50
  # @param [Pathname] old_path
43
51
  # @param [Pathname] new_path
44
52
  def self.symlink(old_path, new_path)
45
- return FileUtils.ln_s(old_path.to_s, new_path.to_s) unless RUBY_PLATFORM =~ /mswin32|cygwin|mingw|bccwin/
53
+ # we would prefer `new_path.make_symlink(old_path)` but "symlink function is unimplemented on this machine" with windows
54
+ return new_path.make_symlink(old_path) unless needs_symlink_hack?
46
55
 
47
- # https://stackoverflow.com/a/22716582/2063546
56
+ # via https://stackoverflow.com/a/22716582/2063546
48
57
  # windows mklink syntax is reverse of unix ln -s
49
58
  # windows mklink is built into cmd.exe
50
59
  # vulnerable to command injection, but okay because this is a hack to make a cli tool work.
51
- orp = old_path.realpath.to_s.tr("/", "\\") # HACK DUE TO REALPATH BUG where it
52
- np = new_path.to_s.tr("/", "\\") # still joins windows paths with '/'
60
+ orp = pathname_to_windows(old_path.realpath)
61
+ np = pathname_to_windows(new_path)
53
62
 
54
63
  _stdout, _stderr, exitstatus = Open3.capture3('cmd.exe', "/C mklink /D #{np} #{orp}")
55
64
  exitstatus.success?
56
65
  end
66
+
67
+ # Hack for "realpath" which on windows joins paths with slashes instead of backslashes
68
+ # @param path [Pathname] the path to render
69
+ # @return [String] A path that will work on windows
70
+ def self.pathname_to_windows(path)
71
+ path.to_s.tr("/", "\\")
72
+ end
73
+
74
+ # Hack for "realpath" which on windows joins paths with slashes instead of backslashes
75
+ # @param str [String] the windows path
76
+ # @return [Pathname] A path that will be recognized by pathname
77
+ def self.windows_to_pathname(str)
78
+ Pathname.new(str.tr("\\", "/"))
79
+ end
80
+
81
+ # Whether this OS requires a hack for symlinks
82
+ # @return [bool]
83
+ def self.needs_symlink_hack?
84
+ RUBY_PLATFORM =~ WINDOWS_VARIANT_REGEX
85
+ end
86
+
87
+ # Cross-platform is-this-a-symlink function
88
+ # @param [Pathname] path
89
+ # @return [bool] Whether the file is a symlink
90
+ def self.symlink?(path)
91
+ return path.symlink? unless needs_symlink_hack?
92
+
93
+ !readlink(path).nil?
94
+ end
95
+
96
+ # Cross-platform "read link" function
97
+ # @param [Pathname] path
98
+ # @return [Pathname] the link target
99
+ def self.readlink(path)
100
+ return path.readlink unless needs_symlink_hack?
101
+
102
+ the_dir = pathname_to_windows(path.parent)
103
+ the_file = path.basename.to_s
104
+
105
+ stdout, _stderr, _exitstatus = Open3.capture3('cmd.exe', "/c dir /al #{the_dir}")
106
+ symlinks = stdout.lines.map { |l| DIR_SYMLINK_REGEX.match(l) }.compact
107
+ our_link = symlinks.find { |m| m[1] == the_file }
108
+ return nil if our_link.nil?
109
+
110
+ windows_to_pathname(our_link[2])
111
+ end
57
112
  end
58
113
  end
@@ -0,0 +1,96 @@
1
+ module ArduinoCI
2
+
3
+ # Information about an Arduino library package, as specified by the library.properties file
4
+ #
5
+ # See https://arduino.github.io/arduino-cli/library-specification/#libraryproperties-file-format
6
+ class LibraryProperties
7
+
8
+ # @return [Hash] The properties file parsed as a hash
9
+ attr_reader :fields
10
+
11
+ # @param path [Pathname] The path to the library.properties file
12
+ def initialize(path)
13
+ @fields = {}
14
+ File.foreach(path) do |line_with_delim|
15
+ line = line_with_delim.chomp
16
+ parts = line.split("=", 2)
17
+ next if parts[0].nil?
18
+ next if parts[0].empty?
19
+ next if parts[1].nil?
20
+
21
+ @fields[parts[0]] = parts[1] unless parts[1].empty?
22
+ end
23
+ end
24
+
25
+ # @return [Hash] the properties as a hash, all strings
26
+ def to_h
27
+ @fields.clone
28
+ end
29
+
30
+ # Enable a shortcut syntax for library property accessors, in the style of `attr_accessor` metaprogramming.
31
+ # This is used to create a named field pointing to a specific property in the file, optionally applying
32
+ # a specific formatting function.
33
+ #
34
+ # The formatting function MUST be a static method on this class. This is a limitation caused by the desire
35
+ # to both (1) expose the formatters outside this class, and (2) use them for metaprogramming without the
36
+ # having to name the entire function. field_reader is a static method, so if not for the fact that
37
+ # `self.class.methods.include? formatter` fails to work for class methods in this context (unlike
38
+ # `self.methods.include?`, which properly finds instance methods), I would allow either one and just
39
+ # conditionally `define_method` the proper definition
40
+ #
41
+ # @param name [String] What the accessor will be called
42
+ # @param field_num [Integer] The name of the key of the property
43
+ # @param formatter [Symbol] The symbol for the formatting function to apply to the field (optional)
44
+ # @return [void]
45
+ # @macro [attach] field_reader
46
+ # @!attribute [r] $1
47
+ # @return property $2 of the library.properties file, formatted with the function {$3}
48
+ def self.field_reader(name, formatter = nil)
49
+ key = name.to_s
50
+ if formatter.nil?
51
+ define_method(name) { @fields[key] }
52
+ else
53
+ define_method(name) { @fields.key?(key) ? self.class.send(formatter.to_sym, @fields[key]) : nil }
54
+ end
55
+ end
56
+
57
+ # Parse a value as a comma-separated array
58
+ # @param input [String]
59
+ # @return [Array<String>] The individual values
60
+ def self._csv(input)
61
+ input.split(",").map(&:strip)
62
+ end
63
+
64
+ # Parse a value as a boolean
65
+ # @param input [String]
66
+ # @return [Array<String>] The individual values
67
+ def self._bool(input)
68
+ input == "true" # no indication given in the docs that anything but lowercase "true" indicates boolean true.
69
+ end
70
+
71
+ field_reader :name
72
+ field_reader :version
73
+ field_reader :author, :_csv
74
+ field_reader :maintainer
75
+ field_reader :sentence
76
+ field_reader :paragraph
77
+ field_reader :category
78
+ field_reader :url
79
+ field_reader :architectures, :_csv
80
+ field_reader :depends, :_csv
81
+ field_reader :dot_a_linkage, :_bool
82
+ field_reader :includes, :_csv
83
+ field_reader :precompiled, :_bool
84
+ field_reader :ldflags, :_csv
85
+
86
+ # The value of sentence always will be prepended, so you should start by writing the second sentence here
87
+ #
88
+ # (according to the docs)
89
+ # @return [String] the sentence and paragraph together
90
+ def full_paragraph
91
+ [sentence, paragraph].join(" ")
92
+ end
93
+
94
+ end
95
+
96
+ end
@@ -1,3 +1,3 @@
1
1
  module ArduinoCI
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "1.1.0".freeze
3
3
  end
@@ -3,7 +3,12 @@
3
3
  # https://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems
4
4
 
5
5
  packages:
6
- # arduino:xxx are builtin, we don't need to include them here
6
+ arduino:avr:
7
+ url: https://downloads.arduino.cc/packages/package_index.json
8
+ arduino:sam:
9
+ url: https://downloads.arduino.cc/packages/package_index.json
10
+ arduino:samd:
11
+ url: https://downloads.arduino.cc/packages/package_index.json
7
12
  esp8266:esp8266:
8
13
  url: http://arduino.esp8266.com/stable/package_esp8266com_index.json
9
14
  adafruit:avr:
@@ -21,7 +26,10 @@ platforms:
21
26
  gcc:
22
27
  features:
23
28
  defines:
29
+ - __AVR__
24
30
  - __AVR_ATmega328P__
31
+ - ARDUINO_ARCH_AVR
32
+ - ARDUINO_AVR_UNO
25
33
  warnings:
26
34
  flags:
27
35
  due:
@@ -30,7 +38,10 @@ platforms:
30
38
  gcc:
31
39
  features:
32
40
  defines:
33
- - __AVR_ATmega328__
41
+ - __SAM3X8E__
42
+ - ARDUINO_ARCH_SAM
43
+ - ARDUINO_SAM_DUE
44
+ - NUM_SERIAL_PORTS=4
34
45
  warnings:
35
46
  flags:
36
47
  zero:
@@ -39,8 +50,11 @@ platforms:
39
50
  gcc:
40
51
  features:
41
52
  defines:
42
- - __SAMD21G18A__
43
- - ARDUINO_SAMD_ZERO
53
+ - __SAMD21G18A__
54
+ - ARDUINO_ARCH_SAMD
55
+ - ARDUINO_SAMD_ZERO
56
+ # This also has SerialUSB, which is not included here.
57
+ - NUM_SERIAL_PORTS=2
44
58
  warnings:
45
59
  flags:
46
60
  esp32:
@@ -49,6 +63,10 @@ platforms:
49
63
  gcc:
50
64
  features:
51
65
  defines:
66
+ - ESP32
67
+ - ARDUINO_ARCH_ESP32
68
+ - ARDUINO_FEATHER_ESP32
69
+ - NUM_SERIAL_PORTS=3
52
70
  warnings:
53
71
  flags:
54
72
  esp8266:
@@ -57,6 +75,10 @@ platforms:
57
75
  gcc:
58
76
  features:
59
77
  defines:
78
+ - ESP8266
79
+ - ARDUINO_ARCH_ESP8266
80
+ - ARDUINO_ESP8266_ESP12
81
+ - NUM_SERIAL_PORTS=2
60
82
  warnings:
61
83
  flags:
62
84
  leonardo:
@@ -65,7 +87,10 @@ platforms:
65
87
  gcc:
66
88
  features:
67
89
  defines:
90
+ - __AVR__
68
91
  - __AVR_ATmega32U4__
92
+ - ARDUINO_ARCH_AVR
93
+ - ARDUINO_AVR_LEONARDO
69
94
  warnings:
70
95
  flags:
71
96
  trinket:
@@ -74,6 +99,10 @@ platforms:
74
99
  gcc:
75
100
  features:
76
101
  defines:
102
+ - __AVR__
103
+ - __AVR_ATtiny85__
104
+ - ARDUINO_ARCH_AVR
105
+ - ARDUINO_AVR_TRINKET5
77
106
  warnings:
78
107
  flags:
79
108
  gemma:
@@ -82,6 +111,10 @@ platforms:
82
111
  gcc:
83
112
  features:
84
113
  defines:
114
+ - __AVR__
115
+ - __AVR_ATtiny85__
116
+ - ARDUINO_ARCH_AVR
117
+ - ARDUINO_AVR_GEMMA
85
118
  warnings:
86
119
  flags:
87
120
  m4:
@@ -90,6 +123,12 @@ platforms:
90
123
  gcc:
91
124
  features:
92
125
  defines:
126
+ - __SAMD51__
127
+ - __SAMD51J19A__
128
+ - ARDUINO_ARCH_SAMD
129
+ - ARDUINO_METRO_M4
130
+ # Serial is actually USB virtual serial, not HardwareSerial
131
+ - NUM_SERIAL_PORTS=2
93
132
  warnings:
94
133
  flags:
95
134
  mega2560:
@@ -98,7 +137,10 @@ platforms:
98
137
  gcc:
99
138
  features:
100
139
  defines:
140
+ - __AVR__
101
141
  - __AVR_ATmega2560__
142
+ - ARDUINO_ARCH_AVR
143
+ - ARDUINO_AVR_MEGA2560
102
144
  warnings:
103
145
  flags:
104
146
  cplayClassic:
@@ -107,6 +149,10 @@ platforms:
107
149
  gcc:
108
150
  features:
109
151
  defines:
152
+ - __AVR__
153
+ - __AVR_ATmega32U4__
154
+ - ARDUINO_ARCH_AVR
155
+ - ARDUINO_AVR_CIRCUITPLAY
110
156
  warnings:
111
157
  flags:
112
158
  cplayExpress:
@@ -115,6 +161,11 @@ platforms:
115
161
  gcc:
116
162
  features:
117
163
  defines:
164
+ - __SAMD21G18A__
165
+ - ARDUINO_ARCH_SAMD
166
+ - ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS
167
+ # Serial is actually an alias of SerialUSB, not a HardwareSerial
168
+ - NUM_SERIAL_PORTS=2
118
169
  warnings:
119
170
  flags:
120
171
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arduino_ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Katz
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-20 00:00:00.000000000 Z
11
+ date: 2020-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os
@@ -38,105 +38,42 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.2'
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.15'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.15'
55
- - !ruby/object:Gem::Dependency
56
- name: keepachangelog_manager
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 0.0.2
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 0.0.2
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3.0'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.59.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 0.59.0
97
- - !ruby/object:Gem::Dependency
98
- name: yard
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 0.9.11
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 0.9.11
111
41
  description: ''
112
42
  email:
113
- - ianfixes@gmail.com
43
+ - arduino.continuous.integration@gmail.com
114
44
  executables:
45
+ - arduino_ci.rb
115
46
  - arduino_ci_remote.rb
116
47
  - arduino_library_location.rb
117
48
  - ensure_arduino_installation.rb
118
- - libasan.rb
119
49
  extensions: []
120
50
  extra_rdoc_files: []
121
51
  files:
122
52
  - ".yardopts"
123
53
  - README.md
54
+ - REFERENCE.md
124
55
  - cpp/arduino/Arduino.cpp
125
56
  - cpp/arduino/Arduino.h
126
- - cpp/arduino/Arduino.h.orig
127
57
  - cpp/arduino/ArduinoDefines.h
128
58
  - cpp/arduino/AvrMath.h
59
+ - cpp/arduino/Client.h
60
+ - cpp/arduino/EEPROM.h
129
61
  - cpp/arduino/Godmode.cpp
130
62
  - cpp/arduino/Godmode.h
131
63
  - cpp/arduino/HardwareSerial.h
64
+ - cpp/arduino/IPAddress.h
132
65
  - cpp/arduino/MockEventQueue.h
133
66
  - cpp/arduino/PinHistory.h
134
67
  - cpp/arduino/Print.h
68
+ - cpp/arduino/Printable.h
135
69
  - cpp/arduino/SPI.h
70
+ - cpp/arduino/Server.h
136
71
  - cpp/arduino/SoftwareSerial.h
137
72
  - cpp/arduino/Stream.h
73
+ - cpp/arduino/Udp.h
138
74
  - cpp/arduino/WCharacter.h
139
75
  - cpp/arduino/WString.h
76
+ - cpp/arduino/Wire.h
140
77
  - cpp/arduino/avr/README.md
141
78
  - cpp/arduino/avr/common.h
142
79
  - cpp/arduino/avr/fuse.h
@@ -416,6 +353,7 @@ files:
416
353
  - cpp/arduino/ci/DeviceUsingBytes.h
417
354
  - cpp/arduino/ci/ObservableDataStream.h
418
355
  - cpp/arduino/ci/README.md
356
+ - cpp/arduino/ci/StreamTape.h
419
357
  - cpp/arduino/ci/Table.h
420
358
  - cpp/arduino/stdlib.cpp
421
359
  - cpp/arduino/stdlib.h
@@ -424,16 +362,12 @@ files:
424
362
  - cpp/unittest/Assertion.h
425
363
  - cpp/unittest/Compare.h
426
364
  - cpp/unittest/OstreamHelpers.h
365
+ - exe/arduino_ci.rb
427
366
  - exe/arduino_ci_remote.rb
428
367
  - exe/arduino_library_location.rb
429
368
  - exe/ensure_arduino_installation.rb
430
- - exe/libasan.rb
431
369
  - lib/arduino_ci.rb
432
- - lib/arduino_ci/arduino_cmd.rb
433
- - lib/arduino_ci/arduino_cmd_linux.rb
434
- - lib/arduino_ci/arduino_cmd_linux_builder.rb
435
- - lib/arduino_ci/arduino_cmd_osx.rb
436
- - lib/arduino_ci/arduino_cmd_windows.rb
370
+ - lib/arduino_ci/arduino_backend.rb
437
371
  - lib/arduino_ci/arduino_downloader.rb
438
372
  - lib/arduino_ci/arduino_downloader_linux.rb
439
373
  - lib/arduino_ci/arduino_downloader_osx.rb
@@ -442,13 +376,14 @@ files:
442
376
  - lib/arduino_ci/ci_config.rb
443
377
  - lib/arduino_ci/cpp_library.rb
444
378
  - lib/arduino_ci/host.rb
379
+ - lib/arduino_ci/library_properties.rb
445
380
  - lib/arduino_ci/version.rb
446
381
  - misc/default.yml
447
- homepage: http://github.com/ianfixes/arduino_ci
382
+ homepage: http://github.com/Arduino-CI/arduino_ci
448
383
  licenses:
449
384
  - Apache-2.0
450
385
  metadata: {}
451
- post_install_message:
386
+ post_install_message:
452
387
  rdoc_options: []
453
388
  require_paths:
454
389
  - lib
@@ -463,9 +398,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
463
398
  - !ruby/object:Gem::Version
464
399
  version: '0'
465
400
  requirements: []
466
- rubyforge_project:
467
- rubygems_version: 2.5.2.3
468
- signing_key:
401
+ rubygems_version: 3.0.3
402
+ signing_key:
469
403
  specification_version: 4
470
404
  summary: Tools for building and unit testing Arduino libraries
471
405
  test_files: []