Skip to content

Commit c4cddac

Browse files
committed
add commands to install boards and libraries
1 parent a76f074 commit c4cddac

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111
- `ArduinoCmd` captures and caches preferences
1212
- `ArduinoCmd` reports on whether a board is installed
1313
- `ArduinoCmd` sets preferences
14+
- `ArduinoCmd` installs boards
15+
- `ArduinoCmd` installs libraries
1416

1517
### Changed
1618
- `DisplayManger.with_display` doesn't `disable` if the display was enabled prior to starting the block

exe/ci_system_check.rb

+4
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,9 @@
2727
result = arduino_cmd.set_pref("boardsmanager.additional.urls", urls.join(","))
2828
got_problem = true unless result
2929

30+
got_problem = true unless arduino_cmd.install_board("arduino:sam")
31+
got_problem = true unless arduino_cmd.install_library("USBHost")
32+
got_problem = true unless arduino_cmd.library_is_indexed
33+
3034
abort if got_problem
3135
exit(0)

lib/arduino_ci/arduino_cmd.rb

+27-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ def autolocate!
2424
attr_accessor :installation
2525
attr_reader :prefs_cache
2626
attr_reader :prefs_response_time
27+
attr_reader :library_is_indexed
2728

2829
# @param installation [ArduinoInstallation] the location of the Arduino program installation
2930
def initialize(installation)
3031
@display_mgr = DisplayManager::instance
3132
@installation = installation
3233
@prefs_response_time = nil
3334
@prefs_cache = prefs
35+
@library_is_indexed = false
3436
end
3537

3638
# fetch preferences to a hash
@@ -95,8 +97,31 @@ def run_and_capture(*args)
9597
{ out: str_out, err: str_err, success: success }
9698
end
9799

98-
def board_installed?(board)
99-
run_with_gui_guess(" about board not installed", "--board", board)
100+
def board_installed?(boardname)
101+
run_with_gui_guess(" about board not installed", "--board", boardname)
102+
end
103+
104+
# install a board by name
105+
# @param name [String] the board name
106+
# @return [bool] whether the command succeeded
107+
def install_board(boardname)
108+
run("--install_boards", boardname)
109+
end
110+
111+
# install a library by name
112+
# @param name [String] the library name
113+
# @return [bool] whether the command succeeded
114+
def install_library(library_name)
115+
result = run("--install_library", library_name)
116+
@library_is_indexed = true if result
117+
result
118+
end
119+
120+
# update the library index
121+
def update_library_index
122+
# install random lib so the arduino IDE grabs a new library index
123+
# see: https://github.com/arduino/Arduino/issues/3535
124+
install_library("USBHost")
100125
end
101126

102127
end

0 commit comments

Comments
 (0)