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