blob: fbfe42faec32a4cebda1434f60c6fa60785e4796 [file] [log] [blame]
# 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/nlio.gni")
import("//build_overrides/pigweed.gni")
import("${build_root}/config/linux/pkg_config.gni")
import("${chip_root}/build/chip/buildconfig_header.gni")
import("device.gni")
if (chip_enable_openthread) {
import("//build_overrides/openthread.gni")
if (chip_device_platform == "linux" || chip_device_platform == "darwin") {
import("//build_overrides/ot_br_posix.gni")
}
}
if (chip_device_platform != "none" && chip_device_platform != "external") {
declare_args() {
# Extra header to include in CHIPDeviceConfig.h for project.
chip_device_project_config_include = ""
# Date the firmware was built.
chip_device_config_firmware_build_date = ""
# Time the firmware was built.
chip_device_config_firmware_build_time = ""
# Use OpenThread ftd or mtd library
chip_device_config_thread_ftd = chip_openthread_ftd
# Enable including the additional data in the advertisement packets
chip_enable_additional_data_advertising = false
# Enable default/generic test-mode CommissionableDataProvider in GenericConfigurationManagerImpl
# === FOR TRANSITION UNTIL ALL EXAMPLES PROVIDE THEIR OWN ===
# Linux platform has already transitioned.
chip_use_transitional_commissionable_data_provider =
chip_device_platform != "linux" && chip_device_platform != "android"
# lock tracking: none/log/fatal or auto for a platform-dependent choice
chip_stack_lock_tracking = "auto"
# todo: below operates are not work without root permission
# pthread_attr_setschedpolicy in GenericPlatformManagerImpl_POSIX.cpp
chip_device_config_run_as_root = current_os != "android"
# Indication that the CHIP data model is included
chip_enable_data_model = false
# The string of device software version was built.
chip_device_config_device_software_version_string = ""
}
if (chip_stack_lock_tracking == "auto") {
if (chip_device_platform == "linux" || chip_device_platform == "tizen" ||
chip_device_platform == "android" || current_os == "freertos" ||
chip_device_platform == "webos" || chip_device_platform == "darwin") {
# TODO: should be fatal for development. Change once bugs are fixed
chip_stack_lock_tracking = "fatal"
} else {
# TODO: may want to enable at least logging for embedded to find bugs
# this needs tuning depending on how many resources various platforms have
# available (mainly flash size)
chip_stack_lock_tracking = "none"
}
} else {
assert(
chip_stack_lock_tracking == "none" ||
chip_stack_lock_tracking == "log" ||
chip_stack_lock_tracking == "fatal",
"Please select a valid value for chip_stack_lock_tracking: auto, none, log, fatal")
}
buildconfig_header("platform_buildconfig") {
header = "CHIPDeviceBuildConfig.h"
header_dir = "platform"
chip_with_gio = chip_enable_wifi
chip_device_config_enable_wpa =
chip_enable_wifi && chip_device_platform != "darwin"
chip_stack_lock_tracking_log = chip_stack_lock_tracking != "none"
chip_stack_lock_tracking_fatal = chip_stack_lock_tracking == "fatal"
defines = [
"CHIP_DEVICE_CONFIG_ENABLE_WPA=${chip_device_config_enable_wpa}",
"CHIP_ENABLE_OPENTHREAD=${chip_enable_openthread}",
"CHIP_DEVICE_CONFIG_THREAD_FTD=${chip_device_config_thread_ftd}",
"CHIP_WITH_GIO=${chip_with_gio}",
"OPENTHREAD_CONFIG_ENABLE_TOBLE=false",
"CHIP_STACK_LOCK_TRACKING_ENABLED=${chip_stack_lock_tracking_log}",
"CHIP_STACK_LOCK_TRACKING_ERROR_FATAL=${chip_stack_lock_tracking_fatal}",
"CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING=${chip_enable_additional_data_advertising}",
"CHIP_DEVICE_CONFIG_RUN_AS_ROOT=${chip_device_config_run_as_root}",
"CHIP_DISABLE_PLATFORM_KVS=${chip_disable_platform_kvs}",
]
if (chip_device_platform == "linux" || chip_device_platform == "darwin" ||
chip_device_platform == "tizen" || chip_device_platform == "android" ||
chip_device_platform == "k32w0" || chip_device_platform == "webos") {
defines += [ "CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE=${chip_enable_ble}" ]
}
if (chip_enable_nfc) {
defines += [
"CHIP_DEVICE_CONFIG_ENABLE_NFC=1",
"CONFIG_CHIP_NFC_COMMISSIONING=1",
]
}
if (chip_enable_ota_requestor) {
defines += [ "CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR=1" ]
}
if (chip_device_project_config_include != "") {
defines += [ "CHIP_DEVICE_PROJECT_CONFIG_INCLUDE=${chip_device_project_config_include}" ]
}
if (chip_device_platform_config_include != "") {
defines += [ "CHIP_DEVICE_PLATFORM_CONFIG_INCLUDE=${chip_device_platform_config_include}" ]
}
if (chip_device_config_firmware_build_date != "") {
defines += [ "CHIP_DEVICE_CONFIG_FIRWMARE_BUILD_DATE=\"${chip_device_config_firmware_build_date}\"" ]
}
if (chip_device_config_firmware_build_time != "") {
defines += [ "CHIP_DEVICE_CONFIG_FIRMWARE_BUILD_TIME=\"${chip_device_config_firmware_build_time}\"" ]
}
if (chip_use_transitional_commissionable_data_provider) {
defines += [ "CHIP_USE_TRANSITIONAL_COMMISSIONABLE_DATA_PROVIDER=1" ]
} else {
defines += [ "CHIP_USE_TRANSITIONAL_COMMISSIONABLE_DATA_PROVIDER=0" ]
}
if (chip_device_platform == "cc13x2_26x2") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_CC13X2_26X2=1",
"CHIP_DEVICE_LAYER_TARGET=cc13x2_26x2",
]
} else if (chip_device_platform == "cc32xx") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_CC32XX=1",
"CHIP_DEVICE_LAYER_TARGET=cc32xx",
]
} else if (chip_device_platform == "darwin") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_DARWIN=1",
"CHIP_DEVICE_LAYER_TARGET=Darwin",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
} else if (chip_device_platform == "efr32") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_EFR32=1",
"CHIP_DEVICE_LAYER_TARGET=EFR32",
]
} else if (chip_device_platform == "esp32") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_ESP32=1",
"CHIP_DEVICE_LAYER_TARGET=ESP32",
]
} else if (chip_device_platform == "psoc6") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_PSOC6=1",
"CHIP_DEVICE_LAYER_TARGET=Infineon/PSOC6",
]
} else if (chip_device_platform == "linux") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_LINUX=1",
"CHIP_DEVICE_LAYER_TARGET=Linux",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
} else if (chip_device_platform == "tizen") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_TIZEN=1",
"CHIP_DEVICE_LAYER_TARGET=Tizen",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
defines -=
[ "CHIP_DEVICE_CONFIG_ENABLE_WPA=${chip_device_config_enable_wpa}" ]
} else if (chip_device_platform == "nrfconnect") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_NRFCONNECT=1",
"CHIP_DEVICE_LAYER_TARGET=nrfconnect",
]
} else if (chip_device_platform == "qpg") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_QPG=1",
"CHIP_DEVICE_LAYER_TARGET=qpg",
]
} else if (chip_device_platform == "k32w0") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_K32W=1",
"CHIP_DEVICE_LAYER_TARGET=nxp/k32w/k32w0",
]
} else if (chip_device_platform == "telink") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_TELINK=1",
"CHIP_DEVICE_LAYER_TARGET=telink",
]
} else if (chip_device_platform == "mbed") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_MBED=1",
"CHIP_DEVICE_LAYER_TARGET=mbed",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
"CHIP_DEVICE_ENABLE_DATA_MODEL=${chip_enable_data_model}",
]
} else if (chip_device_platform == "bl602") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_BL602=1",
"CHIP_DEVICE_LAYER_TARGET=bouffalolab/BL602",
]
} else if (chip_device_platform == "bl702") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_BL702=1",
"CHIP_DEVICE_LAYER_TARGET=bouffalolab/BL702",
]
} else if (chip_device_platform == "fake") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_FAKE=1",
"CHIP_DEVICE_LAYER_TARGET=fake",
]
} else if (chip_device_platform == "android") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_ANDROID=1",
"CHIP_DEVICE_LAYER_TARGET=android",
]
} else if (chip_device_platform == "ameba") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_AMEBA=1",
"CHIP_DEVICE_LAYER_TARGET=Ameba",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
} else if (chip_device_platform == "cyw30739") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_CYW30739=1",
"CHIP_DEVICE_LAYER_TARGET=Infineon/CYW30739",
]
} else if (chip_device_platform == "webos") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_WEBOS=1",
"CHIP_DEVICE_LAYER_TARGET=webos",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
defines -=
[ "CHIP_DEVICE_CONFIG_ENABLE_WPA=${chip_device_config_enable_wpa}" ]
} else if (chip_device_platform == "mw320") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_MW320=1",
"CHIP_DEVICE_LAYER_TARGET=nxp/mw320",
]
} else if (chip_device_platform == "zephyr") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_ZEPHYR=1",
"CHIP_DEVICE_LAYER_TARGET=Zephyr",
]
} else if (chip_device_platform == "beken") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_BEKEN=1",
"CHIP_DEVICE_LAYER_TARGET=Beken",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
} else if (chip_device_platform == "mt793x") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_MT793X=1",
"CHIP_DEVICE_LAYER_TARGET=mt793x",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
}
if (chip_device_config_device_software_version_string != "") {
defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${chip_device_config_device_software_version_string}\"" ]
}
}
} else if (chip_device_platform == "none") {
buildconfig_header("platform_buildconfig") {
header = "CHIPDeviceBuildConfig.h"
header_dir = "platform"
defines = [
"CHIP_DEVICE_LAYER_NONE=1",
"CHIP_DEVICE_LAYER_TARGET=NONE",
]
if (current_os == "android") {
defines += [ "EXTERNAL_KEYVALUESTOREMANAGERIMPL_HEADER=\"controller/java/AndroidKeyValueStoreManagerImpl.h\"" ]
}
}
} else {
group("platform_buildconfig") {
public_deps = [ "${chip_platform_target}:platform_buildconfig" ]
}
}
if (chip_device_platform != "none") {
group("platform_base") {
public_deps = [
":platform_buildconfig",
"${chip_root}/src/ble",
"${chip_root}/src/inet",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
"${chip_root}/src/setup_payload:additional_data_payload",
"${chip_root}/src/system",
]
public_configs = [ "${chip_root}/src:includes" ]
}
static_library("platform") {
output_name = "libDeviceLayer"
sources = [
"../include/platform/BuildTime.h",
"../include/platform/CHIPDeviceConfig.h",
"../include/platform/CHIPDeviceError.h",
"../include/platform/CHIPDeviceEvent.h",
"../include/platform/CHIPDeviceLayer.h",
"../include/platform/CommissionableDataProvider.h",
"../include/platform/ConfigurationManager.h",
"../include/platform/ConnectivityManager.h",
"../include/platform/DeviceControlServer.h",
"../include/platform/DeviceInstanceInfoProvider.h",
"../include/platform/GeneralUtils.h",
"../include/platform/KeyValueStoreManager.h",
"../include/platform/KvsPersistentStorageDelegate.h",
"../include/platform/PersistedStorage.h",
"../include/platform/PlatformManager.h",
"../include/platform/TestOnlyCommissionableDataProvider.h",
"../include/platform/ThreadStackManager.h",
"../include/platform/internal/BLEManager.h",
"../include/platform/internal/CHIPDeviceLayerInternal.h",
"../include/platform/internal/DeviceNetworkInfo.h",
"../include/platform/internal/DeviceNetworkProvisioning.h",
"../include/platform/internal/EventLogging.h",
"../include/platform/internal/GenericConfigurationManagerImpl.h",
"../include/platform/internal/GenericConfigurationManagerImpl.ipp",
"../include/platform/internal/GenericConnectivityManagerImpl.h",
"../include/platform/internal/GenericConnectivityManagerImpl_BLE.h",
"../include/platform/internal/GenericConnectivityManagerImpl_BLE.ipp",
"../include/platform/internal/GenericConnectivityManagerImpl_NoBLE.h",
"../include/platform/internal/GenericConnectivityManagerImpl_NoThread.h",
"../include/platform/internal/GenericConnectivityManagerImpl_NoWiFi.h",
"../include/platform/internal/GenericConnectivityManagerImpl_TCP.h",
"../include/platform/internal/GenericConnectivityManagerImpl_TCP.ipp",
"../include/platform/internal/GenericConnectivityManagerImpl_Thread.h",
"../include/platform/internal/GenericConnectivityManagerImpl_Thread.ipp",
"../include/platform/internal/GenericConnectivityManagerImpl_UDP.h",
"../include/platform/internal/GenericConnectivityManagerImpl_UDP.ipp",
"../include/platform/internal/GenericConnectivityManagerImpl_WiFi.h",
"../include/platform/internal/GenericConnectivityManagerImpl_WiFi.ipp",
"../include/platform/internal/GenericDeviceInstanceInfoProvider.h",
"../include/platform/internal/GenericDeviceInstanceInfoProvider.ipp",
"../include/platform/internal/GenericPlatformManagerImpl.h",
"../include/platform/internal/GenericPlatformManagerImpl.ipp",
"../include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.h",
"../include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp",
"../include/platform/internal/GenericPlatformManagerImpl_POSIX.h",
"../include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp",
"../include/platform/internal/GenericPlatformManagerImpl_Zephyr.ipp",
"../include/platform/internal/testing/ConfigUnitTest.h",
"CommissionableDataProvider.cpp",
"DeviceControlServer.cpp",
"DeviceInfoProvider.cpp",
"DeviceInstanceInfoProvider.cpp",
"DiagnosticDataProvider.cpp",
"Entropy.cpp",
"GeneralUtils.cpp",
"Globals.cpp",
"LockTracker.cpp",
"PersistedStorage.cpp",
"PlatformEventSupport.cpp",
]
# Linux has its own NetworkCommissioningThreadDriver
if (chip_enable_openthread && chip_device_platform != "linux" &&
chip_device_platform != "tizen" && chip_device_platform != "webos") {
sources += [
"OpenThread/GenericNetworkCommissioningThreadDriver.cpp",
"OpenThread/GenericNetworkCommissioningThreadDriver.h",
]
}
cflags = [ "-Wconversion" ]
public_deps = [
":platform_base",
"${chip_root}/src/app:app_config",
"${chip_root}/src/app/common:cluster-objects",
"${chip_root}/src/crypto",
"${chip_root}/src/lib/support",
]
if (chip_device_platform == "cc13x2_26x2") {
_platform_target = "cc13x2_26x2"
} else if (chip_device_platform == "cc32xx") {
_platform_target = "cc32xx"
} else if (chip_device_platform == "darwin") {
_platform_target = "Darwin"
} else if (chip_device_platform == "efr32") {
_platform_target = "EFR32"
} else if (chip_device_platform == "esp32") {
_platform_target = "ESP32"
} else if (chip_device_platform == "k32w0") {
_platform_target = "nxp/k32w/k32w0"
} else if (chip_device_platform == "linux") {
_platform_target = "Linux"
} else if (chip_device_platform == "nrfconnect") {
_platform_target = "nrfconnect"
} else if (chip_device_platform == "qpg") {
_platform_target = "qpg"
} else if (chip_device_platform == "telink") {
_platform_target = "telink"
} else if (chip_device_platform == "mbed") {
_platform_target = "mbed"
} else if (chip_device_platform == "tizen") {
_platform_target = "Tizen"
} else if (chip_device_platform == "android") {
_platform_target = "android"
} else if (chip_device_platform == "external") {
_platform_target = chip_platform_target
} else if (chip_device_platform == "psoc6") {
_platform_target = "Infineon/PSOC6"
} else if (chip_device_platform == "ameba") {
_platform_target = "Ameba"
} else if (chip_device_platform == "webos") {
_platform_target = "webos"
} else if (chip_device_platform == "bl602") {
_platform_target = "bouffalolab/BL602"
} else if (chip_device_platform == "bl702") {
_platform_target = "bouffalolab/BL702"
} else if (chip_device_platform == "fake") {
_platform_target = "fake"
} else if (chip_device_platform == "cyw30739") {
_platform_target = "Infineon/CYW30739"
} else if (chip_device_platform == "mw320") {
_platform_target = "nxp/mw320"
} else if (chip_device_platform == "zephyr") {
_platform_target = "Zephyr"
} else if (chip_device_platform == "beken") {
_platform_target = "Beken"
} else if (chip_device_platform == "mt793x") {
_platform_target = "mt793x"
} else {
assert(false, "Unknown chip_device_platform: ${chip_device_platform}")
}
public_deps += [ _platform_target ]
# The platform target needs to include the headers, so allow that here.
# It should be considered logically part of this target.
allow_circular_includes_from = [
_platform_target,
"${chip_root}/src/lib/support",
]
}
} else {
group("platform") {
public_deps = [ ":platform_buildconfig" ]
}
}