|
17 | 17 | # 3.1. *_ifdef
|
18 | 18 | # 3.2. *_ifndef
|
19 | 19 | # 3.3. *_option compiler compatibility checks
|
| 20 | +# 3.3.1 Toolchain integration |
20 | 21 | # 3.4. Debugging CMake
|
21 | 22 | # 3.5. File system management
|
22 | 23 |
|
@@ -1244,7 +1245,7 @@ function(zephyr_compile_options_ifndef feature_toggle)
|
1244 | 1245 | endif()
|
1245 | 1246 | endfunction()
|
1246 | 1247 |
|
1247 |
| -# 3.2. *_option Compiler-compatibility checks |
| 1248 | +# 3.3. *_option Compiler-compatibility checks |
1248 | 1249 | #
|
1249 | 1250 | # Utility functions for silently omitting compiler flags when the
|
1250 | 1251 | # compiler lacks support. *_cc_option was ported from KBuild, see
|
@@ -1334,6 +1335,45 @@ function(target_ld_options target scope)
|
1334 | 1335 | endforeach()
|
1335 | 1336 | endfunction()
|
1336 | 1337 |
|
| 1338 | +# 3.3.1 Toolchain integration |
| 1339 | +# |
| 1340 | +# 'toolchain_parse_make_rule' is a function that parses the output of |
| 1341 | +# 'gcc -M'. |
| 1342 | +# |
| 1343 | +# The argument 'input_file' is in input parameter with the path to the |
| 1344 | +# file with the dependency information. |
| 1345 | +# |
| 1346 | +# The argument 'include_files' is an output parameter with the result |
| 1347 | +# of parsing the include files. |
| 1348 | +function(toolchain_parse_make_rule input_file include_files) |
| 1349 | + file(READ ${input_file} input) |
| 1350 | + |
| 1351 | + # The file is formatted like this: |
| 1352 | + # empty_file.o: misc/empty_file.c \ |
| 1353 | + # nrf52840_pca10056/nrf52840_pca10056.dts \ |
| 1354 | + # nrf52840_qiaa.dtsi |
| 1355 | + |
| 1356 | + # Get rid of the backslashes |
| 1357 | + string(REPLACE "\\" ";" input_as_list ${input}) |
| 1358 | + |
| 1359 | + # Pop the first line and treat it specially |
| 1360 | + list(GET input_as_list 0 first_input_line) |
| 1361 | + string(FIND ${first_input_line} ": " index) |
| 1362 | + math(EXPR j "${index} + 2") |
| 1363 | + string(SUBSTRING ${first_input_line} ${j} -1 first_include_file) |
| 1364 | + list(REMOVE_AT input_as_list 0) |
| 1365 | + |
| 1366 | + list(APPEND result ${first_include_file}) |
| 1367 | + |
| 1368 | + # Add the other lines |
| 1369 | + list(APPEND result ${input_as_list}) |
| 1370 | + |
| 1371 | + # Strip away the newlines and whitespaces |
| 1372 | + list(TRANSFORM result STRIP) |
| 1373 | + |
| 1374 | + set(${include_files} ${result} PARENT_SCOPE) |
| 1375 | +endfunction() |
| 1376 | + |
1337 | 1377 | # 3.4. Debugging CMake
|
1338 | 1378 |
|
1339 | 1379 | # Usage:
|
|
0 commit comments