Repository navigation
Expand file tree
/
Copy pathmicropython.mk
More file actions
55 lines (50 loc) · 3.18 KB
/
Copy pathmicropython.mk
File metadata and controls
55 lines (50 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# MicroPython user C module glue for pygraphics.
#
# Discovered via USER_C_MODULES pointing at the workspace directory that
# contains this repo (its parent), e.g. `make USER_C_MODULES=../../..`.
PYGRAPHICS_MOD_DIR := $(USERMOD_DIR)
# PYGRAPHICS_USER_C_MODULE tells the C it was built through USER_C_MODULES
# (MicroPython's make ports, or CircuitPython): gfx_png.c allocates from the GC
# heap then, because some CircuitPython ports have no C heap.
CFLAGS_USERMOD += -DPYGRAPHICS_USER_C_MODULE=1 -I$(PYGRAPHICS_MOD_DIR)/src -Wno-unused-function -Wno-sign-compare -Wno-unused-const-variable
# Arc/polygon use Q15 LUT in gfx_trig.h — no libm required.
# --- which pygraphics this firmware was built from --------------------------
#
# pygraphics#25. `os.uname().version` answers for MicroPython and says nothing
# about the user C modules in the image, so a rendering that moves between two
# firmwares cannot be attributed. Computed HERE, from the directory the build
# is actually reading, because that is the only thing that knows which tree it
# compiled -- audiodsp lost a revision exactly this way, to a throwaway source
# tree during a pin move.
#
# `--always --dirty` so a tree with uncommitted changes says so: dirty is the
# normal state in this workspace and a bare hash would claim more than it knows.
# Both fall back to "unknown" rather than guessing -- see src/gfx_build.c.
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_USERMOD += -DPYGRAPHICS_VERSION='"$(PYGRAPHICS_VERSION)"'
CFLAGS_USERMOD += -DPYGRAPHICS_REVISION='"$(PYGRAPHICS_REVISION)"'
SRC_USERMOD_C += \
$(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 \
$(PYGRAPHICS_MOD_DIR)/src/gfx_framebuffer.c \
$(PYGRAPHICS_MOD_DIR)/src/gfx_shapes.c \
$(PYGRAPHICS_MOD_DIR)/src/gfx_draw.c \
$(PYGRAPHICS_MOD_DIR)/src/gfx_font.c \
$(PYGRAPHICS_MOD_DIR)/src/gfx_bmp565.c \
$(PYGRAPHICS_MOD_DIR)/src/gfx_files.c \
$(PYGRAPHICS_MOD_DIR)/src/gfx_png.c \
$(PYGRAPHICS_MOD_DIR)/src/gfx_capabilities.c \
$(PYGRAPHICS_MOD_DIR)/src/gfx_area_mp.c
# Warnings the drawing code trips on purpose: comparing an angle against an
# exact 0.0f to skip rotation, mixed-sign loop bounds, tables only some builds
# use. CFLAGS_USERMOD above carries them for MicroPython. They are given again
# per object because CircuitPython's MCU ports append -Wsign-compare and
# -Wfloat-equal (under -Werror) after the user module flags, and the later
# flag wins; a target-specific flag lands last. The object path is the one py/py.mk gives a user module's source since
# MicroPython 1.29: $(BUILD)/<module directory name>/<path inside it>.o.
PYGRAPHICS_OBJ_CFLAGS := -Wno-unused-function -Wno-sign-compare -Wno-unused-const-variable -Wno-float-equal
$(foreach _src,$(filter $(PYGRAPHICS_MOD_DIR)/%,$(SRC_USERMOD_C)),\
$(eval $(BUILD)/$(notdir $(PYGRAPHICS_MOD_DIR))/$(patsubst $(PYGRAPHICS_MOD_DIR)/%.c,%.o,$(_src)): CFLAGS += $(PYGRAPHICS_OBJ_CFLAGS)))