At least: font code generator, exchange code support for color 128x128
This commit is contained in:
54
Makefile
54
Makefile
@@ -40,16 +40,24 @@ DEVICE_TYPE ?= stm32l031k6
|
||||
DEVICE_FAMILY = stm32l031xx
|
||||
DEVICE_LINE = stm32l0xx
|
||||
|
||||
STACK_SIZE ?= 512
|
||||
HEAP_SIZE ?= 0
|
||||
|
||||
#
|
||||
# Filenames and paths
|
||||
#
|
||||
|
||||
# Ignores dotfiles and other garbage some tools leave behind
|
||||
define find_important
|
||||
$(shell find $(1) -type f -and -name $(2) -and -not -iname "*~" -and -not -iname "*#*" -and -not \( -path "*.cquery_cached_index*" \) )
|
||||
$(shell find $(1) -type f -and -name $(2) -and -not -iname "*~" -and -not -iname "*#*" -and -not \( -path "*.cquery_cached_index*" \) -and -not \( -path "*build*" \) )
|
||||
endef
|
||||
|
||||
C_SOURCES := $(call find_important, $(SOURCEDIR), '*.c')
|
||||
FONTS := small large_digits
|
||||
FONT_GEN_DIR := build/gen/fonts
|
||||
FONT_C_FILES := $(patsubst %,$(FONT_GEN_DIR)/%.c,$(FONTS))
|
||||
FONT_H_FILES := $(patsubst %,$(FONT_GEN_DIR)/%.h,$(FONTS))
|
||||
|
||||
C_SOURCES := $(call find_important, $(SOURCEDIR), '*.c') $(FONT_C_FILES)
|
||||
CXX_SOURCES := $(call find_important, $(SOURCEDIR), '*.cpp')
|
||||
S_SOURCES := $(call find_important, $(SOURCEDIR), '*.s')
|
||||
SPP_SOURCES := $(DEVICE_TYPE).S
|
||||
@@ -66,6 +74,7 @@ LINKER_SCRIPT ?= $(DEVICE_TYPE).ld
|
||||
OUTPUT_NAME ?= watch
|
||||
OUTPUT_BIN ?= $(OUTPUT_NAME).bin
|
||||
OUTPUT_ELF ?= $(OUTPUT_NAME).elf
|
||||
OUTPUT_MAP ?= $(OUTPUT_NAME).map
|
||||
|
||||
#
|
||||
# Flags
|
||||
@@ -76,32 +85,36 @@ DEVICE_DEFINE = $(subst XX,xx,$(shell echo $(DEVICE_FAMILY) | tr '[:lower:]' '[:
|
||||
CPU_FLAGS = -mthumb -mcpu=cortex-m0plus -mfloat-abi=soft
|
||||
|
||||
# C pedantism
|
||||
CFLAGS = -Wall -Wextra -Wpedantic -Werror
|
||||
CFLAGS = -Wall -Wextra -pedantic -Werror -Wcast-align
|
||||
CXX_FLAGS = -Wsuggest-override -Wsuggest-final-methods -Wsuggest-final-types
|
||||
# Debug/optimization
|
||||
CFLAGS += -Os -ggdb -g3
|
||||
CFLAGS += -Os -ggdb
|
||||
CFLAGS += -fdata-sections -ffunction-sections
|
||||
# Architecture
|
||||
CFLAGS += $(CPU_FLAGS)
|
||||
CFLAGS += -ffreestanding
|
||||
CFLAGS += -fstack-usage -Wstack-usage=128
|
||||
# Defines
|
||||
CFLAGS += -D$(DEVICE_DEFINE)
|
||||
# Includes
|
||||
CFLAGS += -I./lib/stm32/$(DEVICE_LINE)/Include
|
||||
CFLAGS += -I./lib/CMSIS/Core/Include
|
||||
CFLAGS += -I./lib/fonts/
|
||||
CFLAGS += -I./build/gen/
|
||||
CFLAGS += -I.
|
||||
|
||||
CXX_FLAGS += -std=c++14 -fno-exceptions -fno-rtti
|
||||
CXX_FLAGS += -std=c++14 -fno-exceptions -fno-rtti -fno-use-cxa-atexit
|
||||
|
||||
# Startup Definitions
|
||||
ASFLAGS += $(CPU_FLAGS)
|
||||
ASFLAGS += -D__STARTUP_CLEAR_BSS
|
||||
ASFLAGS += -D__HEAP_SIZE=0 # No heap- let the linker decide it all
|
||||
ASFLAGS += -D__HEAP_SIZE=$(HEAP_SIZE)
|
||||
ASFLAGS += -D__STACK_SIZE=$(STACK_SIZE)
|
||||
|
||||
LDFLAGS += $(CPU_FLAGS)
|
||||
LDFLAGS += -Wl,--gc-sections -Wl,--build-id=none -static
|
||||
LDFLAGS += -Wl,--wrap=malloc -Wl,--wrap=free # Fail to link if dynamic allocation is sneaking through
|
||||
LDFLAGS += -Wl,-print-memory-usage
|
||||
LDFLAGS += -nostartfiles
|
||||
|
||||
#
|
||||
# Default Target
|
||||
@@ -113,25 +126,40 @@ build: $(OUTPUT_BIN)
|
||||
# Build Logic
|
||||
#
|
||||
|
||||
%.o: %.c
|
||||
|
||||
%.o: %.c $(FONT_H_FILES)
|
||||
@echo "CC $@"
|
||||
@$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.S
|
||||
%.o: %.S $(FONT_H_FILES)
|
||||
@echo "AS $@"
|
||||
@$(CC) $(ASFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.cpp
|
||||
%.o: %.cpp $(FONT_H_FILES)
|
||||
@echo "CXX $@"
|
||||
@$(CXX) $(CXX_FLAGS) $(CFLAGS) -c $< -o $@
|
||||
|
||||
SMALL_FONT=lib/fonts/roboto_mono/RobotoMono-Medium.ttf
|
||||
$(FONT_GEN_DIR)/small.h $(FONT_GEN_DIR)/small.c: gen/fixedfont-to-c.py gen/font.py
|
||||
@echo "GEN $@"
|
||||
@mkdir -p $(FONT_GEN_DIR)
|
||||
@gen/fixedfont-to-c.py $(patsubst .%,%,$(suffix $@)) $(SMALL_FONT) "$@" -s 18 --header-dir "" --name font_small
|
||||
@$(call gen_font,$(FONT),29,small)
|
||||
|
||||
LARGE_FONT=lib/fonts/roboto_mono/RobotoMono-Bold.ttf
|
||||
$(FONT_GEN_DIR)/large_digits.h $(FONT_GEN_DIR)/large_digits.c: gen/fixedfont-to-c.py gen/font.py
|
||||
@echo "GEN $@"
|
||||
@mkdir -p $(FONT_GEN_DIR)
|
||||
@gen/fixedfont-to-c.py $(patsubst .%,%,$(suffix $@)) $(LARGE_FONT) "$@" -s 70 --header-dir "" --name font_large_digits -c "01234567890:"
|
||||
|
||||
$(OUTPUT_BIN): $(OUTPUT_ELF)
|
||||
@echo "OBJCOPY $@"
|
||||
@$(OBJCOPY) -O binary $(OUTPUT_ELF) $(OUTPUT_BIN)
|
||||
|
||||
$(OUTPUT_ELF): $(LINKER_SCRIPT) $(OBJS)
|
||||
$(OUTPUT_MAP) $(OUTPUT_ELF): $(LINKER_SCRIPT) $(OBJS)
|
||||
@echo "LD $@"
|
||||
@$(LD) -T $(LINKER_SCRIPT) $(LDFLAGS) -o $(OUTPUT_ELF) $(OBJS)
|
||||
@$(LD) -T $(LINKER_SCRIPT) $(LDFLAGS) -o $(OUTPUT_ELF) $(OBJS) -Wl,-Map=$(OUTPUT_MAP)
|
||||
|
||||
|
||||
#
|
||||
# Utilities
|
||||
@@ -147,4 +175,4 @@ flash: $(OUTPUT_BIN)
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@echo "RM $(OBJS)"
|
||||
@rm -f $(OBJS) $(OUTPUT_BIN) $(OUTPUT_ELF)
|
||||
@rm -f $(OBJS) $(OUTPUT_BIN) $(OUTPUT_ELF) $(FONT_C_FILES) $(OUTPUT_MAP) ./*.su
|
||||
|
||||
Reference in New Issue
Block a user