zephyr/Makefile: Convert to new CMake-based Zephyr build system.

Zephyr 1.10 switches to CMake-based build system (already in master).
This commit is contained in:
Paul Sokolovsky 2017-11-17 20:23:45 +02:00
parent 25b7c7d7c6
commit a036554a77
2 changed files with 34 additions and 13 deletions

View File

@ -0,0 +1,21 @@
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(NONE)
target_sources(app PRIVATE src/zephyr_start.c src/zephyr_getchar.c)
add_library(libmicropython STATIC IMPORTED)
set_target_properties(libmicropython PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libmicropython.a)
target_link_libraries(app libmicropython)
zephyr_get_include_directories_as_string(includes)
zephyr_get_system_include_directories_as_string(system_includes)
zephyr_get_compile_definitions_as_string(definitions)
zephyr_get_compile_options_as_string(options)
add_custom_target(
outputexports
COMMAND echo CC="${CMAKE_C_COMPILER}"
COMMAND echo Z_CFLAGS=${system_includes}${includes}${definitions}${options}
VERBATIM
USES_TERMINAL
)

View File

@ -20,15 +20,15 @@ FROZEN_DIR = scripts
# Default target # Default target
all: all:
include ../../py/mkenv.mk
include $(TOP)/py/py.mk
# Zephyr (generated) config files - must be defined before include below # Zephyr (generated) config files - must be defined before include below
Z_EXPORTS = outdir/$(OUTDIR_PREFIX)/Makefile.export Z_EXPORTS = outdir/$(OUTDIR_PREFIX)/Makefile.export
ifneq ($(MAKECMDGOALS), clean) ifneq ($(MAKECMDGOALS), clean)
include $(Z_EXPORTS) include $(Z_EXPORTS)
endif endif
include ../../py/mkenv.mk
include $(TOP)/py/py.mk
INC += -I. INC += -I.
INC += -I$(TOP) INC += -I$(TOP)
INC += -I$(BUILD) INC += -I$(BUILD)
@ -56,19 +56,11 @@ SRC_QSTR += $(SRC_C)
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
CFLAGS = $(KBUILD_CFLAGS) $(NOSTDINC_FLAGS) $(ZEPHYRINCLUDE) \ CFLAGS = $(Z_CFLAGS) \
-std=gnu99 -fomit-frame-pointer -DNDEBUG -DMICROPY_HEAP_SIZE=$(MICROPY_HEAP_SIZE) $(CFLAGS_EXTRA) $(INC) -std=gnu99 -fomit-frame-pointer -DNDEBUG -DMICROPY_HEAP_SIZE=$(MICROPY_HEAP_SIZE) $(CFLAGS_EXTRA) $(INC)
include $(TOP)/py/mkrules.mk include $(TOP)/py/mkrules.mk
# We use single target here ($(Z_EXPORTS)) for simplicity, but actually
# number of things get generated here: 'initconfig' generates C header for
# Kconfig configuration, 'outputexports' generates make environment with CC,
# etc., and 'lib' generates other headers which may be included by zephyr.h,
# e.g. DTS-related.
$(Z_EXPORTS): $(CONF_FILE)
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) CONF_FILE=$(CONF_FILE) initconfig outputexports lib
GENERIC_TARGETS = all zephyr run qemu qemugdb flash debug debugserver GENERIC_TARGETS = all zephyr run qemu qemugdb flash debug debugserver
KCONFIG_TARGETS = \ KCONFIG_TARGETS = \
initconfig config nconfig menuconfig xconfig gconfig \ initconfig config nconfig menuconfig xconfig gconfig \
@ -81,7 +73,7 @@ $(GENERIC_TARGETS): $(LIBMICROPYTHON)
$(CLEAN_TARGETS): clean $(CLEAN_TARGETS): clean
$(GENERIC_TARGETS) $(KCONFIG_TARGETS) $(CLEAN_TARGETS): $(GENERIC_TARGETS) $(KCONFIG_TARGETS) $(CLEAN_TARGETS):
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) CONF_FILE=$(CONF_FILE) $@ $(MAKE) -C outdir/$(BOARD) $@
$(LIBMICROPYTHON): | $(Z_EXPORTS) $(LIBMICROPYTHON): | $(Z_EXPORTS)
build/genhdr/qstr.i.last: | $(Z_EXPORTS) build/genhdr/qstr.i.last: | $(Z_EXPORTS)
@ -103,3 +95,11 @@ prj_$(BOARD)_merged.conf: prj_base.conf prj_$(BOARD).conf
test: test:
cd $(TOP)/tests && ./run-tests --target minimal --device "execpty:make -C ../ports/zephyr run BOARD=$(BOARD) QEMU_PTY=1" cd $(TOP)/tests && ./run-tests --target minimal --device "execpty:make -C ../ports/zephyr run BOARD=$(BOARD) QEMU_PTY=1"
cmake: outdir/$(BOARD)/Makefile
outdir/$(BOARD)/Makefile: $(CONF_FILE)
mkdir -p outdir/$(BOARD) && cmake -DBOARD=$(BOARD) -DCONF_FILE=$(CONF_FILE) -Boutdir/$(BOARD) -H.
$(Z_EXPORTS): outdir/$(BOARD)/Makefile
make --no-print-directory -C outdir/$(BOARD) outputexports CMAKE_COMMAND=: >$@