blob: 38ee31fccb94e542d34f3a18def8e7dff1e7f30b [file] [log] [blame]
# 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("//build_overrides/pigweed.gni")
import("$dir_pw_build/target_types.gni")
import("${chip_root}/build/chip/chip_version.gni")
import("${chip_root}/build/chip/java/config.gni")
import("${chip_root}/build/chip/tests.gni")
import("${chip_root}/src/lib/core/core.gni")
declare_args() {
# Set to true to run the PersistentStorageDelegate API compliance audit
chip_support_enable_storage_api_audit = false
# Set to true to run the PersistentStorageDelegate load test audit
chip_support_enable_storage_load_test_audit = false
}
config("storage_audit_config") {
defines = []
if (chip_support_enable_storage_api_audit) {
defines += [ "CHIP_SUPPORT_ENABLE_STORAGE_API_AUDIT" ]
}
if (chip_support_enable_storage_load_test_audit) {
defines += [ "CHIP_SUPPORT_ENABLE_STORAGE_LOAD_TEST_AUDIT" ]
}
}
if (chip_pw_tokenizer_logging) {
import("//build_overrides/pigweed.gni")
}
action("gen_chip_version") {
script = "${chip_root}/scripts/gen_chip_version.py"
version_file = "${root_gen_dir}/include/CHIPVersion.h"
outputs = [ version_file ]
args = [
"--output_file=" + rebase_path(version_file, root_build_dir),
"--chip_major=${chip_version_major}",
"--chip_minor=${chip_version_minor}",
"--chip_patch=${chip_version_patch}",
"--chip_extra=${chip_version_extra}",
]
}
source_set("logging_constants") {
sources = [ "logging/Constants.h" ]
}
source_set("attributes") {
sources = [
"Compiler.h",
"DLLUtil.h",
"EnforceFormat.h",
]
}
source_set("verifymacros_no_logging") {
sources = [ "VerificationMacrosNoLogging.h" ]
public_deps = [ "${nlassert_root}:nlassert" ]
}
source_set("safeint") {
sources = [ "SafeInt.h" ]
}
source_set("memory") {
sources = [
"CHIPMem.cpp",
"CHIPMem.h",
"CHIPPlatformMemory.cpp",
"CHIPPlatformMemory.h",
]
if (chip_config_memory_management == "simple") {
sources += [ "CHIPMem-Simple.cpp" ]
}
if (chip_config_memory_management == "malloc") {
sources += [ "CHIPMem-Malloc.cpp" ]
}
public_deps = [ "${chip_root}/src/lib/core:error" ]
deps = [
":safeint",
":verifymacros_no_logging",
"${chip_root}/src/lib/core:chip_config_header",
]
}
source_set("text_only_logging") {
sources = [
"logging/TextOnlyLogging.cpp",
"logging/TextOnlyLogging.h",
]
public_deps = [
":attributes",
":logging_constants",
":verifymacros_no_logging",
"${chip_root}/src/lib/core:chip_config_header",
]
if (chip_pw_tokenizer_logging) {
public_deps += [ "${dir_pw_tokenizer}" ]
}
deps = [
":memory",
"${chip_root}/src/lib/core:chip_config_header",
"${chip_root}/src/platform/logging:headers",
]
}
source_set("verifymacros") {
sources = [
"CodeUtils.h",
"ObjectDump.h",
]
public_deps = [
":attributes",
":text_only_logging",
":verifymacros_no_logging",
"${chip_root}/src/lib/core:chip_config_header",
"${chip_root}/src/lib/core:error",
"${nlassert_root}:nlassert",
]
}
source_set("span") {
sources = [ "Span.h" ]
public_deps = [
":verifymacros",
"${chip_root}/src/lib/core:types",
]
}
source_set("chip_version_header") {
sources = get_target_outputs(":gen_chip_version")
deps = [ ":gen_chip_version" ]
}
source_set("testing") {
sources = [
"TestGroupData.h",
"TestPersistentStorageDelegate.h",
]
}
source_set("type-traits") {
sources = [ "TypeTraits.h" ]
}
source_set("static-support") {
sources = [ "static_support_smart_ptr.h" ]
}
static_library("support") {
output_name = "libSupportLayer"
sources = [
"Base64.cpp",
"Base64.h",
"BitFlags.h",
"BitMask.h",
"BufferReader.cpp",
"BufferReader.h",
"BufferWriter.cpp",
"BufferWriter.h",
"BytesCircularBuffer.cpp",
"BytesCircularBuffer.h",
"BytesToHex.cpp",
"BytesToHex.h",
"CHIPArgParser.cpp",
"CHIPArgParser.hpp",
"CHIPCounter.h",
"CHIPMemString.h",
"CommonIterator.h",
"CommonPersistentData.h",
"DLLUtil.h",
"DefaultStorageKeyAllocator.h",
"Defer.h",
"FibonacciUtils.cpp",
"FibonacciUtils.h",
"FixedBufferAllocator.cpp",
"FixedBufferAllocator.h",
"Fold.h",
"FunctionTraits.h",
"IniEscaping.cpp",
"IniEscaping.h",
"IntrusiveList.h",
"Iterators.h",
"LambdaBridge.h",
"LifetimePersistedCounter.h",
"LinkedList.h",
"ObjectLifeCycle.h",
"PersistedCounter.h",
"PersistentData.h",
"PersistentStorageAudit.cpp",
"PersistentStorageAudit.h",
"PersistentStorageMacros.h",
"Pool.cpp",
"Pool.h",
"PoolWrapper.h",
"PrivateHeap.cpp",
"PrivateHeap.h",
"ReferenceCountedHandle.h",
"SafePointerCast.h",
"SafeString.h",
"Scoped.h",
"ScopedBuffer.h",
"SetupDiscriminator.h",
"SortUtils.h",
"StateMachine.h",
"StringBuilder.cpp",
"StringBuilder.h",
"StringSplitter.h",
"ThreadOperationalDataset.cpp",
"ThreadOperationalDataset.h",
"TimeUtils.cpp",
"TimeUtils.h",
"Variant.h",
"ZclString.cpp",
"ZclString.h",
"logging/BinaryLogging.cpp",
"logging/BinaryLogging.h",
"logging/CHIPLogging.h",
"utf8.cpp",
"utf8.h",
"verhoeff/Verhoeff.cpp",
"verhoeff/Verhoeff.h",
"verhoeff/Verhoeff10.cpp",
]
if (current_os == "android" || matter_enable_java_compilation) {
if (matter_enable_java_compilation) {
include_dirs = java_matter_controller_dependent_paths
}
# added JNI helper on android
sources += [
"CHIPJNIError.h",
"JniReferences.cpp",
"JniReferences.h",
"JniTypeWrappers.h",
]
}
libs = []
cflags = [ "-Wconversion" ]
public_deps = [
":attributes",
":chip_version_header",
":logging_constants",
":memory",
":safeint",
":span",
":text_only_logging",
":type-traits",
":verifymacros",
":verifymacros_no_logging",
"${chip_root}/src/lib/core:chip_config_header",
"${chip_root}/src/lib/core:encoding",
"${chip_root}/src/lib/core:error",
"${chip_root}/src/lib/core:types",
"${chip_root}/src/platform:platform_config_header",
"${chip_root}/src/system:system_config_header",
"${nlassert_root}:nlassert",
]
# These are needed because we include CHIPCore.h, which uses config
# options for src/ble and src/inet, however we cannot depend on those
# directly as such a dependency is cyclic.
public_deps += [
"${chip_root}/src/ble:ble_config_header",
"${chip_root}/src/inet:inet_config_header",
]
# Platforms that utilize CHIP_SYSTEM_CONFIG_PLATFORM_LOG need to
# be pulled in here as public_deps since they hook into logging at
# the macro level rather than just providing a LogV implementation.
if (current_os == "mac" || current_os == "ios") {
public_deps += [ "${chip_root}/src/platform/Darwin:logging" ]
}
public_configs = [
"${chip_root}/src:includes",
"${chip_root}/src/system:system_config",
":storage_audit_config",
]
if (chip_with_nlfaultinjection) {
sources += [
"CHIPFaultInjection.cpp",
"CHIPFaultInjection.h",
]
public_deps += [ "${nlfaultinjection_root}:nlfaultinjection" ]
}
if (chip_pw_tokenizer_logging) {
public_deps += [ "${dir_pw_tokenizer}" ]
}
if (chip_config_memory_debug_dmalloc) {
libs += [ "dmallocthcxx" ]
}
}
static_library("test_utils") {
output_name = "libTestUtils"
output_dir = "${root_out_dir}/lib"
deps = [ "${chip_root}/src/platform" ]
sources = [
"UnitTestUtils.cpp",
"UnitTestUtils.h",
]
}
pw_static_library("pw_tests_wrapper") {
if (chip_device_platform == "esp32") {
complete_static_lib = true
}
output_name = "libPWTestsWrapper"
output_dir = "${root_out_dir}/lib"
public_deps = [
"$dir_pw_log:impl",
"$dir_pw_unit_test",
"$dir_pw_unit_test:logging",
"${chip_root}/src/lib/core:string-builder-adapters",
]
sources = [
"UnitTest.cpp",
"UnitTest.h",
]
}