freetype2/builds/testing.mk

102 lines
3.1 KiB
Makefile
Raw Normal View History

2023-06-12 16:44:04 +02:00
# Variables
FTBENCH_DIR = $(TOP_DIR)/src/tools/ftbench
FTBENCH_SRC = $(FTBENCH_DIR)/ftbench.c
2023-07-14 15:18:00 +02:00
FTBENCH_OBJ = $(OBJ_DIR)/bench.$(SO)
FTBENCH_BIN = $(OBJ_DIR)/bench
2023-07-20 13:51:58 +02:00
FTBENCH_FLAG ?= -c 2000
INCLUDES = $(TOP_DIR)/include
2023-06-12 16:44:04 +02:00
FONTS = $(wildcard $(FTBENCH_DIR)/fonts/*.ttf)
2023-07-11 23:52:31 +02:00
BASELINE_DIR = $(OBJ_DIR)/baseline/
BENCHMARK_DIR = $(OBJ_DIR)/benchmark/
BASELINE = $(addprefix $(BASELINE_DIR), $(notdir $(FONTS:.ttf=.txt)))
BENCHMARK = $(addprefix $(BENCHMARK_DIR), $(notdir $(FONTS:.ttf=.txt)))
2023-07-04 15:48:48 +02:00
BASELINE_INFO = $(BASELINE_DIR)info.txt
BENCHMARK_INFO = $(BENCHMARK_DIR)info.txt
2023-06-12 16:44:04 +02:00
HTMLCREATOR = $(FTBENCH_DIR)/src/tohtml.py
2023-07-11 23:52:31 +02:00
HTMLFILE = $(OBJ_DIR)/benchmark.html
2023-06-12 16:44:04 +02:00
2023-07-20 13:51:58 +02:00
FT_INCLUDES := $(OBJ_BUILD) \
$(INCLUDES)
COMPILE = $(CC) $(ANSIFLAGS) \
$(INCLUDES:%=$I%) \
$(CFLAGS)
ifneq ($(findstring -pedantic,$(COMPILE)),)
ifeq ($(findstring ++,$(CC)),)
COMPILE += -std=c99
endif
endif
FTLIB := $(LIB_DIR)/$(LIBRARY).$A
override CC = $(CCraw)
LINK_CMD = $(LIBTOOL) --mode=link $(CC) $(LDFLAGS)
EXTRAFLAGS = $DUNIX $DHAVE_POSIX_TERMIOS
INCLUDES := $(subst /,$(COMPILER_SEP),$(FT_INCLUDES))
2023-06-16 22:16:14 +02:00
# Create directories for baseline and benchmark
$(OBJ_DIR) $(BASELINE_DIR) $(BENCHMARK_DIR):
2023-06-12 16:44:04 +02:00
@mkdir -p $@
2023-07-20 13:51:58 +02:00
$(FTBENCH_OBJ): $(FTBENCH_SRC)
$(COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) $(EXTRAFLAGS)
@echo "Object created."
2023-06-12 16:44:04 +02:00
# Build ftbench
2023-07-20 13:51:58 +02:00
$(FTBENCH_BIN): $(FTBENCH_OBJ)
2023-07-14 15:18:00 +02:00
@echo "Linking ftbench..."
2023-07-20 13:51:58 +02:00
$(LINK_CMD) $T$(subst /,$(COMPILER_SEP),$@ $<) $(FTLIB)
2023-07-12 00:18:21 +02:00
@echo "Built."
2023-06-12 16:44:04 +02:00
# Create a baseline
.PHONY: baseline
2023-06-16 22:16:14 +02:00
baseline: $(FTBENCH_BIN) $(BASELINE_DIR)
2023-07-05 11:59:59 +02:00
@$(RM) -f $(BASELINE)
2023-06-12 16:44:04 +02:00
@echo "Creating baseline..."
2023-07-04 15:48:48 +02:00
@echo "$(FTBENCH_FLAG)" > $(BASELINE_INFO)
@echo "`git -C $(TOP_DIR) rev-parse HEAD`" >> $(BASELINE_INFO)
@echo "`git -C $(TOP_DIR) show -s --format=%ci HEAD`" >> $(BASELINE_INFO)
@echo "`git -C $(TOP_DIR) rev-parse --abbrev-ref HEAD`" >> $(BASELINE_INFO)
2023-07-12 00:18:21 +02:00
@fonts=($(FONTS)); \
total_fonts=$${#fonts[@]}; \
step=0; \
for font in $${fonts[@]}; do \
step=$$((step+1)); \
percent=$$((step * 100 / total_fonts)); \
printf "\rProcessing %d%%..." $$percent; \
$(FTBENCH_BIN) $(FTBENCH_FLAG) "$$font" > $(BASELINE_DIR)$$(basename $$font .ttf).txt; \
done
@echo "\nBaseline created."
2023-06-12 16:44:04 +02:00
# Benchmark and compare to baseline
.PHONY: benchmark
2023-06-16 22:16:14 +02:00
benchmark: $(FTBENCH_BIN) $(BENCHMARK_DIR)
2023-07-05 11:59:59 +02:00
@$(RM) -f $(BENCHMARK) $(HTMLFILE)
2023-06-12 16:44:04 +02:00
@echo "Creating benchmark..."
2023-07-04 15:48:48 +02:00
@echo "$(FTBENCH_FLAG)" > $(BENCHMARK_INFO)
@echo "`git -C $(TOP_DIR) rev-parse HEAD`" >> $(BENCHMARK_INFO)
@echo "`git -C $(TOP_DIR) show -s --format=%ci HEAD`" >> $(BENCHMARK_INFO)
@echo "`git -C $(TOP_DIR) rev-parse --abbrev-ref HEAD`" >> $(BENCHMARK_INFO)
2023-07-12 00:18:21 +02:00
@fonts=($(FONTS)); \
total_fonts=$${#fonts[@]}; \
step=0; \
for font in $${fonts[@]}; do \
step=$$((step+1)); \
percent=$$((step * 100 / total_fonts)); \
printf "\rProcessing %d%%..." $$percent; \
$(FTBENCH_BIN) $(FTBENCH_FLAG) "$$font" > $(BENCHMARK_DIR)$$(basename $$font .ttf).txt; \
done
2023-07-11 23:52:31 +02:00
@$(PYTHON) $(HTMLCREATOR) $(OBJ_DIR)
2023-07-12 00:18:21 +02:00
@echo "\nBenchmark created."
2023-06-12 16:44:04 +02:00
.PHONY: clean-benchmark
clean-benchmark:
@echo "Cleaning..."
2023-07-14 15:18:00 +02:00
@$(RM) $(FTBENCH_BIN) $(FTBENCH_OBJ)
2023-07-04 15:48:48 +02:00
@$(RM) -rf $(BASELINE_DIR) $(BENCHMARK_DIR) $(HTMLFILE)
2023-07-20 13:51:58 +02:00
@echo "Cleaned"