# Copyright (c) 2023 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/asr.gni")
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("${asr_sdk_build_root}/asr_sdk.gni")
import("${build_root}/config/defaults.gni")
import("${chip_root}/src/lib/lib.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/third_party/asr/asr_executable.gni")

import("//cfg.gni")

assert(current_os == "freertos")

asr_project_dir = "${chip_root}/examples/thermostat/asr"
examples_plat_dir = "${chip_root}/examples/platform/asr"

declare_args() {
  # Dump memory usage at link time.
  chip_print_memory_usage = false
}

asr_sdk_sources("thermostat_sdk_sources") {
  include_dirs = [
    "${chip_root}/src/platform/ASR",
    "${asr_project_dir}/include",
    "${examples_plat_dir}",
  ]

  defines = [
    "ASR_LOG_ENABLED=1",
    "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
    "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
    "ASR_ENABLE_LED1_DISPLAY=0",
    "ASR_ENABLE_LED2_DISPLAY=0",
  ]

  if (chip_enable_factory_data) {
    defines += [
      "CONFIG_ENABLE_ASR_FACTORY_DATA_PROVIDER=1",
      "CONFIG_ENABLE_ASR_FACTORY_DEVICE_INFO_PROVIDER=1",
    ]
  }

  if (chip_lwip_ip6_hook) {
    defines += [
      "CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT",
      "CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT",
    ]
  }

  sources = [ "${asr_project_dir}/include/CHIPProjectConfig.h" ]

  public_configs = [ "${asr_sdk_build_root}:asr_sdk_config" ]
}

asr_executable("thermostat") {
  include_dirs = []
  defines = []
  output_name = "chip-asr-thermostat-example.out"

  public_deps = [
    ":thermostat_sdk_sources",
    "${chip_root}/examples/common/QRCode",
    "${chip_root}/examples/providers:device_info_provider",
    "${chip_root}/examples/thermostat/thermostat-common",
    "${chip_root}/src/lib",
    "${chip_root}/src/setup_payload",
  ]

  include_dirs += [
    "include",
    "${examples_plat_dir}",
    "${asr_project_dir}/include",
    "${chip_root}/src/lib",
  ]

  sources = [
    "${examples_plat_dir}/CHIPDeviceManager.cpp",
    "${examples_plat_dir}/LEDWidget.cpp",
    "${examples_plat_dir}/init_Matter.cpp",
    "${examples_plat_dir}/init_asrPlatform.cpp",
    "${examples_plat_dir}/shell/matter_shell.cpp",
    "src/AppTask.cpp",
    "src/DeviceCallbacks.cpp",
    "src/SensorManager.cpp",
    "src/TemperatureManager.cpp",
    "src/main.cpp",
  ]

  if (chip_enable_ota_requestor) {
    sources += [ "${examples_plat_dir}/init_OTARequestor.cpp" ]
  }

  defines = [ "ASR_NETWORK_LAYER_BLE=${chip_config_network_layer_ble}" ]

  if (chip_build_libshell) {
    defines += [ "CONFIG_ENABLE_CHIP_SHELL=1" ]
    sources += [ "${examples_plat_dir}/shell/launch_shell.cpp" ]
    include_dirs += [ "${examples_plat_dir}/shell" ]
  }

  output_dir = root_out_dir

  if (chip_print_memory_usage) {
    ldflags = [
      "-Wl,--print-memory-usage",
      "-fstack-usage",
    ]
  }
}

group("asr") {
  deps = [ ":thermostat" ]
}

group("default") {
  deps = [ ":asr" ]
}
