# Copyright (c) 2020 Project CHIP 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
#
# http://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/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")

import("$dir_pw_build/python.gni")

import("${chip_root}/build/chip/tools.gni")
import("${chip_root}/src/platform/device.gni")
import("${dir_pw_unit_test}/test.gni")

config("controller_wno_deprecate") {
  cflags = [ "-Wno-deprecated-declarations" ]
}

config("includes") {
  include_dirs =
      [ "${chip_root}/src/controller/CHIPDeviceController_deprecated.h" ]
}

shared_library("ChipDeviceCtrl") {
  output_name = "_ChipDeviceCtrl"
  output_dir = "${target_out_dir}/chip"
  include_dirs = [ "." ]

  sources = [
    "ChipDeviceController-ClusterCommands.cpp",
    "ChipDeviceController-ScriptBinding.cpp",
    "ChipDeviceController-ScriptDeviceAddressUpdateDelegate.cpp",
    "ChipDeviceController-ScriptDeviceAddressUpdateDelegate.h",
    "ChipDeviceController-ScriptDevicePairingDelegate.cpp",
    "ChipDeviceController-ScriptDevicePairingDelegate.h",
    "ChipDeviceController-StorageDelegate.cpp",
    "ChipDeviceController-StorageDelegate.h",
    "chip/internal/ChipThreadWork.cpp",
    "chip/internal/ChipThreadWork.h",
    "chip/internal/CommissionerImpl.cpp",
    "chip/logging/LoggingRedirect.cpp",
    "chip/native/StackInit.cpp",
  ]

  if (current_os == "linux" && chip_enable_ble) {
    sources += [ "chip/ble/LinuxImpl.cpp" ]
  }

  public_deps = [
    "${chip_root}/src/app",
    "${chip_root}/src/controller",
    "${chip_root}/src/lib",
    "${chip_root}/src/lib/core",
    "${chip_root}/src/lib/support",
    "${chip_root}/src/platform",
    "${chip_root}/src/transport",
  ]
  allow_circular_includes_from = [ "${chip_root}/src/controller" ]
  configs += [ ":controller_wno_deprecate" ]
}

pw_python_action("python") {
  script = "build-chip-wheel.py"

  _py_manifest_files = [
    {
      src_dir = "."
      sources = [
        "chip-device-ctrl.py",
        "chip-repl.py",
        "chip/ChipBleBase.py",
        "chip/ChipBleUtility.py",
        "chip/ChipBluezMgr.py",
        "chip/ChipCluster.py",
        "chip/ChipCoreBluetoothMgr.py",
        "chip/ChipDeviceCtrl.py",
        "chip/ChipStack.py",
        "chip/ChipUtility.py",
        "chip/__init__.py",
        "chip/configuration/__init__.py",
        "chip/exceptions/__init__.py",
        "chip/internal/__init__.py",
        "chip/internal/commissioner.py",
        "chip/internal/types.py",
        "chip/logging/__init__.py",
        "chip/logging/library_handle.py",
        "chip/logging/types.py",
        "chip/native/__init__.py",
        "chip/tlv/__init__.py",
      ]
    },
    {
      src_dir = target_out_dir
      sources = [ "${target_out_dir}/chip/_ChipDeviceCtrl.so" ]
    },
    {
      src_dir = "//"
      sources = [ "//LICENSE" ]
    },
  ]

  if (chip_enable_ble) {
    _py_manifest_files += [
      {
        src_dir = "."
        sources = [
          "chip/ble/__init__.py",
          "chip/ble/commissioning/__init__.py",
          "chip/ble/get_adapters.py",
          "chip/ble/library_handle.py",
          "chip/ble/scan_devices.py",
          "chip/ble/types.py",
        ]
      },
    ]
  }

  _py_manifest_file = "${target_gen_dir}/${target_name}.py_manifest.json"

  inputs = []
  _py_manifest_files_rebased = []
  foreach(_manifest_entry, _py_manifest_files) {
    inputs += _manifest_entry.sources
    _py_manifest_files_rebased += [
      {
        src_dir = rebase_path(_manifest_entry.src_dir,
                              get_path_info(_py_manifest_file, "dir"))
        sources = rebase_path(_manifest_entry.sources, _manifest_entry.src_dir)
      },
    ]
  }

  _py_manifest = {
    files = _py_manifest_files_rebased
  }

  write_file(_py_manifest_file, _py_manifest, "json")

  _dist_dir = "${root_out_dir}/controller/python"

  args = [
    "--package_name",
    "chip",
    "--build_number",
    "0.0",
    "--build_dir",
    rebase_path("${target_gen_dir}/${target_name}.py_build", root_build_dir),
    "--dist_dir",
    rebase_path(_dist_dir, root_build_dir),
    "--manifest",
    rebase_path(_py_manifest_file, root_build_dir),
  ]

  public_deps = [ ":ChipDeviceCtrl" ]

  pythontags = exec_script("${chip_root}/build/chip/python_gen_tags.py",
                           [],
                           "list lines",
                           [])
  pythontagsStr = string_join("", pythontags)
  output_name = "chip-0.0-$pythontagsStr.whl"
  outputs = [ "${_dist_dir}/$output_name" ]
}
