Skip to content

Commit 1109048

Browse files
ATmobicapull[bot]
authored andcommitted
[cmake] Add project include dir option to common GN args (#27407)
Add option to pass extra include dirs for project configurations to GN build. It uses the chip_project_config_include_dirs argument. Add macro to set GN list argument. Signed-off-by: ATmobica <[email protected]>
1 parent c3d959d commit 1109048

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

config/common/cmake/chip_gn_args.cmake

+20-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,18 @@ macro(matter_add_gn_arg key value)
9191
string(APPEND MATTER_GN_ARGS "--arg\n${key}\n${value}\n")
9292
endmacro()
9393

94+
# Add list variable GN argument
95+
# [Args]:
96+
# key - variable name
97+
# value - list variable
98+
macro(matter_add_gn_arg_list key value)
99+
set(_value_list ${value} ${ARGN})
100+
if (_value_list)
101+
string(REPLACE ";" "," _list_str "${_value_list}")
102+
string(APPEND MATTER_GN_ARGS "--arg\n${key}\n[${_list_str}]\n")
103+
endif()
104+
endmacro()
105+
94106
# Add items to Matter common compiler flags
95107
# [Args]:
96108
# flags - flags to add
@@ -148,6 +160,7 @@ endmacro()
148160
# LIB_TESTS Add Matter unit tests library
149161
# DEVICE_INFO_EXAMPLE_PROVIDER Add example device info provider support
150162
# PROJECT_CONFIG Path to the project-specific configuration file
163+
# PROJECT_CONFIG_INC_DIR Extra include dirs for project configurations
151164
#
152165
macro(matter_common_gn_args)
153166
set(options)
@@ -158,8 +171,11 @@ macro(matter_common_gn_args)
158171
LIB_PW_RPC
159172
DEVICE_INFO_EXAMPLE_PROVIDER
160173
PROJECT_CONFIG
174+
175+
)
176+
set(multiValueArgs
177+
PROJECT_CONFIG_INC_DIR
161178
)
162-
set(multiValueArgs)
163179

164180
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
165181

@@ -196,6 +212,9 @@ macro(matter_common_gn_args)
196212
matter_add_gn_arg_string("chip_project_config_include" "<${PROJECT_CONFIG}>")
197213
matter_add_gn_arg_string("chip_system_project_config_include" "<${PROJECT_CONFIG}>")
198214
endif() # CHIP_PROJECT_CONFIG
215+
if (ARG_PROJECT_CONFIG_INC_DIR)
216+
matter_add_gn_arg_list("chip_project_config_include_dirs" ${ARG_PROJECT_CONFIG_INC_DIR})
217+
endif()
199218
endmacro()
200219

201220
# Generate the temporary GN arguments file from the settings

0 commit comments

Comments
 (0)