Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_arduino_build / arduino.gni
1 # Copyright 2020 The Pigweed Authors
2 #
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
5 # the License at
6 #
7 #     https://www.apache.org/licenses/LICENSE-2.0
8 #
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
13 # the License.
14
15 import("//build_overrides/pigweed.gni")
16
17 declare_args() {
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 = ""
21
22   # Expected args for an Arduino build:
23   pw_arduino_build_CORE_NAME = ""
24
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 = ""
30
31   # Menu options should be a list of strings.
32   pw_arduino_build_MENU_OPTIONS = []
33 }
34
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)
47
48   _arduino_selected_core_path =
49       rebase_path("$pw_arduino_build_CORE_PATH/$pw_arduino_build_CORE_NAME")
50
51   arduino_builder_script =
52       get_path_info("py/pw_arduino_build/__main__.py", "abspath")
53
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")
61
62   _compiler_path_override =
63       rebase_path(getenv("_PW_ACTUAL_ENVIRONMENT_ROOT") + "/cipd/pigweed/bin")
64
65   arduino_core_library_path = "$_arduino_selected_core_path/hardware/" +
66                               "$pw_arduino_build_PACKAGE_NAME/libraries"
67
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,
75
76     # Save config files to "out/arduino_debug/gen/arduino_builder_config.json"
77     "--config-file",
78     rebase_path(root_gen_dir) + "/arduino_builder_config.json",
79     "--save-config",
80   ]
81
82   arduino_board_args = [
83     "--build-path",
84     rebase_path(root_build_dir),
85     "--board",
86     pw_arduino_build_BOARD,
87   ]
88   if (pw_arduino_build_MENU_OPTIONS != []) {
89     arduino_board_args += [ "--menu-options" ]
90     arduino_board_args += pw_arduino_build_MENU_OPTIONS
91   }
92
93   arduino_show_command_args = arduino_global_args + [
94                                 "show",
95                                 "--delimit-with-newlines",
96                               ] + arduino_board_args
97
98   arduino_run_command_args =
99       arduino_global_args + [ "run" ] + arduino_board_args
100 }