mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 13:01:10 +02:00
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
This mirrors how it works when using a Makefile. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
67 lines
2.6 KiB
CMake
67 lines
2.6 KiB
CMake
# Create a target for all user modules to link against.
|
|
add_library(usermod INTERFACE)
|
|
|
|
function(usermod_gather_sources SOURCES_VARNAME INCLUDE_DIRECTORIES_VARNAME INCLUDED_VARNAME LIB)
|
|
if (NOT ${LIB} IN_LIST ${INCLUDED_VARNAME})
|
|
list(APPEND ${INCLUDED_VARNAME} ${LIB})
|
|
|
|
if (NOT TARGET ${LIB})
|
|
return()
|
|
endif()
|
|
|
|
# Gather library sources
|
|
get_target_property(lib_sources ${LIB} INTERFACE_SOURCES)
|
|
if (lib_sources)
|
|
list(APPEND ${SOURCES_VARNAME} ${lib_sources})
|
|
endif()
|
|
|
|
# Gather library includes
|
|
get_target_property(lib_include_directories ${LIB} INTERFACE_INCLUDE_DIRECTORIES)
|
|
if (lib_include_directories)
|
|
list(APPEND ${INCLUDE_DIRECTORIES_VARNAME} ${lib_include_directories})
|
|
endif()
|
|
|
|
# Recurse linked libraries
|
|
get_target_property(trans_depend ${LIB} INTERFACE_LINK_LIBRARIES)
|
|
if (trans_depend)
|
|
foreach(SUB_LIB ${trans_depend})
|
|
usermod_gather_sources(
|
|
${SOURCES_VARNAME}
|
|
${INCLUDE_DIRECTORIES_VARNAME}
|
|
${INCLUDED_VARNAME}
|
|
${SUB_LIB})
|
|
endforeach()
|
|
endif()
|
|
|
|
set(${SOURCES_VARNAME} ${${SOURCES_VARNAME}} PARENT_SCOPE)
|
|
set(${INCLUDE_DIRECTORIES_VARNAME} ${${INCLUDE_DIRECTORIES_VARNAME}} PARENT_SCOPE)
|
|
set(${INCLUDED_VARNAME} ${${INCLUDED_VARNAME}} PARENT_SCOPE)
|
|
endif()
|
|
endfunction()
|
|
|
|
# Include CMake files for user modules.
|
|
if (USER_C_MODULES)
|
|
foreach(USER_C_MODULE_PATH ${USER_C_MODULES})
|
|
# If a directory is given, append the micropython.cmake to it.
|
|
if (IS_DIRECTORY ${USER_C_MODULE_PATH})
|
|
set(USER_C_MODULE_PATH "${USER_C_MODULE_PATH}/micropython.cmake")
|
|
endif()
|
|
# Confirm the provided path exists, show abspath if not to make it clearer to fix.
|
|
if (NOT EXISTS ${USER_C_MODULE_PATH})
|
|
get_filename_component(USER_C_MODULES_ABS "${USER_C_MODULE_PATH}" ABSOLUTE)
|
|
message(FATAL_ERROR "USER_C_MODULES doesn't exist: ${USER_C_MODULES_ABS}")
|
|
endif()
|
|
|
|
message("Including User C Module(s) from ${USER_C_MODULE_PATH}")
|
|
include(${USER_C_MODULE_PATH})
|
|
endforeach()
|
|
endif()
|
|
|
|
# Recursively gather sources for QSTR scanning - doesn't support generator expressions.
|
|
usermod_gather_sources(MICROPY_SOURCE_USERMOD MICROPY_INC_USERMOD found_modules usermod)
|
|
|
|
# Report found modules.
|
|
list(REMOVE_ITEM found_modules "usermod")
|
|
list(JOIN found_modules ", " found_modules)
|
|
message("Found User C Module(s): ${found_modules}")
|