# Copyright (c) 2020-2021 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}/src/lwip/lwip.gni")

declare_args() {
  # Use the lwIP library.
  chip_system_config_use_lwip = chip_with_lwip && current_os == "freertos"

  # Use Network.framework API
  chip_system_config_use_network_framework = false

  # Mutex implementation: posix, freertos, none.
  chip_system_config_locking = ""

  # Clock implementation: clock_gettime, gettimeofday
  chip_system_config_clock = "clock_gettime"

  # Enable metrics collection.
  chip_system_config_provide_statistics = true

  # Use OpenThread TCP/UDP stack directly
  chip_system_config_use_open_thread_inet_endpoints = false
}

declare_args() {
  # Use BSD/POSIX socket API.
  chip_system_config_use_sockets =
      current_os != "freertos" && !chip_system_config_use_network_framework
}

declare_args() {
  # do not use libev by default
  chip_system_config_use_libev = false

  # use the dispatch library on darwin targets
  chip_system_config_use_dispatch =
      (chip_system_config_use_sockets ||
       chip_system_config_use_network_framework) &&
      (current_os == "mac" || current_os == "ios")
}

declare_args() {
  # Event loop type.
  if (chip_system_config_use_lwip ||
      chip_system_config_use_open_thread_inet_endpoints) {
    chip_system_config_event_loop = "FreeRTOS"
  } else {
    chip_system_config_event_loop = "Select"
  }
}

if (chip_system_config_locking == "") {
  if (current_os == "freertos") {
    chip_system_config_locking = "freertos"
  } else if (current_os == "mbed") {
    chip_system_config_locking = "mbed"
  } else if (current_os == "cmsis-rtos") {
    chip_system_config_locking = "cmsis-rtos"
  } else if (current_os == "zephyr") {
    chip_system_config_locking = "zephyr"
  } else if (chip_system_config_use_dispatch == false) {
    chip_system_config_locking = "posix"
  } else {
    chip_system_config_locking = "none"
  }
}

if (target_os == "mac" || target_os == "ios") {
  chip_system_config_clock = "gettimeofday"
}

assert(
    chip_system_config_locking == "posix" ||
        chip_system_config_locking == "freertos" ||
        chip_system_config_locking == "none" ||
        chip_system_config_locking == "mbed" ||
        chip_system_config_locking == "cmsis-rtos" ||
        chip_system_config_locking == "zephyr",
    "Please select a valid mutex implementation: posix, freertos, mbed, cmsis-rtos, zephyr, none")

assert(
    !chip_system_config_use_dispatch || chip_system_config_locking == "none",
    "When chip_system_config_use_dispatch is true, chip_system_config_locking must be 'none'")

assert(
    chip_system_config_clock == "clock_gettime" ||
        chip_system_config_clock == "gettimeofday",
    "Please select a valid clock implementation: clock_gettime, gettimeofday")
