pw_package: Arduino core installers and teensy presubmit
Summary of Changes
==================
1. Rename arduino build args to support cores in any location and have
consistent naming.
2. Update docs to reflect above.
3. `pw package install teensy` working with nice status message on how
to use ge pw_arduino_build_* args.
4. Added gn_teensy_build presubmit test step, not run by default.
`pw presubmit --step gn_teensy_build`
5. Added missing system_rpc_server impl for //targets/arduino. This is
just a copy of the stm32f429i one.
Build arg Change Examples
=========================
OLD:
dir_pw_third_party_arduino = "//third_party/arduino"
arduino_core_name = "teensy"
arduino_package_name = "teensy/avr"
arduino_board = "teensy41"
arduino_menu_options = ["menu.usb.serial",
"menu.opt.o2std"]
NEW:
pw_arduino_build_CORE_PATH =
"/mnt/pigweed/pigweed/.environment/packages"
pw_arduino_build_CORE_NAME = "teensy"
pw_arduino_build_PACKAGE_NAME = "teensy/avr"
pw_arduino_build_BOARD = "teensy41"
pw_arduino_build_MENU_OPTIONS = ["menu.usb.serial",
"menu.opt.o2std"]
All BUILD.gn checks for enabled arduino builds changed too:
OLD:
if (dir_pw_third_party_arduino != "") {}
NEW:
if (pw_arduino_build_CORE_PATH != "") {}
All gn target deps on arduino core sources changed.
OLD:
"$dir_pw_third_party_arduino:arduino_core_sources",
NEW:
"$dir_pw_third_party/arduino:arduino_core_sources",
Teensy package post install & status message
============================================
$ pw package status teensy
20210114 11:58:18 INF teensy is installed.
20210114 11:58:18 INF teensy currently installed in:
/mnt/pigweed/pigweed/.environment/packages/teensy
20210114 11:58:18 INF Enable by running "gn args out" and adding
these lines:
pw_arduino_build_CORE_PATH =
"/mnt/pigweed/pigweed/.environment/packages"
pw_arduino_build_CORE_NAME = "teensy"
pw_arduino_build_PACKAGE_NAME = "teensy/avr"
pw_arduino_build_BOARD = "BOARD_NAME"
20210114 11:58:18 INF Where BOARD_NAME is any supported board.
20210114 11:58:18 INF List available boards by running:
arduino_builder
--arduino-package-path
/mnt/pigweed/pigweed/.environment/packages/teensy
--arduino-package-name teensy/avr
list-boards
Requires: pigweed:29490
Change-Id: Ifd0bd214777392a29af3ab24711edf2f2c1086f3
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/26240
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
diff --git a/pw_arduino_build/arduino.gni b/pw_arduino_build/arduino.gni
index dd1e6f7..0d1704c 100644
--- a/pw_arduino_build/arduino.gni
+++ b/pw_arduino_build/arduino.gni
@@ -16,59 +16,85 @@
declare_args() {
# Enable/disable Arduino builds via group("arduino").
- # Set to the full path of ./third_party/arduino
- dir_pw_third_party_arduino = ""
+ # Set to the full path of where cores are installed.
+ pw_arduino_build_CORE_PATH = ""
# Expected args for an Arduino build:
- arduino_core_name = "teensy"
+ pw_arduino_build_CORE_NAME = ""
# TODO(tonymd): "teensy/avr" here should match the folders in this dir:
- # "../third_party/arduino/cores/$arduino_core_name/hardware/*")
+ # "../third_party/arduino/cores/$pw_arduino_build_CORE_NAME/hardware/*")
# For teensy: "teensy/avr", for adafruit-samd: "samd/1.6.2"
- arduino_package_name = "teensy/avr"
- arduino_board = "teensy40"
+ pw_arduino_build_PACKAGE_NAME = ""
+ pw_arduino_build_BOARD = ""
# Menu options should be a list of strings.
- arduino_menu_options = [
- "menu.usb.serial",
- "menu.keys.en-us",
- ]
+ pw_arduino_build_MENU_OPTIONS = []
}
-arduino_builder_script =
- get_path_info("py/pw_arduino_build/__main__.py", "abspath")
+if (pw_arduino_build_CORE_PATH != "") {
+ # Check that enough pw_arduino_build_* args are set to find and use a core.
+ _required_args_message =
+ "The following build args must all be set: " +
+ "pw_arduino_build_CORE_PATH, pw_arduino_build_CORE_NAME, " +
+ "pw_arduino_build_PACKAGE_NAME."
+ assert(pw_arduino_build_CORE_NAME != "",
+ "Missing 'pw_arduino_build_CORE_NAME' build arg. " +
+ _required_args_message)
+ assert(pw_arduino_build_PACKAGE_NAME != "",
+ "Missing 'pw_arduino_build_PACKAGE_NAME' build arg. " +
+ _required_args_message)
-_arduino_core_path =
- rebase_path("../third_party/arduino/cores/$arduino_core_name")
-_compiler_path_override =
- rebase_path(getenv("_PW_ACTUAL_ENVIRONMENT_ROOT") + "/cipd/pigweed/bin")
+ _arduino_selected_core_path =
+ rebase_path("$pw_arduino_build_CORE_PATH/$pw_arduino_build_CORE_NAME")
-arduino_global_args = [
- "--arduino-package-path",
- _arduino_core_path,
- "--arduino-package-name",
- arduino_package_name,
- "--compiler-path-override",
- _compiler_path_override,
+ arduino_builder_script =
+ get_path_info("py/pw_arduino_build/__main__.py", "abspath")
- # Save config files to "out/arduino_debug/gen/arduino_builder_config.json"
- "--config-file",
- rebase_path(root_gen_dir) + "/arduino_builder_config.json",
- "--save-config",
-]
+ # Check pw_arduino_build_BOARD is set
+ assert(pw_arduino_build_BOARD != "",
+ "pw_arduino_build_BOARD build arg not set. " +
+ "To see supported boards run: " +
+ "arduino_builder --arduino-package-path " +
+ _arduino_selected_core_path + " --arduino-package-name " +
+ pw_arduino_build_PACKAGE_NAME + " list-boards")
-arduino_board_args = [
- "--build-path",
- rebase_path(root_build_dir),
- "--board",
- arduino_board,
- "--menu-options",
-]
-arduino_board_args += arduino_menu_options
+ _compiler_path_override =
+ rebase_path(getenv("_PW_ACTUAL_ENVIRONMENT_ROOT") + "/cipd/pigweed/bin")
-arduino_show_command_args = arduino_global_args + [
- "show",
- "--delimit-with-newlines",
- ] + arduino_board_args
+ arduino_core_library_path = "$_arduino_selected_core_path/hardware/" +
+ "$pw_arduino_build_PACKAGE_NAME/libraries"
-arduino_run_command_args = arduino_global_args + [ "run" ] + arduino_board_args
+ arduino_global_args = [
+ "--arduino-package-path",
+ _arduino_selected_core_path,
+ "--arduino-package-name",
+ pw_arduino_build_PACKAGE_NAME,
+ "--compiler-path-override",
+ _compiler_path_override,
+
+ # Save config files to "out/arduino_debug/gen/arduino_builder_config.json"
+ "--config-file",
+ rebase_path(root_gen_dir) + "/arduino_builder_config.json",
+ "--save-config",
+ ]
+
+ arduino_board_args = [
+ "--build-path",
+ rebase_path(root_build_dir),
+ "--board",
+ pw_arduino_build_BOARD,
+ ]
+ if (pw_arduino_build_MENU_OPTIONS != []) {
+ arduino_board_args += [ "--menu-options" ]
+ arduino_board_args += pw_arduino_build_MENU_OPTIONS
+ }
+
+ arduino_show_command_args = arduino_global_args + [
+ "show",
+ "--delimit-with-newlines",
+ ] + arduino_board_args
+
+ arduino_run_command_args =
+ arduino_global_args + [ "run" ] + arduino_board_args
+}