|
3 | 3 |
|
4 | 4 | # This script generates a tarball containing all headers and flags necessary to |
5 | 5 | # build an llext extension. It does so by copying all headers accessible from |
6 | | -# INTERFACE_INCLUDE_DIRECTORIES and generating a Makefile.cflags file (and a |
| 6 | +# a C compiler command line and generating a Makefile.cflags file (and a |
7 | 7 | # cmake.cflags one) with all flags necessary to build the extension. |
8 | 8 | # |
9 | 9 | # The tarball can be extracted and used in the extension build system to include |
@@ -152,19 +152,34 @@ if (CONFIG_LLEXT_EXPORT_BUILTINS_BY_SLID) |
152 | 152 | "The LLEXT EDK is not compatible with CONFIG_LLEXT_EXPORT_BUILTINS_BY_SLID.") |
153 | 153 | endif() |
154 | 154 |
|
| 155 | +set(build_flags_dir ${PROJECT_BINARY_DIR}/misc/llext_edk) |
155 | 156 | set(build_info_file ${PROJECT_BINARY_DIR}/../build_info.yml) |
156 | 157 | yaml_load(FILE ${build_info_file} NAME build_info) |
157 | 158 |
|
158 | | -yaml_get(llext_edk_cflags NAME build_info KEY cmake llext-edk cflags) |
| 159 | +# process C flags |
| 160 | +file(READ ${build_flags_dir}/c_flags.txt llext_edk_c_flags_raw) |
| 161 | +string(STRIP ${llext_edk_c_flags_raw} llext_edk_c_flags) |
| 162 | +string(REPLACE " " ";" llext_edk_cflags "${llext_edk_c_flags}") |
159 | 163 | yaml_get(llext_remove_cflags NAME build_info KEY cmake llext-edk remove-cflags) |
160 | 164 | yaml_get(llext_append_cflags NAME build_info KEY cmake llext-edk append-cflags) |
161 | 165 | foreach(item IN_LIST ${llext_remove_cflags}) |
162 | 166 | list(FILTER llext_edk_cflags EXCLUDE REGEX "^${item}$") |
163 | 167 | endforeach() |
164 | 168 | list(APPEND llext_edk_cflags ${llext_append_cflags}) |
165 | 169 |
|
| 170 | +# process C definitions |
| 171 | +file(READ ${build_flags_dir}/c_defs.txt llext_edk_c_defs_raw) |
| 172 | +string(STRIP ${llext_edk_c_defs_raw} llext_edk_c_defs) |
| 173 | +string(REPLACE " " ";" llext_edk_c_defs "${llext_edk_c_defs}") |
| 174 | +list(PREPEND llext_edk_cflags ${llext_edk_c_defs}) |
| 175 | + |
| 176 | +# process C include directories |
| 177 | +file(READ ${build_flags_dir}/c_incs.txt llext_edk_c_incs_raw) |
| 178 | +string(STRIP ${llext_edk_c_incs_raw} llext_edk_c_incs) |
| 179 | +string(REPLACE " " ";" llext_edk_c_incs "${llext_edk_c_incs}") |
| 180 | +list(TRANSFORM llext_edk_c_incs REPLACE "^-I" "") |
| 181 | + |
166 | 182 | yaml_get(llext_edk_file NAME build_info KEY cmake llext-edk file) |
167 | | -yaml_get(INTERFACE_INCLUDE_DIRECTORIES NAME build_info KEY cmake llext-edk include-dirs) |
168 | 183 | yaml_get(APPLICATION_SOURCE_DIR NAME build_info KEY cmake application source-dir) |
169 | 184 | yaml_get(WEST_TOPDIR NAME build_info KEY west topdir) |
170 | 185 |
|
@@ -217,8 +232,8 @@ set(llext_edk_cflags ${new_cflags}) |
217 | 232 | list(APPEND base_flags ${llext_edk_cflags} ${imacros}) |
218 | 233 |
|
219 | 234 | file(MAKE_DIRECTORY ${llext_edk_inc}) |
220 | | -foreach(dir ${INTERFACE_INCLUDE_DIRECTORIES}) |
221 | | - if (NOT EXISTS ${dir}) |
| 235 | +foreach(dir ${llext_edk_c_incs}) |
| 236 | + if(NOT EXISTS ${dir}) |
222 | 237 | continue() |
223 | 238 | endif() |
224 | 239 |
|
|
0 commit comments