From c44647edb4eadcf10932b95a37bfa675d06acd7c Mon Sep 17 00:00:00 2001 From: Brad Barnett <127794626+bdbarnett@users.noreply.github.com> Date: Tue, 22 Sep 2026 20:07:23 -0500 Subject: [PATCH] CircuitPython: compile the build stamp there too #28 gave pygraphics __version__ and __revision__ by pointing the module table at objects defined in gfx_build.c, but only micropython.mk compiled that file, so CircuitPython's unix build failed at link with pygraphics_version_obj and pygraphics_revision_obj undefined. circuitpython.mk now compiles gfx_build.c and passes the same VERSION and git describe micropython.mk does. Proven: cmods' cp-unix build (10.3.0 coverage) links, and pygraphics reports 0.0.38 / v0.0.32-78-g2f944ea-dirty on it. --- circuitpython.mk | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/circuitpython.mk b/circuitpython.mk index 81fb147..fe70f39 100644 --- a/circuitpython.mk +++ b/circuitpython.mk @@ -22,7 +22,15 @@ endif CFLAGS += -I$(PYGRAPHICS_MOD_DIR)/src -DCIRCUITPY_PYGRAPHICS=1 QSTR_DEFS += $(PYGRAPHICS_MOD_DIR)/src/pygraphics_qstrdefs.h +# __version__ / __revision__, the same two strings micropython.mk passes; +# gfx_build.c defines the objects the module table points at, so a build +# that leaves it out fails at link, not at runtime. +PYGRAPHICS_VERSION := $(shell cat $(PYGRAPHICS_MOD_DIR)/VERSION 2>/dev/null || echo 0.0.0+unknown) +PYGRAPHICS_REVISION := $(shell git -C $(PYGRAPHICS_MOD_DIR) describe --always --dirty --abbrev=7 2>/dev/null || echo unknown) +CFLAGS += -DPYGRAPHICS_VERSION='"$(PYGRAPHICS_VERSION)"' -DPYGRAPHICS_REVISION='"$(PYGRAPHICS_REVISION)"' + GRAPHICS_SOURCES := \ + $(PYGRAPHICS_MOD_DIR)/src/gfx_build.c \ $(PYGRAPHICS_MOD_DIR)/src/gfx_module_mp.c \ $(PYGRAPHICS_MOD_DIR)/src/gfx_bindings_mp.c \ $(PYGRAPHICS_MOD_DIR)/src/gfx_canvas_mp.c \