zephyr: Implement smart way to access Zephyr config variables.

For this, we first build Z part with libmicropython.a not existing. This
produces autoconf.h with all setiings, but eventually fails on linking
stage due to missing libmicropython.a. We then build MicroPython, which
now can access values in autoconf.h. Then we execute Z build again, which
now succeeds.
hacking-on-plane
Paul Sokolovsky 2016-09-13 01:51:48 +03:00
parent e4d4c55621
commit 21bc7ccbaf
2 changed files with 21 additions and 2 deletions

View File

@ -11,14 +11,18 @@
ARCH ?= x86
BOARD = qemu_x86
# Zephyr 1.5.0
OUTDIR_PREFIX =
# Zephyr 1.6.0
#OUTDIR_PREFIX = $(BOARD)
# Zephyr toolchain config is 2-pass, so included twice
include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
CFLAGS_arm = -mthumb -mcpu=cortex-m3 -mabi=aapcs -DCONFIG_ARM=y -DCONFIG_ISA_THUMB2=y
CFLAGS_arm = -mthumb -mcpu=cortex-m3 -mabi=aapcs
CFLAGS_x86 = -fno-asynchronous-unwind-tables -ffreestanding -fno-stack-protector \
-fno-omit-frame-pointer -mpreferred-stack-boundary=2 -mno-sse -march=pentium -DCONFIG_X86=1
-fno-omit-frame-pointer -mpreferred-stack-boundary=2 -mno-sse -march=pentium
CFLAGS_TARGET = $(CFLAGS_$(ARCH))
include ../py/mkenv.mk
@ -27,6 +31,9 @@ include ../py/py.mk
INC += -I.
INC += -I..
INC += -I$(BUILD)
INC += -I$(ZEPHYR_BASE)/include -I$(ZEPHYR_BASE) \
-Ioutdir/$(OUTDIR_PREFIX)/misc/generated/sysgen \
-I$(dir $(Z_AUTOCONF_H))
SRC_C = main.c \
uart_core.c \
@ -49,5 +56,14 @@ all: $(LIBMICROPYTHON)
qemu: all
make -f Makefile.zephyr qemu BOARD=$(BOARD)
Z_AUTOCONF_H = outdir/$(OUTDIR_PREFIX)/include/generated/autoconf.h
$(LIBMICROPYTHON): $(Z_AUTOCONF_H)
build/genhdr/qstr.i.last: $(Z_AUTOCONF_H)
$(Z_AUTOCONF_H):
rm -f $(LIBMICROPYTHON)
-make -f Makefile.zephyr BOARD=$(BOARD)
# Clean Zephyr things too
CLEAN_EXTRA = outdir

View File

@ -46,3 +46,6 @@ typedef long mp_off_t;
#define MICROPY_PORT_ROOT_POINTERS \
const char *readline_hist[8];
// Include Zephyr's autoconf.h, which should be made first by Zephyr makefiles
#include "autoconf.h"