119ea8026Sopenharmony_ci# overrideable build dir, default is in-place 219ea8026Sopenharmony_ciBUILDDIR ?= . 319ea8026Sopenharmony_ci# overridable target/src/tools/flags/etc 419ea8026Sopenharmony_ciifneq ($(wildcard test.c main.c),) 519ea8026Sopenharmony_ciTARGET ?= $(BUILDDIR)/lfs 619ea8026Sopenharmony_cielse 719ea8026Sopenharmony_ciTARGET ?= $(BUILDDIR)/liblfs.a 819ea8026Sopenharmony_ciendif 919ea8026Sopenharmony_ci 1019ea8026Sopenharmony_ci 1119ea8026Sopenharmony_ciCC ?= gcc 1219ea8026Sopenharmony_ciAR ?= ar 1319ea8026Sopenharmony_ciSIZE ?= size 1419ea8026Sopenharmony_ciCTAGS ?= ctags 1519ea8026Sopenharmony_ciNM ?= nm 1619ea8026Sopenharmony_ciOBJDUMP ?= objdump 1719ea8026Sopenharmony_ciVALGRIND ?= valgrind 1819ea8026Sopenharmony_ciGDB ?= gdb 1919ea8026Sopenharmony_ciPERF ?= perf 2019ea8026Sopenharmony_ci 2119ea8026Sopenharmony_ciSRC ?= $(filter-out $(wildcard *.t.* *.b.*),$(wildcard *.c)) 2219ea8026Sopenharmony_ciOBJ := $(SRC:%.c=$(BUILDDIR)/%.o) 2319ea8026Sopenharmony_ciDEP := $(SRC:%.c=$(BUILDDIR)/%.d) 2419ea8026Sopenharmony_ciASM := $(SRC:%.c=$(BUILDDIR)/%.s) 2519ea8026Sopenharmony_ciCI := $(SRC:%.c=$(BUILDDIR)/%.ci) 2619ea8026Sopenharmony_ciGCDA := $(SRC:%.c=$(BUILDDIR)/%.t.gcda) 2719ea8026Sopenharmony_ci 2819ea8026Sopenharmony_ciTESTS ?= $(wildcard tests/*.toml) 2919ea8026Sopenharmony_ciTEST_SRC ?= $(SRC) \ 3019ea8026Sopenharmony_ci $(filter-out $(wildcard bd/*.t.* bd/*.b.*),$(wildcard bd/*.c)) \ 3119ea8026Sopenharmony_ci runners/test_runner.c 3219ea8026Sopenharmony_ciTEST_RUNNER ?= $(BUILDDIR)/runners/test_runner 3319ea8026Sopenharmony_ciTEST_A := $(TESTS:%.toml=$(BUILDDIR)/%.t.a.c) \ 3419ea8026Sopenharmony_ci $(TEST_SRC:%.c=$(BUILDDIR)/%.t.a.c) 3519ea8026Sopenharmony_ciTEST_C := $(TEST_A:%.t.a.c=%.t.c) 3619ea8026Sopenharmony_ciTEST_OBJ := $(TEST_C:%.t.c=%.t.o) 3719ea8026Sopenharmony_ciTEST_DEP := $(TEST_C:%.t.c=%.t.d) 3819ea8026Sopenharmony_ciTEST_CI := $(TEST_C:%.t.c=%.t.ci) 3919ea8026Sopenharmony_ciTEST_GCNO := $(TEST_C:%.t.c=%.t.gcno) 4019ea8026Sopenharmony_ciTEST_GCDA := $(TEST_C:%.t.c=%.t.gcda) 4119ea8026Sopenharmony_ciTEST_PERF := $(TEST_RUNNER:%=%.perf) 4219ea8026Sopenharmony_ciTEST_TRACE := $(TEST_RUNNER:%=%.trace) 4319ea8026Sopenharmony_ciTEST_CSV := $(TEST_RUNNER:%=%.csv) 4419ea8026Sopenharmony_ci 4519ea8026Sopenharmony_ciBENCHES ?= $(wildcard benches/*.toml) 4619ea8026Sopenharmony_ciBENCH_SRC ?= $(SRC) \ 4719ea8026Sopenharmony_ci $(filter-out $(wildcard bd/*.t.* bd/*.b.*),$(wildcard bd/*.c)) \ 4819ea8026Sopenharmony_ci runners/bench_runner.c 4919ea8026Sopenharmony_ciBENCH_RUNNER ?= $(BUILDDIR)/runners/bench_runner 5019ea8026Sopenharmony_ciBENCH_A := $(BENCHES:%.toml=$(BUILDDIR)/%.b.a.c) \ 5119ea8026Sopenharmony_ci $(BENCH_SRC:%.c=$(BUILDDIR)/%.b.a.c) 5219ea8026Sopenharmony_ciBENCH_C := $(BENCH_A:%.b.a.c=%.b.c) 5319ea8026Sopenharmony_ciBENCH_OBJ := $(BENCH_C:%.b.c=%.b.o) 5419ea8026Sopenharmony_ciBENCH_DEP := $(BENCH_C:%.b.c=%.b.d) 5519ea8026Sopenharmony_ciBENCH_CI := $(BENCH_C:%.b.c=%.b.ci) 5619ea8026Sopenharmony_ciBENCH_GCNO := $(BENCH_C:%.b.c=%.b.gcno) 5719ea8026Sopenharmony_ciBENCH_GCDA := $(BENCH_C:%.b.c=%.b.gcda) 5819ea8026Sopenharmony_ciBENCH_PERF := $(BENCH_RUNNER:%=%.perf) 5919ea8026Sopenharmony_ciBENCH_TRACE := $(BENCH_RUNNER:%=%.trace) 6019ea8026Sopenharmony_ciBENCH_CSV := $(BENCH_RUNNER:%=%.csv) 6119ea8026Sopenharmony_ci 6219ea8026Sopenharmony_ciCFLAGS += -fcallgraph-info=su 6319ea8026Sopenharmony_ciCFLAGS += -g3 6419ea8026Sopenharmony_ciCFLAGS += -I. 6519ea8026Sopenharmony_ciCFLAGS += -std=c99 -Wall -Wextra -pedantic 6619ea8026Sopenharmony_ciCFLAGS += -ftrack-macro-expansion=0 6719ea8026Sopenharmony_ciifdef DEBUG 6819ea8026Sopenharmony_ciCFLAGS += -O0 6919ea8026Sopenharmony_cielse 7019ea8026Sopenharmony_ciCFLAGS += -Os 7119ea8026Sopenharmony_ciendif 7219ea8026Sopenharmony_ciifdef TRACE 7319ea8026Sopenharmony_ciCFLAGS += -DLFS_YES_TRACE 7419ea8026Sopenharmony_ciendif 7519ea8026Sopenharmony_ciifdef YES_COV 7619ea8026Sopenharmony_ciCFLAGS += --coverage 7719ea8026Sopenharmony_ciendif 7819ea8026Sopenharmony_ciifdef YES_PERF 7919ea8026Sopenharmony_ciCFLAGS += -fno-omit-frame-pointer 8019ea8026Sopenharmony_ciendif 8119ea8026Sopenharmony_ciifdef YES_PERFBD 8219ea8026Sopenharmony_ciCFLAGS += -fno-omit-frame-pointer 8319ea8026Sopenharmony_ciendif 8419ea8026Sopenharmony_ci 8519ea8026Sopenharmony_ciifdef VERBOSE 8619ea8026Sopenharmony_ciCODEFLAGS += -v 8719ea8026Sopenharmony_ciDATAFLAGS += -v 8819ea8026Sopenharmony_ciSTACKFLAGS += -v 8919ea8026Sopenharmony_ciSTRUCTSFLAGS += -v 9019ea8026Sopenharmony_ciCOVFLAGS += -v 9119ea8026Sopenharmony_ciPERFFLAGS += -v 9219ea8026Sopenharmony_ciPERFBDFLAGS += -v 9319ea8026Sopenharmony_ciendif 9419ea8026Sopenharmony_ci# forward -j flag 9519ea8026Sopenharmony_ciPERFFLAGS += $(filter -j%,$(MAKEFLAGS)) 9619ea8026Sopenharmony_ciPERFBDFLAGS += $(filter -j%,$(MAKEFLAGS)) 9719ea8026Sopenharmony_ciifneq ($(NM),nm) 9819ea8026Sopenharmony_ciCODEFLAGS += --nm-path="$(NM)" 9919ea8026Sopenharmony_ciDATAFLAGS += --nm-path="$(NM)" 10019ea8026Sopenharmony_ciendif 10119ea8026Sopenharmony_ciifneq ($(OBJDUMP),objdump) 10219ea8026Sopenharmony_ciCODEFLAGS += --objdump-path="$(OBJDUMP)" 10319ea8026Sopenharmony_ciDATAFLAGS += --objdump-path="$(OBJDUMP)" 10419ea8026Sopenharmony_ciSTRUCTSFLAGS += --objdump-path="$(OBJDUMP)" 10519ea8026Sopenharmony_ciPERFFLAGS += --objdump-path="$(OBJDUMP)" 10619ea8026Sopenharmony_ciPERFBDFLAGS += --objdump-path="$(OBJDUMP)" 10719ea8026Sopenharmony_ciendif 10819ea8026Sopenharmony_ciifneq ($(PERF),perf) 10919ea8026Sopenharmony_ciPERFFLAGS += --perf-path="$(PERF)" 11019ea8026Sopenharmony_ciendif 11119ea8026Sopenharmony_ci 11219ea8026Sopenharmony_ciTESTFLAGS += -b 11319ea8026Sopenharmony_ciBENCHFLAGS += -b 11419ea8026Sopenharmony_ci# forward -j flag 11519ea8026Sopenharmony_ciTESTFLAGS += $(filter -j%,$(MAKEFLAGS)) 11619ea8026Sopenharmony_ciBENCHFLAGS += $(filter -j%,$(MAKEFLAGS)) 11719ea8026Sopenharmony_ciifdef YES_PERF 11819ea8026Sopenharmony_ciTESTFLAGS += -p $(TEST_PERF) 11919ea8026Sopenharmony_ciBENCHFLAGS += -p $(BENCH_PERF) 12019ea8026Sopenharmony_ciendif 12119ea8026Sopenharmony_ciifdef YES_PERFBD 12219ea8026Sopenharmony_ciTESTFLAGS += -t $(TEST_TRACE) --trace-backtrace --trace-freq=100 12319ea8026Sopenharmony_ciendif 12419ea8026Sopenharmony_ciifndef NO_PERFBD 12519ea8026Sopenharmony_ciBENCHFLAGS += -t $(BENCH_TRACE) --trace-backtrace --trace-freq=100 12619ea8026Sopenharmony_ciendif 12719ea8026Sopenharmony_ciifdef YES_TESTMARKS 12819ea8026Sopenharmony_ciTESTFLAGS += -o $(TEST_CSV) 12919ea8026Sopenharmony_ciendif 13019ea8026Sopenharmony_ciifndef NO_BENCHMARKS 13119ea8026Sopenharmony_ciBENCHFLAGS += -o $(BENCH_CSV) 13219ea8026Sopenharmony_ciendif 13319ea8026Sopenharmony_ciifdef VERBOSE 13419ea8026Sopenharmony_ciTESTFLAGS += -v 13519ea8026Sopenharmony_ciTESTCFLAGS += -v 13619ea8026Sopenharmony_ciBENCHFLAGS += -v 13719ea8026Sopenharmony_ciBENCHCFLAGS += -v 13819ea8026Sopenharmony_ciendif 13919ea8026Sopenharmony_ciifdef EXEC 14019ea8026Sopenharmony_ciTESTFLAGS += --exec="$(EXEC)" 14119ea8026Sopenharmony_ciBENCHFLAGS += --exec="$(EXEC)" 14219ea8026Sopenharmony_ciendif 14319ea8026Sopenharmony_ciifneq ($(GDB),gdb) 14419ea8026Sopenharmony_ciTESTFLAGS += --gdb-path="$(GDB)" 14519ea8026Sopenharmony_ciBENCHFLAGS += --gdb-path="$(GDB)" 14619ea8026Sopenharmony_ciendif 14719ea8026Sopenharmony_ciifneq ($(VALGRIND),valgrind) 14819ea8026Sopenharmony_ciTESTFLAGS += --valgrind-path="$(VALGRIND)" 14919ea8026Sopenharmony_ciBENCHFLAGS += --valgrind-path="$(VALGRIND)" 15019ea8026Sopenharmony_ciendif 15119ea8026Sopenharmony_ciifneq ($(PERF),perf) 15219ea8026Sopenharmony_ciTESTFLAGS += --perf-path="$(PERF)" 15319ea8026Sopenharmony_ciBENCHFLAGS += --perf-path="$(PERF)" 15419ea8026Sopenharmony_ciendif 15519ea8026Sopenharmony_ci 15619ea8026Sopenharmony_ci# this is a bit of a hack, but we want to make sure the BUILDDIR 15719ea8026Sopenharmony_ci# directory structure is correct before we run any commands 15819ea8026Sopenharmony_ciifneq ($(BUILDDIR),.) 15919ea8026Sopenharmony_ci$(if $(findstring n,$(MAKEFLAGS)),, $(shell mkdir -p \ 16019ea8026Sopenharmony_ci $(addprefix $(BUILDDIR)/,$(dir \ 16119ea8026Sopenharmony_ci $(SRC) \ 16219ea8026Sopenharmony_ci $(TESTS) \ 16319ea8026Sopenharmony_ci $(TEST_SRC) \ 16419ea8026Sopenharmony_ci $(BENCHES) \ 16519ea8026Sopenharmony_ci $(BENCH_SRC))))) 16619ea8026Sopenharmony_ciendif 16719ea8026Sopenharmony_ci 16819ea8026Sopenharmony_ci 16919ea8026Sopenharmony_ci# commands 17019ea8026Sopenharmony_ci 17119ea8026Sopenharmony_ci## Build littlefs 17219ea8026Sopenharmony_ci.PHONY: all build 17319ea8026Sopenharmony_ciall build: $(TARGET) 17419ea8026Sopenharmony_ci 17519ea8026Sopenharmony_ci## Build assembly files 17619ea8026Sopenharmony_ci.PHONY: asm 17719ea8026Sopenharmony_ciasm: $(ASM) 17819ea8026Sopenharmony_ci 17919ea8026Sopenharmony_ci## Find the total size 18019ea8026Sopenharmony_ci.PHONY: size 18119ea8026Sopenharmony_cisize: $(OBJ) 18219ea8026Sopenharmony_ci $(SIZE) -t $^ 18319ea8026Sopenharmony_ci 18419ea8026Sopenharmony_ci## Generate a ctags file 18519ea8026Sopenharmony_ci.PHONY: tags 18619ea8026Sopenharmony_citags: 18719ea8026Sopenharmony_ci $(CTAGS) --totals --c-types=+p $(shell find -H -name '*.h') $(SRC) 18819ea8026Sopenharmony_ci 18919ea8026Sopenharmony_ci## Show this help text 19019ea8026Sopenharmony_ci.PHONY: help 19119ea8026Sopenharmony_cihelp: 19219ea8026Sopenharmony_ci @$(strip awk '/^## / { \ 19319ea8026Sopenharmony_ci sub(/^## /,""); \ 19419ea8026Sopenharmony_ci getline rule; \ 19519ea8026Sopenharmony_ci while (rule ~ /^(#|\.PHONY|ifdef|ifndef)/) getline rule; \ 19619ea8026Sopenharmony_ci gsub(/:.*/, "", rule); \ 19719ea8026Sopenharmony_ci printf " "" %-25s %s\n", rule, $$0 \ 19819ea8026Sopenharmony_ci }' $(MAKEFILE_LIST)) 19919ea8026Sopenharmony_ci 20019ea8026Sopenharmony_ci## Find the per-function code size 20119ea8026Sopenharmony_ci.PHONY: code 20219ea8026Sopenharmony_cicode: CODEFLAGS+=-S 20319ea8026Sopenharmony_cicode: $(OBJ) $(BUILDDIR)/lfs.code.csv 20419ea8026Sopenharmony_ci ./scripts/code.py $(OBJ) $(CODEFLAGS) 20519ea8026Sopenharmony_ci 20619ea8026Sopenharmony_ci## Compare per-function code size 20719ea8026Sopenharmony_ci.PHONY: code-diff 20819ea8026Sopenharmony_cicode-diff: $(OBJ) 20919ea8026Sopenharmony_ci ./scripts/code.py $^ $(CODEFLAGS) -d $(BUILDDIR)/lfs.code.csv 21019ea8026Sopenharmony_ci 21119ea8026Sopenharmony_ci## Find the per-function data size 21219ea8026Sopenharmony_ci.PHONY: data 21319ea8026Sopenharmony_cidata: DATAFLAGS+=-S 21419ea8026Sopenharmony_cidata: $(OBJ) $(BUILDDIR)/lfs.data.csv 21519ea8026Sopenharmony_ci ./scripts/data.py $(OBJ) $(DATAFLAGS) 21619ea8026Sopenharmony_ci 21719ea8026Sopenharmony_ci## Compare per-function data size 21819ea8026Sopenharmony_ci.PHONY: data-diff 21919ea8026Sopenharmony_cidata-diff: $(OBJ) 22019ea8026Sopenharmony_ci ./scripts/data.py $^ $(DATAFLAGS) -d $(BUILDDIR)/lfs.data.csv 22119ea8026Sopenharmony_ci 22219ea8026Sopenharmony_ci## Find the per-function stack usage 22319ea8026Sopenharmony_ci.PHONY: stack 22419ea8026Sopenharmony_cistack: STACKFLAGS+=-S 22519ea8026Sopenharmony_cistack: $(CI) $(BUILDDIR)/lfs.stack.csv 22619ea8026Sopenharmony_ci ./scripts/stack.py $(CI) $(STACKFLAGS) 22719ea8026Sopenharmony_ci 22819ea8026Sopenharmony_ci## Compare per-function stack usage 22919ea8026Sopenharmony_ci.PHONY: stack-diff 23019ea8026Sopenharmony_cistack-diff: $(CI) 23119ea8026Sopenharmony_ci ./scripts/stack.py $^ $(STACKFLAGS) -d $(BUILDDIR)/lfs.stack.csv 23219ea8026Sopenharmony_ci 23319ea8026Sopenharmony_ci## Find function sizes 23419ea8026Sopenharmony_ci.PHONY: funcs 23519ea8026Sopenharmony_cifuncs: SUMMARYFLAGS+=-S 23619ea8026Sopenharmony_cifuncs: \ 23719ea8026Sopenharmony_ci $(BUILDDIR)/lfs.code.csv \ 23819ea8026Sopenharmony_ci $(BUILDDIR)/lfs.data.csv \ 23919ea8026Sopenharmony_ci $(BUILDDIR)/lfs.stack.csv 24019ea8026Sopenharmony_ci $(strip ./scripts/summary.py $^ \ 24119ea8026Sopenharmony_ci -bfunction \ 24219ea8026Sopenharmony_ci -fcode=code_size \ 24319ea8026Sopenharmony_ci -fdata=data_size \ 24419ea8026Sopenharmony_ci -fstack=stack_limit --max=stack \ 24519ea8026Sopenharmony_ci $(SUMMARYFLAGS)) 24619ea8026Sopenharmony_ci 24719ea8026Sopenharmony_ci## Compare function sizes 24819ea8026Sopenharmony_ci.PHONY: funcs-diff 24919ea8026Sopenharmony_cifuncs-diff: SHELL=/bin/bash 25019ea8026Sopenharmony_cifuncs-diff: $(OBJ) $(CI) 25119ea8026Sopenharmony_ci $(strip ./scripts/summary.py \ 25219ea8026Sopenharmony_ci <(./scripts/code.py $(OBJ) -q $(CODEFLAGS) -o-) \ 25319ea8026Sopenharmony_ci <(./scripts/data.py $(OBJ) -q $(DATAFLAGS) -o-) \ 25419ea8026Sopenharmony_ci <(./scripts/stack.py $(CI) -q $(STACKFLAGS) -o-) \ 25519ea8026Sopenharmony_ci -bfunction \ 25619ea8026Sopenharmony_ci -fcode=code_size \ 25719ea8026Sopenharmony_ci -fdata=data_size \ 25819ea8026Sopenharmony_ci -fstack=stack_limit --max=stack \ 25919ea8026Sopenharmony_ci $(SUMMARYFLAGS) -d <(./scripts/summary.py \ 26019ea8026Sopenharmony_ci $(BUILDDIR)/lfs.code.csv \ 26119ea8026Sopenharmony_ci $(BUILDDIR)/lfs.data.csv \ 26219ea8026Sopenharmony_ci $(BUILDDIR)/lfs.stack.csv \ 26319ea8026Sopenharmony_ci -q $(SUMMARYFLAGS) -o-)) 26419ea8026Sopenharmony_ci 26519ea8026Sopenharmony_ci## Find struct sizes 26619ea8026Sopenharmony_ci.PHONY: structs 26719ea8026Sopenharmony_cistructs: STRUCTSFLAGS+=-S 26819ea8026Sopenharmony_cistructs: $(OBJ) $(BUILDDIR)/lfs.structs.csv 26919ea8026Sopenharmony_ci ./scripts/structs.py $(OBJ) $(STRUCTSFLAGS) 27019ea8026Sopenharmony_ci 27119ea8026Sopenharmony_ci## Compare struct sizes 27219ea8026Sopenharmony_ci.PHONY: structs-diff 27319ea8026Sopenharmony_cistructs-diff: $(OBJ) 27419ea8026Sopenharmony_ci ./scripts/structs.py $^ $(STRUCTSFLAGS) -d $(BUILDDIR)/lfs.structs.csv 27519ea8026Sopenharmony_ci 27619ea8026Sopenharmony_ci## Find the line/branch coverage after a test run 27719ea8026Sopenharmony_ci.PHONY: cov 27819ea8026Sopenharmony_cicov: COVFLAGS+=-s 27919ea8026Sopenharmony_cicov: $(GCDA) $(BUILDDIR)/lfs.cov.csv 28019ea8026Sopenharmony_ci $(strip ./scripts/cov.py $(GCDA) \ 28119ea8026Sopenharmony_ci $(patsubst %,-F%,$(SRC)) \ 28219ea8026Sopenharmony_ci $(COVFLAGS)) 28319ea8026Sopenharmony_ci 28419ea8026Sopenharmony_ci## Compare line/branch coverage 28519ea8026Sopenharmony_ci.PHONY: cov-diff 28619ea8026Sopenharmony_cicov-diff: $(GCDA) 28719ea8026Sopenharmony_ci $(strip ./scripts/cov.py $^ \ 28819ea8026Sopenharmony_ci $(patsubst %,-F%,$(SRC)) \ 28919ea8026Sopenharmony_ci $(COVFLAGS) -d $(BUILDDIR)/lfs.cov.csv) 29019ea8026Sopenharmony_ci 29119ea8026Sopenharmony_ci## Find the perf results after bench run with YES_PERF 29219ea8026Sopenharmony_ci.PHONY: perf 29319ea8026Sopenharmony_ciperf: PERFFLAGS+=-S 29419ea8026Sopenharmony_ciperf: $(BENCH_PERF) $(BUILDDIR)/lfs.perf.csv 29519ea8026Sopenharmony_ci $(strip ./scripts/perf.py $(BENCH_PERF) \ 29619ea8026Sopenharmony_ci $(patsubst %,-F%,$(SRC)) \ 29719ea8026Sopenharmony_ci $(PERFFLAGS)) 29819ea8026Sopenharmony_ci 29919ea8026Sopenharmony_ci## Compare perf results 30019ea8026Sopenharmony_ci.PHONY: perf-diff 30119ea8026Sopenharmony_ciperf-diff: $(BENCH_PERF) 30219ea8026Sopenharmony_ci $(strip ./scripts/perf.py $^ \ 30319ea8026Sopenharmony_ci $(patsubst %,-F%,$(SRC)) \ 30419ea8026Sopenharmony_ci $(PERFFLAGS) -d $(BUILDDIR)/lfs.perf.csv) 30519ea8026Sopenharmony_ci 30619ea8026Sopenharmony_ci## Find the perfbd results after a bench run 30719ea8026Sopenharmony_ci.PHONY: perfbd 30819ea8026Sopenharmony_ciperfbd: PERFBDFLAGS+=-S 30919ea8026Sopenharmony_ciperfbd: $(BENCH_TRACE) $(BUILDDIR)/lfs.perfbd.csv 31019ea8026Sopenharmony_ci $(strip ./scripts/perfbd.py $(BENCH_RUNNER) $(BENCH_TRACE) \ 31119ea8026Sopenharmony_ci $(patsubst %,-F%,$(SRC)) \ 31219ea8026Sopenharmony_ci $(PERFBDFLAGS)) 31319ea8026Sopenharmony_ci 31419ea8026Sopenharmony_ci## Compare perfbd results 31519ea8026Sopenharmony_ci.PHONY: perfbd-diff 31619ea8026Sopenharmony_ciperfbd-diff: $(BENCH_TRACE) 31719ea8026Sopenharmony_ci $(strip ./scripts/perfbd.py $(BENCH_RUNNER) $^ \ 31819ea8026Sopenharmony_ci $(patsubst %,-F%,$(SRC)) \ 31919ea8026Sopenharmony_ci $(PERFBDFLAGS) -d $(BUILDDIR)/lfs.perfbd.csv) 32019ea8026Sopenharmony_ci 32119ea8026Sopenharmony_ci## Find a summary of compile-time sizes 32219ea8026Sopenharmony_ci.PHONY: summary sizes 32319ea8026Sopenharmony_cisummary sizes: \ 32419ea8026Sopenharmony_ci $(BUILDDIR)/lfs.code.csv \ 32519ea8026Sopenharmony_ci $(BUILDDIR)/lfs.data.csv \ 32619ea8026Sopenharmony_ci $(BUILDDIR)/lfs.stack.csv \ 32719ea8026Sopenharmony_ci $(BUILDDIR)/lfs.structs.csv 32819ea8026Sopenharmony_ci $(strip ./scripts/summary.py $^ \ 32919ea8026Sopenharmony_ci -fcode=code_size \ 33019ea8026Sopenharmony_ci -fdata=data_size \ 33119ea8026Sopenharmony_ci -fstack=stack_limit --max=stack \ 33219ea8026Sopenharmony_ci -fstructs=struct_size \ 33319ea8026Sopenharmony_ci -Y $(SUMMARYFLAGS)) 33419ea8026Sopenharmony_ci 33519ea8026Sopenharmony_ci## Compare compile-time sizes 33619ea8026Sopenharmony_ci.PHONY: summary-diff sizes-diff 33719ea8026Sopenharmony_cisummary-diff sizes-diff: SHELL=/bin/bash 33819ea8026Sopenharmony_cisummary-diff sizes-diff: $(OBJ) $(CI) 33919ea8026Sopenharmony_ci $(strip ./scripts/summary.py \ 34019ea8026Sopenharmony_ci <(./scripts/code.py $(OBJ) -q $(CODEFLAGS) -o-) \ 34119ea8026Sopenharmony_ci <(./scripts/data.py $(OBJ) -q $(DATAFLAGS) -o-) \ 34219ea8026Sopenharmony_ci <(./scripts/stack.py $(CI) -q $(STACKFLAGS) -o-) \ 34319ea8026Sopenharmony_ci <(./scripts/structs.py $(OBJ) -q $(STRUCTSFLAGS) -o-) \ 34419ea8026Sopenharmony_ci -fcode=code_size \ 34519ea8026Sopenharmony_ci -fdata=data_size \ 34619ea8026Sopenharmony_ci -fstack=stack_limit --max=stack \ 34719ea8026Sopenharmony_ci -fstructs=struct_size \ 34819ea8026Sopenharmony_ci -Y $(SUMMARYFLAGS) -d <(./scripts/summary.py \ 34919ea8026Sopenharmony_ci $(BUILDDIR)/lfs.code.csv \ 35019ea8026Sopenharmony_ci $(BUILDDIR)/lfs.data.csv \ 35119ea8026Sopenharmony_ci $(BUILDDIR)/lfs.stack.csv \ 35219ea8026Sopenharmony_ci $(BUILDDIR)/lfs.structs.csv \ 35319ea8026Sopenharmony_ci -q $(SUMMARYFLAGS) -o-)) 35419ea8026Sopenharmony_ci 35519ea8026Sopenharmony_ci## Build the test-runner 35619ea8026Sopenharmony_ci.PHONY: test-runner build-test 35719ea8026Sopenharmony_ciifndef NO_COV 35819ea8026Sopenharmony_citest-runner build-test: CFLAGS+=--coverage 35919ea8026Sopenharmony_ciendif 36019ea8026Sopenharmony_ciifdef YES_PERF 36119ea8026Sopenharmony_citest-runner build-test: CFLAGS+=-fno-omit-frame-pointer 36219ea8026Sopenharmony_ciendif 36319ea8026Sopenharmony_ciifdef YES_PERFBD 36419ea8026Sopenharmony_citest-runner build-test: CFLAGS+=-fno-omit-frame-pointer 36519ea8026Sopenharmony_ciendif 36619ea8026Sopenharmony_ci# note we remove some binary dependent files during compilation, 36719ea8026Sopenharmony_ci# otherwise it's way to easy to end up with outdated results 36819ea8026Sopenharmony_citest-runner build-test: $(TEST_RUNNER) 36919ea8026Sopenharmony_ciifndef NO_COV 37019ea8026Sopenharmony_ci rm -f $(TEST_GCDA) 37119ea8026Sopenharmony_ciendif 37219ea8026Sopenharmony_ciifdef YES_PERF 37319ea8026Sopenharmony_ci rm -f $(TEST_PERF) 37419ea8026Sopenharmony_ciendif 37519ea8026Sopenharmony_ciifdef YES_PERFBD 37619ea8026Sopenharmony_ci rm -f $(TEST_TRACE) 37719ea8026Sopenharmony_ciendif 37819ea8026Sopenharmony_ci 37919ea8026Sopenharmony_ci## Run the tests, -j enables parallel tests 38019ea8026Sopenharmony_ci.PHONY: test 38119ea8026Sopenharmony_citest: test-runner 38219ea8026Sopenharmony_ci ./scripts/test.py $(TEST_RUNNER) $(TESTFLAGS) 38319ea8026Sopenharmony_ci 38419ea8026Sopenharmony_ci## List the tests 38519ea8026Sopenharmony_ci.PHONY: test-list 38619ea8026Sopenharmony_citest-list: test-runner 38719ea8026Sopenharmony_ci ./scripts/test.py $(TEST_RUNNER) $(TESTFLAGS) -l 38819ea8026Sopenharmony_ci 38919ea8026Sopenharmony_ci## Summarize the testmarks 39019ea8026Sopenharmony_ci.PHONY: testmarks 39119ea8026Sopenharmony_citestmarks: SUMMARYFLAGS+=-spassed 39219ea8026Sopenharmony_citestmarks: $(TEST_CSV) $(BUILDDIR)/lfs.test.csv 39319ea8026Sopenharmony_ci $(strip ./scripts/summary.py $(TEST_CSV) \ 39419ea8026Sopenharmony_ci -bsuite \ 39519ea8026Sopenharmony_ci -fpassed=test_passed \ 39619ea8026Sopenharmony_ci $(SUMMARYFLAGS)) 39719ea8026Sopenharmony_ci 39819ea8026Sopenharmony_ci## Compare testmarks against a previous run 39919ea8026Sopenharmony_ci.PHONY: testmarks-diff 40019ea8026Sopenharmony_citestmarks-diff: $(TEST_CSV) 40119ea8026Sopenharmony_ci $(strip ./scripts/summary.py $^ \ 40219ea8026Sopenharmony_ci -bsuite \ 40319ea8026Sopenharmony_ci -fpassed=test_passed \ 40419ea8026Sopenharmony_ci $(SUMMARYFLAGS) -d $(BUILDDIR)/lfs.test.csv) 40519ea8026Sopenharmony_ci 40619ea8026Sopenharmony_ci## Build the bench-runner 40719ea8026Sopenharmony_ci.PHONY: bench-runner build-bench 40819ea8026Sopenharmony_ciifdef YES_COV 40919ea8026Sopenharmony_cibench-runner build-bench: CFLAGS+=--coverage 41019ea8026Sopenharmony_ciendif 41119ea8026Sopenharmony_ciifdef YES_PERF 41219ea8026Sopenharmony_cibench-runner build-bench: CFLAGS+=-fno-omit-frame-pointer 41319ea8026Sopenharmony_ciendif 41419ea8026Sopenharmony_ciifndef NO_PERFBD 41519ea8026Sopenharmony_cibench-runner build-bench: CFLAGS+=-fno-omit-frame-pointer 41619ea8026Sopenharmony_ciendif 41719ea8026Sopenharmony_ci# note we remove some binary dependent files during compilation, 41819ea8026Sopenharmony_ci# otherwise it's way to easy to end up with outdated results 41919ea8026Sopenharmony_cibench-runner build-bench: $(BENCH_RUNNER) 42019ea8026Sopenharmony_ciifdef YES_COV 42119ea8026Sopenharmony_ci rm -f $(BENCH_GCDA) 42219ea8026Sopenharmony_ciendif 42319ea8026Sopenharmony_ciifdef YES_PERF 42419ea8026Sopenharmony_ci rm -f $(BENCH_PERF) 42519ea8026Sopenharmony_ciendif 42619ea8026Sopenharmony_ciifndef NO_PERFBD 42719ea8026Sopenharmony_ci rm -f $(BENCH_TRACE) 42819ea8026Sopenharmony_ciendif 42919ea8026Sopenharmony_ci 43019ea8026Sopenharmony_ci## Run the benchmarks, -j enables parallel benchmarks 43119ea8026Sopenharmony_ci.PHONY: bench 43219ea8026Sopenharmony_cibench: bench-runner 43319ea8026Sopenharmony_ci ./scripts/bench.py $(BENCH_RUNNER) $(BENCHFLAGS) 43419ea8026Sopenharmony_ci 43519ea8026Sopenharmony_ci## List the benchmarks 43619ea8026Sopenharmony_ci.PHONY: bench-list 43719ea8026Sopenharmony_cibench-list: bench-runner 43819ea8026Sopenharmony_ci ./scripts/bench.py $(BENCH_RUNNER) $(BENCHFLAGS) -l 43919ea8026Sopenharmony_ci 44019ea8026Sopenharmony_ci## Summarize the benchmarks 44119ea8026Sopenharmony_ci.PHONY: benchmarks 44219ea8026Sopenharmony_cibenchmarks: SUMMARYFLAGS+=-Serased -Sproged -Sreaded 44319ea8026Sopenharmony_cibenchmarks: $(BENCH_CSV) $(BUILDDIR)/lfs.bench.csv 44419ea8026Sopenharmony_ci $(strip ./scripts/summary.py $(BENCH_CSV) \ 44519ea8026Sopenharmony_ci -bsuite \ 44619ea8026Sopenharmony_ci -freaded=bench_readed \ 44719ea8026Sopenharmony_ci -fproged=bench_proged \ 44819ea8026Sopenharmony_ci -ferased=bench_erased \ 44919ea8026Sopenharmony_ci $(SUMMARYFLAGS)) 45019ea8026Sopenharmony_ci 45119ea8026Sopenharmony_ci## Compare benchmarks against a previous run 45219ea8026Sopenharmony_ci.PHONY: benchmarks-diff 45319ea8026Sopenharmony_cibenchmarks-diff: $(BENCH_CSV) 45419ea8026Sopenharmony_ci $(strip ./scripts/summary.py $^ \ 45519ea8026Sopenharmony_ci -bsuite \ 45619ea8026Sopenharmony_ci -freaded=bench_readed \ 45719ea8026Sopenharmony_ci -fproged=bench_proged \ 45819ea8026Sopenharmony_ci -ferased=bench_erased \ 45919ea8026Sopenharmony_ci $(SUMMARYFLAGS) -d $(BUILDDIR)/lfs.bench.csv) 46019ea8026Sopenharmony_ci 46119ea8026Sopenharmony_ci 46219ea8026Sopenharmony_ci 46319ea8026Sopenharmony_ci# rules 46419ea8026Sopenharmony_ci-include $(DEP) 46519ea8026Sopenharmony_ci-include $(TEST_DEP) 46619ea8026Sopenharmony_ci.SUFFIXES: 46719ea8026Sopenharmony_ci.SECONDARY: 46819ea8026Sopenharmony_ci 46919ea8026Sopenharmony_ci$(BUILDDIR)/lfs: $(OBJ) 47019ea8026Sopenharmony_ci $(CC) $(CFLAGS) $^ $(LFLAGS) -o $@ 47119ea8026Sopenharmony_ci 47219ea8026Sopenharmony_ci$(BUILDDIR)/liblfs.a: $(OBJ) 47319ea8026Sopenharmony_ci $(AR) rcs $@ $^ 47419ea8026Sopenharmony_ci 47519ea8026Sopenharmony_ci$(BUILDDIR)/lfs.code.csv: $(OBJ) 47619ea8026Sopenharmony_ci ./scripts/code.py $^ -q $(CODEFLAGS) -o $@ 47719ea8026Sopenharmony_ci 47819ea8026Sopenharmony_ci$(BUILDDIR)/lfs.data.csv: $(OBJ) 47919ea8026Sopenharmony_ci ./scripts/data.py $^ -q $(DATAFLAGS) -o $@ 48019ea8026Sopenharmony_ci 48119ea8026Sopenharmony_ci$(BUILDDIR)/lfs.stack.csv: $(CI) 48219ea8026Sopenharmony_ci ./scripts/stack.py $^ -q $(STACKFLAGS) -o $@ 48319ea8026Sopenharmony_ci 48419ea8026Sopenharmony_ci$(BUILDDIR)/lfs.structs.csv: $(OBJ) 48519ea8026Sopenharmony_ci ./scripts/structs.py $^ -q $(STRUCTSFLAGS) -o $@ 48619ea8026Sopenharmony_ci 48719ea8026Sopenharmony_ci$(BUILDDIR)/lfs.cov.csv: $(GCDA) 48819ea8026Sopenharmony_ci $(strip ./scripts/cov.py $^ \ 48919ea8026Sopenharmony_ci $(patsubst %,-F%,$(SRC)) \ 49019ea8026Sopenharmony_ci -q $(COVFLAGS) -o $@) 49119ea8026Sopenharmony_ci 49219ea8026Sopenharmony_ci$(BUILDDIR)/lfs.perf.csv: $(BENCH_PERF) 49319ea8026Sopenharmony_ci $(strip ./scripts/perf.py $^ \ 49419ea8026Sopenharmony_ci $(patsubst %,-F%,$(SRC)) \ 49519ea8026Sopenharmony_ci -q $(PERFFLAGS) -o $@) 49619ea8026Sopenharmony_ci 49719ea8026Sopenharmony_ci$(BUILDDIR)/lfs.perfbd.csv: $(BENCH_TRACE) 49819ea8026Sopenharmony_ci $(strip ./scripts/perfbd.py $(BENCH_RUNNER) $^ \ 49919ea8026Sopenharmony_ci $(patsubst %,-F%,$(SRC)) \ 50019ea8026Sopenharmony_ci -q $(PERFBDFLAGS) -o $@) 50119ea8026Sopenharmony_ci 50219ea8026Sopenharmony_ci$(BUILDDIR)/lfs.test.csv: $(TEST_CSV) 50319ea8026Sopenharmony_ci cp $^ $@ 50419ea8026Sopenharmony_ci 50519ea8026Sopenharmony_ci$(BUILDDIR)/lfs.bench.csv: $(BENCH_CSV) 50619ea8026Sopenharmony_ci cp $^ $@ 50719ea8026Sopenharmony_ci 50819ea8026Sopenharmony_ci$(BUILDDIR)/runners/test_runner: $(TEST_OBJ) 50919ea8026Sopenharmony_ci $(CC) $(CFLAGS) $^ $(LFLAGS) -o $@ 51019ea8026Sopenharmony_ci 51119ea8026Sopenharmony_ci$(BUILDDIR)/runners/bench_runner: $(BENCH_OBJ) 51219ea8026Sopenharmony_ci $(CC) $(CFLAGS) $^ $(LFLAGS) -o $@ 51319ea8026Sopenharmony_ci 51419ea8026Sopenharmony_ci# our main build rule generates .o, .d, and .ci files, the latter 51519ea8026Sopenharmony_ci# used for stack analysis 51619ea8026Sopenharmony_ci$(BUILDDIR)/%.o $(BUILDDIR)/%.ci: %.c 51719ea8026Sopenharmony_ci $(CC) -c -MMD $(CFLAGS) $< -o $(BUILDDIR)/$*.o 51819ea8026Sopenharmony_ci 51919ea8026Sopenharmony_ci$(BUILDDIR)/%.o $(BUILDDIR)/%.ci: $(BUILDDIR)/%.c 52019ea8026Sopenharmony_ci $(CC) -c -MMD $(CFLAGS) $< -o $(BUILDDIR)/$*.o 52119ea8026Sopenharmony_ci 52219ea8026Sopenharmony_ci$(BUILDDIR)/%.s: %.c 52319ea8026Sopenharmony_ci $(CC) -S $(CFLAGS) $< -o $@ 52419ea8026Sopenharmony_ci 52519ea8026Sopenharmony_ci$(BUILDDIR)/%.c: %.a.c 52619ea8026Sopenharmony_ci ./scripts/prettyasserts.py -p LFS_ASSERT $< -o $@ 52719ea8026Sopenharmony_ci 52819ea8026Sopenharmony_ci$(BUILDDIR)/%.c: $(BUILDDIR)/%.a.c 52919ea8026Sopenharmony_ci ./scripts/prettyasserts.py -p LFS_ASSERT $< -o $@ 53019ea8026Sopenharmony_ci 53119ea8026Sopenharmony_ci$(BUILDDIR)/%.t.a.c: %.toml 53219ea8026Sopenharmony_ci ./scripts/test.py -c $< $(TESTCFLAGS) -o $@ 53319ea8026Sopenharmony_ci 53419ea8026Sopenharmony_ci$(BUILDDIR)/%.t.a.c: %.c $(TESTS) 53519ea8026Sopenharmony_ci ./scripts/test.py -c $(TESTS) -s $< $(TESTCFLAGS) -o $@ 53619ea8026Sopenharmony_ci 53719ea8026Sopenharmony_ci$(BUILDDIR)/%.b.a.c: %.toml 53819ea8026Sopenharmony_ci ./scripts/bench.py -c $< $(BENCHCFLAGS) -o $@ 53919ea8026Sopenharmony_ci 54019ea8026Sopenharmony_ci$(BUILDDIR)/%.b.a.c: %.c $(BENCHES) 54119ea8026Sopenharmony_ci ./scripts/bench.py -c $(BENCHES) -s $< $(BENCHCFLAGS) -o $@ 54219ea8026Sopenharmony_ci 54319ea8026Sopenharmony_ci## Clean everything 54419ea8026Sopenharmony_ci.PHONY: clean 54519ea8026Sopenharmony_ciclean: 54619ea8026Sopenharmony_ci rm -f $(BUILDDIR)/lfs 54719ea8026Sopenharmony_ci rm -f $(BUILDDIR)/liblfs.a 54819ea8026Sopenharmony_ci rm -f $(BUILDDIR)/lfs.code.csv 54919ea8026Sopenharmony_ci rm -f $(BUILDDIR)/lfs.data.csv 55019ea8026Sopenharmony_ci rm -f $(BUILDDIR)/lfs.stack.csv 55119ea8026Sopenharmony_ci rm -f $(BUILDDIR)/lfs.structs.csv 55219ea8026Sopenharmony_ci rm -f $(BUILDDIR)/lfs.cov.csv 55319ea8026Sopenharmony_ci rm -f $(BUILDDIR)/lfs.perf.csv 55419ea8026Sopenharmony_ci rm -f $(BUILDDIR)/lfs.perfbd.csv 55519ea8026Sopenharmony_ci rm -f $(BUILDDIR)/lfs.test.csv 55619ea8026Sopenharmony_ci rm -f $(BUILDDIR)/lfs.bench.csv 55719ea8026Sopenharmony_ci rm -f $(OBJ) 55819ea8026Sopenharmony_ci rm -f $(DEP) 55919ea8026Sopenharmony_ci rm -f $(ASM) 56019ea8026Sopenharmony_ci rm -f $(CI) 56119ea8026Sopenharmony_ci rm -f $(TEST_RUNNER) 56219ea8026Sopenharmony_ci rm -f $(TEST_A) 56319ea8026Sopenharmony_ci rm -f $(TEST_C) 56419ea8026Sopenharmony_ci rm -f $(TEST_OBJ) 56519ea8026Sopenharmony_ci rm -f $(TEST_DEP) 56619ea8026Sopenharmony_ci rm -f $(TEST_CI) 56719ea8026Sopenharmony_ci rm -f $(TEST_GCNO) 56819ea8026Sopenharmony_ci rm -f $(TEST_GCDA) 56919ea8026Sopenharmony_ci rm -f $(TEST_PERF) 57019ea8026Sopenharmony_ci rm -f $(TEST_TRACE) 57119ea8026Sopenharmony_ci rm -f $(TEST_CSV) 57219ea8026Sopenharmony_ci rm -f $(BENCH_RUNNER) 57319ea8026Sopenharmony_ci rm -f $(BENCH_A) 57419ea8026Sopenharmony_ci rm -f $(BENCH_C) 57519ea8026Sopenharmony_ci rm -f $(BENCH_OBJ) 57619ea8026Sopenharmony_ci rm -f $(BENCH_DEP) 57719ea8026Sopenharmony_ci rm -f $(BENCH_CI) 57819ea8026Sopenharmony_ci rm -f $(BENCH_GCNO) 57919ea8026Sopenharmony_ci rm -f $(BENCH_GCDA) 58019ea8026Sopenharmony_ci rm -f $(BENCH_PERF) 58119ea8026Sopenharmony_ci rm -f $(BENCH_TRACE) 58219ea8026Sopenharmony_ci rm -f $(BENCH_CSV) 583