Skip to content

Commit a036554

Browse files
committed
zephyr/Makefile: Convert to new CMake-based Zephyr build system.
Zephyr 1.10 switches to CMake-based build system (already in master).
1 parent 25b7c7d commit a036554

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

ports/zephyr/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
2+
project(NONE)
3+
4+
target_sources(app PRIVATE src/zephyr_start.c src/zephyr_getchar.c)
5+
6+
add_library(libmicropython STATIC IMPORTED)
7+
set_target_properties(libmicropython PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libmicropython.a)
8+
target_link_libraries(app libmicropython)
9+
10+
zephyr_get_include_directories_as_string(includes)
11+
zephyr_get_system_include_directories_as_string(system_includes)
12+
zephyr_get_compile_definitions_as_string(definitions)
13+
zephyr_get_compile_options_as_string(options)
14+
15+
add_custom_target(
16+
outputexports
17+
COMMAND echo CC="${CMAKE_C_COMPILER}"
18+
COMMAND echo Z_CFLAGS=${system_includes}${includes}${definitions}${options}
19+
VERBATIM
20+
USES_TERMINAL
21+
)

ports/zephyr/Makefile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ FROZEN_DIR = scripts
2020
# Default target
2121
all:
2222

23+
include ../../py/mkenv.mk
24+
include $(TOP)/py/py.mk
25+
2326
# Zephyr (generated) config files - must be defined before include below
2427
Z_EXPORTS = outdir/$(OUTDIR_PREFIX)/Makefile.export
2528
ifneq ($(MAKECMDGOALS), clean)
2629
include $(Z_EXPORTS)
2730
endif
2831

29-
include ../../py/mkenv.mk
30-
include $(TOP)/py/py.mk
31-
3232
INC += -I.
3333
INC += -I$(TOP)
3434
INC += -I$(BUILD)
@@ -56,19 +56,11 @@ SRC_QSTR += $(SRC_C)
5656

5757
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
5858

59-
CFLAGS = $(KBUILD_CFLAGS) $(NOSTDINC_FLAGS) $(ZEPHYRINCLUDE) \
59+
CFLAGS = $(Z_CFLAGS) \
6060
-std=gnu99 -fomit-frame-pointer -DNDEBUG -DMICROPY_HEAP_SIZE=$(MICROPY_HEAP_SIZE) $(CFLAGS_EXTRA) $(INC)
6161

6262
include $(TOP)/py/mkrules.mk
6363

64-
# We use single target here ($(Z_EXPORTS)) for simplicity, but actually
65-
# number of things get generated here: 'initconfig' generates C header for
66-
# Kconfig configuration, 'outputexports' generates make environment with CC,
67-
# etc., and 'lib' generates other headers which may be included by zephyr.h,
68-
# e.g. DTS-related.
69-
$(Z_EXPORTS): $(CONF_FILE)
70-
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) CONF_FILE=$(CONF_FILE) initconfig outputexports lib
71-
7264
GENERIC_TARGETS = all zephyr run qemu qemugdb flash debug debugserver
7365
KCONFIG_TARGETS = \
7466
initconfig config nconfig menuconfig xconfig gconfig \
@@ -81,7 +73,7 @@ $(GENERIC_TARGETS): $(LIBMICROPYTHON)
8173
$(CLEAN_TARGETS): clean
8274

8375
$(GENERIC_TARGETS) $(KCONFIG_TARGETS) $(CLEAN_TARGETS):
84-
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) CONF_FILE=$(CONF_FILE) $@
76+
$(MAKE) -C outdir/$(BOARD) $@
8577

8678
$(LIBMICROPYTHON): | $(Z_EXPORTS)
8779
build/genhdr/qstr.i.last: | $(Z_EXPORTS)
@@ -103,3 +95,11 @@ prj_$(BOARD)_merged.conf: prj_base.conf prj_$(BOARD).conf
10395

10496
test:
10597
cd $(TOP)/tests && ./run-tests --target minimal --device "execpty:make -C ../ports/zephyr run BOARD=$(BOARD) QEMU_PTY=1"
98+
99+
cmake: outdir/$(BOARD)/Makefile
100+
101+
outdir/$(BOARD)/Makefile: $(CONF_FILE)
102+
mkdir -p outdir/$(BOARD) && cmake -DBOARD=$(BOARD) -DCONF_FILE=$(CONF_FILE) -Boutdir/$(BOARD) -H.
103+
104+
$(Z_EXPORTS): outdir/$(BOARD)/Makefile
105+
make --no-print-directory -C outdir/$(BOARD) outputexports CMAKE_COMMAND=: >$@

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy