# 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 > /README.md" ]
}
