1
1
#
2
- # Copyright (c) 2022-2023 Project CHIP Authors
2
+ # Copyright (c) 2022-2023 Project CHIP Authors
3
3
#
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
7
#
8
- # http://www.apache.org/licenses/LICENSE-2.0
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
9
#
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
15
#
16
16
17
17
#
18
- # @file
19
- # CMake sub-project defining 'chip' target which represents CHIP library
20
- # Since CHIP doesn't provide native CMake support, ExternalProject
21
- # module is used to build the required artifacts with GN meta-build
22
- # system. It is assumed that find_package(Zephyr) has been called before
23
- # including this file.
18
+ # @file
19
+ # CMake sub-project defining 'chip' target which represents CHIP library
20
+ # Since CHIP doesn't provide native CMake support, ExternalProject
21
+ # module is used to build the required artifacts with GN meta-build
22
+ # system. It is assumed that find_package(Zephyr) has been called before
23
+ # including this file.
24
24
#
25
25
26
- if (CONFIG_CHIP )
27
-
28
- include (ExternalProject )
29
- include (../zephyr-util.cmake )
30
-
31
- #
32
- # ==============================================================================
33
- # Prepare CHIP configuration based on the project Kconfig configuration
34
- # ==============================================================================
35
- # Set paths
36
- if (NOT CHIP_ROOT )
37
- get_filename_component (CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR} /../../.. REALPATH )
38
- endif ()
39
- get_filename_component (GN_ROOT_TARGET ${CHIP_ROOT} /config/zephyr/chip-gn REALPATH )
40
- get_filename_component (COMMON_CMAKE_SOURCE_DIR ${CHIP_ROOT} /config/common/cmake REALPATH )
41
-
42
-
43
- # Get common Cmake sources
44
- include (${COMMON_CMAKE_SOURCE_DIR} /chip_gn_args.cmake )
45
- include (${COMMON_CMAKE_SOURCE_DIR} /chip_gn.cmake )
46
-
47
- if (CONFIG_POSIX_API )
48
- matter_add_flags (-D_DEFAULT_SOURCE )
49
- matter_add_flags (-isystem${ZEPHYR_BASE}/include/zephyr/posix )
50
- endif ()
51
-
52
- if (CONFIG_MBEDTLS )
53
- zephyr_include_directories ($< TARGET_PROPERTY:mbedTLS,INTERFACE_INCLUDE_DIRECTORIES> )
54
- zephyr_compile_definitions ($< TARGET_PROPERTY:mbedTLS,INTERFACE_COMPILE_DEFINITIONS> )
55
- endif ()
56
-
57
- zephyr_get_compile_flags (ZEPHYR_CFLAGS_C C )
58
- matter_add_cflags ("${ZEPHYR_CFLAGS_C} " )
59
- zephyr_get_compile_flags (ZEPHYR_CFLAGS_CC CXX )
60
- matter_add_cxxflags ("${ZEPHYR_CFLAGS_CC} " )
61
- zephyr_get_gnu_cpp_standard (ZEPHYR_GNU_CPP_STD )
62
- matter_add_cxxflags ("${ZEPHYR_GNU_CPP_STD} " )
63
-
64
- # Set up custom OpenThread configuration
65
-
66
- if (CONFIG_CHIP_OPENTHREAD_CONFIG )
67
- get_filename_component (CHIP_OPENTHREAD_CONFIG
68
- ${CONFIG_CHIP_OPENTHREAD_CONFIG}
69
- REALPATH
70
- BASE_DIR ${CMAKE_SOURCE_DIR}
26
+ if (CONFIG_CHIP )
27
+ include (ExternalProject )
28
+ include (../zephyr-util.cmake )
29
+
30
+ #
31
+ # ==============================================================================
32
+ # Prepare CHIP configuration based on the project Kconfig configuration
33
+ # ==============================================================================
34
+ # Set paths
35
+ if (NOT CHIP_ROOT )
36
+ get_filename_component (CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR} /../../.. REALPATH )
37
+ endif ()
38
+
39
+ get_filename_component (GN_ROOT_TARGET ${CHIP_ROOT} /config/zephyr/chip-gn REALPATH )
40
+ get_filename_component (COMMON_CMAKE_SOURCE_DIR ${CHIP_ROOT} /config/common/cmake REALPATH )
41
+
42
+ # Get common Cmake sources
43
+ include (${COMMON_CMAKE_SOURCE_DIR} /chip_gn_args.cmake )
44
+ include (${COMMON_CMAKE_SOURCE_DIR} /chip_gn.cmake )
45
+
46
+ if (CONFIG_POSIX_API )
47
+ matter_add_flags (-D_DEFAULT_SOURCE )
48
+ matter_add_flags (-isystem${ZEPHYR_BASE}/include/zephyr/posix )
49
+ endif ()
50
+
51
+ if (CONFIG_MBEDTLS )
52
+ zephyr_include_directories ($< TARGET_PROPERTY:mbedTLS,INTERFACE_INCLUDE_DIRECTORIES> )
53
+ zephyr_compile_definitions ($< TARGET_PROPERTY:mbedTLS,INTERFACE_COMPILE_DEFINITIONS> )
54
+ endif ()
55
+
56
+ zephyr_get_compile_flags (ZEPHYR_CFLAGS_C C )
57
+ matter_add_cflags ("${ZEPHYR_CFLAGS_C} " )
58
+ zephyr_get_compile_flags (ZEPHYR_CFLAGS_CC CXX )
59
+ matter_add_cxxflags ("${ZEPHYR_CFLAGS_CC} " )
60
+ zephyr_get_gnu_cpp_standard (ZEPHYR_GNU_CPP_STD )
61
+ matter_add_cxxflags ("${ZEPHYR_GNU_CPP_STD} " )
62
+
63
+ # Set up custom OpenThread configuration
64
+ if (CONFIG_CHIP_OPENTHREAD_CONFIG )
65
+ get_filename_component (CHIP_OPENTHREAD_CONFIG
66
+ ${CONFIG_CHIP_OPENTHREAD_CONFIG}
67
+ REALPATH
68
+ BASE_DIR ${CMAKE_SOURCE_DIR}
69
+ )
70
+ zephyr_set_openthread_config (${CHIP_OPENTHREAD_CONFIG} )
71
+ endif ()
72
+
73
+ # ==============================================================================
74
+ # Generate configuration for CHIP GN build system
75
+ # ==============================================================================
76
+ matter_common_gn_args (
77
+ DEBUG CONFIG_DEBUG
78
+ LIB_SHELL CONFIG_CHIP_LIB_SHELL
79
+ LIB_TESTS CONFIG_CHIP_BUILD_TESTS
80
+ PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG}
71
81
)
72
- zephyr_set_openthread_config (${CHIP_OPENTHREAD_CONFIG} )
73
- endif ()
74
-
75
- # ==============================================================================
76
- # Generate configuration for CHIP GN build system
77
- # ==============================================================================
78
- matter_common_gn_args (
79
- DEBUG CONFIG_DEBUG
80
- LIB_SHELL CONFIG_CHIP_LIB_SHELL
81
- LIB_TESTS CONFIG_CHIP_BUILD_TESTS
82
- PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG}
83
- )
84
-
85
- matter_add_gn_arg_string ("zephyr_ar" ${CMAKE_AR} )
86
- matter_add_gn_arg_string ("zephyr_cc" ${CMAKE_C_COMPILER} )
87
- matter_add_gn_arg_string ("zephyr_cxx" ${CMAKE_CXX_COMPILER} )
88
- matter_add_gn_arg_bool ("chip_logging" CONFIG_LOG )
89
- matter_add_gn_arg_bool ("chip_error_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 1 )
90
- matter_add_gn_arg_bool ("chip_progress_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 3 )
91
- matter_add_gn_arg_bool ("chip_detail_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 4 )
92
- matter_add_gn_arg_bool ("chip_automation_logging" FALSE )
93
- matter_add_gn_arg_bool ("chip_enable_openthread" CONFIG_NET_L2_OPENTHREAD )
94
- matter_add_gn_arg_bool ("chip_openthread_ftd" CONFIG_OPENTHREAD_FTD )
95
- matter_add_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_CHIP_IPV4 )
96
- matter_add_gn_arg_bool ("chip_enable_wifi" CONFIG_WIFI )
97
- matter_add_gn_arg_bool ("chip_config_network_layer_ble" CONFIG_BT )
98
- matter_add_gn_arg_bool ("chip_mdns_minimal" CONFIG_WIFI )
99
- matter_add_gn_arg_bool ("chip_mdns_minimal" CONFIG_NET_L2_ETHERNET )
100
- matter_add_gn_arg_bool ("chip_mdns_platform" CONFIG_NET_L2_OPENTHREAD )
101
- matter_add_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS )
102
- matter_add_gn_arg_bool ("chip_inet_config_enable_udp_endpoint" CONFIG_NET_UDP )
103
- matter_add_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_NET_TCP )
104
- matter_add_gn_arg_bool ("chip_malloc_sys_heap" CONFIG_CHIP_MALLOC_SYS_HEAP )
105
-
106
-
107
- if (CONFIG_CHIP_ENABLE_DNSSD_SRP )
108
- matter_add_gn_arg_string ("chip_mdns" "platform" )
109
- endif ()
110
-
111
- if (CONFIG_WIFI )
112
- matter_add_gn_arg_string ("chip_mdns" "minimal" )
113
- elseif (CONFIG_NET_L2_ETHERNET )
114
- matter_add_gn_arg_string ("chip_mdns" "minimal" )
115
- elseif (CONFIG_NET_L2_OPENTHREAD )
116
- matter_add_gn_arg_string ("chip_mdns" "platform" )
117
- else ()
118
- matter_add_gn_arg_string ("chip_mdns" "none" )
119
- endif ()
120
-
121
- if (CONFIG_CHIP_PW_RPC )
122
- set (PIGWEED_DIR "//third_party/pigweed/repo" )
123
- matter_add_gn_arg_string ("pw_assert_BACKEND" ${PIGWEED_DIR} /pw_assert_log:check_backend )
124
- matter_add_gn_arg_string ("pw_log_BACKEND" ${PIGWEED_DIR} /pw_log_basic )
125
- matter_add_gn_arg ("pw_build_LINK_DEPS" [\" ${PIGWEED_DIR} /pw_assert:impl\" ,\ \" ${PIGWEED_DIR} /pw_log:impl\" ] )
126
- endif ()
127
-
128
- matter_generate_args_tmp_file ()
129
-
130
- # ==============================================================================
131
- # Build chip library
132
- # ==============================================================================
133
- matter_build (chip
134
- LIB_SHELL ${CONFIG_CHIP_LIB_SHELL}
135
- LIB_TESTS ${CONFIG_CHIP_BUILD_TESTS}
136
- GN_DEPENDENCIES kernel
137
- )
138
- set_property (GLOBAL APPEND PROPERTY ZEPHYR_INTERFACE_LIBS chip )
139
82
83
+ matter_add_gn_arg_string ("zephyr_ar" ${CMAKE_AR} )
84
+ matter_add_gn_arg_string ("zephyr_cc" ${CMAKE_C_COMPILER} )
85
+ matter_add_gn_arg_string ("zephyr_cxx" ${CMAKE_CXX_COMPILER} )
86
+ matter_add_gn_arg_bool ("chip_logging" CONFIG_LOG )
87
+ matter_add_gn_arg_bool ("chip_error_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 1 )
88
+ matter_add_gn_arg_bool ("chip_progress_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 3 )
89
+ matter_add_gn_arg_bool ("chip_detail_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 4 )
90
+ matter_add_gn_arg_bool ("chip_automation_logging" FALSE )
91
+ matter_add_gn_arg_bool ("chip_enable_openthread" CONFIG_NET_L2_OPENTHREAD )
92
+ matter_add_gn_arg_bool ("chip_openthread_ftd" CONFIG_OPENTHREAD_FTD )
93
+ matter_add_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_CHIP_IPV4 )
94
+ matter_add_gn_arg_bool ("chip_enable_wifi" CONFIG_WIFI )
95
+ matter_add_gn_arg_bool ("chip_config_network_layer_ble" CONFIG_BT )
96
+ matter_add_gn_arg_bool ("chip_mdns_minimal" CONFIG_WIFI )
97
+ matter_add_gn_arg_bool ("chip_mdns_minimal" CONFIG_NET_L2_ETHERNET )
98
+ matter_add_gn_arg_bool ("chip_mdns_platform" CONFIG_NET_L2_OPENTHREAD )
99
+ matter_add_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS )
100
+ matter_add_gn_arg_bool ("chip_malloc_sys_heap" CONFIG_CHIP_MALLOC_SYS_HEAP )
101
+ matter_add_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" FALSE )
102
+ matter_add_gn_arg_bool ("chip_enable_read_client" CONFIG_CHIP_ENABLE_READ_CLIENT )
103
+
104
+ if (BOARD STREQUAL "native_posix" )
105
+ matter_add_gn_arg_string ("target_cpu" "x86" )
106
+ elseif (BOARD STREQUAL "native_posix_64" )
107
+ matter_add_gn_arg_string ("target_cpu" "x64" )
108
+ endif ()
109
+
110
+ if (CONFIG_CHIP_ENABLE_DNSSD_SRP )
111
+ matter_add_gn_arg_string ("chip_mdns" "platform" )
112
+ endif ()
113
+
114
+ if (CONFIG_WIFI )
115
+ matter_add_gn_arg_string ("chip_mdns" "minimal" )
116
+ elseif (CONFIG_NET_L2_ETHERNET )
117
+ matter_add_gn_arg_string ("chip_mdns" "minimal" )
118
+ elseif (CONFIG_NET_L2_OPENTHREAD )
119
+ matter_add_gn_arg_string ("chip_mdns" "platform" )
120
+ else ()
121
+ matter_add_gn_arg_string ("chip_mdns" "none" )
122
+ endif ()
123
+
124
+ if (CONFIG_CHIP_PW_RPC )
125
+ set (PIGWEED_DIR "//third_party/pigweed/repo" )
126
+ matter_add_gn_arg_string ("pw_assert_BACKEND" ${PIGWEED_DIR} /pw_assert_log:check_backend )
127
+ matter_add_gn_arg_string ("pw_log_BACKEND" ${PIGWEED_DIR} /pw_log_basic )
128
+ matter_add_gn_arg ("pw_build_LINK_DEPS" [\" ${PIGWEED_DIR} /pw_assert:impl\" ,\ \" ${PIGWEED_DIR} /pw_log:impl\" ] )
129
+ endif ()
130
+
131
+ matter_generate_args_tmp_file ()
132
+
133
+ # ==============================================================================
134
+ # Build chip library
135
+ # ==============================================================================
136
+ matter_build (chip
137
+ LIB_SHELL ${CONFIG_CHIP_LIB_SHELL}
138
+ LIB_TESTS ${CONFIG_CHIP_BUILD_TESTS}
139
+ GN_DEPENDENCIES kernel
140
+ )
141
+ set_property (GLOBAL APPEND PROPERTY ZEPHYR_INTERFACE_LIBS chip )
140
142
endif () # CONFIG_CHIP
0 commit comments