# 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 BSD/POSIX socket API.
  chip_system_config_use_sockets = current_os != "freertos"

  # 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() {
  # 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 &&
                                    (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")
