Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] support custom build config for external platform #16618

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions config/esp32/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ chip_ble_project_config_include = ""
mbedtls_target = "//mbedtls:mbedtls"
lwip_platform = "external"

chip_build_tests = true

#Enabling this causes some error
#chip_inet_config_enable_tun_endpoint = false
chip_inet_config_enable_tcp_endpoint = true
Expand Down
9 changes: 9 additions & 0 deletions config/esp32/components/chip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ if(CONFIG_ENABLE_PW_RPC)
chip_gn_arg_append("pw_build_LINK_DEPS" "[\"\$dir_pw_assert:impl\", \"\$dir_pw_log:impl\"]")
endif()

if (CONFIG_BUILD_CHIP_TESTS)
chip_gn_arg_bool("chip_build_tests" "true")
endif()

if (NOT CONFIG_USE_MINIMAL_MDNS)
chip_gn_arg_append("chip_mdns" "\"platform\"")
endif()
Expand All @@ -116,6 +120,11 @@ if (CONFIG_ENABLE_ROTATING_DEVICE_ID)
chip_gn_arg_append("chip_enable_rotating_device_id" "true")
endif()

if (CONFIG_CHIP_ENABLE_EXTERNAL_PLATFORM)
chip_gn_arg_append("chip_device_platform" "\"external\"")
chip_gn_arg_append("chip_platform_target" "\"${CONFIG_CHIP_EXTERNAL_PLATFORM_TARGET}\"")
endif()

set(args_gn_input "${CMAKE_CURRENT_BINARY_DIR}/args.gn.in")
file(GENERATE OUTPUT "${args_gn_input}" CONTENT "${chip_gn_args}")

Expand Down
20 changes: 20 additions & 0 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ menu "CHIP Core"
help
Matter spec is based on IPv6 communication only. Enabling this option may save some flash/ram.

config BUILD_CHIP_TESTS
bool "Build CHIP tests"
default "y"
help
Build CHIP test binaries.

# TODO: add log level selection

endmenu # "General Options"
Expand Down Expand Up @@ -748,4 +754,18 @@ menu "CHIP Device Layer"

endmenu

menu "External Platform"
config CHIP_ENABLE_EXTERNAL_PLATFORM
bool "Enable external platform layer"
default n
help
Use external platform layer to override the default ESP32 platform in Matter SDK.

config CHIP_EXTERNAL_PLATFORM_TARGET
string "The external platform target"
depends on CHIP_ENABLE_EXTERNAL_PLATFORM
help
The gn target of the external platform.
endmenu

endmenu
1 change: 1 addition & 0 deletions src/ble/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ source_set("ble_config_header") {

public_deps = [
":ble_buildconfig",
"${chip_root}/src/platform:platform_buildconfig",
"${chip_root}/src/system:system_config_header",
]
}
Expand Down
1 change: 1 addition & 0 deletions src/ble/BleConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#if CHIP_HAVE_CONFIG_H
#include <ble/BleBuildConfig.h>
#include <platform/CHIPDeviceBuildConfig.h>
#endif

#include <system/SystemConfig.h>
Expand Down
8 changes: 6 additions & 2 deletions src/platform/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (chip_device_platform == "linux" && chip_mdns != "none") {
}
}

if (chip_device_platform != "none") {
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 = ""
Expand Down Expand Up @@ -244,7 +244,7 @@ if (chip_device_platform != "none") {
[ "CHIP_DEVICE_CONFIG_ENABLE_WPA=${chip_device_config_enable_wpa}" ]
}
}
} else {
} else if (chip_device_platform == "none") {
buildconfig_header("platform_buildconfig") {
header = "CHIPDeviceBuildConfig.h"
header_dir = "platform"
Expand All @@ -258,6 +258,10 @@ if (chip_device_platform != "none") {
defines += [ "EXTERNAL_KEYVALUESTOREMANAGERIMPL_HEADER=\"controller/java/AndroidKeyValueStoreManagerImpl.h\"" ]
}
}
} else {
group("platform_buildconfig") {
public_deps = [ "${chip_platform_target}:platform_buildconfig" ]
}
}

if (chip_device_platform != "none") {
Expand Down
5 changes: 4 additions & 1 deletion src/system/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ source_set("system_config_header") {
"${chip_root}/src:includes",
]

public_deps = [ ":system_buildconfig" ]
public_deps = [
":system_buildconfig",
"${chip_root}/src/platform:platform_buildconfig",
]

if (target_cpu != "esp32") {
if (chip_system_config_use_lwip) {
Expand Down
1 change: 1 addition & 0 deletions src/system/SystemConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

/* Platform include headers */
#if CHIP_HAVE_CONFIG_H
#include <platform/CHIPDeviceBuildConfig.h>
#include <system/SystemBuildConfig.h>
#endif

Expand Down