blob: 56be5448a6105b5c2e5b83863a592e68fec4d81d [file]
# 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_build/python_dist.gni")
import("$dir_pw_build/python_venv.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",
":docs",
":examples",
":host",
":legacy_examples",
":python.lint",
":python.tests",
]
}
group("docs") {
deps = [ "//docs($dir_pigweed/targets/docs)" ]
}
# Group all targets that run on host only, e.g. tests, utils.
group("host") {
deps = [ ":run_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 = [ ":run_tests(//targets/arduino:arduino_debug_tests)" ]
}
}
# stm32f429i_disc1 specific targets
group("stm32f429i_disc1") {
_default_toolchain = "//targets/stm32f429i_disc1:stm32f429i_disc1_debug"
_testing_toolchain = "${_default_toolchain}_tests"
deps = [ ":run_tests(${_testing_toolchain})" ]
}
# This group is built during bootstrap to setup the interactive Python
# environment.
pw_python_group("python") {
python_deps = [
# Generate and pip install _all_python_packages
":pip_install_sample_project_tools",
"examples/05-factory-test:factory_test_script",
]
}
# In-tree Python packages
_sample_project_python_packages = [ "//tools:tools" ]
# Pigweed Python packages to include
_pigweed_python_packages = [
"$dir_pw_env_setup:core_pigweed_python_packages",
"$dir_pigweed/targets/lm3s6965evb_qemu/py",
"$dir_pigweed/targets/stm32f429i_disc1/py",
]
_all_python_packages =
_sample_project_python_packages + _pigweed_python_packages
# The default venv for Python actions in GN
# Set this gn arg in a declare_args block in this file 'BUILD.gn' or in '.gn' to
# use this venv.
#
# pw_build_PYTHON_BUILD_VENV = "//:sample_project_build_venv"
#
pw_python_venv("sample_project_build_venv") {
path = "$root_build_dir/python-venv"
constraints = pw_build_PIP_CONSTRAINTS
requirements = pw_build_PIP_REQUIREMENTS
# Ensure all third party Python dependencies are installed into this venv.
# This works by checking the setup.cfg files for all packages listed here and
# installing the packages listed in the [options].install_requires field.
source_packages = _all_python_packages
}
# This template collects all python packages and their dependencies into a
# single super Python package for installation into the bootstrapped virtual
# environment.
pw_python_distribution("sample_project_python_distribution") {
packages = _all_python_packages
generate_setup_cfg = {
name = "sample-project-tools"
version = "0.0.1"
append_date_to_version = true
include_default_pyproject_file = true
}
}
# Install the sample-project-tools super Python package into the bootstrapped
# Python venv.
pw_python_pip_install("pip_install_sample_project_tools") {
packages = [ ":sample_project_python_distribution" ]
}
group("examples") {
deps = []
# STMicroelectronics STM32F429I-DISC1 examples.
deps += [
"//examples/01-blinky:blinky(//targets/stm32f429i_disc1:stm32f429i_disc1_stm32cube.size_optimized)",
"//examples/02-unit-testing:test_runner_app(//targets/stm32f429i_disc1:stm32f429i_disc1_stm32cube.size_optimized)",
]
# TODO: b/297277142 - This will work when There's a SocketStream equivalent
# for Windows.
if (host_os != "win") {
# Host examples.
deps += [
"//examples/01-blinky:blinky(//targets/host:host_device_simulator.speed_optimized)",
"//examples/02-unit-testing:test_runner_app(//targets/host:host_device_simulator.speed_optimized)",
]
}
}
# Legacy examples.
group("legacy_examples") {
deps = []
# Teensy 3.0/4.0 examples steps.
if (pw_arduino_build_CORE_PATH != "") {
deps += [
"//examples/03-rpc:all(//targets/arduino:arduino_debug)",
"//examples/04-kvs:all(//targets/arduino:arduino_debug)",
"//examples/05-factory-test:all(//targets/arduino:arduino_debug)",
]
}
# STMicroelectronics STM32F429I-DISC1 examples steps.
deps += [
"//examples/03-rpc:all(//targets/stm32f429i_disc1:stm32f429i_disc1_debug)",
"//examples/04-kvs:all(//targets/stm32f429i_disc1:stm32f429i_disc1_debug)",
"//examples/05-factory-test:all(//targets/stm32f429i_disc1:stm32f429i_disc1_debug)",
]
}
# All the tests that should run as part of the build.
pw_test_group("tests") {
group_deps = [
# Uncomment this to automatically run the example unit test.
# "//examples/02-unit-testing:tests",
]
}
group("run_tests") {
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" ]
}
}