py,extmod: Add core cmake rule files.
These allow a port to use cmake natively instead of make. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
bffb71f523
commit
66098c0985
|
@ -0,0 +1,44 @@
|
|||
# CMake fragment for MicroPython extmod component
|
||||
|
||||
set(MICROPY_EXTMOD_DIR "${MICROPY_DIR}/extmod")
|
||||
set(MICROPY_OOFATFS_DIR "${MICROPY_DIR}/lib/oofatfs")
|
||||
|
||||
set(MICROPY_SOURCE_EXTMOD
|
||||
${MICROPY_EXTMOD_DIR}/machine_i2c.c
|
||||
${MICROPY_EXTMOD_DIR}/machine_mem.c
|
||||
${MICROPY_EXTMOD_DIR}/machine_pulse.c
|
||||
${MICROPY_EXTMOD_DIR}/machine_signal.c
|
||||
${MICROPY_EXTMOD_DIR}/machine_spi.c
|
||||
${MICROPY_EXTMOD_DIR}/modbluetooth.c
|
||||
${MICROPY_EXTMOD_DIR}/modbtree.c
|
||||
${MICROPY_EXTMOD_DIR}/modframebuf.c
|
||||
${MICROPY_EXTMOD_DIR}/moduasyncio.c
|
||||
${MICROPY_EXTMOD_DIR}/modubinascii.c
|
||||
${MICROPY_EXTMOD_DIR}/moducryptolib.c
|
||||
${MICROPY_EXTMOD_DIR}/moductypes.c
|
||||
${MICROPY_EXTMOD_DIR}/moduhashlib.c
|
||||
${MICROPY_EXTMOD_DIR}/moduheapq.c
|
||||
${MICROPY_EXTMOD_DIR}/modujson.c
|
||||
${MICROPY_EXTMOD_DIR}/modurandom.c
|
||||
${MICROPY_EXTMOD_DIR}/modure.c
|
||||
${MICROPY_EXTMOD_DIR}/moduselect.c
|
||||
${MICROPY_EXTMOD_DIR}/modussl_axtls.c
|
||||
${MICROPY_EXTMOD_DIR}/modussl_mbedtls.c
|
||||
${MICROPY_EXTMOD_DIR}/modutimeq.c
|
||||
${MICROPY_EXTMOD_DIR}/moduwebsocket.c
|
||||
${MICROPY_EXTMOD_DIR}/moduzlib.c
|
||||
${MICROPY_EXTMOD_DIR}/modwebrepl.c
|
||||
${MICROPY_EXTMOD_DIR}/uos_dupterm.c
|
||||
${MICROPY_EXTMOD_DIR}/utime_mphal.c
|
||||
${MICROPY_EXTMOD_DIR}/vfs.c
|
||||
${MICROPY_EXTMOD_DIR}/vfs_blockdev.c
|
||||
${MICROPY_EXTMOD_DIR}/vfs_fat.c
|
||||
${MICROPY_EXTMOD_DIR}/vfs_fat_diskio.c
|
||||
${MICROPY_EXTMOD_DIR}/vfs_fat_file.c
|
||||
${MICROPY_EXTMOD_DIR}/vfs_lfs.c
|
||||
${MICROPY_EXTMOD_DIR}/vfs_posix.c
|
||||
${MICROPY_EXTMOD_DIR}/vfs_posix_file.c
|
||||
${MICROPY_EXTMOD_DIR}/vfs_reader.c
|
||||
${MICROPY_EXTMOD_DIR}/virtpin.c
|
||||
${MICROPY_EXTMOD_DIR}/nimble/modbluetooth_nimble.c
|
||||
)
|
|
@ -0,0 +1,128 @@
|
|||
# CMake fragment for MicroPython rules
|
||||
|
||||
set(MICROPY_PY_QSTRDEFS "${MICROPY_PY_DIR}/qstrdefs.h")
|
||||
set(MICROPY_GENHDR_DIR "${CMAKE_BINARY_DIR}/genhdr")
|
||||
set(MICROPY_MPVERSION "${MICROPY_GENHDR_DIR}/mpversion.h")
|
||||
set(MICROPY_MODULEDEFS "${MICROPY_GENHDR_DIR}/moduledefs.h")
|
||||
set(MICROPY_QSTR_DEFS_LAST "${MICROPY_GENHDR_DIR}/qstr.i.last")
|
||||
set(MICROPY_QSTR_DEFS_SPLIT "${MICROPY_GENHDR_DIR}/qstr.split")
|
||||
set(MICROPY_QSTR_DEFS_COLLECTED "${MICROPY_GENHDR_DIR}/qstrdefs.collected.h")
|
||||
set(MICROPY_QSTR_DEFS_PREPROCESSED "${MICROPY_GENHDR_DIR}/qstrdefs.preprocessed.h")
|
||||
set(MICROPY_QSTR_DEFS_GENERATED "${MICROPY_GENHDR_DIR}/qstrdefs.generated.h")
|
||||
|
||||
# Provide defaults for preprocessor flags if not already defined
|
||||
if(NOT MICROPY_CPP_FLAGS)
|
||||
get_target_property(MICROPY_CPP_INC ${MICROPY_TARGET} INCLUDE_DIRECTORIES)
|
||||
get_target_property(MICROPY_CPP_DEF ${MICROPY_TARGET} COMPILE_DEFINITIONS)
|
||||
endif()
|
||||
|
||||
# Compute MICROPY_CPP_FLAGS for preprocessor
|
||||
list(APPEND MICROPY_CPP_INC ${MICROPY_CPP_INC_EXTRA})
|
||||
list(APPEND MICROPY_CPP_DEF ${MICROPY_CPP_DEF_EXTRA})
|
||||
set(_prefix "-I")
|
||||
foreach(_arg ${MICROPY_CPP_INC})
|
||||
list(APPEND MICROPY_CPP_FLAGS ${_prefix}${_arg})
|
||||
endforeach()
|
||||
set(_prefix "-D")
|
||||
foreach(_arg ${MICROPY_CPP_DEF})
|
||||
list(APPEND MICROPY_CPP_FLAGS ${_prefix}${_arg})
|
||||
endforeach()
|
||||
list(APPEND MICROPY_CPP_FLAGS ${MICROPY_CPP_FLAGS_EXTRA})
|
||||
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||
|
||||
target_sources(${MICROPY_TARGET} PRIVATE
|
||||
${MICROPY_MPVERSION}
|
||||
${MICROPY_QSTR_DEFS_GENERATED}
|
||||
)
|
||||
|
||||
# Command to force the build of another command
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT MICROPY_FORCE_BUILD
|
||||
COMMENT ""
|
||||
COMMAND echo -n
|
||||
)
|
||||
|
||||
# Generate mpversion.h
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MICROPY_MPVERSION}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${MICROPY_GENHDR_DIR}
|
||||
COMMAND ${Python3_EXECUTABLE} ${MICROPY_DIR}/py/makeversionhdr.py ${MICROPY_MPVERSION}
|
||||
DEPENDS MICROPY_FORCE_BUILD
|
||||
)
|
||||
|
||||
# Generate moduledefs.h
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MICROPY_MODULEDEFS}
|
||||
COMMAND ${Python3_EXECUTABLE} ${MICROPY_PY_DIR}/makemoduledefs.py --vpath="/" ${MICROPY_SOURCE_QSTR} > ${MICROPY_MODULEDEFS}
|
||||
DEPENDS ${MICROPY_MPVERSION}
|
||||
${MICROPY_SOURCE_QSTR}
|
||||
)
|
||||
|
||||
# Generate qstrs
|
||||
|
||||
# If any of the dependencies in this rule change then the C-preprocessor step must be run.
|
||||
# It only needs to be passed the list of MICROPY_SOURCE_QSTR files that have changed since
|
||||
# it was last run, but it looks like it's not possible to specify that with cmake.
|
||||
add_custom_command(
|
||||
OUTPUT ${MICROPY_QSTR_DEFS_LAST}
|
||||
COMMAND ${Python3_EXECUTABLE} ${MICROPY_PY_DIR}/makeqstrdefs.py pp ${CMAKE_C_COMPILER} -E output ${MICROPY_GENHDR_DIR}/qstr.i.last cflags ${MICROPY_CPP_FLAGS} -DNO_QSTR sources ${MICROPY_SOURCE_QSTR}
|
||||
DEPENDS ${MICROPY_MODULEDEFS}
|
||||
${MICROPY_SOURCE_QSTR}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MICROPY_QSTR_DEFS_SPLIT}
|
||||
COMMAND ${Python3_EXECUTABLE} ${MICROPY_PY_DIR}/makeqstrdefs.py split qstr ${MICROPY_GENHDR_DIR}/qstr.i.last ${MICROPY_GENHDR_DIR}/qstr _
|
||||
COMMAND touch ${MICROPY_QSTR_DEFS_SPLIT}
|
||||
DEPENDS ${MICROPY_QSTR_DEFS_LAST}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MICROPY_QSTR_DEFS_COLLECTED}
|
||||
COMMAND ${Python3_EXECUTABLE} ${MICROPY_PY_DIR}/makeqstrdefs.py cat qstr _ ${MICROPY_GENHDR_DIR}/qstr ${MICROPY_QSTR_DEFS_COLLECTED}
|
||||
DEPENDS ${MICROPY_QSTR_DEFS_SPLIT}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MICROPY_QSTR_DEFS_PREPROCESSED}
|
||||
COMMAND cat ${MICROPY_PY_QSTRDEFS} ${MICROPY_QSTR_DEFS_COLLECTED} | sed "s/^Q(.*)/\"&\"/" | ${CMAKE_C_COMPILER} -E ${MICROPY_CPP_FLAGS} - | sed "s/^\\\"\\(Q(.*)\\)\\\"/\\1/" > ${MICROPY_QSTR_DEFS_PREPROCESSED}
|
||||
DEPENDS ${MICROPY_QSTR_DEFS_COLLECTED}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MICROPY_QSTR_DEFS_GENERATED}
|
||||
COMMAND ${Python3_EXECUTABLE} ${MICROPY_PY_DIR}/makeqstrdata.py ${MICROPY_QSTR_DEFS_PREPROCESSED} > ${MICROPY_QSTR_DEFS_GENERATED}
|
||||
DEPENDS ${MICROPY_QSTR_DEFS_PREPROCESSED}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# Build frozen code if enabled
|
||||
|
||||
if(MICROPY_FROZEN_MANIFEST)
|
||||
set(MICROPY_FROZEN_CONTENT "${CMAKE_BINARY_DIR}/frozen_content.c")
|
||||
|
||||
target_sources(${MICROPY_TARGET} PRIVATE
|
||||
${MICROPY_FROZEN_CONTENT}
|
||||
)
|
||||
|
||||
target_compile_definitions(${MICROPY_TARGET} PUBLIC
|
||||
MICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
|
||||
MICROPY_MODULE_FROZEN_MPY=\(1\)
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MICROPY_FROZEN_CONTENT}
|
||||
COMMAND ${Python3_EXECUTABLE} ${MICROPY_DIR}/tools/makemanifest.py -o ${MICROPY_FROZEN_CONTENT} -v "MPY_DIR=${MICROPY_DIR}" -v "PORT_DIR=${MICROPY_PORT_DIR}" -b "${CMAKE_BINARY_DIR}" -f${MICROPY_CROSS_FLAGS} ${MICROPY_FROZEN_MANIFEST}
|
||||
DEPENDS MICROPY_FORCE_BUILD
|
||||
${MICROPY_QSTR_DEFS_GENERATED}
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
|
@ -0,0 +1,124 @@
|
|||
# CMake fragment for MicroPython core py component
|
||||
|
||||
set(MICROPY_PY_DIR "${MICROPY_DIR}/py")
|
||||
|
||||
# All py/ source files
|
||||
set(MICROPY_SOURCE_PY
|
||||
${MICROPY_PY_DIR}/argcheck.c
|
||||
${MICROPY_PY_DIR}/asmarm.c
|
||||
${MICROPY_PY_DIR}/asmbase.c
|
||||
${MICROPY_PY_DIR}/asmthumb.c
|
||||
${MICROPY_PY_DIR}/asmx64.c
|
||||
${MICROPY_PY_DIR}/asmx86.c
|
||||
${MICROPY_PY_DIR}/asmxtensa.c
|
||||
${MICROPY_PY_DIR}/bc.c
|
||||
${MICROPY_PY_DIR}/binary.c
|
||||
${MICROPY_PY_DIR}/builtinevex.c
|
||||
${MICROPY_PY_DIR}/builtinhelp.c
|
||||
${MICROPY_PY_DIR}/builtinimport.c
|
||||
${MICROPY_PY_DIR}/compile.c
|
||||
${MICROPY_PY_DIR}/emitbc.c
|
||||
${MICROPY_PY_DIR}/emitcommon.c
|
||||
${MICROPY_PY_DIR}/emitglue.c
|
||||
${MICROPY_PY_DIR}/emitinlinethumb.c
|
||||
${MICROPY_PY_DIR}/emitinlinextensa.c
|
||||
${MICROPY_PY_DIR}/emitnarm.c
|
||||
${MICROPY_PY_DIR}/emitnthumb.c
|
||||
${MICROPY_PY_DIR}/emitnx64.c
|
||||
${MICROPY_PY_DIR}/emitnx86.c
|
||||
${MICROPY_PY_DIR}/emitnxtensa.c
|
||||
${MICROPY_PY_DIR}/emitnxtensawin.c
|
||||
${MICROPY_PY_DIR}/formatfloat.c
|
||||
${MICROPY_PY_DIR}/frozenmod.c
|
||||
${MICROPY_PY_DIR}/gc.c
|
||||
${MICROPY_PY_DIR}/lexer.c
|
||||
${MICROPY_PY_DIR}/malloc.c
|
||||
${MICROPY_PY_DIR}/map.c
|
||||
${MICROPY_PY_DIR}/modarray.c
|
||||
${MICROPY_PY_DIR}/modbuiltins.c
|
||||
${MICROPY_PY_DIR}/modcmath.c
|
||||
${MICROPY_PY_DIR}/modcollections.c
|
||||
${MICROPY_PY_DIR}/modgc.c
|
||||
${MICROPY_PY_DIR}/modio.c
|
||||
${MICROPY_PY_DIR}/modmath.c
|
||||
${MICROPY_PY_DIR}/modmicropython.c
|
||||
${MICROPY_PY_DIR}/modstruct.c
|
||||
${MICROPY_PY_DIR}/modsys.c
|
||||
${MICROPY_PY_DIR}/modthread.c
|
||||
${MICROPY_PY_DIR}/moduerrno.c
|
||||
${MICROPY_PY_DIR}/mpprint.c
|
||||
${MICROPY_PY_DIR}/mpstate.c
|
||||
${MICROPY_PY_DIR}/mpz.c
|
||||
${MICROPY_PY_DIR}/nativeglue.c
|
||||
${MICROPY_PY_DIR}/nlr.c
|
||||
${MICROPY_PY_DIR}/nlrpowerpc.c
|
||||
${MICROPY_PY_DIR}/nlrsetjmp.c
|
||||
${MICROPY_PY_DIR}/nlrthumb.c
|
||||
${MICROPY_PY_DIR}/nlrx64.c
|
||||
${MICROPY_PY_DIR}/nlrx86.c
|
||||
${MICROPY_PY_DIR}/nlrxtensa.c
|
||||
${MICROPY_PY_DIR}/obj.c
|
||||
${MICROPY_PY_DIR}/objarray.c
|
||||
${MICROPY_PY_DIR}/objattrtuple.c
|
||||
${MICROPY_PY_DIR}/objbool.c
|
||||
${MICROPY_PY_DIR}/objboundmeth.c
|
||||
${MICROPY_PY_DIR}/objcell.c
|
||||
${MICROPY_PY_DIR}/objclosure.c
|
||||
${MICROPY_PY_DIR}/objcomplex.c
|
||||
${MICROPY_PY_DIR}/objdeque.c
|
||||
${MICROPY_PY_DIR}/objdict.c
|
||||
${MICROPY_PY_DIR}/objenumerate.c
|
||||
${MICROPY_PY_DIR}/objexcept.c
|
||||
${MICROPY_PY_DIR}/objfilter.c
|
||||
${MICROPY_PY_DIR}/objfloat.c
|
||||
${MICROPY_PY_DIR}/objfun.c
|
||||
${MICROPY_PY_DIR}/objgenerator.c
|
||||
${MICROPY_PY_DIR}/objgetitemiter.c
|
||||
${MICROPY_PY_DIR}/objint.c
|
||||
${MICROPY_PY_DIR}/objint_longlong.c
|
||||
${MICROPY_PY_DIR}/objint_mpz.c
|
||||
${MICROPY_PY_DIR}/objlist.c
|
||||
${MICROPY_PY_DIR}/objmap.c
|
||||
${MICROPY_PY_DIR}/objmodule.c
|
||||
${MICROPY_PY_DIR}/objnamedtuple.c
|
||||
${MICROPY_PY_DIR}/objnone.c
|
||||
${MICROPY_PY_DIR}/objobject.c
|
||||
${MICROPY_PY_DIR}/objpolyiter.c
|
||||
${MICROPY_PY_DIR}/objproperty.c
|
||||
${MICROPY_PY_DIR}/objrange.c
|
||||
${MICROPY_PY_DIR}/objreversed.c
|
||||
${MICROPY_PY_DIR}/objset.c
|
||||
${MICROPY_PY_DIR}/objsingleton.c
|
||||
${MICROPY_PY_DIR}/objslice.c
|
||||
${MICROPY_PY_DIR}/objstr.c
|
||||
${MICROPY_PY_DIR}/objstringio.c
|
||||
${MICROPY_PY_DIR}/objstrunicode.c
|
||||
${MICROPY_PY_DIR}/objtuple.c
|
||||
${MICROPY_PY_DIR}/objtype.c
|
||||
${MICROPY_PY_DIR}/objzip.c
|
||||
${MICROPY_PY_DIR}/opmethods.c
|
||||
${MICROPY_PY_DIR}/pairheap.c
|
||||
${MICROPY_PY_DIR}/parse.c
|
||||
${MICROPY_PY_DIR}/parsenum.c
|
||||
${MICROPY_PY_DIR}/parsenumbase.c
|
||||
${MICROPY_PY_DIR}/persistentcode.c
|
||||
${MICROPY_PY_DIR}/profile.c
|
||||
${MICROPY_PY_DIR}/pystack.c
|
||||
${MICROPY_PY_DIR}/qstr.c
|
||||
${MICROPY_PY_DIR}/reader.c
|
||||
${MICROPY_PY_DIR}/repl.c
|
||||
${MICROPY_PY_DIR}/ringbuf.c
|
||||
${MICROPY_PY_DIR}/runtime.c
|
||||
${MICROPY_PY_DIR}/runtime_utils.c
|
||||
${MICROPY_PY_DIR}/scheduler.c
|
||||
${MICROPY_PY_DIR}/scope.c
|
||||
${MICROPY_PY_DIR}/sequence.c
|
||||
${MICROPY_PY_DIR}/showbc.c
|
||||
${MICROPY_PY_DIR}/smallint.c
|
||||
${MICROPY_PY_DIR}/stackctrl.c
|
||||
${MICROPY_PY_DIR}/stream.c
|
||||
${MICROPY_PY_DIR}/unicode.c
|
||||
${MICROPY_PY_DIR}/vm.c
|
||||
${MICROPY_PY_DIR}/vstr.c
|
||||
${MICROPY_PY_DIR}/warning.c
|
||||
)
|
Loading…
Reference in New Issue