Skip to content

Commit 2f604f7

Browse files
committed
codal_port: Generate and use correct versions for uPy and micro:bit.
Signed-off-by: Damien George <[email protected]>
1 parent 532cf5a commit 2f604f7

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/codal_port/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ QSTR_DEFS = qstrdefsport.h
1414
# Include py core make definitions.
1515
include $(TOP)/py/py.mk
1616

17+
MP_VER_FILE = $(HEADER_BUILD)/mpversion.h
1718
MBIT_VER_FILE = $(HEADER_BUILD)/microbitversion.h
1819

1920
LOCAL_LIB_DIR = ../../lib
@@ -115,8 +116,11 @@ QSTR_GLOBAL_REQUIREMENTS += $(MBIT_VER_FILE)
115116
all: lib $(MBIT_VER_FILE)
116117

117118
# Rule to build header with micro:bit specific version information.
119+
# Also rebuild MicroPython version header in correct directory to pick up git hash.
118120
$(MBIT_VER_FILE): FORCE
119-
$(PYTHON) $(TOP)/py/makeversionhdr.py $(MBIT_VER_FILE)
121+
(cd $(TOP) && $(PYTHON) py/makeversionhdr.py $(abspath $(MP_VER_FILE)))
122+
$(PYTHON) $(TOP)/py/makeversionhdr.py $(MBIT_VER_FILE).pre
123+
$(CAT) $(MBIT_VER_FILE).pre | $(SED) s/MICROPY_/MICROBIT_/ > $(MBIT_VER_FILE)
120124

121125
include $(TOP)/py/mkrules.mk
122126

src/codal_port/modos.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,9 @@
2929
#include "py/objstr.h"
3030
#include "ports/nrf/modules/uos/microbitfs.h"
3131

32-
// The microbitversion.h file is generated with the same tool as mpversion.h and
33-
// defines MICROPY_xxx symbols, so rename them.
34-
#include "genhdr/microbitversion.h"
35-
#define MICROBIT_GIT_HASH MICROPY_GIT_HASH
36-
#define MICROBIT_BUILD_DATE MICROPY_BUILD_DATE
37-
#undef MICROPY_GIT_TAG
38-
#undef MICROPY_GIT_HASH
39-
#undef MICROPY_BUILD_DATE
40-
41-
// Include MicroPython version information.
32+
// Include MicroPython and micro:bit version information.
4233
#include "genhdr/mpversion.h"
34+
#include "genhdr/microbitversion.h"
4335

4436
#define MICROBIT_VERSION \
4537
"micro:bit v" MICROBIT_RELEASE "+" MICROBIT_GIT_HASH " on " MICROBIT_BUILD_DATE \

0 commit comments

Comments
 (0)