Skip to content

Commit 29dd92c

Browse files
committed
zephyr/Makefile: Rework to use modern, official build integration.
Build happens in 3 stages: 1. Zephyr config header and make vars are generated from prj.conf. 2. libmicropython is built using them. 3. Zephyr is built and final link happens.
1 parent e9d7c3e commit 29dd92c

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

py/mkrules.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,15 @@ clean-prog:
142142
endif
143143

144144
LIBMICROPYTHON = libmicropython.a
145+
146+
# We can execute extra commands after library creation using
147+
# LIBMICROPYTHON_EXTRA_CMD. This may be needed e.g. to integrate
148+
# with 3rd-party projects which don't have proper dependency
149+
# tracking. Then LIBMICROPYTHON_EXTRA_CMD can e.g. touch some
150+
# other file to cause needed effect, e.g. relinking with new lib.
145151
lib $(LIBMICROPYTHON): $(OBJ)
146152
$(AR) rcs $(LIBMICROPYTHON) $^
153+
$(LIBMICROPYTHON_EXTRA_CMD)
147154

148155
clean:
149156
$(RM) -rf $(BUILD) $(CLEAN_EXTRA)

zephyr/Makefile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ MICROPY_HEAP_SIZE = 16384
1818
FROZEN_DIR = scripts
1919

2020
# Zephyr (generated) config files - must be defined before include below
21-
Z_SYSGEN_H = outdir/$(OUTDIR_PREFIX)/misc/generated/sysgen/sysgen.h
2221
Z_EXPORTS = outdir/$(OUTDIR_PREFIX)/Makefile.export
2322
include $(Z_EXPORTS)
2423

@@ -71,15 +70,13 @@ $(GENERIC_TARGETS): $(LIBMICROPYTHON)
7170
$(CLEAN_TARGETS): clean
7271

7372
$(GENERIC_TARGETS) $(KCONFIG_TARGETS) $(CLEAN_TARGETS):
74-
$(RM) -f outdir/$(OUTDIR_PREFIX)/zephyr.lnk
7573
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) CONF_FILE=$(CONF_FILE) $@
7674

77-
$(LIBMICROPYTHON): $(Z_SYSGEN_H)
78-
build/genhdr/qstr.i.last: $(Z_SYSGEN_H)
75+
$(LIBMICROPYTHON): | $(Z_EXPORTS)
76+
build/genhdr/qstr.i.last: | $(Z_EXPORTS)
7977

80-
$(Z_SYSGEN_H):
81-
rm -f $(LIBMICROPYTHON)
82-
-$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) CONF_FILE=$(CONF_FILE)
78+
# If we recreate libmicropython, also cause zephyr.bin relink
79+
LIBMICROPYTHON_EXTRA_CMD = -$(RM) -f outdir/$(OUTDIR_PREFIX)/zephyr.lnk
8380

8481
# Clean Zephyr things too
8582
clean: z_clean

0 commit comments

Comments
 (0)