| # 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/build.gni") |
| import("//build_overrides/chip.gni") |
| import("//build_overrides/nlassert.gni") |
| import("//build_overrides/nlfaultinjection.gni") |
| |
| import("${chip_root}/build/chip/buildconfig_header.gni") |
| import("${chip_root}/build/chip/tests.gni") |
| import("${chip_root}/src/platform/device.gni") |
| import("system.gni") |
| |
| declare_args() { |
| # Extra header to include in CHIPConfig.h for project. |
| # TODO - This should probably be in src/core but src/system also uses it. |
| chip_project_config_include = "<CHIPProjectConfig.h>" |
| |
| # Extra header to include in SystemConfig.h for project. |
| chip_system_project_config_include = "<SystemProjectConfig.h>" |
| |
| # Extra include dirs for project configs. |
| chip_project_config_include_dirs = [] |
| } |
| |
| if (chip_project_config_include_dirs == [] && |
| chip_project_config_include == "<CHIPProjectConfig.h>" && |
| chip_system_project_config_include == "<SystemProjectConfig.h>") { |
| chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] |
| } |
| |
| if (chip_device_platform == "cc13x2_26x2") { |
| import("//build_overrides/ti_simplelink_sdk.gni") |
| } else if (chip_device_platform == "efr32") { |
| import("//build_overrides/efr32_sdk.gni") |
| } else if (chip_device_platform == "qpg") { |
| import("//build_overrides/qpg_sdk.gni") |
| import("${qpg_sdk_build_root}/qpg_sdk.gni") |
| } else if (chip_device_platform == "k32w0") { |
| import("//build_overrides/k32w0_sdk.gni") |
| } else if (chip_device_platform == "psoc6") { |
| import("//build_overrides/psoc6.gni") |
| } else if (chip_device_platform == "cyw30739") { |
| import("//build_overrides/cyw30739_sdk.gni") |
| } else if (chip_device_platform == "mt793x") { |
| import("//build_overrides/mt793x_sdk.gni") |
| } |
| |
| buildconfig_header("system_buildconfig") { |
| header = "SystemBuildConfig.h" |
| header_dir = "system" |
| |
| config_device_layer = chip_device_platform != "none" |
| chip_system_config_posix_locking = chip_system_config_locking == "posix" |
| chip_system_config_freertos_locking = chip_system_config_locking == "freertos" |
| chip_system_config_mbed_locking = chip_system_config_locking == "mbed" |
| chip_system_config_cmsis_rtos_locking = |
| chip_system_config_locking == "cmsis-rtos" |
| chip_system_config_no_locking = chip_system_config_locking == "none" |
| have_clock_gettime = chip_system_config_clock == "clock_gettime" |
| have_clock_settime = have_clock_gettime |
| have_gettimeofday = chip_system_config_clock == "gettimeofday" |
| |
| defines = [ |
| "CONFIG_DEVICE_LAYER=${config_device_layer}", |
| "CHIP_SYSTEM_CONFIG_TEST=${chip_build_tests}", |
| "CHIP_WITH_NLFAULTINJECTION=${chip_with_nlfaultinjection}", |
| "CHIP_SYSTEM_CONFIG_USE_DISPATCH=${chip_system_config_use_dispatch}", |
| "CHIP_SYSTEM_CONFIG_USE_LWIP=${chip_system_config_use_lwip}", |
| "CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT=${chip_system_config_use_open_thread_inet_endpoints}", |
| "CHIP_SYSTEM_CONFIG_USE_SOCKETS=${chip_system_config_use_sockets}", |
| "CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK=false", |
| "CHIP_SYSTEM_CONFIG_POSIX_LOCKING=${chip_system_config_posix_locking}", |
| "CHIP_SYSTEM_CONFIG_FREERTOS_LOCKING=${chip_system_config_freertos_locking}", |
| "CHIP_SYSTEM_CONFIG_MBED_LOCKING=${chip_system_config_mbed_locking}", |
| "CHIP_SYSTEM_CONFIG_CMSIS_RTOS_LOCKING=${chip_system_config_cmsis_rtos_locking}", |
| "CHIP_SYSTEM_CONFIG_NO_LOCKING=${chip_system_config_no_locking}", |
| "CHIP_SYSTEM_CONFIG_PROVIDE_STATISTICS=${chip_system_config_provide_statistics}", |
| "HAVE_CLOCK_GETTIME=${have_clock_gettime}", |
| "HAVE_CLOCK_SETTIME=${have_clock_settime}", |
| "HAVE_GETTIMEOFDAY=${have_gettimeofday}", |
| "HAVE_SYS_TIME_H=true", |
| "HAVE_NETINET_ICMP6_H=true", |
| "HAVE_ICMP6_FILTER=true", |
| "CONFIG_HAVE_VCBPRINTF=false", |
| "CONFIG_HAVE_VSNPRINTF_EX=false", |
| "HAVE_SYS_SOCKET_H=${chip_system_config_use_sockets}", |
| ] |
| |
| if (chip_project_config_include != "") { |
| defines += [ "CHIP_PROJECT_CONFIG_INCLUDE=${chip_project_config_include}" ] |
| } |
| if (chip_platform_config_include != "") { |
| defines += |
| [ "CHIP_PLATFORM_CONFIG_INCLUDE=${chip_platform_config_include}" ] |
| } |
| if (chip_system_project_config_include != "") { |
| defines += [ |
| "SYSTEM_PROJECT_CONFIG_INCLUDE=${chip_system_project_config_include}", |
| ] |
| } |
| if (chip_system_platform_config_include != "") { |
| defines += [ |
| "SYSTEM_PLATFORM_CONFIG_INCLUDE=${chip_system_platform_config_include}", |
| ] |
| } |
| |
| if (chip_system_layer_impl_config_file != "") { |
| defines += [ "CHIP_SYSTEM_LAYER_IMPL_CONFIG_FILE=${chip_system_layer_impl_config_file}" ] |
| } else { |
| defines += [ "CHIP_SYSTEM_LAYER_IMPL_CONFIG_FILE=<system/SystemLayerImpl${chip_system_config_event_loop}.h>" ] |
| } |
| |
| if (chip_system_config_use_sockets && current_os != "zephyr") { |
| defines += [ |
| "CHIP_SYSTEM_CONFIG_MULTICAST_HOMING=${chip_system_config_use_sockets} ", |
| ] |
| } else { |
| defines += [ "CHIP_SYSTEM_CONFIG_MULTICAST_HOMING=0 " ] |
| } |
| } |
| |
| config("system_config") { |
| include_dirs = chip_project_config_include_dirs |
| } |
| |
| source_set("system_config_header") { |
| sources = [ "SystemConfig.h" ] |
| |
| public_configs = [ |
| ":system_config", |
| "${chip_root}/src:includes", |
| ] |
| |
| public_deps = [ |
| ":system_buildconfig", |
| "${chip_root}/src/platform:platform_buildconfig", |
| ] |
| |
| if (target_cpu != "esp32") { |
| if (chip_system_config_use_lwip) { |
| public_deps += [ "${chip_root}/src/lwip" ] |
| } else { |
| if (chip_device_platform == "efr32") { |
| public_deps += [ "${efr32_sdk_build_root}:efr32_sdk" ] |
| } |
| if (chip_device_platform == "qpg") { |
| public_deps += [ "${qpg_sdk_build_root}:qpg_sdk" ] |
| } |
| if (chip_device_platform == "k32w0") { |
| public_deps += [ "${k32w0_sdk_build_root}:k32w0_sdk" ] |
| } |
| if (chip_device_platform == "cyw30739") { |
| public_deps += [ "${cyw30739_sdk_build_root}:cyw30739_sdk" ] |
| } |
| |
| # Add platform here as needed. |
| } |
| } |
| |
| if (chip_device_platform == "mt793x") { |
| public_deps += [ "${mt793x_sdk_build_root}:mt793x_sdk" ] |
| } |
| } |
| |
| static_library("system") { |
| output_name = "libSystemLayer" |
| |
| sources = [ |
| "PlatformEventSupport.h", |
| "SystemAlignSize.h", |
| "SystemClock.cpp", |
| "SystemClock.h", |
| "SystemConfig.h", |
| "SystemError.cpp", |
| "SystemError.h", |
| "SystemEvent.h", |
| "SystemLayer.cpp", |
| "SystemLayer.h", |
| "SystemLayerImpl.h", |
| "SystemMutex.cpp", |
| "SystemMutex.h", |
| "SystemPacketBuffer.cpp", |
| "SystemPacketBuffer.h", |
| "SystemPacketBufferInternal.h", |
| "SystemStats.cpp", |
| "SystemStats.h", |
| "SystemTimer.cpp", |
| "SystemTimer.h", |
| "TLVPacketBufferBackingStore.cpp", |
| "TLVPacketBufferBackingStore.h", |
| "TimeSource.h", |
| "WakeEvent.cpp", |
| "WakeEvent.h", |
| ] |
| |
| if (chip_system_layer_impl_config_file == "") { |
| sources += [ |
| "SystemLayerImpl${chip_system_config_event_loop}.cpp", |
| "SystemLayerImpl${chip_system_config_event_loop}.h", |
| ] |
| } |
| |
| cflags = [ "-Wconversion" ] |
| |
| public_deps = [ |
| "${chip_root}/src/lib/support", |
| "${chip_root}/src/platform:platform_buildconfig", |
| "${nlassert_root}:nlassert", |
| ] |
| |
| allow_circular_includes_from = [ "${chip_root}/src/lib/support" ] |
| |
| if (chip_system_config_use_sockets) { |
| sources += [ "SocketEvents.h" ] |
| } |
| |
| if (chip_with_nlfaultinjection) { |
| sources += [ |
| "SystemFaultInjection.cpp", |
| "SystemFaultInjection.h", |
| ] |
| public_deps += [ "${nlfaultinjection_root}:nlfaultinjection" ] |
| } |
| } |