blob: 4abef86e50736cf3a279c464cfc7916cdd4c1e35 [file] [log] [blame]
# 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/python.gni")
import("$dir_pw_tokenizer/database.gni")
import("$dir_pw_unit_test/test.gni")
# NOTE: All the `deps` listed in `//BUILD.gn` must either be instantiated with a
# toolchain, e.g. `":my_host_target(//path/to/host:toolchain)"`, or listed
# within an `if (current_toolchain != default_toolchain)` statement.
# It also prevents the default toolchain from parsing any unnecessary BUILD.gn
# files.
# Lists all the targets build by default with e.g. `ninja -C out`.
group("default") {
deps = [
":arduino",
":host",
":python.lint",
":python.tests",
":tokenizer_database",
":workshop",
]
}
# Hello world group, this will be built using multiple toolchains.
group("app") {
deps = []
# pw_rpc codegen is broken on Windows, so it won't be built for host yet.
if (current_toolchain != default_toolchain && current_os != "win") {
deps = [ "//source:hello_world" ]
}
}
# Group all targets that run on host only, e.g. tests, utils.
group("host") {
deps = [
":app(//targets/host:host_debug)",
":host_tests(//targets/host:host_debug_tests)",
]
}
# Arduino specific targets.
group("arduino") {
# If the 'pw_arduino_build_CORE_PATH' build arg is defined assume an arduino
# core is available for building.
#
# For example:
# pw_arduino_build_CORE_PATH="//third_party/pigweed/third_party/arduino/cores"
if (pw_arduino_build_CORE_PATH != "") {
deps = [
":app(//targets/arduino:arduino_debug)",
":arduino_tests(//targets/arduino:arduino_debug_tests)",
"//source/arduino_example:blink(//targets/arduino:arduino_debug)",
"//source/teensy_time:all(//targets/arduino:arduino_debug)",
]
}
}
# stm32f429i_disc1 specific targets
group("stm32f429i_disc1") {
_default_toolchain = "//targets/stm32f429i_disc1:stm32f429i_disc1_debug"
_testing_toolchain = "${_default_toolchain}_tests"
deps = [
":app(${_default_toolchain})",
":tests(${_testing_toolchain})",
]
}
# Python packages are built using the host toolchain.
pw_python_group("python") {
# This depends on the 'tools' target in //tools/BUILD.gn
python_deps = [
"tools",
"workshop/05-factory-test:factory_test_script",
"//third_party/pigweed/pw_env_setup:python",
"//third_party/pigweed/pw_env_setup:target_support_packages",
]
}
# This 'pw_tokenizer_database' target will update the tokenizer_database.csv
# file for all dependencies listed in 'targets'.
pw_tokenizer_database("tokenizer_database") {
database = "//source/tokenizer_database.csv"
# Tokenizer databases can only be created for elf binaries
if (host_os == "linux") {
targets = [ ":app(//targets/host:host_debug)" ]
} else {
targets = []
}
if (pw_arduino_build_CORE_PATH != "") {
targets += [
":app(//targets/arduino:arduino_debug)",
"//source/arduino_example:blink(//targets/arduino:arduino_debug)",
]
}
}
# Workshop Exercises
group("workshop") {
deps = []
# Teensy 3.0/4.0 workshop steps.
if (pw_arduino_build_CORE_PATH != "") {
deps += [
":workshop_tests(//targets/arduino:arduino_debug_tests)",
"//workshop/01-blinky:all(//targets/arduino:arduino_debug)",
"//workshop/02-string-functions:all(//targets/arduino:arduino_debug)",
"//workshop/03-rpc:all(//targets/arduino:arduino_debug)",
"//workshop/04-kvs:all(//targets/arduino:arduino_debug)",
"//workshop/05-factory-test:all(//targets/arduino:arduino_debug)",
]
}
# STMicroelectronics STM32F429I-DISC1 workshop steps.
deps += [
":workshop_tests(//targets/stm32f429i_disc1:stm32f429i_disc1_debug_tests)",
"//workshop/01-blinky:blinky(//targets/stm32f429i_disc1:stm32f429i_disc1_debug)",
"//workshop/02-string-functions:all(//targets/stm32f429i_disc1:stm32f429i_disc1_debug)",
"//workshop/03-rpc:all(//targets/stm32f429i_disc1:stm32f429i_disc1_debug)",
"//workshop/04-kvs:all(//targets/stm32f429i_disc1:stm32f429i_disc1_debug)",
"//workshop/05-factory-test:all(//targets/stm32f429i_disc1:stm32f429i_disc1_debug)",
]
# Host workshop steps.
deps += [
":workshop_tests(//targets/host:host_debug_tests)",
"//workshop/01-blinky:all(//targets/host:host_debug)",
"//workshop/02-string-functions:all(//targets/host:host_debug)",
]
}
# Group the different modules tests together.
pw_test_group("tests") {
group_deps = [
"//source/simple_counter:tests",
# Disable teensy flash tests until the patcher is available.
# To enable: uncomment this and modify eeprom.c to remove static from
# flash_write() and flash_erase_sector()
# "//source/teensy_flash:tests",
"//workshop/02-string-functions:tests",
]
}
# Test groups for each platform that will build and optionally run the tests.
foreach(test_group,
[
"arduino",
"host",
"workshop",
]) {
group("${test_group}_tests") {
deps = []
if (pw_unit_test_AUTOMATIC_RUNNER == "") {
# Without a test runner defined, build the tests but don't run them.
deps += [ ":tests" ]
} else {
# With a test runner, build and run tests.
deps += [ ":tests_run" ]
}
}
}