diff --git a/examples/lighting-app/nrf5/BUILD.gn b/examples/lighting-app/nrf5/BUILD.gn index a79e9a0b49aa54..d7f3856dd933f5 100644 --- a/examples/lighting-app/nrf5/BUILD.gn +++ b/examples/lighting-app/nrf5/BUILD.gn @@ -14,6 +14,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nrf5_sdk.gni") +import("//build_overrides/openthread.gni") import("${nrf5_sdk_build_root}/nrf5_sdk.gni") diff --git a/examples/lighting-app/nrf5/main/main.cpp b/examples/lighting-app/nrf5/main/main.cpp index 962374424845ff..761b4238498eca 100644 --- a/examples/lighting-app/nrf5/main/main.cpp +++ b/examples/lighting-app/nrf5/main/main.cpp @@ -17,6 +17,8 @@ * limitations under the License. */ +#include + #include #include diff --git a/examples/lock-app/nrf5/BUILD.gn b/examples/lock-app/nrf5/BUILD.gn index a127e5c827d7f7..6792c0995b54e7 100644 --- a/examples/lock-app/nrf5/BUILD.gn +++ b/examples/lock-app/nrf5/BUILD.gn @@ -105,8 +105,6 @@ executable("lock_app") { ldscript = "${nrf5_platform_dir}/app/ldscripts/chip-nrf52840-example.ld" ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] - - defines = [ "CHIP_ENABLE_OPENTHREAD=1" ] } group("nrf5") { diff --git a/examples/lock-app/nrf5/main/main.cpp b/examples/lock-app/nrf5/main/main.cpp index 797aabcffb6e9a..678881fd34954e 100644 --- a/examples/lock-app/nrf5/main/main.cpp +++ b/examples/lock-app/nrf5/main/main.cpp @@ -17,6 +17,8 @@ * limitations under the License. */ +#include + #include #include diff --git a/examples/platform/nrf528xx/app/chipinit.cpp b/examples/platform/nrf528xx/app/chipinit.cpp index b008f138d2c950..5ac034a9f53755 100644 --- a/examples/platform/nrf528xx/app/chipinit.cpp +++ b/examples/platform/nrf528xx/app/chipinit.cpp @@ -1,5 +1,7 @@ #include "chipinit.h" +#include + #include #include diff --git a/gn/chip/buildconfig_header.gni b/gn/chip/buildconfig_header.gni new file mode 100644 index 00000000000000..25ee93d47c86c1 --- /dev/null +++ b/gn/chip/buildconfig_header.gni @@ -0,0 +1,158 @@ +# 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. + +# Copyright 2015 The Chromium Authors. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Generates a header with preprocessor defines specified by the build file. +# +# In the GN template, specify build defines in the template as a list +# of strings that encode key/value pairs like this: +# +# defines = [ "ENABLE_FOO=1", "ENABLE_BAR=$enable_bar" ] +# +# The GN values "true" and "false" will be mapped to 0 and 1 for boolean +# #if defines to be expressed naturally. This means you can't directly make a +# define that generates C++ value of true or false for use in code. If you +# REALLY need this, you can also use the string "(true)" and "(false)" to +# prevent the rewriting. + +# To check the value of the define in C code: +# +# #include "path/to/here/header_file.h" +# +# #if ENABLE_FOO +# ... +# #endif +# +# const char kSpamServerUrl[] = SPAM_SERVER_URL; +# +# Template parameters +# +# defines [required, list of strings] +# Defines as described above. +# +# header [required, string] +# File name for generated header. By default, this will go in the +# generated file directory for this target, and you would include it +# with: +# #include "/
" +# +# header_dir [optional, string] +# Override the default location of the generated header. The string will +# be treated as a subdirectory of the root_gen_dir. For example: +# header_dir = "foo/bar" +# Then you can include the header as: +# #include "foo/bar/baz.h" +# +# deps, public_deps, testonly, visibility +# Normal meaning. +# +# Example +# +# buildconfig_header("foo_buildconfig") { +# header = "foo_buildconfig.h" +# +# defines = [ +# # This uses the GN build argument enable_doom_melon as the definition. +# "ENABLE_DOOM_MELON=$enable_doom_melon", +# +# # This force-enables the define +# "ENABLE_SPACE_LASER=true", +# +# # This will expand to the quoted C string when used in source code. +# "SPAM_SERVER_URL=\"http://www.example.com/\"", +# ] +# } + +import("//build_overrides/chip.gni") + +template("buildconfig_header") { + source_set_name = target_name + gen_target_name = "gen_${target_name}" + + action(gen_target_name) { + script = "${chip_root}/gn/chip/write_buildconfig_header.py" + + if (defined(invoker.header_dir)) { + header_file = "${invoker.header_dir}/${invoker.header}" + } else { + # Compute the path from the root to this file. + header_file = rebase_path(".", "//") + "/${invoker.header}" + } + + include_dir = "${root_gen_dir}/include" + + outputs = [ "${include_dir}/${header_file}" ] + + # Always write --defines to the file so it's not empty. Empty will confuse GN + # into thinking the response file isn't used. + response_file_contents = [ "--defines" ] + if (defined(invoker.defines)) { + response_file_contents += invoker.defines + } + + args = [ + "--output", + header_file, # Not rebased, Python script puts it inside gen-dir. + "--rulename", + get_label_info(":$target_name", "label_no_toolchain"), + "--gen-dir", + rebase_path(include_dir, root_build_dir), + "--definitions", + "{{response_file_name}}", + ] + + visibility = [ ":${source_set_name}" ] + } + + source_set(source_set_name) { + sources = get_target_outputs(":${gen_target_name}") + + deps = [ ":${gen_target_name}" ] + + forward_variables_from(invoker, + [ + "deps", + "public_deps", + "testonly", + "visibility", + ]) + } +} diff --git a/gn/chip/write_buildconfig_header.py b/gn/chip/write_buildconfig_header.py new file mode 100755 index 00000000000000..7087921f7939ae --- /dev/null +++ b/gn/chip/write_buildconfig_header.py @@ -0,0 +1,132 @@ +#!/usr/bin/env python +# 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. + +# Copyright 2015 The Chromium Authors. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# This writes headers for build defines. See buildconfig_header.gni for +# usage of this system as a whole. +# +# The parameters are passed in a response file so we don't have to worry +# about command line lengths. The name of the response file is passed on the +# command line. +# +# The format of the response file is: +# [--defines ] + +import optparse +import os +import shlex +import sys + + +class Options: + def __init__(self, output, rulename, header_guard, defines): + self.output = output + self.rulename = rulename + self.header_guard = header_guard + self.defines = defines + + +def GetOptions(): + parser = optparse.OptionParser() + parser.add_option('--output', help="Output header name inside --gen-dir.") + parser.add_option('--rulename', + help="Helpful name of build rule for including in the " + + "comment at the top of the file.") + parser.add_option('--gen-dir', + help="Path to root of generated file directory tree.") + parser.add_option('--definitions', + help="Name of the response file containing the defines.") + cmdline_options, cmdline_flags = parser.parse_args() + + # Compute header guard by replacing some chars with _ and upper-casing. + header_guard = cmdline_options.output.upper() + header_guard = \ + header_guard.replace('/', '_').replace('\\', '_').replace('.', '_') + header_guard += '_' + + # The actual output file is inside the gen dir. + output = os.path.join(cmdline_options.gen_dir, cmdline_options.output) + + # Definition file in GYP is newline separated, in GN they are shell formatted. + # shlex can parse both of these. + with open(cmdline_options.definitions, 'r') as def_file: + defs = shlex.split(def_file.read()) + defines_index = defs.index('--defines') + + # Everything after --defines are defines. true/false are remapped to 1/0, + # everything else is passed through. + defines = [] + for define in defs[defines_index + 1 :]: + equals_index = define.index('=') + key = define[:equals_index] + value = define[equals_index + 1:] + + # Canonicalize and validate the value. + if value == 'true': + value = '1' + elif value == 'false': + value = '0' + defines.append((key, str(value))) + + return Options(output=output, + rulename=cmdline_options.rulename, + header_guard=header_guard, + defines=defines) + + +def WriteHeader(options): + with open(options.output, 'w') as output_file: + output_file.write("// Generated by gn/chip/write_buildconfig_header.py\n") + if options.rulename: + output_file.write('// From "' + options.rulename + '"\n') + + output_file.write('\n#ifndef %s\n' % options.header_guard) + output_file.write('#define %s\n\n' % options.header_guard) + + for pair in options.defines: + output_file.write('#define %s %s\n' % pair) + + output_file.write('\n#endif // %s\n' % options.header_guard) + + +options = GetOptions() +WriteHeader(options) diff --git a/src/BUILD.gn b/src/BUILD.gn index 92d1b43b02e939..ea7eff4a1e2528 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -14,12 +14,12 @@ import("//build_overrides/chip.gni") -config("public_includes") { - include_dirs = [ "include" ] -} - config("includes") { - include_dirs = [ "." ] + include_dirs = [ + "include", + ".", + "${root_gen_dir}/include", + ] - configs = [ ":public_includes" ] + defines = [ "CHIP_SEPARATE_CONFIG_H=1" ] } diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index 244eda8ed166f9..de24bfc5c29b30 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -37,7 +37,10 @@ static_library("app") { "${chip_root}/src/system", ] - public_configs = [ ":app_config" ] + public_configs = [ + ":app_config", + "${chip_root}/src:includes", + ] } copy("codec_headers") { diff --git a/src/ble/BUILD.gn b/src/ble/BUILD.gn index e1d0fb0e068923..184a93f2d059b3 100644 --- a/src/ble/BUILD.gn +++ b/src/ble/BUILD.gn @@ -14,6 +14,7 @@ import("//build_overrides/chip.gni") +import("${chip_root}/gn/chip/buildconfig_header.gni") import("${chip_root}/src/platform/device.gni") import("ble.gni") @@ -22,10 +23,15 @@ declare_args() { chip_ble_project_config_include = "" } -config("ble_config") { - configs = [ "${chip_root}/src:includes" ] +buildconfig_header("ble_buildconfig") { + header = "BleBuildConfig.h" + header_dir = "ble" + + defines = [ + "CONFIG_NETWORK_LAYER_BLE=${chip_config_network_layer_ble}", + "CHIP_ENABLE_CHIPOBLE_TEST=false", + ] - defines = [] if (chip_ble_project_config_include != "") { defines += [ "BLE_PROJECT_CONFIG_INCLUDE=${chip_ble_project_config_include}" ] @@ -34,20 +40,17 @@ config("ble_config") { defines += [ "BLE_PLATFORM_CONFIG_INCLUDE=${chip_ble_platform_config_include}" ] } - - if (chip_config_network_layer_ble) { - defines += [ "CONFIG_NETWORK_LAYER_BLE=1" ] - } else { - defines += [ "CONFIG_NETWORK_LAYER_BLE=0" ] - } } source_set("ble_config_header") { sources = [ "BleConfig.h" ] - public_configs = [ ":ble_config" ] + public_configs = [ "${chip_root}/src:includes" ] - public_deps = [ "${chip_root}/src/system:system_config_header" ] + public_deps = [ + ":ble_buildconfig", + "${chip_root}/src/system:system_config_header", + ] } if (chip_config_network_layer_ble) { diff --git a/src/ble/BleConfig.h b/src/ble/BleConfig.h index 4e421ec5317866..1d5df4b1c0fbd9 100644 --- a/src/ble/BleConfig.h +++ b/src/ble/BleConfig.h @@ -36,6 +36,10 @@ #ifndef BLECONFIG_H_ #define BLECONFIG_H_ +#if CHIP_SEPARATE_CONFIG_H +#include +#endif + #include /* Include a project-specific configuration file, if defined. diff --git a/src/crypto/BUILD.gn b/src/crypto/BUILD.gn index 2af246b2d79fd0..718091d655f95f 100644 --- a/src/crypto/BUILD.gn +++ b/src/crypto/BUILD.gn @@ -15,26 +15,22 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlassert.gni") +import("${chip_root}/gn/chip/buildconfig_header.gni") + import("crypto.gni") -config("crypto_config") { - defines = [] - if (chip_crypto == "mbedtls") { - defines += [ "CHIP_CRYPTO_MBEDTLS=1" ] - } else { - defines += [ "CHIP_CRYPTO_MBEDTLS=0" ] - } - if (chip_crypto == "openssl") { - defines += [ - "CHIP_CRYPTO_OPENSSL=1", - "CHIP_WITH_OPENSSL=1", - ] - } else { - defines += [ - "CHIP_CRYPTO_OPENSSL=0", - "CHIP_WITH_OPENSSL=0", - ] - } +buildconfig_header("crypto_buildconfig") { + header = "CryptoBuildConfig.h" + header_dir = "crypto" + + chip_crypto_mbedtls = chip_crypto == "mbedtls" + chip_crypto_openssl = chip_crypto == "openssl" + + defines = [ + "CHIP_CRYPTO_MBEDTLS=${chip_crypto_mbedtls}", + "CHIP_CRYPTO_OPENSSL=${chip_crypto_openssl}", + "CHIP_WITH_OPENSSL=${chip_crypto_openssl}", + ] } if (chip_crypto == "openssl") { @@ -56,12 +52,12 @@ static_library("crypto") { ] public_deps = [ + ":crypto_buildconfig", "${chip_root}/src/lib/core", "${nlassert_root}:nlassert", ] - public_configs = [ ":crypto_config" ] - + public_configs = [] if (chip_crypto == "mbedtls") { sources += [ "CHIPCryptoPALmbedTLS.cpp" ] public_deps += [ "${mbedtls_root}:mbedtls" ] diff --git a/src/crypto/CHIPCryptoPAL.h b/src/crypto/CHIPCryptoPAL.h index 8bdfbf68851d5d..08394a5075bd14 100644 --- a/src/crypto/CHIPCryptoPAL.h +++ b/src/crypto/CHIPCryptoPAL.h @@ -23,6 +23,10 @@ #ifndef _CHIP_CRYPTO_PAL_H_ #define _CHIP_CRYPTO_PAL_H_ +#if CHIP_SEPARATE_CONFIG_H +#include +#endif + #include #include #include diff --git a/src/include/platform/CHIPDeviceConfig.h b/src/include/platform/CHIPDeviceConfig.h index 8aa3ce36e96082..c0727e76c9f51f 100644 --- a/src/include/platform/CHIPDeviceConfig.h +++ b/src/include/platform/CHIPDeviceConfig.h @@ -25,6 +25,10 @@ #ifndef CHIP_DEVICE_CONFIG_H #define CHIP_DEVICE_CONFIG_H +#if CHIP_SEPARATE_CONFIG_H +#include +#endif + #include /* Include a project-specific configuration file, if defined. diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index 729f500b905f3c..39fe7be7829623 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -17,6 +17,7 @@ import("//build_overrides/nlassert.gni") import("//build_overrides/nlfaultinjection.gni") import("//build_overrides/nlio.gni") +import("${chip_root}/gn/chip/buildconfig_header.gni") import("${chip_root}/gn/chip/tests.gni") import("${chip_root}/src/platform/device.gni") import("inet.gni") @@ -26,10 +27,21 @@ declare_args() { chip_inet_project_config_include = "" } -config("inet_config") { - configs = [ "${chip_root}/src:includes" ] +buildconfig_header("inet_buildconfig") { + header = "InetBuildConfig.h" + header_dir = "inet" + + defines = [ + "INET_CONFIG_TEST=${chip_build_tests}", + "INET_CONFIG_ENABLE_IPV4=${chip_inet_config_enable_ipv4}", + "INET_CONFIG_ENABLE_DNS_RESOLVER=${chip_inet_config_enable_dns_resolver}", + "INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS=${chip_inet_config_enable_async_dns_sockets}", + "INET_CONFIG_ENABLE_RAW_ENDPOINT=${chip_inet_config_enable_raw_endpoint}", + "INET_CONFIG_ENABLE_TCP_ENDPOINT=${chip_inet_config_enable_tcp_endpoint}", + "INET_CONFIG_ENABLE_UDP_ENDPOINT=${chip_inet_config_enable_udp_endpoint}", + "HAVE_LWIP_RAW_BIND_NETIF=true", + ] - defines = [] if (chip_inet_project_config_include != "") { defines += [ "INET_PROJECT_CONFIG_INCLUDE=${chip_inet_project_config_include}" ] @@ -38,49 +50,17 @@ config("inet_config") { defines += [ "INET_PLATFORM_CONFIG_INCLUDE=${chip_inet_platform_config_include}" ] } - if (chip_build_tests) { - defines += [ "INET_CONFIG_TEST=1" ] - } else { - defines += [ "INET_CONFIG_TEST=0" ] - } - if (chip_inet_config_enable_ipv4) { - defines += [ "INET_CONFIG_ENABLE_IPV4=1" ] - } else { - defines += [ "INET_CONFIG_ENABLE_IPV4=0" ] - } - if (chip_inet_config_enable_dns_resolver) { - defines += [ "INET_CONFIG_ENABLE_DNS_RESOLVER=1" ] - } else { - defines += [ "INET_CONFIG_ENABLE_DNS_RESOLVER=0" ] - } - if (chip_inet_config_enable_async_dns_sockets) { - defines += [ "INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS=1" ] - } else { - defines += [ "INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS=0" ] - } - if (chip_inet_config_enable_raw_endpoint) { - defines += [ "INET_CONFIG_ENABLE_RAW_ENDPOINT=1" ] - } else { - defines += [ "INET_CONFIG_ENABLE_RAW_ENDPOINT=0" ] - } - if (chip_inet_config_enable_tcp_endpoint) { - defines += [ "INET_CONFIG_ENABLE_TCP_ENDPOINT=1" ] - } else { - defines += [ "INET_CONFIG_ENABLE_TCP_ENDPOINT=0" ] - } - if (chip_inet_config_enable_udp_endpoint) { - defines += [ "INET_CONFIG_ENABLE_UDP_ENDPOINT=1" ] - } else { - assert(false, "CHIP currently request UDP endpoint") - } } source_set("inet_config_header") { sources = [ "InetConfig.h" ] - public_configs = [ ":inet_config" ] + public_configs = [ "${chip_root}/src:includes" ] - public_deps = [ "${chip_root}/src/system:system_config_header" ] + public_deps = [ + ":inet_buildconfig", + "${chip_root}/src/system:system_config_header", + ] } static_library("inet") { diff --git a/src/inet/InetArgParser.h b/src/inet/InetArgParser.h index e3d79c26adbba3..b5fbd35f1d001d 100644 --- a/src/inet/InetArgParser.h +++ b/src/inet/InetArgParser.h @@ -26,6 +26,8 @@ #ifndef INETARGPARSER_H_ #define INETARGPARSER_H_ +#include + #if CHIP_CONFIG_ENABLE_ARG_PARSER #include diff --git a/src/inet/InetConfig.h b/src/inet/InetConfig.h index 316eba66a3caeb..be800739a09751 100644 --- a/src/inet/InetConfig.h +++ b/src/inet/InetConfig.h @@ -36,6 +36,10 @@ #ifndef INETCONFIG_H #define INETCONFIG_H +#if CHIP_SEPARATE_CONFIG_H +#include +#endif + /*--- Include configuration headers ---*/ #include diff --git a/src/inet/InetInterface.h b/src/inet/InetInterface.h index 4a4d846a4f75b5..dee996df6d9fc7 100644 --- a/src/inet/InetInterface.h +++ b/src/inet/InetInterface.h @@ -27,6 +27,8 @@ #ifndef INETINTERFACE_H #define INETINTERFACE_H +#include + #include #include #include diff --git a/src/inet/tests/TestInetCommon.cpp b/src/inet/tests/TestInetCommon.cpp index dd4824f47831e6..d4791ad14618d7 100644 --- a/src/inet/tests/TestInetCommon.cpp +++ b/src/inet/tests/TestInetCommon.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include diff --git a/src/inet/tests/TestInetCommonOptions.cpp b/src/inet/tests/TestInetCommonOptions.cpp index dfc9d24e397086..26f693ef8052a4 100644 --- a/src/inet/tests/TestInetCommonOptions.cpp +++ b/src/inet/tests/TestInetCommonOptions.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn index 09b2e33d3dd3cc..137c8f7537a065 100644 --- a/src/lib/core/BUILD.gn +++ b/src/lib/core/BUILD.gn @@ -15,105 +15,56 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlio.gni") +import("${chip_root}/gn/chip/buildconfig_header.gni") import("${chip_root}/gn/chip/tests.gni") import("${chip_root}/src/inet/inet.gni") import("core.gni") -config("chip_config") { +buildconfig_header("chip_buildconfig") { + header = "CHIPBuildConfig.h" + header_dir = "core" + + chip_target_style_unix = chip_target_style == "unix" + chip_target_style_embedded = chip_target_style == "embedded" + chip_logging_style_android = chip_logging_style == "android" + chip_logging_style_external = chip_logging_style == "external" + chip_logging_style_stdio = chip_logging_style == "stdio" + chip_logging_style_stdio_weak = chip_logging_style == "stdio_weak" + chip_logging_style_stdio_with_timestamps = + chip_logging_style == "stdio_with_timestamps" + + chip_config_memory_management_malloc = + chip_config_memory_management == "malloc" + chip_config_memory_management_simple = + chip_config_memory_management == "simple" + chip_config_memory_management_platform = + chip_config_memory_management == "platform" + # TODO - Move CHIP_PROJECT_CONFIG_INCLUDE, CHIP_PLATFORM_CONFIG_INCLUDE here. # Currently those are also used from src/system. - defines = [] - - if (chip_build_tests) { - defines += [ "CHIP_CONFIG_TEST=1" ] - } else { - defines += [ "CHIP_CONFIG_TEST=0" ] - } - if (chip_error_logging) { - defines += [ "CHIP_ERROR_LOGGING=1" ] - } else { - defines += [ "CHIP_ERROR_LOGGING=0" ] - } - if (chip_progress_logging) { - defines += [ "CHIP_PROGRESS_LOGGING=1" ] - } else { - defines += [ "CHIP_PROGRESS_LOGGING=0" ] - } - if (chip_detail_logging) { - defines += [ "CHIP_DETAIL_LOGGING=1" ] - } else { - defines += [ "CHIP_DETAIL_LOGGING=0" ] - } - - if (chip_config_short_error_str) { - defines += [ "CHIP_CONFIG_SHORT_ERROR_STR=1" ] - } else { - defines += [ "CHIP_CONFIG_SHORT_ERROR_STR=0" ] - } - - if (chip_config_enable_arg_parser) { - defines += [ "CHIP_CONFIG_ENABLE_ARG_PARSER=1" ] - } else { - defines += [ "CHIP_CONFIG_ENABLE_ARG_PARSER=0" ] - } - - if (chip_target_style == "unix") { - defines += [ "CHIP_TARGET_STYLE_UNIX=1" ] - } else { - defines += [ "CHIP_TARGET_STYLE_UNIX=0" ] - } - if (chip_target_style == "embedded") { - defines += [ "CHIP_TARGET_STYLE_EMBEDDED=1" ] - } else { - defines += [ "CHIP_TARGET_STYLE_EMBEDDED=0" ] - } - - if (chip_logging_style == "android") { - defines += [ "CHIP_LOGGING_STYLE_ANDROID=1" ] - } else { - defines += [ "CHIP_LOGGING_STYLE_ANDROID=0" ] - } - if (chip_logging_style == "external") { - defines += [ "CHIP_LOGGING_STYLE_EXTERNAL=1" ] - } else { - defines += [ "CHIP_LOGGING_STYLE_EXTERNAL=0" ] - } - if (chip_logging_style == "stdio") { - defines += [ "CHIP_LOGGING_STYLE_STDIO=1" ] - } else { - defines += [ "CHIP_LOGGING_STYLE_STDIO=0" ] - } - if (chip_logging_style == "stdio_weak") { - defines += [ "CHIP_LOGGING_STYLE_STDIO_WEAK=1" ] - } else { - defines += [ "CHIP_LOGGING_STYLE_STDIO_WEAK=0" ] - } - - if (chip_config_memory_management == "malloc") { - defines += [ - "CHIP_CONFIG_MEMORY_MGMT_MALLOC=1", - "HAVE_MALLOC=1", - "HAVE_FREE=1", - ] - } else { - defines += [ "CHIP_CONFIG_MEMORY_MGMT_MALLOC=0" ] - } - if (chip_config_memory_management == "simple") { - defines += [ "CHIP_CONFIG_MEMORY_MGMT_SIMPLE=1" ] - } else { - defines += [ "CHIP_CONFIG_MEMORY_MGMT_SIMPLE=0" ] - } - if (chip_config_memory_management == "platform") { - defines += [ "CHIP_CONFIG_MEMORY_MGMT_PLATFORM=1" ] - } else { - defines += [ "CHIP_CONFIG_MEMORY_MGMT_PLATFORM=0" ] - } - - include_dirs = [ target_gen_dir ] - - configs = [ - "${chip_root}/src:includes", - "${chip_root}/src/lib:includes", + defines = [ + "CHIP_FUZZING_ENABLED=false", + "CHIP_CONFIG_TEST=${chip_build_tests}", + "CHIP_ERROR_LOGGING=${chip_error_logging}", + "CHIP_PROGRESS_LOGGING=${chip_progress_logging}", + "CHIP_DETAIL_LOGGING=${chip_detail_logging}", + "CHIP_CONFIG_SHORT_ERROR_STR=${chip_config_short_error_str}", + "CHIP_CONFIG_ENABLE_ARG_PARSER=${chip_config_enable_arg_parser}", + "CHIP_TARGET_STYLE_UNIX=${chip_target_style_unix}", + "CHIP_TARGET_STYLE_EMBEDDED=${chip_target_style_embedded}", + "CHIP_LOGGING_STYLE_ANDROID=${chip_logging_style_android}", + "CHIP_LOGGING_STYLE_EXTERNAL=${chip_logging_style_external}", + "CHIP_LOGGING_STYLE_STDIO=${chip_logging_style_stdio}", + "CHIP_LOGGING_STYLE_STDIO_WEAK=${chip_logging_style_stdio_weak}", + "CHIP_LOGGING_STYLE_STDIO_WITH_TIMESTAMPS=${chip_logging_style_stdio_with_timestamps}", + "CHIP_CONFIG_MEMORY_MGMT_MALLOC=${chip_config_memory_management_malloc}", + "HAVE_MALLOC=${chip_config_memory_management_malloc}", + "HAVE_FREE=${chip_config_memory_management_malloc}", + "HAVE_NEW=false", + "CHIP_CONFIG_MEMORY_MGMT_SIMPLE=${chip_config_memory_management_simple}", + "CHIP_CONFIG_MEMORY_MGMT_PLATFORM=${chip_config_memory_management_platform}", + "CHIP_CONFIG_ENABLE_RELIABLE_MESSAGING=true", + "CHIP_CONFIG_PROVIDE_OBSOLESCENT_INTERFACES=false", ] } @@ -124,9 +75,16 @@ source_set("chip_config_header") { "CHIPTimeConfig.h", ] - public_configs = [ ":chip_config" ] + public_configs = [ + "${chip_root}/src:includes", + "${chip_root}/src/lib:includes", + ] - public_deps = [ "${chip_root}/src/system:system_config_header" ] + public_deps = [ + ":chip_buildconfig", + "${chip_root}/src/ble:ble_config_header", + "${chip_root}/src/system:system_config_header", + ] } static_library("core") { diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index 8dd32624ce68f1..132b1b4d371db6 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -36,6 +36,11 @@ #ifndef CHIP_CONFIG_H_ #define CHIP_CONFIG_H_ +#if CHIP_SEPARATE_CONFIG_H +#include +#endif + +#include #include /* COMING SOON: making the INET Layer optional entails making this inclusion optional. */ diff --git a/src/lib/core/CHIPCore.h b/src/lib/core/CHIPCore.h index 46759c30c729b2..c09e75ce4bf16d 100644 --- a/src/lib/core/CHIPCore.h +++ b/src/lib/core/CHIPCore.h @@ -30,6 +30,8 @@ #include +#include + #if CONFIG_NETWORK_LAYER_BLE #include #endif // CONFIG_NETWORK_LAYER_BLE diff --git a/src/lib/message/support/crypto/CHIPCrypto.h b/src/lib/message/support/crypto/CHIPCrypto.h index b0e4bfceca4876..51c214fc7710c7 100644 --- a/src/lib/message/support/crypto/CHIPCrypto.h +++ b/src/lib/message/support/crypto/CHIPCrypto.h @@ -26,6 +26,10 @@ #ifndef CHIPCRYPTO_H_ #define CHIPCRYPTO_H_ +#if CHIP_SEPARATE_CONFIG_H +#include +#endif + #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS #endif diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn index ba31999762d7b7..e0543996b4aee3 100644 --- a/src/lib/support/BUILD.gn +++ b/src/lib/support/BUILD.gn @@ -24,7 +24,7 @@ import("${chip_root}/src/lib/core/core.gni") action("gen_chip_version") { script = "${chip_root}/scripts/gen_chip_version.py" - version_file = "${target_gen_dir}/include/CHIPVersion.h" + version_file = "${root_gen_dir}/include/CHIPVersion.h" outputs = [ version_file ] args = [ "--output_file=" + rebase_path(version_file, root_build_dir), @@ -41,16 +41,6 @@ source_set("chip_version_header") { deps = [ ":gen_chip_version" ] } -config("support_config") { - configs = [ - "${chip_root}/src:includes", - "${chip_root}/src/lib:includes", - "${chip_root}/src/system:system_config", - ] - - include_dirs = [ "${target_gen_dir}/include" ] -} - support_headers = [ "Base64.h", "BufBound.h", @@ -107,7 +97,11 @@ static_library("support") { "${chip_root}/src/inet:inet_config_header", ] - public_configs = [ ":support_config" ] + public_configs = [ + "${chip_root}/src:includes", + "${chip_root}/src/lib:includes", + "${chip_root}/src/system:system_config", + ] if (chip_config_memory_management == "simple") { sources += [ "CHIPMem-SimpleAlloc.cpp" ] @@ -125,5 +119,5 @@ static_library("support") { copy("support_headers") { sources = support_headers - outputs = [ "${target_gen_dir}/include/support/{{source_file_part}}" ] + outputs = [ "${root_gen_dir}/include/support/{{source_file_part}}" ] } diff --git a/src/lib/support/tests/TestErrorStr.cpp b/src/lib/support/tests/TestErrorStr.cpp index 87f8a16e20ed27..2d9fc9b274123b 100644 --- a/src/lib/support/tests/TestErrorStr.cpp +++ b/src/lib/support/tests/TestErrorStr.cpp @@ -20,6 +20,7 @@ #include #include +#include #include diff --git a/src/lwip/BUILD.gn b/src/lwip/BUILD.gn index a27f73fb1e8052..cdfab8117c6f6f 100644 --- a/src/lwip/BUILD.gn +++ b/src/lwip/BUILD.gn @@ -15,6 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/lwip.gni") +import("${chip_root}/gn/chip/buildconfig_header.gni") import("${lwip_root}/lwip.gni") declare_args() { @@ -41,7 +42,10 @@ if (lwip_platform == "nrf5") { import("//build_overrides/efr32_sdk.gni") } -config("lwip_config") { +buildconfig_header("lwip_buildconfig") { + header = "lwip_buildconfig.h" + header_dir = "lwip" + # Automatically enable LWIP_DEBUG for internal is_debug builds. if (lwip_debug) { lwip_debug = 1 @@ -56,7 +60,9 @@ config("lwip_config") { if (current_os == "android") { defines += [ "LWIP_NO_STDINT_H=1" ] } +} +config("lwip_config") { include_dirs = [ lwip_platform ] if (lwip_platform != "standalone") { @@ -84,14 +90,17 @@ lwip_target("lwip") { sources += [ "freertos/sys_arch.c" ] } - public_deps = [] + public_deps = [ ":lwip_buildconfig" ] if (lwip_platform == "nrf5") { public_deps += [ "${nrf5_sdk_build_root}:nrf5_sdk" ] } else if (lwip_platform == "efr32") { public_deps += [ "${efr32_sdk_build_root}:efr32_sdk" ] } - public_configs = [ ":lwip_config" ] + public_configs = [ + ":lwip_config", + "${chip_root}/src:includes", + ] } group("all") { diff --git a/src/lwip/efr32/lwipopts.h b/src/lwip/efr32/lwipopts.h index 15e67108a67255..312e28836e4c6f 100644 --- a/src/lwip/efr32/lwipopts.h +++ b/src/lwip/efr32/lwipopts.h @@ -26,6 +26,10 @@ #ifndef __LWIPOPTS_H__ #define __LWIPOPTS_H__ +#if CHIP_SEPARATE_CONFIG_H +#include +#endif + #include #define NO_SYS 0 diff --git a/src/lwip/k32w/lwipopts.h b/src/lwip/k32w/lwipopts.h index f6eb20763206c9..e78906707c80ca 100644 --- a/src/lwip/k32w/lwipopts.h +++ b/src/lwip/k32w/lwipopts.h @@ -26,6 +26,10 @@ #ifndef __LWIPOPTS_H__ #define __LWIPOPTS_H__ +#if CHIP_SEPARATE_CONFIG_H +#include +#endif + #include #define NO_SYS 0 diff --git a/src/lwip/nrf5/lwipopts.h b/src/lwip/nrf5/lwipopts.h index 9f719ebec0bb9b..70282bee561e1d 100644 --- a/src/lwip/nrf5/lwipopts.h +++ b/src/lwip/nrf5/lwipopts.h @@ -26,6 +26,10 @@ #ifndef __LWIPOPTS_H__ #define __LWIPOPTS_H__ +#if CHIP_SEPARATE_CONFIG_H +#include +#endif + #include #define NO_SYS 0 diff --git a/src/lwip/standalone/lwipopts.h b/src/lwip/standalone/lwipopts.h index 5e9ee66bd09bad..8c9450e4e07b99 100644 --- a/src/lwip/standalone/lwipopts.h +++ b/src/lwip/standalone/lwipopts.h @@ -28,6 +28,10 @@ #ifndef __LWIPOPTS_H__ #define __LWIPOPTS_H__ +#if CHIP_SEPARATE_CONFIG_H +#include +#endif + #include /** diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 82d332befa88a3..91d11bb0aedcdf 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -16,6 +16,8 @@ import("//build/config/linux/pkg_config.gni") import("//build_overrides/chip.gni") import("//build_overrides/nlio.gni") +import("${chip_root}/gn/chip/buildconfig_header.gni") + import("device.gni") if (chip_enable_openthread) { @@ -39,11 +41,21 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { chip_device_config_firmware_build_time = "" } - config("platform_config") { - configs = [ "${chip_root}/src:includes" ] + buildconfig_header("platform_buildconfig") { + header = "CHIPDeviceBuildConfig.h" + header_dir = "platform" + + chip_with_gio = chip_enable_wifi + chip_device_config_enable_wpa = chip_enable_wifi + + defines = [ + "CHIP_DEVICE_CONFIG_ENABLE_THREAD=${chip_enable_openthread}", + "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", + ] - defines = [] - libs = [] if (chip_device_project_config_include != "") { defines += [ "CHIP_DEVICE_PROJECT_CONFIG_INCLUDE=${chip_device_project_config_include}" ] } @@ -59,60 +71,36 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { } if (chip_device_platform == "darwin") { - frameworks = [ - "CoreFoundation.framework", - "CoreBluetooth.framework", - "Foundation.framework", - ] defines += [ - "CONFIG_DEVICE_LAYER=1", "CHIP_DEVICE_LAYER_TARGET_DARWIN=1", "CHIP_DEVICE_LAYER_TARGET=Darwin", ] - } else { - defines += [ "CHIP_DEVICE_LAYER_TARGET_DARWIN=0" ] - } - if (chip_device_platform == "linux") { + } else if (chip_device_platform == "linux") { defines += [ - "CONFIG_DEVICE_LAYER=1", "CHIP_DEVICE_LAYER_TARGET_LINUX=1", "CHIP_DEVICE_LAYER_TARGET=Linux", ] - } else { - defines += [ "CHIP_DEVICE_LAYER_TARGET_LINUX=0" ] - } - if (chip_device_platform == "nrf5") { + } else if (chip_device_platform == "nrf5") { defines += [ - "CONFIG_DEVICE_LAYER=1", "CHIP_DEVICE_LAYER_TARGET_NRF5=1", "CHIP_DEVICE_LAYER_TARGET=nRF5", ] - } else { - defines += [ "CHIP_DEVICE_LAYER_TARGET_NRF5=0" ] - } - if (chip_enable_openthread) { - defines += [ - "CHIP_DEVICE_CONFIG_ENABLE_THREAD=1", - "CHIP_ENABLE_OPENTHREAD=1", - ] - } - if (chip_enable_wifi) { - defines += [ "CHIP_DEVICE_CONFIG_ENABLE_WPA=1" ] } if (chip_device_platform == "efr32") { defines += [ - "CONFIG_DEVICE_LAYER=1", "CHIP_DEVICE_LAYER_TARGET_EFR32=1", "CHIP_DEVICE_LAYER_TARGET=EFR32", ] - if (chip_enable_openthread) { - defines += [ - "CHIP_DEVICE_CONFIG_ENABLE_THREAD=1", - "CHIP_ENABLE_OPENTHREAD=1", - ] - } - } else { - defines += [ "CHIP_DEVICE_LAYER_TARGET_EFR32=0" ] + } + } + + config("platform_config") { + if (chip_device_platform == "darwin") { + frameworks = [ + "CoreFoundation.framework", + "CoreBluetooth.framework", + "Foundation.framework", + ] } } @@ -161,6 +149,7 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { ] public_deps = [ + ":platform_buildconfig", "${chip_root}/src/ble", "${chip_root}/src/inet", "${chip_root}/src/lib/core:chip_config_header", @@ -168,7 +157,10 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { "${nlio_root}:nlio", ] - public_configs = [ ":platform_config" ] + public_configs = [ + ":platform_config", + "${chip_root}/src:includes", + ] if (chip_device_platform == "darwin") { sources += [ diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index edbc008ca4de0e..dff7fd0df07256 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -16,6 +16,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlassert.gni") import("//build_overrides/nlfaultinjection.gni") +import("${chip_root}/gn/chip/buildconfig_header.gni") import("${chip_root}/gn/chip/tests.gni") import("${chip_root}/src/platform/device.gni") import("system.gni") @@ -38,10 +39,40 @@ if (chip_project_config_include_dirs == [] && chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] } -config("system_config") { - configs = [ "${chip_root}/src:includes" ] +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_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_LWIP=${chip_system_config_use_lwip}", + "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_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}", + ] - defines = [] if (chip_project_config_include != "") { defines += [ "CHIP_PROJECT_CONFIG_INCLUDE=${chip_project_config_include}" ] } @@ -59,63 +90,21 @@ config("system_config") { "SYSTEM_PLATFORM_CONFIG_INCLUDE=${chip_system_platform_config_include}", ] } - if (chip_build_tests) { - defines += [ "CHIP_SYSTEM_CONFIG_TEST=1" ] - } else { - defines += [ "CHIP_SYSTEM_CONFIG_TEST=0" ] - } - if (chip_with_nlfaultinjection) { - defines += [ "CHIP_WITH_NLFAULTINJECTION=1" ] - } else { - defines += [ "CHIP_WITH_NLFAULTINJECTION=0" ] - } - if (chip_system_config_use_lwip) { - defines += [ "CHIP_SYSTEM_CONFIG_USE_LWIP=1" ] - } else { - defines += [ "CHIP_SYSTEM_CONFIG_USE_LWIP=0" ] - } - if (chip_system_config_use_sockets) { - defines += [ "CHIP_SYSTEM_CONFIG_USE_SOCKETS=1" ] - } else { - defines += [ "CHIP_SYSTEM_CONFIG_USE_SOCKETS=0" ] - } - if (chip_system_config_locking == "posix") { - defines += [ "CHIP_SYSTEM_CONFIG_POSIX_LOCKING=1" ] - } else { - defines += [ "CHIP_SYSTEM_CONFIG_POSIX_LOCKING=0" ] - } - if (chip_system_config_locking == "freertos") { - defines += [ "CHIP_SYSTEM_CONFIG_FREERTOS_LOCKING=1" ] - } else { - defines += [ "CHIP_SYSTEM_CONFIG_FREERTOS_LOCKING=0" ] - } - if (chip_system_config_locking == "none") { - defines += [ "CHIP_SYSTEM_CONFIG_NO_LOCKING=1" ] - } else { - defines += [ "CHIP_SYSTEM_CONFIG_NO_LOCKING=0" ] - } - if (chip_system_config_provide_statistics) { - defines += [ "CHIP_SYSTEM_CONFIG_PROVIDE_STATISTICS=1" ] - } else { - defines += [ "CHIP_SYSTEM_CONFIG_PROVIDE_STATISTICS=0" ] - } - if (chip_system_config_clock == "clock_gettime") { - defines += [ "HAVE_CLOCK_GETTIME=1" ] - defines += [ "HAVE_CLOCK_SETTIME=1" ] - } - if (chip_system_config_clock == "gettimeofday") { - defines += [ "HAVE_GETTIMEOFDAY=1" ] - } +} +config("system_config") { include_dirs = chip_project_config_include_dirs } source_set("system_config_header") { sources = [ "SystemConfig.h" ] - public_configs = [ ":system_config" ] + public_configs = [ + ":system_config", + "${chip_root}/src:includes", + ] - public_deps = [] + public_deps = [ ":system_buildconfig" ] if (chip_system_config_use_lwip) { public_deps += [ "${chip_root}/src/lwip" ] diff --git a/src/system/SystemConfig.h b/src/system/SystemConfig.h index 503457e991a21d..6f887a77f1c885 100644 --- a/src/system/SystemConfig.h +++ b/src/system/SystemConfig.h @@ -38,7 +38,9 @@ #define SYSTEMCONFIG_H /* Platform include headers */ -#ifdef HAVE_CONFIG_H +#if CHIP_SEPARATE_CONFIG_H +#include +#elif defined(HAVE_CONFIG_H) #include #endif diff --git a/src/system/SystemError.cpp b/src/system/SystemError.cpp index ec2b56d291394d..f351e999d22b72 100644 --- a/src/system/SystemError.cpp +++ b/src/system/SystemError.cpp @@ -33,6 +33,8 @@ #include #include +#include + // Include local headers #if CHIP_SYSTEM_CONFIG_USE_LWIP #include diff --git a/src/system/SystemFaultInjection.cpp b/src/system/SystemFaultInjection.cpp index 8b64401c201686..6b31418103422d 100644 --- a/src/system/SystemFaultInjection.cpp +++ b/src/system/SystemFaultInjection.cpp @@ -16,6 +16,8 @@ * limitations under the License. */ +#include + /** * @file * Implementation of the fault-injection utilities for CHIP System Layer. diff --git a/src/system/SystemStats.h b/src/system/SystemStats.h index 00e21fe38f9a90..f79813017f669e 100644 --- a/src/system/SystemStats.h +++ b/src/system/SystemStats.h @@ -31,6 +31,7 @@ // Include configuration headers #include +#include // Include dependent headers #include diff --git a/third_party/jlink/segger_rtt/RTT/BUILD.gn b/third_party/jlink/segger_rtt/RTT/BUILD.gn index 71f618b8450387..007c506bc57da6 100644 --- a/third_party/jlink/segger_rtt/RTT/BUILD.gn +++ b/third_party/jlink/segger_rtt/RTT/BUILD.gn @@ -15,6 +15,8 @@ import("//build/config/arm.gni") import("//build_overrides/chip.gni") +import("${chip_root}/gn/chip/buildconfig_header.gni") + declare_args() { # Size of SEGGER RTT up buffer. segger_rtt_buffer_size_up = -1 @@ -44,15 +46,11 @@ declare_args() { rtt_use_asm = _rtt_asm != "" } -config("rtt_config") { - include_dirs = [ "." ] +buildconfig_header("rtt_buildconfig") { + header = "SEGGER_RTT_BuildConfig.h" + header_dir = "RTT" - defines = [] - if (rtt_use_asm) { - defines += [ "RTT_USE_ASM=1" ] - } else { - defines += [ "RTT_USE_ASM=0" ] - } + defines = [ "RTT_USE_ASM=${rtt_use_asm}" ] if (segger_rtt_buffer_size_up != -1) { defines += [ "BUFFER_SIZE_UP=${segger_rtt_buffer_size_up}" ] @@ -73,6 +71,13 @@ config("rtt_config") { } } +config("rtt_config") { + include_dirs = [ + ".", + "${root_gen_dir}/include/RTT", + ] +} + source_set("RTT") { sources = [ "SEGGER_RTT.c", @@ -84,9 +89,13 @@ source_set("RTT") { sources += [ _rtt_asm ] } + public_deps = [ ":rtt_buildconfig" ] + public_configs = [ ":rtt_config" ] } source_set("printf") { sources = [ "SEGGER_RTT_printf.c" ] + + public_deps = [ ":RTT" ] } diff --git a/third_party/jlink/segger_rtt/RTT/SEGGER_RTT_Conf.h b/third_party/jlink/segger_rtt/RTT/SEGGER_RTT_Conf.h index 211d8a08809bc5..08844af35fb7ca 100644 --- a/third_party/jlink/segger_rtt/RTT/SEGGER_RTT_Conf.h +++ b/third_party/jlink/segger_rtt/RTT/SEGGER_RTT_Conf.h @@ -53,6 +53,8 @@ Revision: $Rev: 18601 $ #ifndef SEGGER_RTT_CONF_H #define SEGGER_RTT_CONF_H +#include + #ifdef __IAR_SYSTEMS_ICC__ #include #endif diff --git a/third_party/mbedtls/BUILD.gn b/third_party/mbedtls/BUILD.gn index 9a82581f518539..4dbe91efcefcc4 100644 --- a/third_party/mbedtls/BUILD.gn +++ b/third_party/mbedtls/BUILD.gn @@ -24,15 +24,6 @@ if (mbedtls_target != "") { } else { config("mbedtls_config") { include_dirs = [ "repo/include" ] - - if (current_os == "freertos") { - defines = [ - "MBEDTLS_NO_PLATFORM_ENTROPY", - "MBEDTLS_TEST_NULL_ENTROPY", - "MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES", - ] - cflags = [ "-Wno-cpp" ] - } } static_library("mbedtls") { diff --git a/third_party/openthread/repo b/third_party/openthread/repo index 6886ff1e4c5dcf..d20a8951fe0d7f 160000 --- a/third_party/openthread/repo +++ b/third_party/openthread/repo @@ -1 +1 @@ -Subproject commit 6886ff1e4c5dcf1bdc6ac7a067a81debff113938 +Subproject commit d20a8951fe0d7f400c0639dcf0c1c1454a01d58b