# 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/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/lwip.gni")

import("${chip_root}/build/chip/buildconfig_header.gni")
import("${chip_root}/src/lwip/lwip.gni")
import("${lwip_root}/lwip.gni")

assert(chip_with_lwip)

if (lwip_platform == "") {
  if (current_os != "freertos") {
    lwip_platform = "standalone"
  }
}

assert(lwip_platform == "external" || lwip_platform == "standalone" ||
           lwip_platform == "cc13x2_26x2" || lwip_platform == "efr32" ||
           lwip_platform == "k32w" || lwip_platform == "qpg6100",
       "Unsupported lwIP platform: ${lwip_platform}")

if (lwip_platform != "external") {
  declare_args() {
    # Enable lwIP debugging.
    lwip_debug = is_debug
  }
}

if (lwip_platform == "cc13x2_26x2") {
  import("//build_overrides/ti_simplelink_sdk.gni")
} else if (lwip_platform == "efr32") {
  import("//build_overrides/efr32_sdk.gni")
} else if (lwip_platform == "qpg6100") {
  import("//build_overrides/qpg6100_sdk.gni")
} else if (lwip_platform == "k32w") {
  import("//build_overrides/k32w_sdk.gni")
}

buildconfig_header("lwip_buildconfig") {
  header = "lwip_buildconfig.h"
  header_dir = "lwip"

  defines = [ "HAVE_LWIP_UDP_BIND_NETIF=1" ]
  if (lwip_platform != "external") {
    if (is_debug) {
      # Automatically enable LWIP_DEBUG for internal is_debug builds.
      defines += [ "LWIP_DEBUG=1" ]
    }

    if (current_os == "android") {
      defines += [ "LWIP_NO_STDINT_H=1" ]
    }
  }
}

if (current_os == "zephyr") {
  group("lwip") {
  }
} else if (lwip_platform == "external") {
  group("lwip") {
    public_deps = [ ":lwip_buildconfig" ]
  }

  group("all") {
    deps = [ ":lwip" ]
  }
} else {
  config("lwip_config") {
    include_dirs = [ lwip_platform ]

    if (lwip_platform != "standalone") {
      include_dirs += [ "freertos" ]
    }
  }

  lwip_target("lwip") {
    public = [
      "${lwip_platform}/arch/cc.h",
      "${lwip_platform}/arch/perf.h",
      "${lwip_platform}/lwipopts.h",
    ]

    sources = []

    if (lwip_platform == "standalone") {
      public += [ "standalone/arch/sys_arch.h" ]
      sources += [ "standalone/sys_arch.c" ]
    } else {
      public += [
        "${lwip_platform}/lwippools.h",
        "freertos/arch/sys_arch.h",
      ]
      sources += [ "freertos/sys_arch.c" ]
    }

    public_deps = [ ":lwip_buildconfig" ]
    if (lwip_platform == "cc13x2_26x2") {
      public_deps += [ "${ti_simplelink_sdk_build_root}:ti_simplelink_sdk" ]
    } else if (lwip_platform == "efr32") {
      public_deps += [ "${efr32_sdk_build_root}:efr32_sdk" ]
    } else if (lwip_platform == "qpg6100") {
      public_deps += [ "${qpg6100_sdk_build_root}:qpg6100_sdk" ]
    } else if (lwip_platform == "standalone") {
      public_deps += [ "${chip_root}/src/lib/support" ]
    } else if (lwip_platform == "k32w") {
      public_deps += [ "${k32w_sdk_build_root}:k32w_sdk" ]
    }

    public_configs = [
      ":lwip_config",
      "${chip_root}/src:includes",
    ]
  }
}
