8000 py/mkrules.cmake: Support passing CFLAGS_EXTRA in environment variable. · malcolm-sparkfun/micropython@516709b · GitHub
[go: up one dir, main page]

Skip to content

Commit 516709b

Browse files
committed
py/mkrules.cmake: Support passing CFLAGS_EXTRA in environment variable.
This works similarly to the existing support in "bare metal" make ports, with the caveat that CMake will only set this value on a clean build and will reuse the previous value otherwise. This is slightly different to the CMake built-in support for CFLAGS, as this variable is used when evaluating source files for qstr generation, etc. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent 71df9d0 commit 516709b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

py/mkrules.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ foreach(_arg ${MICROPY_CPP_DEF})
5353
endforeach()
5454
list(APPEND MICROPY_CPP_FLAGS ${MICROPY_CPP_FLAGS_EXTRA})
5555

56+
# Include anything passed in via CFLAGS_EXTRA
57+
# in both MICROPY_CPP_FLAGS and CMAKE_C_FLAGS
58+
if(DEFINED ENV{CFLAGS_EXTRA})
59+
set(CFLAGS_EXTRA $ENV{CFLAGS_EXTRA})
60+
string(APPEND CMAKE_C_FLAGS " ${CFLAGS_EXTRA}") # ... not a list
61+
separate_arguments(CFLAGS_EXTRA)
62+
list(APPEND MICROPY_CPP_FLAGS ${CFLAGS_EXTRA}) # ... a list
63+
endif()
64+
5665
find_package(Python3 REQUIRED COMPONENTS Interpreter)
5766

5867
target_sources(${MICROPY_TARGET} PRIVATE

0 commit comments

Comments
 (0)
0