|
| 1 | +# This file is part of the MicroPython project, http://micropython.org/ |
| 2 | +# |
| 3 | +# The MIT License (MIT) |
| 4 | +# |
| 5 | +# Copyright 2020 NXP |
| 6 | +# |
| 7 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | +# of this software and associated documentation files (the "Software"), to deal |
| 9 | +# in the Software without restriction, including without limitation the rights |
| 10 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | +# copies of the Software, and to permit persons to whom the Software is |
| 12 | +# furnished to do so, subject to the following conditions: |
| 13 | +# |
| 14 | +# The above copyright notice and this permission notice shall be included in |
| 15 | +# all copies or substantial portions of the Software. |
| 16 | +# |
| 17 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 23 | +# THE SOFTWARE. |
| 24 | + |
1 | 25 | cmake_minimum_required(VERSION 3.13.1)
|
2 | 26 |
|
3 | 27 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
4 |
| -project(NONE) |
5 |
| - |
6 |
| -target_sources(app PRIVATE src/zephyr_start.c src/zephyr_getchar.c) |
7 |
| - |
8 |
| -add_library(libmicropython STATIC IMPORTED) |
9 |
| -set_target_properties(libmicropython PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libmicropython.a) |
10 |
| -target_link_libraries(app PUBLIC libmicropython) |
11 |
| - |
12 |
| -zephyr_get_include_directories_for_lang_as_string(C includes) |
13 |
| -zephyr_get_system_include_directories_for_lang_as_string(C system_includes) |
14 |
| -zephyr_get_compile_definitions_for_lang_as_string(C definitions) |
15 |
| -zephyr_get_compile_options_for_lang_as_string(C options) |
16 |
| - |
17 |
| -add_custom_target( |
18 |
| - outputexports |
19 |
| - COMMAND echo CC="${CMAKE_C_COMPILER}" |
20 |
| - COMMAND echo AR="${CMAKE_AR}" |
21 |
| - COMMAND echo Z_CFLAGS=${system_includes} ${includes} ${definitions} ${options} |
22 |
| - VERBATIM |
23 |
| - USES_TERMINAL |
| 28 | +project(micropython) |
| 29 | + |
| 30 | +set(MICROPY_PORT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 31 | +set(MICROPY_DIR ${MICROPY_PORT_DIR}/../..) |
| 32 | +set(MICROPY_TARGET micropython) |
| 33 | + |
| 34 | +include(${MICROPY_DIR}/py/py.cmake) |
| 35 | +include(${MICROPY_DIR}/extmod/extmod.cmake) |
| 36 | + |
| 37 | +set(MICROPY_SOURCE_PORT |
| 38 | + main.c |
| 39 | + help.c |
| 40 | + machine_i2c.c |
| 41 | + machine_pin.c |
| 42 | + modmachine.c |
| 43 | + moduos.c |
| 44 | + modusocket.c |
| 45 | + modutime.c |
| 46 | + modzephyr.c |
| 47 | + modzsensor.c |
| 48 | + uart_core.c |
| 49 | + zephyr_storage.c |
| 50 | +) |
| 51 | +list(TRANSFORM MICROPY_SOURCE_PORT PREPEND ${MICROPY_PORT_DIR}/) |
| 52 | + |
| 53 | +set(MICROPY_SOURCE_LIB |
| 54 | + timeutils/timeutils.c |
| 55 | + utils/mpirq.c |
| 56 | + utils/stdout_helpers.c |
| 57 | + utils/printf.c |
| 58 | + utils/pyexec.c |
| 59 | + utils/interrupt_char.c |
| 60 | + mp-readline/readline.c |
| 61 | + oofatfs/ff.c |
| 62 | + oofatfs/ffunicode.c |
| 63 | + littlefs/lfs1.c |
| 64 | + littlefs/lfs1_util.c |
| 65 | + littlefs/lfs2.c |
| 66 | + littlefs/lfs2_util.c |
24 | 67 | )
|
| 68 | +list(TRANSFORM MICROPY_SOURCE_LIB PREPEND ${MICROPY_DIR}/lib/) |
| 69 | + |
| 70 | +set(MICROPY_SOURCE_QSTR |
| 71 | + ${MICROPY_SOURCE_PY} |
| 72 | + ${MICROPY_SOURCE_EXTMOD} |
| 73 | + ${MICROPY_SOURCE_LIB} |
| 74 | + ${MICROPY_SOURCE_PORT} |
| 75 | +) |
| 76 | + |
| 77 | +zephyr_get_include_directories_for_lang(C includes) |
| 78 | +zephyr_get_system_include_directories_for_lang(C system_includes) |
| 79 | +zephyr_get_compile_definitions_for_lang(C definitions) |
| 80 | +zephyr_get_compile_options_for_lang(C options) |
| 81 | + |
| 82 | +set(MICROPY_CPP_FLAGS_EXTRA ${includes} ${system_includes} ${definitions} ${options}) |
| 83 | + |
| 84 | +zephyr_library_named(${MICROPY_TARGET}) |
| 85 | + |
| 86 | +zephyr_library_include_directories( |
| 87 | + ${MICROPY_DIR} |
| 88 | + ${MICROPY_PORT_DIR} |
| 89 | + ${CMAKE_CURRENT_BINARY_DIR} |
| 90 | +) |
| 91 | + |
| 92 | +zephyr_library_compile_options( |
| 93 | + -std=gnu99 -fomit-frame-pointer |
| 94 | +) |
| 95 | + |
| 96 | +zephyr_library_compile_definitions( |
| 97 | + NDEBUG |
| 98 | + MP_CONFIGFILE=<${CONFIG_MICROPY_CONFIGFILE}> |
| 99 | + MICROPY_HEAP_SIZE=${CONFIG_MICROPY_HEAP_SIZE} |
| 100 | + FFCONF_H=\"${OOFATFS_DIR}/ffconf.h\" |
| 101 | + MICROPY_VFS_FAT=$<BOOL:${CONFIG_MICROPY_VFS_FAT}> |
| 102 | + MICROPY_VFS_LFS1=$<BOOL:${CONFIG_MICROPY_VFS_LFS1}> |
| 103 | + MICROPY_VFS_LFS2=$<BOOL:${CONFIG_MICROPY_VFS_LFS2}> |
| 104 | +) |
| 105 | + |
| 106 | +zephyr_library_sources(${MICROPY_SOURCE_QSTR}) |
| 107 | + |
| 108 | +add_dependencies(${MICROPY_TARGET} zephyr_generated_headers) |
| 109 | + |
| 110 | +include(${MICROPY_DIR}/py/mkrules.cmake) |
| 111 | + |
| 112 | +target_sources(app PRIVATE |
| 113 | + src/zephyr_start.c |
| 114 | + src/zephyr_getchar.c |
| 115 | +) |
| 116 | + |
| 117 | +target_link_libraries(app PRIVATE ${MICROPY_TARGET}) |
0 commit comments