# 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() {
  # use the dispatch library
  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_event_loop = "LwIP"
  } 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 (chip_system_config_use_dispatch == false) {
    chip_system_config_locking = "posix"
  } else {
    chip_system_config_locking = "none"
  }
}

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

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