summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-11-17 20:23:45 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-11-28 16:37:51 +0200
commita036554a77c50fc4aabf056d93f7b3170ee4af21 (patch)
tree5295858120ff9dc1531a090f188a3c00198ea504
parent25b7c7d7c66e46a9a5729b149ac35ebf13343716 (diff)
zephyr/Makefile: Convert to new CMake-based Zephyr build system.
Zephyr 1.10 switches to CMake-based build system (already in master).
-rw-r--r--ports/zephyr/CMakeLists.txt21
-rw-r--r--ports/zephyr/Makefile26
2 files changed, 34 insertions, 13 deletions
diff --git a/ports/zephyr/CMakeLists.txt b/ports/zephyr/CMakeLists.txt
new file mode 100644
index 000000000..cd7eda227
--- /dev/null
+++ b/ports/zephyr/CMakeLists.txt
@@ -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
+)
diff --git a/ports/zephyr/Makefile b/ports/zephyr/Makefile
index 81aaaa6dc..ec2bbbcb6 100644
--- a/ports/zephyr/Makefile
+++ b/ports/zephyr/Makefile
@@ -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=: >$@