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:
parent
25b7c7d7c6
commit
a036554a77
|
@ -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
|
||||
)
|
|
@ -20,15 +20,15 @@ FROZEN_DIR = scripts
|
|||
# Default target
|
||||
all:
|
||||
|
||||
include ../../py/mkenv.mk
|
||||
include $(TOP)/py/py.mk
|
||||
|
||||
# Zephyr (generated) config files - must be defined before include below
|
||||
Z_EXPORTS = outdir/$(OUTDIR_PREFIX)/Makefile.export
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
include $(Z_EXPORTS)
|
||||
endif
|
||||
|
||||
include ../../py/mkenv.mk
|
||||
include $(TOP)/py/py.mk
|
||||
|
||||
INC += -I.
|
||||
INC += -I$(TOP)
|
||||
INC += -I$(BUILD)
|
||||
|
@ -56,19 +56,11 @@ SRC_QSTR += $(SRC_C)
|
|||
|
||||
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)
|
||||
|
||||
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
|
||||
KCONFIG_TARGETS = \
|
||||
initconfig config nconfig menuconfig xconfig gconfig \
|
||||
|
@ -81,7 +73,7 @@ $(GENERIC_TARGETS): $(LIBMICROPYTHON)
|
|||
$(CLEAN_TARGETS): clean
|
||||
|
||||
$(GENERIC_TARGETS) $(KCONFIG_TARGETS) $(CLEAN_TARGETS):
|
||||
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) CONF_FILE=$(CONF_FILE) $@
|
||||
$(MAKE) -C outdir/$(BOARD) $@
|
||||
|
||||
$(LIBMICROPYTHON): | $(Z_EXPORTS)
|
||||
build/genhdr/qstr.i.last: | $(Z_EXPORTS)
|
||||
|
@ -103,3 +95,11 @@ prj_$(BOARD)_merged.conf: prj_base.conf prj_$(BOARD).conf
|
|||
|
||||
test:
|
||||
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=: >$@
|
||||
|
|
Loading…
Reference in New Issue