blob: 337294c77bb5151c50adf54efd65ed56a946515b [file] [log] [blame]
# Copyright 2023 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_build/python.gni")
import("$dir_pw_build/python_dist.gni")
import("$dir_pw_build/python_venv.gni")
import("$dir_pw_unit_test/test.gni")
# All the targets build by default with e.g. `ninja -C out`.
group("default") {
deps = [
":applications",
":gonk_python.lint",
":gonk_python.tests",
":python.install",
# TODO(tonymd): Enable the verilog build by default when the following tools
# are available in CIPD: yosys, nextpnr-ice40, icetime, icepack
# ":fpga",
]
}
group("applications") {
deps = [
"//applications/system_example(//targets/host:host_device_simulator.speed_optimized)",
"//applications/system_example(//targets/stm32f769i_disc0_stm32cube:stm32f769i_disc0_stm32cube.size_optimized)",
# Arduino targets
"//applications/gonk(//targets/stm32f730r8tx_arduino:arduino_size_optimized)",
"//applications/spi_flash_test(//targets/stm32f730r8tx_arduino:arduino_size_optimized)",
]
}
# This group requires the following tools for the FPGA build:
# yosys, nextpnr-ice40, icepack, icetime
group("fpga") {
deps = [ "//fpga" ]
}
# Python Targets
_gonk_python_packages = [ "//tools" ]
_gonk_proto_packages = [ "//lib/adc:protos.python" ]
# Pigweed Python packages to include
_pigweed_python_packages = [ "$dir_pw_env_setup:core_pigweed_python_packages" ]
_all_python_packages =
_gonk_python_packages + _gonk_proto_packages + _pigweed_python_packages
# Group that defines all Python test and lint targets.
pw_python_group("gonk_python") {
python_deps = _gonk_python_packages
}
# The python virtualenv used for testing and linting.
pw_python_venv("gonk_build_venv") {
path = "$root_build_dir/python-venv"
source_packages = _all_python_packages
}
# Bundle of all Gonk Python packages and their Pigweed dependencies
pw_python_distribution("gonk_python_tools") {
packages = _gonk_python_packages + _gonk_proto_packages
generate_setup_cfg = {
name = "gonk-dist"
version = "0.0.1"
append_date_to_version = true
include_default_pyproject_file = true
}
}
# Pip install target for Gonk Python tools and protos.
pw_python_pip_install("pip_install_gonk_tools") {
packages = [ ":gonk_python_tools" ]
}
# Python data package for Gonk firmware build.
pw_python_distribution("gonk_firmware") {
packages = []
generate_setup_cfg = {
name = "gonk-firmware"
version = "0.0.1"
append_date_to_version = true
include_default_pyproject_file = true
include_extra_files_in_package_data = true
auto_create_package_data_init_py_files = true
}
public_deps = [
"//applications/gonk:gonk(//targets/stm32f730r8tx_arduino:arduino_size_optimized)",
"//applications/gonk:gonk.elf(//targets/stm32f730r8tx_arduino:arduino_size_optimized)",
]
_gonk_bin =
"$root_build_dir/arduino_size_optimized/obj/applications/gonk/gonk.bin"
_gonk_elf = "$root_build_dir/arduino_size_optimized/obj/applications/gonk/bin/gonk.elf"
extra_files = [
"$_gonk_bin > gonk_firmware/gonk.bin",
"$_gonk_elf > gonk_firmware/gonk.elf",
]
# The FPGA image is only built on Linux so far.
if (host_os == "linux") {
_fpga_artifacts_dir = "$root_build_dir/obj/fpga/toplevel"
public_deps += [ "//fpga:toplevel._bin($default_toolchain)" ]
extra_files +=
[ "$_fpga_artifacts_dir/toplevel.bin > gonk_firmware/fpga.bin" ]
}
}
# Pip install target for the firmware datapackage only. This is separate since
# the FPGA toolchain is an optional build component.
pw_python_pip_install("pip_install_gonk_firmware") {
packages = [ ":gonk_firmware" ]
}
# Python group used durring bootstrap.
pw_python_group("python") {
python_deps = [
":pip_install_gonk_tools",
"$dir_pw_env_setup:pip_install_pigweed_package",
]
}
_gonk_bundle_packages =
_gonk_python_packages + _gonk_proto_packages + [ ":gonk_firmware" ]
pw_python_venv("gonk_bundle_venv") {
path = "$root_build_dir/gonk-bundle-venv"
source_packages = _gonk_bundle_packages
}
pw_python_zip_with_setup("gonk_bundle") {
# Include vendored wheels for this virtualenv.
venv = ":gonk_bundle_venv"
# Gonk packages to include
packages = [
":gonk_firmware",
":gonk_python_tools",
]
# Add the tools README to the zipfile.
inputs = [ "//tools/README.md > /gonk_bundle/README.md" ]
}