summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-04-08 23:42:22 +1000
committerDamien George <damien@micropython.org>2021-04-09 13:08:35 +1000
commit0fabda31de33b38c6858925d9195731deba6f54a (patch)
treed3edf90690bc923bcdee413c19c2e1b2227ccfac
parent7b41d7f187d0bbfdda66db06b523c8829f198998 (diff)
py/py.cmake: Move qstr helper code to micropy_gather_target_properties.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--ports/esp32/main/CMakeLists.txt17
-rw-r--r--ports/rp2/CMakeLists.txt24
-rw-r--r--py/py.cmake22
3 files changed, 25 insertions, 38 deletions
diff --git a/ports/esp32/main/CMakeLists.txt b/ports/esp32/main/CMakeLists.txt
index d7d08ea66..1f4bb3175 100644
--- a/ports/esp32/main/CMakeLists.txt
+++ b/ports/esp32/main/CMakeLists.txt
@@ -170,22 +170,7 @@ target_link_libraries(${MICROPY_TARGET} usermod)
# Collect all of the include directories and compile definitions for the IDF components.
foreach(comp ${IDF_COMPONENTS})
- get_target_property(type __idf_${comp} TYPE)
- set(_inc OFF)
- set(_def OFF)
- if(${type} STREQUAL STATIC_LIBRARY)
- get_target_property(_inc __idf_${comp} INCLUDE_DIRECTORIES)
- get_target_property(_def __idf_${comp} COMPILE_DEFINITIONS)
- elseif(${type} STREQUAL INTERFACE_LIBRARY)
- get_target_property(_inc __idf_${comp} INTERFACE_INCLUDE_DIRECTORIES)
- get_target_property(_def __idf_${comp} INTERFACE_COMPILE_DEFINITIONS)
- endif()
- if(_inc)
- list(APPEND MICROPY_CPP_INC_EXTRA ${_inc})
- endif()
- if(_def)
- list(APPEND MICROPY_CPP_DEF_EXTRA ${_def})
- endif()
+ micropy_gather_target_properties(__idf_${comp})
endforeach()
if(IDF_VERSION_MINOR GREATER_EQUAL 2)
diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt
index 37b041279..5f3cdebd8 100644
--- a/ports/rp2/CMakeLists.txt
+++ b/ports/rp2/CMakeLists.txt
@@ -193,29 +193,9 @@ add_custom_command(TARGET ${MICROPY_TARGET}
)
# Collect all the include directories and compile definitions for the pico-sdk components.
-macro(_process_target targ)
- if(TARGET ${targ})
- get_target_property(type ${targ} TYPE)
- set(_inc OFF)
- set(_def OFF)
- if(${type} STREQUAL STATIC_LIBRARY)
- get_target_property(_inc ${targ} INCLUDE_DIRECTORIES)
- get_target_property(_def ${targ} COMPILE_DEFINITIONS)
- elseif(${type} STREQUAL INTERFACE_LIBRARY)
- get_target_property(_inc ${targ} INTERFACE_INCLUDE_DIRECTORIES)
- get_target_property(_def ${targ} INTERFACE_COMPILE_DEFINITIONS)
- endif()
- if(_inc)
- list(APPEND MICROPY_CPP_INC_EXTRA ${_inc})
- endif()
- if(_def)
- list(APPEND MICROPY_CPP_DEF_EXTRA ${_def})
- endif()
- endif()
-endmacro()
foreach(comp ${PICO_SDK_COMPONENTS})
- _process_target(${comp})
- _process_target(${comp}_headers)
+ micropy_gather_target_properties(${comp})
+ micropy_gather_target_properties(${comp}_headers)
endforeach()
# Include the main MicroPython cmake rules.
diff --git a/py/py.cmake b/py/py.cmake
index 52baaa8ef..be5deca25 100644
--- a/py/py.cmake
+++ b/py/py.cmake
@@ -122,3 +122,25 @@ set(MICROPY_SOURCE_PY
${MICROPY_PY_DIR}/vstr.c
${MICROPY_PY_DIR}/warning.c
)
+
+# Helper macro to collect include directories and compile definitions for qstr processing.
+macro(micropy_gather_target_properties targ)
+ if(TARGET ${targ})
+ get_target_property(type ${targ} TYPE)
+ set(_inc OFF)
+ set(_def OFF)
+ if(${type} STREQUAL STATIC_LIBRARY)
+ get_target_property(_inc ${targ} INCLUDE_DIRECTORIES)
+ get_target_property(_def ${targ} COMPILE_DEFINITIONS)
+ elseif(${type} STREQUAL INTERFACE_LIBRARY)
+ get_target_property(_inc ${targ} INTERFACE_INCLUDE_DIRECTORIES)
+ get_target_property(_def ${targ} INTERFACE_COMPILE_DEFINITIONS)
+ endif()
+ if(_inc)
+ list(APPEND MICROPY_CPP_INC_EXTRA ${_inc})
+ endif()
+ if(_def)
+ list(APPEND MICROPY_CPP_DEF_EXTRA ${_def})
+ endif()
+ endif()
+endmacro()