# 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/chip.gni")

import("${chip_root}/build/chip/tests.gni")
import("${chip_root}/src/ble/ble.gni")
import("${chip_root}/src/lwip/lwip.gni")
import("${chip_root}/src/platform/device.gni")

config("includes") {
  include_dirs = [
    "include",
    ".",
    "${root_gen_dir}/include",
  ]

  defines = [ "CHIP_HAVE_CONFIG_H=1" ]

  if (chip_device_platform == "linux" || chip_device_platform == "darwin") {
    defines += [ "CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE=${chip_enable_ble}" ]
  }
}

if (chip_build_tests) {
  import("${chip_root}/build/chip/chip_test_group.gni")

  chip_test_group("tests") {
    deps = [
      "${chip_root}/src/app/tests",
      "${chip_root}/src/credentials/tests",
      "${chip_root}/src/crypto/tests",
      "${chip_root}/src/inet/tests",
      "${chip_root}/src/lib/asn1/tests",
      "${chip_root}/src/lib/core/tests",
      "${chip_root}/src/lib/mdns/minimal/core/tests",
      "${chip_root}/src/lib/mdns/minimal/records/tests",
      "${chip_root}/src/lib/mdns/minimal/responders/tests",
      "${chip_root}/src/lib/mdns/minimal/tests",
      "${chip_root}/src/lib/support/tests",
      "${chip_root}/src/messaging/tests",
      "${chip_root}/src/protocols/bdx/tests",
      "${chip_root}/src/setup_payload/tests",
      "${chip_root}/src/system/tests",
      "${chip_root}/src/transport/raw/tests",
      "${chip_root}/src/transport/retransmit/tests",
      "${chip_root}/src/transport/tests",
    ]

    if (chip_device_platform != "none") {
      deps += [ "${chip_root}/src/lib/mdns/minimal/tests" ]
    }

    if (chip_device_platform != "esp32") {
      deps += [ "${chip_root}/src/platform/tests" ]
    }

    if (chip_config_network_layer_ble) {
      deps += [ "${chip_root}/src/ble/tests" ]
    }

    if (chip_with_lwip && chip_device_platform != "esp32") {
      deps += [ "${chip_root}/src/lwip/tests" ]
    }

    if (current_os != "zephyr" && chip_device_platform != "esp32") {
      deps += [ "${chip_root}/src/lib/shell/tests" ]
    }
  }

  if (chip_enable_happy_tests) {
    group("happy_tests") {
      deps = [
        "${chip_root}/src/test_driver/happy/tests/standalone/inet:inet_tests",
      ]
    }
  }
}
