| # Copyright 2022 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/pi_pico.gni") | 
 | 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_third_party/mcuxpresso/mcuxpresso.gni") | 
 | import("$dir_pw_third_party/stm32cube/stm32cube.gni") | 
 | import("$dir_pw_tokenizer/database.gni") | 
 | import("$dir_pw_unit_test/test.gni") | 
 |  | 
 | # Lists all the targets build by default with e.g. `ninja -C out`. | 
 | group("default") { | 
 |   deps = [ | 
 |     ":applications", | 
 |     ":arduino", | 
 |     ":host", | 
 |     ":host_opt", | 
 |     ":mimxrt595_evk", | 
 |     ":pico", | 
 |     ":pw_experimental_python.lint", | 
 |     ":pw_experimental_python.tests", | 
 |     ":python.install", | 
 |   ] | 
 | } | 
 |  | 
 | # Group all targets that run on host only, e.g. tests, utils. | 
 | group("host") { | 
 |   deps = [ | 
 |     ":host_tests(//targets/host:host_debug_tests)", | 
 |     "$dir_pwexperimental_color:tests.run(//targets/host:host_debug_tests)", | 
 |     "$dir_pwexperimental_display:tests.run(//targets/host:host_debug_tests)", | 
 |     "$dir_pwexperimental_draw:tests.run(//targets/host:host_debug_tests)", | 
 |     "$dir_pwexperimental_framebuffer:tests.run(//targets/host:host_debug_tests)", | 
 |  | 
 |     # See //applications/pw_lcd_display_host_imgui/README.md for instructions. | 
 |     "//applications/32blit_demo:all(//targets/host:host_debug)", | 
 |     "//applications/terminal_display:all(//targets/host:host_debug)", | 
 |   ] | 
 | } | 
 |  | 
 | # Group targets which need to do an optimized host build (e.g. for benchmarking). | 
 | group("host_opt") { | 
 |   deps = [ | 
 |     "$dir_pw_async_bench:size_benchmarks(//targets/host:host_size_optimized)", | 
 |   ] | 
 | } | 
 |  | 
 | # Arduino specific targets. | 
 | group("arduino") { | 
 |   if (pw_arduino_build_CORE_PATH != "") { | 
 |     deps = [ ":arduino_tests(//targets/arduino:arduino_debug_tests)" ] | 
 |  | 
 |     if (pw_arduino_build_CORE_NAME == "teensy") { | 
 |       deps += [ | 
 |         # TODO: https://pwbug.dev/331975034 - use pw_system for these examples | 
 |         # "//applications/terminal_display:all(//targets/arduino:arduino_debug)", | 
 |       ] | 
 |     } | 
 |   } | 
 | } | 
 |  | 
 | # This gn arg must be set to build for the rp2040 | 
 | # PICO_SRC_DIR = "$HOME/pico-sdk" | 
 | group("pico") { | 
 |   if (PICO_SRC_DIR != "") { | 
 |     # TODO: https://pwbug.dev/325649415 - Replace broken bare metal rp2040 target | 
 |     # with one based on pw_system. | 
 |     # deps = [ | 
 |     #   ":pico_tests(//targets/rp2040)", | 
 |     #   "//applications/32blit_demo:all(//targets/rp2040)", | 
 |     #   "//applications/terminal_display:all(//targets/rp2040)", | 
 |     # ] | 
 |   } | 
 | } | 
 |  | 
 | group("mimxrt595_evk") { | 
 |   if (pw_third_party_mcuxpresso_SDK != "") { | 
 |     deps = [ "//applications/terminal_display:all(//targets/mimxrt595_evk:mimxrt595_evk_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})", | 
 |   ] | 
 | } | 
 |  | 
 | # stm32f769i_disc0 specific targets. | 
 | group("stm32f769i_disc0") { | 
 |   _default_toolchain = "//targets/stm32f769i_disc0:stm32f769i_disc0_debug" | 
 |   _testing_toolchain = "${_default_toolchain}_tests" | 
 |   deps = [ | 
 |     # ":app(${_default_toolchain})", | 
 |     ":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_experimental_tools", | 
 |   ] | 
 | } | 
 |  | 
 | # In-tree Python packages | 
 | _pw_experimental_python_packages = [ | 
 |   "//applications/tls_example/trust_store/py", | 
 |   "//tools:tools", | 
 |   "//pw_graphics/py", | 
 | ] | 
 |  | 
 | # 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", | 
 |   "//targets/stm32f769i_disc0/py", | 
 | ] | 
 |  | 
 | _all_python_packages = | 
 |     _pw_experimental_python_packages + _pigweed_python_packages | 
 |  | 
 | pw_python_group("pw_experimental_python") { | 
 |   python_deps = _pw_experimental_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 = "//:pw_experimental_build_venv" | 
 | # | 
 | pw_python_venv("pw_experimental_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_create_python_source_tree( | 
 |     "generate_experimental_tools_python_distribution") { | 
 |   packages = _all_python_packages | 
 |   generate_setup_cfg = { | 
 |     name = "pw-experimental-tools" | 
 |     version = "0.0.1" | 
 |     append_date_to_version = true | 
 |     include_default_pyproject_file = true | 
 |   } | 
 | } | 
 |  | 
 | # Install the pw-experimental-tools super Python package into the bootstrapped | 
 | # Python venv. | 
 | pw_internal_pip_install("pip_install_experimental_tools") { | 
 |   packages = [ ":generate_experimental_tools_python_distribution" ] | 
 | } | 
 |  | 
 | group("applications") { | 
 |   deps = [] | 
 |  | 
 |   # Teensy 3.0/4.0 applications steps. | 
 |   if (pw_arduino_build_CORE_PATH != "") { | 
 |     deps += [ | 
 |       ":applications_tests(//targets/arduino:arduino_debug_tests)", | 
 |       "//applications/blinky:blinky(//targets/arduino:arduino_debug)", | 
 |       "//applications/rpc:all(//targets/arduino:arduino_debug)", | 
 |       "//applications/strings:all(//targets/arduino:arduino_debug)", | 
 |     ] | 
 |  | 
 |     # TODO(b/258827934): Fix size report and reenable. | 
 |     if (pw_arduino_build_CORE_NAME == "teensy-<disabled>") { | 
 |       deps += [ | 
 |         "//applications/tls_example:boringssl_teensy_ethernet(//targets/arduino:arduino_debug)", | 
 |         "//applications/tls_example:mbedtls_teensy_ethernet(//targets/arduino:arduino_debug)", | 
 |         "//applications/tls_example:picotls_teensy_ethernet(//targets/arduino:arduino_debug)", | 
 |       ] | 
 |     } | 
 |   } | 
 |  | 
 |   # Raspberry Pi Pico | 
 |   # TODO: https://pwbug.dev/325649415 - Replace broken bare metal rp2040 target | 
 |   # with one based on pw_system. | 
 |   # if (PICO_SRC_DIR != "") { | 
 |   #   deps += [ | 
 |   #     ":applications_tests(//targets/rp2040)", | 
 |   #     "//applications/blinky:blinky(//targets/rp2040)", | 
 |   #     "//applications/rpc:all(//targets/rp2040)", | 
 |   #     "//applications/strings:all(//targets/rp2040)", | 
 |   #   ] | 
 |   # } | 
 |  | 
 |   # MIMXRT595-EVK application steps. | 
 |   if (pw_third_party_mcuxpresso_SDK != "") { | 
 |     deps += [ | 
 |       ":applications_tests(//targets/mimxrt595_evk:mimxrt595_evk_debug)", | 
 |       "//applications/blinky:blinky(//targets/mimxrt595_evk:mimxrt595_evk_debug)", | 
 |       "//applications/rpc:all(//targets/mimxrt595_evk:mimxrt595_evk_debug)", | 
 |       "//applications/strings:all(//targets/mimxrt595_evk:mimxrt595_evk_debug)", | 
 |       "//applications/terminal_display:all(//targets/mimxrt595_evk:mimxrt595_evk_debug)", | 
 |     ] | 
 |   } | 
 |  | 
 |   if (dir_pw_third_party_stm32cube_f4 != "") { | 
 |     # STMicroelectronics STM32F429I-DISC1 applications steps. | 
 |     deps += [ | 
 |       ":applications_tests(//targets/stm32f429i_disc1:stm32f429i_disc1_debug_tests)", | 
 |       "//applications/blinky:blinky(//targets/stm32f429i_disc1:stm32f429i_disc1_debug)", | 
 |       "//applications/rpc:all(//targets/stm32f429i_disc1:stm32f429i_disc1_debug)", | 
 |       "//applications/strings:all(//targets/stm32f429i_disc1:stm32f429i_disc1_debug)", | 
 |     ] | 
 |  | 
 |     # STMicroelectronics STM32F429I-DISC1 STM32Cube applications steps. | 
 |     deps += [ | 
 |       ":applications_tests(//targets/stm32f429i_disc1_stm32cube:stm32f429i_disc1_stm32cube_debug)", | 
 |       "//applications/blinky:blinky(//targets/stm32f429i_disc1_stm32cube:stm32f429i_disc1_stm32cube_debug)", | 
 |  | 
 |       # TODO: https://pwbug.dev/331975034 - use pw_system for these examples | 
 |       # "//applications/32blit_demo:all(//targets/stm32f429i_disc1_stm32cube:stm32f429i_disc1_stm32cube_debug)", | 
 |       # "//applications/terminal_display:all(//targets/stm32f429i_disc1_stm32cube:stm32f429i_disc1_stm32cube_debug)", | 
 |     ] | 
 |  | 
 |     # STMicroelectronics STM32F439ZI-Nucleo applications steps. | 
 |     deps += [ | 
 |       ":applications_tests(//targets/stm32f439zi_nucleo:stm32f439zi_nucleo_debug)", | 
 |       "//applications/blinky:blinky(//targets/stm32f439zi_nucleo:stm32f439zi_nucleo_debug)", | 
 |     ] | 
 |   } | 
 |  | 
 |   if (dir_pw_third_party_stm32cube_f2 != "") { | 
 |     deps += [ "//applications/blinky:blinky(//targets/stm32f207zg-nucleo:stm32f207zg_nucleo_debug)" ] | 
 |   } | 
 |  | 
 |   if (dir_pw_third_party_stm32cube_f7 != "") { | 
 |     # STMicroelectronics STM32F769I-DISC0 applications steps. | 
 |     deps += [ | 
 |       ":applications_tests(//targets/stm32f769i_disc0:stm32f769i_disc0_debug_tests)", | 
 |       "//applications/blinky:blinky(//targets/stm32f769i_disc0:stm32f769i_disc0_debug)", | 
 |       "//applications/rpc:all(//targets/stm32f769i_disc0:stm32f769i_disc0_debug)", | 
 |       "//applications/strings:all(//targets/stm32f769i_disc0:stm32f769i_disc0_debug)", | 
 |     ] | 
 |  | 
 |     # STMicroelectronics STM32F769I-DISC0 STM32Cube applications steps. | 
 |     deps += [ | 
 |       ":applications_tests(//targets/stm32f769i_disc0_stm32cube:stm32f769i_disc0_stm32cube_debug)", | 
 |       "//applications/blinky:blinky(//targets/stm32f769i_disc0_stm32cube:stm32f769i_disc0_stm32cube_debug)", | 
 |     ] | 
 |   } | 
 |  | 
 |   if (dir_pw_third_party_stm32cube_l5 != "") { | 
 |     deps += [ "//applications/blinky:blinky(//targets/stm32l552ze-nucleo:stm32l552ze_nucleo_debug)" ] | 
 |   } | 
 |  | 
 |   if (dir_pw_third_party_stm32cube_h7 != "") { | 
 |     deps += [ "//applications/blinky:blinky(//targets/stm32h753zi-nucleo:stm32h753zi_nucleo_debug)" ] | 
 |   } | 
 |  | 
 |   # Host applications steps. | 
 |   deps += [ | 
 |     ":applications_tests(//targets/host:host_debug_tests)", | 
 |     "//applications/blinky:blinky(//targets/host:host_debug)", | 
 |     "//applications/strings:all(//targets/host:host_debug)", | 
 |   ] | 
 | } | 
 |  | 
 | # Group the different modules tests together. | 
 | pw_test_group("tests") { | 
 |   group_deps = [ | 
 |     "//applications/strings:tests", | 
 |     "//applications/terminal_display:tests", | 
 |   ] | 
 |  | 
 |   if (pw_arduino_build_CORE_NAME == "teensy") { | 
 |     group_deps += [] | 
 |   } | 
 | } | 
 |  | 
 | # Test groups for each platform that will build and optionally run the tests. | 
 | foreach(test_group, | 
 |         [ | 
 |           "arduino", | 
 |           "pico", | 
 |           "mimxrt595_evk", | 
 |           "host", | 
 |           "applications", | 
 |         ]) { | 
 |   group("${test_group}_tests") { | 
 |     deps = [] | 
 |     if (pw_unit_test_AUTOMATIC_RUNNER == "" || test_group != "host") { | 
 |       # 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" ] | 
 |     } | 
 |   } | 
 | } |