Anthony DiGirolamo | e9a3ce6 | 2023-10-20 21:06:44 +0000 | [diff] [blame] | 1 | # Copyright 2023 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 | |
| 15 | import("//build_overrides/pigweed.gni") |
| 16 | |
| 17 | import("$dir_pw_build/python.gni") |
| 18 | import("$dir_pw_build/python_dist.gni") |
| 19 | import("$dir_pw_build/python_venv.gni") |
| 20 | import("$dir_pw_unit_test/test.gni") |
| 21 | |
| 22 | # All the targets build by default with e.g. `ninja -C out`. |
| 23 | group("default") { |
| 24 | deps = [ |
| 25 | ":applications", |
| 26 | ":gonk_python.lint", |
| 27 | ":gonk_python.tests", |
| 28 | ":python.install", |
Anthony DiGirolamo | 63be565 | 2023-12-18 22:33:30 +0000 | [diff] [blame] | 29 | |
| 30 | # TODO(tonymd): Enable the verilog build by default when the following tools |
| 31 | # are available in CIPD: yosys, nextpnr-ice40, icetime, icepack |
| 32 | # ":fpga", |
Anthony DiGirolamo | e9a3ce6 | 2023-10-20 21:06:44 +0000 | [diff] [blame] | 33 | ] |
| 34 | } |
| 35 | |
| 36 | group("applications") { |
| 37 | deps = [ |
| 38 | "//applications/system_example(//targets/host:host_device_simulator.speed_optimized)", |
Anthony DiGirolamo | f9ab1c4 | 2023-10-20 21:24:41 +0000 | [diff] [blame] | 39 | "//applications/system_example(//targets/stm32f769i_disc0_stm32cube:stm32f769i_disc0_stm32cube.size_optimized)", |
Anthony DiGirolamo | 76488cf | 2023-10-30 18:57:46 +0000 | [diff] [blame] | 40 | |
| 41 | # Arduino targets |
Anthony DiGirolamo | 87acfa9 | 2024-08-02 20:32:54 +0000 | [diff] [blame] | 42 | "//applications/gonk(//targets/stm32f730r8tx_arduino:arduino_size_optimized)", |
Anthony DiGirolamo | 8e681ef | 2023-12-18 22:13:33 +0000 | [diff] [blame] | 43 | "//applications/spi_flash_test(//targets/stm32f730r8tx_arduino:arduino_size_optimized)", |
Anthony DiGirolamo | e9a3ce6 | 2023-10-20 21:06:44 +0000 | [diff] [blame] | 44 | ] |
| 45 | } |
| 46 | |
Anthony DiGirolamo | cbdd610 | 2024-02-08 15:43:10 +0000 | [diff] [blame] | 47 | # This group requires the following tools for the FPGA build: |
| 48 | # yosys, nextpnr-ice40, icepack, icetime |
Anthony DiGirolamo | 63be565 | 2023-12-18 22:33:30 +0000 | [diff] [blame] | 49 | group("fpga") { |
Anthony DiGirolamo | 7d7ff1a | 2024-03-05 22:30:07 +0000 | [diff] [blame] | 50 | deps = [ "//fpga" ] |
Anthony DiGirolamo | 63be565 | 2023-12-18 22:33:30 +0000 | [diff] [blame] | 51 | } |
| 52 | |
Anthony DiGirolamo | e9a3ce6 | 2023-10-20 21:06:44 +0000 | [diff] [blame] | 53 | # Python Targets |
| 54 | _gonk_python_packages = [ "//tools" ] |
Anthony DiGirolamo | 1848b89 | 2024-02-01 16:36:41 +0000 | [diff] [blame] | 55 | _gonk_proto_packages = [ "//lib/adc:protos.python" ] |
| 56 | |
Anthony DiGirolamo | e9a3ce6 | 2023-10-20 21:06:44 +0000 | [diff] [blame] | 57 | # Pigweed Python packages to include |
| 58 | _pigweed_python_packages = [ "$dir_pw_env_setup:core_pigweed_python_packages" ] |
| 59 | |
Anthony DiGirolamo | cbdd610 | 2024-02-08 15:43:10 +0000 | [diff] [blame] | 60 | _all_python_packages = |
| 61 | _gonk_python_packages + _gonk_proto_packages + _pigweed_python_packages |
Anthony DiGirolamo | e9a3ce6 | 2023-10-20 21:06:44 +0000 | [diff] [blame] | 62 | |
Anthony DiGirolamo | cbdd610 | 2024-02-08 15:43:10 +0000 | [diff] [blame] | 63 | # Group that defines all Python test and lint targets. |
Anthony DiGirolamo | e9a3ce6 | 2023-10-20 21:06:44 +0000 | [diff] [blame] | 64 | pw_python_group("gonk_python") { |
| 65 | python_deps = _gonk_python_packages |
| 66 | } |
| 67 | |
Anthony DiGirolamo | cbdd610 | 2024-02-08 15:43:10 +0000 | [diff] [blame] | 68 | # The python virtualenv used for testing and linting. |
Anthony DiGirolamo | e9a3ce6 | 2023-10-20 21:06:44 +0000 | [diff] [blame] | 69 | pw_python_venv("gonk_build_venv") { |
| 70 | path = "$root_build_dir/python-venv" |
| 71 | source_packages = _all_python_packages |
| 72 | } |
| 73 | |
Anthony DiGirolamo | cbdd610 | 2024-02-08 15:43:10 +0000 | [diff] [blame] | 74 | # Bundle of all Gonk Python packages and their Pigweed dependencies |
Anthony DiGirolamo | 7d7ff1a | 2024-03-05 22:30:07 +0000 | [diff] [blame] | 75 | pw_python_distribution("gonk_python_tools") { |
Anthony DiGirolamo | cbdd610 | 2024-02-08 15:43:10 +0000 | [diff] [blame] | 76 | packages = _gonk_python_packages + _gonk_proto_packages |
Anthony DiGirolamo | e9a3ce6 | 2023-10-20 21:06:44 +0000 | [diff] [blame] | 77 | generate_setup_cfg = { |
| 78 | name = "gonk-dist" |
| 79 | version = "0.0.1" |
| 80 | append_date_to_version = true |
| 81 | include_default_pyproject_file = true |
| 82 | } |
| 83 | } |
| 84 | |
Anthony DiGirolamo | cbdd610 | 2024-02-08 15:43:10 +0000 | [diff] [blame] | 85 | # Pip install target for Gonk Python tools and protos. |
Anthony DiGirolamo | 7d7ff1a | 2024-03-05 22:30:07 +0000 | [diff] [blame] | 86 | pw_python_pip_install("pip_install_gonk_tools") { |
| 87 | packages = [ ":gonk_python_tools" ] |
Anthony DiGirolamo | e9a3ce6 | 2023-10-20 21:06:44 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Anthony DiGirolamo | 7d7ff1a | 2024-03-05 22:30:07 +0000 | [diff] [blame] | 90 | # Python data package for Gonk firmware build. |
| 91 | pw_python_distribution("gonk_firmware") { |
Anthony DiGirolamo | cbdd610 | 2024-02-08 15:43:10 +0000 | [diff] [blame] | 92 | packages = [] |
| 93 | generate_setup_cfg = { |
Anthony DiGirolamo | 7d7ff1a | 2024-03-05 22:30:07 +0000 | [diff] [blame] | 94 | name = "gonk-firmware" |
Anthony DiGirolamo | cbdd610 | 2024-02-08 15:43:10 +0000 | [diff] [blame] | 95 | version = "0.0.1" |
| 96 | append_date_to_version = true |
| 97 | include_default_pyproject_file = true |
| 98 | include_extra_files_in_package_data = true |
| 99 | auto_create_package_data_init_py_files = true |
| 100 | } |
| 101 | |
Anthony DiGirolamo | 7d7ff1a | 2024-03-05 22:30:07 +0000 | [diff] [blame] | 102 | public_deps = [ |
Anthony DiGirolamo | 87acfa9 | 2024-08-02 20:32:54 +0000 | [diff] [blame] | 103 | "//applications/gonk:gonk(//targets/stm32f730r8tx_arduino:arduino_size_optimized)", |
| 104 | "//applications/gonk:gonk.elf(//targets/stm32f730r8tx_arduino:arduino_size_optimized)", |
Anthony DiGirolamo | 7d7ff1a | 2024-03-05 22:30:07 +0000 | [diff] [blame] | 105 | ] |
| 106 | |
Anthony DiGirolamo | 87acfa9 | 2024-08-02 20:32:54 +0000 | [diff] [blame] | 107 | _gonk_bin = |
| 108 | "$root_build_dir/arduino_size_optimized/obj/applications/gonk/gonk.bin" |
| 109 | _gonk_elf = "$root_build_dir/arduino_size_optimized/obj/applications/gonk/bin/gonk.elf" |
Anthony DiGirolamo | 7d7ff1a | 2024-03-05 22:30:07 +0000 | [diff] [blame] | 110 | extra_files = [ |
| 111 | "$_gonk_bin > gonk_firmware/gonk.bin", |
| 112 | "$_gonk_elf > gonk_firmware/gonk.elf", |
| 113 | ] |
Anthony DiGirolamo | cbdd610 | 2024-02-08 15:43:10 +0000 | [diff] [blame] | 114 | |
| 115 | # The FPGA image is only built on Linux so far. |
| 116 | if (host_os == "linux") { |
| 117 | _fpga_artifacts_dir = "$root_build_dir/obj/fpga/toplevel" |
| 118 | |
| 119 | public_deps += [ "//fpga:toplevel._bin($default_toolchain)" ] |
Anthony DiGirolamo | 7d7ff1a | 2024-03-05 22:30:07 +0000 | [diff] [blame] | 120 | extra_files += |
| 121 | [ "$_fpga_artifacts_dir/toplevel.bin > gonk_firmware/fpga.bin" ] |
Anthony DiGirolamo | cbdd610 | 2024-02-08 15:43:10 +0000 | [diff] [blame] | 122 | } |
Anthony DiGirolamo | e9a3ce6 | 2023-10-20 21:06:44 +0000 | [diff] [blame] | 123 | } |
| 124 | |
Anthony DiGirolamo | 7d7ff1a | 2024-03-05 22:30:07 +0000 | [diff] [blame] | 125 | # Pip install target for the firmware datapackage only. This is separate since |
| 126 | # the FPGA toolchain is an optional build component. |
| 127 | pw_python_pip_install("pip_install_gonk_firmware") { |
| 128 | packages = [ ":gonk_firmware" ] |
Anthony DiGirolamo | cbdd610 | 2024-02-08 15:43:10 +0000 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | # Python group used durring bootstrap. |
Anthony DiGirolamo | e9a3ce6 | 2023-10-20 21:06:44 +0000 | [diff] [blame] | 132 | pw_python_group("python") { |
| 133 | python_deps = [ |
Anthony DiGirolamo | 7d7ff1a | 2024-03-05 22:30:07 +0000 | [diff] [blame] | 134 | ":pip_install_gonk_tools", |
Anthony DiGirolamo | cbdd610 | 2024-02-08 15:43:10 +0000 | [diff] [blame] | 135 | "$dir_pw_env_setup:pip_install_pigweed_package", |
Anthony DiGirolamo | e9a3ce6 | 2023-10-20 21:06:44 +0000 | [diff] [blame] | 136 | ] |
| 137 | } |
Anthony DiGirolamo | 7d7ff1a | 2024-03-05 22:30:07 +0000 | [diff] [blame] | 138 | |
| 139 | _gonk_bundle_packages = |
| 140 | _gonk_python_packages + _gonk_proto_packages + [ ":gonk_firmware" ] |
| 141 | |
| 142 | pw_python_venv("gonk_bundle_venv") { |
| 143 | path = "$root_build_dir/gonk-bundle-venv" |
| 144 | source_packages = _gonk_bundle_packages |
| 145 | } |
| 146 | |
| 147 | pw_python_zip_with_setup("gonk_bundle") { |
| 148 | # Include vendored wheels for this virtualenv. |
| 149 | venv = ":gonk_bundle_venv" |
| 150 | |
| 151 | # Gonk packages to include |
| 152 | packages = [ |
| 153 | ":gonk_firmware", |
| 154 | ":gonk_python_tools", |
| 155 | ] |
Anthony DiGirolamo | a597058 | 2024-05-07 21:19:13 +0000 | [diff] [blame] | 156 | |
| 157 | # Add the tools README to the zipfile. |
Anthony DiGirolamo | 5625ff0 | 2024-10-14 20:46:03 +0000 | [diff] [blame] | 158 | inputs = [ "//tools/README.md > /gonk_bundle/README.md" ] |
Anthony DiGirolamo | 7d7ff1a | 2024-03-05 22:30:07 +0000 | [diff] [blame] | 159 | } |