1 # Copyright 2020 The Pigweed Authors
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 # use this file except in compliance with the License. You may obtain a copy of
7 # https://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations under
15 import("//build_overrides/pigweed.gni")
18 # Enable/disable Arduino builds via group("arduino").
19 # Set to the full path of where cores are installed.
20 pw_arduino_build_CORE_PATH = ""
22 # Expected args for an Arduino build:
23 pw_arduino_build_CORE_NAME = ""
25 # TODO(tonymd): "teensy/avr" here should match the folders in this dir:
26 # "../third_party/arduino/cores/$pw_arduino_build_CORE_NAME/hardware/*")
27 # For teensy: "teensy/avr", for adafruit-samd: "samd/1.6.2"
28 pw_arduino_build_PACKAGE_NAME = ""
29 pw_arduino_build_BOARD = ""
31 # Menu options should be a list of strings.
32 pw_arduino_build_MENU_OPTIONS = []
35 if (pw_arduino_build_CORE_PATH != "") {
36 # Check that enough pw_arduino_build_* args are set to find and use a core.
37 _required_args_message =
38 "The following build args must all be set: " +
39 "pw_arduino_build_CORE_PATH, pw_arduino_build_CORE_NAME, " +
40 "pw_arduino_build_PACKAGE_NAME."
41 assert(pw_arduino_build_CORE_NAME != "",
42 "Missing 'pw_arduino_build_CORE_NAME' build arg. " +
43 _required_args_message)
44 assert(pw_arduino_build_PACKAGE_NAME != "",
45 "Missing 'pw_arduino_build_PACKAGE_NAME' build arg. " +
46 _required_args_message)
48 _arduino_selected_core_path =
49 rebase_path("$pw_arduino_build_CORE_PATH/$pw_arduino_build_CORE_NAME")
51 arduino_builder_script =
52 get_path_info("py/pw_arduino_build/__main__.py", "abspath")
54 # Check pw_arduino_build_BOARD is set
55 assert(pw_arduino_build_BOARD != "",
56 "pw_arduino_build_BOARD build arg not set. " +
57 "To see supported boards run: " +
58 "arduino_builder --arduino-package-path " +
59 _arduino_selected_core_path + " --arduino-package-name " +
60 pw_arduino_build_PACKAGE_NAME + " list-boards")
62 _compiler_path_override =
63 rebase_path(getenv("_PW_ACTUAL_ENVIRONMENT_ROOT") + "/cipd/pigweed/bin")
65 arduino_core_library_path = "$_arduino_selected_core_path/hardware/" +
66 "$pw_arduino_build_PACKAGE_NAME/libraries"
68 arduino_global_args = [
69 "--arduino-package-path",
70 _arduino_selected_core_path,
71 "--arduino-package-name",
72 pw_arduino_build_PACKAGE_NAME,
73 "--compiler-path-override",
74 _compiler_path_override,
76 # Save config files to "out/arduino_debug/gen/arduino_builder_config.json"
78 rebase_path(root_gen_dir) + "/arduino_builder_config.json",
82 arduino_board_args = [
84 rebase_path(root_build_dir),
86 pw_arduino_build_BOARD,
88 if (pw_arduino_build_MENU_OPTIONS != []) {
89 arduino_board_args += [ "--menu-options" ]
90 arduino_board_args += pw_arduino_build_MENU_OPTIONS
93 arduino_show_command_args = arduino_global_args + [
95 "--delimit-with-newlines",
96 ] + arduino_board_args
98 arduino_run_command_args =
99 arduino_global_args + [ "run" ] + arduino_board_args