blob: 922d501fe6212b26bae5c97d26a9fafd93593772 [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 == "linux" && chip_mdns != "none") {
pkg_config("avahi_client_config") {
packages = [ "avahi-client" ]
}
}
if (chip_device_platform != "none") {
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 = ""
# By pass provision and secure session
chip_bypass_rendezvous = false
# Enable including the additional data in the advertisement packets
chip_enable_additional_data_advertising = true
# Enable adding rotating device id to the additional data.
chip_enable_rotating_device_id = true
# lock tracking: none/log/fatal or auto for a platform-dependent choice
chip_stack_lock_tracking = "auto"
}
if (chip_stack_lock_tracking == "auto") {
if (chip_device_platform == "linux") {
# TODO: should be fatal for development. Change once bugs are fixed
chip_stack_lock_tracking = "log"
} 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_config_enable_mdns = chip_mdns != "none"
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_WITH_GIO=${chip_with_gio}",
"OPENTHREAD_CONFIG_ENABLE_TOBLE=false",
"CONFIG_USE_CLUSTERS_FOR_IP_COMMISSIONING=${chip_use_clusters_for_ip_commissioning}",
"CHIP_DEVICE_CONFIG_ENABLE_MDNS=${chip_device_config_enable_mdns}",
"CHIP_BYPASS_RENDEZVOUS=${chip_bypass_rendezvous}",
"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_ENABLE_ROTATING_DEVICE_ID=${chip_enable_rotating_device_id}",
]
if (chip_device_platform == "linux" || chip_device_platform == "darwin") {
defines += [ "CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE=${chip_enable_ble}" ]
}
if (chip_enable_nfc) {
defines += [ "CHIP_DEVICE_CONFIG_ENABLE_NFC=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_device_platform == "cc13x2_26x2") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_CC13X2_26X2=1",
"CHIP_DEVICE_LAYER_TARGET=cc13x2_26x2",
]
} else if (chip_device_platform == "darwin") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_DARWIN=1",
"CHIP_DEVICE_LAYER_TARGET=Darwin",
]
} 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 == "p6") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_P6=1",
"CHIP_DEVICE_LAYER_TARGET=P6",
]
} else if (chip_device_platform == "linux") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_LINUX=1",
"CHIP_DEVICE_LAYER_TARGET=Linux",
]
} 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 == "k32w") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_K32W=1",
"CHIP_DEVICE_LAYER_TARGET=K32W",
]
} 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",
]
} else if (chip_device_platform == "fake") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_FAKE=1",
"CHIP_DEVICE_LAYER_TARGET=fake",
]
}
}
} else {
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") {
chip_device_config_enable_mdns = chip_mdns != "none"
defines += [
"CHIP_DEVICE_CONFIG_ENABLE_MDNS=${chip_device_config_enable_mdns}",
"CONFIG_USE_CLUSTERS_FOR_IP_COMMISSIONING=${chip_use_clusters_for_ip_commissioning}",
"EXTERNAL_KEYVALUESTOREMANAGERIMPL_HEADER=\"controller/java/AndroidKeyValueStoreManagerImpl.h\"",
]
}
}
}
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/system",
]
public_configs = [ "${chip_root}/src:includes" ]
}
static_library("platform") {
output_name = "libDeviceLayer"
sources = [
"../include/platform/CHIPDeviceConfig.h",
"../include/platform/CHIPDeviceError.h",
"../include/platform/CHIPDeviceEvent.h",
"../include/platform/CHIPDeviceLayer.h",
"../include/platform/ConfigurationManager.h",
"../include/platform/ConnectivityManager.h",
"../include/platform/GeneralUtils.h",
"../include/platform/KeyValueStoreManager.h",
"../include/platform/PersistedStorage.h",
"../include/platform/PlatformManager.h",
"../include/platform/SoftwareUpdateManagerImpl.h",
"../include/platform/ThreadStackManager.h",
"../include/platform/internal/BLEManager.h",
"../include/platform/internal/CHIPDeviceLayerInternal.h",
"../include/platform/internal/DeviceControlServer.h",
"../include/platform/internal/DeviceNetworkInfo.h",
"../include/platform/internal/DeviceNetworkProvisioning.h",
"../include/platform/internal/EventLogging.h",
"../include/platform/internal/GenericConfigurationManagerImpl.h",
"../include/platform/internal/GenericConnectivityManagerImpl.h",
"../include/platform/internal/GenericConnectivityManagerImpl_BLE.h",
"../include/platform/internal/GenericConnectivityManagerImpl_NoBLE.h",
"../include/platform/internal/GenericConnectivityManagerImpl_NoThread.h",
"../include/platform/internal/GenericConnectivityManagerImpl_NoWiFi.h",
"../include/platform/internal/GenericConnectivityManagerImpl_Thread.h",
"../include/platform/internal/GenericConnectivityManagerImpl_WiFi.h",
"../include/platform/internal/GenericPlatformManagerImpl.h",
"../include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.h",
"../include/platform/internal/GenericPlatformManagerImpl_POSIX.h",
"../include/platform/internal/GenericSoftwareUpdateManagerImpl.h",
"../include/platform/internal/GenericSoftwareUpdateManagerImpl_BDX.h",
"../include/platform/internal/testing/ConfigUnitTest.h",
"DeviceControlServer.cpp",
"Entropy.cpp",
"GeneralUtils.cpp",
"Globals.cpp",
"LockTracker.cpp",
"LwIPEventSupport.cpp",
"PersistedStorage.cpp",
"TestIdentity.cpp",
]
cflags = [ "-Wconversion" ]
public_deps = [
":platform_base",
"${chip_root}/src/crypto",
"${chip_root}/src/lib/support",
]
if (chip_device_platform == "cc13x2_26x2") {
_platform_target = "cc13x2_26x2"
} 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 == "k32w") {
_platform_target = "K32W"
} 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 == "external") {
_platform_target = chip_platform_target
} else if (chip_device_platform == "p6") {
_platform_target = "P6"
} else if (chip_device_platform == "fake") {
_platform_target = "fake"
} 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" ]
}
}