Skip to content

Commit d1279a8

Browse files
Add matter_enable_recommended meta-setting (#34942)
* Add matter_enable_recommended meta-setting This setting defaults to true which leaves current behavior unchanged. However it can be set to false to achieve a more conservative / minimal set of defaults, without having to manually disable an ever-increasing set of features. Consider using this setting as the default value for other settings that increase code size or add debugging / tracing or similar features that are not always desired. Especially settings that default to true on Linux and Mac ("because you're probably building for development") should likely use this option for their default, e.g. matter_foo = matter_enable_recommended && (current_os == "linux" || current_os == "mac") * Add more documentation and turn off the setting for minimal CI builds * Move matter_enable_recommended into /config/recommended.gni This allows it to be uesd from args.gni (i.e. in the context of a default_args scope, where variables like current_os are not defined) as well as within a build / toolchain context.
1 parent cbd15a1 commit d1279a8

File tree

6 files changed

+57
-17
lines changed

6 files changed

+57
-17
lines changed

.github/workflows/minimal-build.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ name: Minimal Build (Linux / configure)
1717
on:
1818
push:
1919
branches-ignore:
20-
- 'dependabot/**'
20+
- "dependabot/**"
2121
pull_request:
2222
merge_group:
2323

@@ -42,11 +42,11 @@ jobs:
4242
- name: Checkout submodules # but don't bootstrap!
4343
uses: ./.github/actions/checkout-submodules
4444
with:
45-
platform: linux
45+
platform: linux
4646

4747
- name: Configure and build All Clusters App
4848
run: |
49-
CC=gcc CXX=g++ scripts/configure --project=examples/all-clusters-app/linux && ./ninja-build
49+
CC=gcc CXX=g++ scripts/configure --project=examples/all-clusters-app/linux --enable-recommended=no && ./ninja-build
5050
5151
minimal-network-manager:
5252
name: Linux / configure build of network-manager-app
@@ -64,8 +64,8 @@ jobs:
6464
- name: Checkout submodules # but don't bootstrap!
6565
uses: ./.github/actions/checkout-submodules
6666
with:
67-
platform: linux
67+
platform: linux
6868

6969
- name: Configure and build Network Manager App
7070
run: |
71-
CC=gcc CXX=g++ scripts/configure --project=examples/network-manager-app/linux && ./ninja-build
71+
CC=gcc CXX=g++ scripts/configure --project=examples/network-manager-app/linux --enable-recommended=no && ./ninja-build

config/recommended.gni

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
declare_args() {
16+
# Note for SDK developers: As additional features with their own settings
17+
# are added to the SDK, consider using the `matter_enable_recommended`
18+
# meta-setting instead of a default value of 'true', especially where a
19+
# different default is used based on platform (current_os): Often various
20+
# debugging features have previously been defaulted to on for Linux and/or
21+
# Mac but off for embedded platforms (on the assumption that Linux / Mac
22+
# don't have resource constraints?); build settings of that nature should
23+
# instead reference this meta-setting. E.g.
24+
# enable_flux_capacitor = matter_enable_recommended && current_os == "linux"
25+
26+
# Enable recommended settings by default. This is a meta-setting
27+
# that is enabled by default, and acts as a default for various
28+
# other settings. Setting it to false produces a more conservative /
29+
# minimal set of defaults.
30+
matter_enable_recommended = true
31+
}

examples/shell/shell_common/BUILD.gn

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
# limitations under the License.
1414

1515
import("//build_overrides/chip.gni")
16-
import("//build_overrides/openthread.gni")
17-
16+
import("${chip_root}/config/recommended.gni")
1817
import("${chip_root}/src/platform/device.gni")
1918

2019
declare_args() {
21-
# Enable server command only on linux for now.
22-
chip_shell_cmd_server = current_os == "linux" || current_os == "mac"
20+
chip_shell_cmd_server = matter_enable_recommended &&
21+
(current_os == "linux" || current_os == "mac")
2322
}
2423

2524
config("shell_common_config") {

src/app/common_flags.gni

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import("//build_overrides/chip.gni")
16+
import("${chip_root}/config/recommended.gni")
17+
1518
declare_args() {
1619
# Temporary flag for interaction model and echo protocols, set it to true to enable
1720
chip_app_use_echo = false
@@ -26,7 +29,7 @@ declare_args() {
2629
# - disabled: does not use data model interface at all
2730
# - check: runs BOTH datamodel and non-data-model (if possible) functionality and compares results
2831
# - enabled: runs only the data model interface (does not use the legacy code)
29-
if (current_os == "linux") {
32+
if (matter_enable_recommended && current_os == "linux") {
3033
chip_use_data_model_interface = "check"
3134
} else {
3235
chip_use_data_model_interface = "disabled"

src/lib/core/core.gni

+11-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import("//build_overrides/chip.gni")
16+
import("${chip_root}/config/recommended.gni")
17+
1518
declare_args() {
1619
# Enable logging. Shorthand for chip_error_logging, etc.
1720
chip_logging = true
@@ -28,13 +31,16 @@ declare_args() {
2831
chip_progress_logging = chip_logging
2932

3033
# Enable detail logging.
31-
chip_detail_logging = chip_logging
34+
chip_detail_logging = matter_enable_recommended && chip_logging
3235

3336
# Enable automation logging.
34-
chip_automation_logging = chip_logging
37+
chip_automation_logging = matter_enable_recommended && chip_logging
38+
}
3539

40+
declare_args() {
3641
# Configure the maximum size for logged messages
37-
if (current_os == "linux" || current_os == "mac" || current_os == "ios") {
42+
if ((matter_enable_recommended || chip_detail_logging) &&
43+
(current_os == "linux" || current_os == "mac" || current_os == "ios")) {
3844
# Allow base64 encoding of 1 MTU (4 * (1280 / 3) + padding
3945
chip_log_message_max_size = 1708
4046
} else {
@@ -88,7 +94,8 @@ declare_args() {
8894
chip_config_memory_debug_dmalloc = false
8995

9096
# When enabled trace messages using tansport trace hook.
91-
chip_enable_transport_trace = current_os == "linux" || current_os == "mac"
97+
chip_enable_transport_trace = matter_enable_recommended &&
98+
(current_os == "linux" || current_os == "mac")
9299

93100
# When this is enabled trace messages will be sent to pw_trace.
94101
chip_enable_transport_pw_trace = false

src/tracing/tracing_args.gni

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
import("//build_overrides/build.gni")
1514
import("//build_overrides/chip.gni")
16-
import("${build_root}/config/compiler/compiler.gni")
15+
import("${chip_root}/config/recommended.gni")
1716
import("${chip_root}/src/platform/device.gni")
1817

1918
declare_args() {
@@ -24,7 +23,8 @@ declare_args() {
2423
# Additionally, if tracing is enabled, the main() function has to add
2524
# backends explicitly
2625
matter_enable_tracing_support =
27-
current_os == "android" || chip_device_platform == "darwin"
26+
matter_enable_recommended &&
27+
(current_os == "android" || chip_device_platform == "darwin")
2828

2929
# Defines the trace backend. Current matter tracing splits the logic
3030
# into two parts:

0 commit comments

Comments
 (0)