Anthony DiGirolamo | eea0d77 | 2020-08-06 12:00:36 -0700 | [diff] [blame] | 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 | |
Anthony DiGirolamo | eea0d77 | 2020-08-06 12:00:36 -0700 | [diff] [blame] | 15 | import("//build_overrides/pigweed.gni") |
| 16 | |
| 17 | import("$dir_pw_arduino_build/arduino.gni") |
| 18 | import("$dir_pw_build/target_types.gni") |
| 19 | import("$dir_pw_docgen/docs.gni") |
| 20 | import("$dir_pw_toolchain/generate_toolchain.gni") |
| 21 | pw_doc_group("target_docs") { |
| 22 | sources = [ "target_docs.rst" ] |
| 23 | } |
| 24 | |
Anthony DiGirolamo | 383be05 | 2020-11-26 12:06:41 -0800 | [diff] [blame] | 25 | if (pw_arduino_build_CORE_PATH != "") { |
Anthony DiGirolamo | eea0d77 | 2020-08-06 12:00:36 -0700 | [diff] [blame] | 26 | import("target_toolchains.gni") |
Wyatt Hepler | d49f8fe | 2020-10-15 10:13:47 -0700 | [diff] [blame] | 27 | |
Anthony DiGirolamo | eea0d77 | 2020-08-06 12:00:36 -0700 | [diff] [blame] | 28 | generate_toolchains("target_toolchains") { |
| 29 | toolchains = pw_target_toolchain_arduino_list |
| 30 | } |
| 31 | |
Anthony DiGirolamo | eea0d77 | 2020-08-06 12:00:36 -0700 | [diff] [blame] | 32 | if (current_toolchain != default_toolchain) { |
Anthony DiGirolamo | c36af65 | 2020-09-29 14:34:27 -0700 | [diff] [blame] | 33 | config("arduino_build") { |
| 34 | # Debug: Print out arduinobuilder.py args |
Michael Spang | c8b9390 | 2021-05-30 15:53:56 -0400 | [diff] [blame] | 35 | # print(string_join(" ", [rebase_path(arduino_builder_script, root_build_dir)] + arduino_show_command_args)) |
Anthony DiGirolamo | c36af65 | 2020-09-29 14:34:27 -0700 | [diff] [blame] | 36 | |
| 37 | # Run prebuilds |
| 38 | # TODO(tonymd) This only needs to be run once but it's happening multiple times. |
| 39 | exec_script(arduino_builder_script, |
| 40 | filter_exclude(arduino_run_command_args, |
| 41 | [ "--save-config" ]) + [ "--run-prebuilds" ], |
| 42 | "string") |
| 43 | |
| 44 | _exclude_flags = [ "-std=gnu++14" ] |
| 45 | |
| 46 | _cflags = exec_script(arduino_builder_script, |
| 47 | arduino_show_command_args + [ "--c-flags" ], |
| 48 | "list lines") |
| 49 | cflags = filter_exclude(_cflags, _exclude_flags) |
| 50 | |
| 51 | asmflags = exec_script(arduino_builder_script, |
Anthony DiGirolamo | efdd240 | 2020-10-31 20:31:54 -0700 | [diff] [blame] | 52 | arduino_show_command_args + [ "--s-only-flags" ], |
Anthony DiGirolamo | c36af65 | 2020-09-29 14:34:27 -0700 | [diff] [blame] | 53 | "list lines") |
| 54 | |
Anthony DiGirolamo | efdd240 | 2020-10-31 20:31:54 -0700 | [diff] [blame] | 55 | _cflags_cc = |
| 56 | exec_script(arduino_builder_script, |
| 57 | arduino_show_command_args + [ "--cpp-only-flags" ], |
| 58 | "list lines") |
Anthony DiGirolamo | c36af65 | 2020-09-29 14:34:27 -0700 | [diff] [blame] | 59 | cflags_cc = filter_exclude(_cflags_cc, _exclude_flags) |
| 60 | |
| 61 | _ldflags = exec_script(arduino_builder_script, |
| 62 | arduino_show_command_args + [ "--ld-flags" ], |
| 63 | "list lines") |
| 64 | ldflags = |
| 65 | filter_exclude(_ldflags, |
| 66 | [ |
| 67 | # Remove arguments ending in 'core.a', for example: |
| 68 | # C:/Users/username/pigweed/out/core.a |
| 69 | "*core.a\b", |
| 70 | |
| 71 | # Remove .elf output file, for example: |
| 72 | # -o C:/Users/username/pigweed/out/pigweed.elf |
| 73 | "\b-o\b", |
| 74 | "*.elf\b", |
| 75 | |
| 76 | # Remove the Arduino {object_files} variable |
| 77 | "{object_files}", |
| 78 | ]) |
Anthony DiGirolamo | efdd240 | 2020-10-31 20:31:54 -0700 | [diff] [blame] | 79 | |
| 80 | # TODO(tonymd): Determine if libs are needed. |
| 81 | # Teensy4 core recipe uses: '-larm_cortexM7lfsp_math -lm -lstdc++' |
Anthony DiGirolamo | 14f3a06 | 2020-12-14 13:29:59 -0800 | [diff] [blame] | 82 | libs = filter_exclude( |
| 83 | exec_script(arduino_builder_script, |
| 84 | arduino_show_command_args + [ "--ld-lib-names" ], |
| 85 | "list lines"), |
| 86 | # Exclude stdc++ which causes linking errors for teensy cores. |
| 87 | [ "\bstdc++\b" ]) |
Anthony DiGirolamo | c36af65 | 2020-09-29 14:34:27 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Anthony DiGirolamo | eea0d77 | 2020-08-06 12:00:36 -0700 | [diff] [blame] | 90 | pw_source_set("pre_init") { |
Anthony DiGirolamo | 9147aa0 | 2020-09-22 10:41:05 -0700 | [diff] [blame] | 91 | sources = [ "init.cc" ] |
Anthony DiGirolamo | eea0d77 | 2020-08-06 12:00:36 -0700 | [diff] [blame] | 92 | public_deps = [ |
| 93 | "$dir_pw_sys_io_arduino", |
Anthony DiGirolamo | 383be05 | 2020-11-26 12:06:41 -0800 | [diff] [blame] | 94 | "$dir_pw_third_party/arduino:arduino_core_sources", |
Anthony DiGirolamo | eea0d77 | 2020-08-06 12:00:36 -0700 | [diff] [blame] | 95 | ] |
Anthony DiGirolamo | 9147aa0 | 2020-09-22 10:41:05 -0700 | [diff] [blame] | 96 | deps = [ |
Wyatt Hepler | e0575f7 | 2020-10-16 10:47:03 -0700 | [diff] [blame] | 97 | "$dir_pw_arduino_build:arduino_init.facade", |
Anthony DiGirolamo | 9147aa0 | 2020-09-22 10:41:05 -0700 | [diff] [blame] | 98 | "$dir_pw_preprocessor", |
| 99 | ] |
Anthony DiGirolamo | eea0d77 | 2020-08-06 12:00:36 -0700 | [diff] [blame] | 100 | } |
Anthony DiGirolamo | 383be05 | 2020-11-26 12:06:41 -0800 | [diff] [blame] | 101 | |
| 102 | pw_source_set("system_rpc_server") { |
| 103 | deps = [ |
| 104 | "$dir_pw_hdlc:pw_rpc", |
| 105 | "$dir_pw_hdlc:rpc_channel_output", |
| 106 | "$dir_pw_rpc/system_server:facade", |
| 107 | "$dir_pw_stream:sys_io_stream", |
| 108 | dir_pw_log, |
| 109 | ] |
| 110 | sources = [ "system_rpc_server.cc" ] |
| 111 | } |
Anthony DiGirolamo | eea0d77 | 2020-08-06 12:00:36 -0700 | [diff] [blame] | 112 | } |
| 113 | } else { |
Carlos Chinchilla | 32358e5 | 2020-10-05 17:21:34 -0700 | [diff] [blame] | 114 | config("arduino_build") { |
Anthony DiGirolamo | eea0d77 | 2020-08-06 12:00:36 -0700 | [diff] [blame] | 115 | } |
| 116 | group("pre_init") { |
| 117 | } |
| 118 | } |