third_party.pigweed.src/targets/arduino/BUILD.gn

119 lines
4.1 KiB
Plaintext
Raw Normal View History

# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
import("//build_overrides/pigweed.gni")
import("$dir_pw_arduino_build/arduino.gni")
import("$dir_pw_build/target_types.gni")
import("$dir_pw_docgen/docs.gni")
import("$dir_pw_toolchain/generate_toolchain.gni")
pw_doc_group("target_docs") {
sources = [ "target_docs.rst" ]
}
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>
2020-11-26 20:06:41 +00:00
if (pw_arduino_build_CORE_PATH != "") {
import("target_toolchains.gni")
generate_toolchains("target_toolchains") {
toolchains = pw_target_toolchain_arduino_list
}
if (current_toolchain != default_toolchain) {
config("arduino_build") {
# Debug: Print out arduinobuilder.py args
# print(string_join(" ", [rebase_path(arduino_builder_script)] + arduino_show_command_args))
# Run prebuilds
# TODO(tonymd) This only needs to be run once but it's happening multiple times.
exec_script(arduino_builder_script,
filter_exclude(arduino_run_command_args,
[ "--save-config" ]) + [ "--run-prebuilds" ],
"string")
_exclude_flags = [ "-std=gnu++14" ]
_cflags = exec_script(arduino_builder_script,
arduino_show_command_args + [ "--c-flags" ],
"list lines")
cflags = filter_exclude(_cflags, _exclude_flags)
asmflags = exec_script(arduino_builder_script,
arduino_show_command_args + [ "--s-only-flags" ],
"list lines")
_cflags_cc =
exec_script(arduino_builder_script,
arduino_show_command_args + [ "--cpp-only-flags" ],
"list lines")
cflags_cc = filter_exclude(_cflags_cc, _exclude_flags)
_ldflags = exec_script(arduino_builder_script,
arduino_show_command_args + [ "--ld-flags" ],
"list lines")
ldflags =
filter_exclude(_ldflags,
[
# Remove arguments ending in 'core.a', for example:
# C:/Users/username/pigweed/out/core.a
"*core.a\b",
# Remove .elf output file, for example:
# -o C:/Users/username/pigweed/out/pigweed.elf
"\b-o\b",
"*.elf\b",
# Remove the Arduino {object_files} variable
"{object_files}",
])
# TODO(tonymd): Determine if libs are needed.
# Teensy4 core recipe uses: '-larm_cortexM7lfsp_math -lm -lstdc++'
libs = filter_exclude(
exec_script(arduino_builder_script,
arduino_show_command_args + [ "--ld-lib-names" ],
"list lines"),
# Exclude stdc++ which causes linking errors for teensy cores.
[ "\bstdc++\b" ])
}
pw_source_set("pre_init") {
sources = [ "init.cc" ]
public_deps = [
"$dir_pw_sys_io_arduino",
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>
2020-11-26 20:06:41 +00:00
"$dir_pw_third_party/arduino:arduino_core_sources",
]
deps = [
"$dir_pw_arduino_build:arduino_init.facade",
"$dir_pw_preprocessor",
]
}
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>
2020-11-26 20:06:41 +00:00
pw_source_set("system_rpc_server") {
deps = [
"$dir_pw_hdlc:pw_rpc",
"$dir_pw_hdlc:rpc_channel_output",
"$dir_pw_rpc/system_server:facade",
"$dir_pw_stream:sys_io_stream",
dir_pw_log,
]
sources = [ "system_rpc_server.cc" ]
}
}
} else {
config("arduino_build") {
}
group("pre_init") {
}
}