treewide: restucture source tree per project

Signed-off-by: Max Regan <mgregan2@gmail.com>
This commit is contained in:
2017-04-20 18:12:28 -07:00
parent 6ba525b64b
commit e5acc3088c
24 changed files with 43 additions and 45 deletions

View File

@@ -1,7 +1,8 @@
OUT=build
build=OUT
COV_DIR=$(OUT)/coverage/
SRC_DIR=src
APP_DIR=src/apps/
OUT=build
CC=gcc
@@ -36,9 +37,9 @@ LDFLAGS += -lglib-2.0
C_SOURCES = $(shell find $(SRC_DIR) -name "*.c")
ALL_OBJS = $(patsubst $(SRC_DIR)/%.c, $(OUT)/%.o, $(C_SOURCES))
APP_OBJS = $(filter $(OUT)/apps/%, $(ALL_OBJS))
OBJS = $(filter-out $(APP_OBJS), $(ALL_OBJS))
TEST_OBJS = $(filter $(OUT)%test.o, $(ALL_OBJS))
OBJS = $(filter-out $(TEST_OBJS) $(APP_OBJS), $(ALL_OBJS))
APPS = $(patsubst %.o, %, $(APP_OBJS))
.PHONY: all
all: gbdb gbasm tests
@@ -66,7 +67,7 @@ gbasm: $(OUT)/apps/gbasm
.PHONY: gbasm-test sample-test tests
TESTS=$(OUT)/apps/gbasm_test $(OUT)/apps/tri_test $(OUT)/apps/cpu_integ_test
TESTS = $(patsubst %.o, %, $(filter %/test.o, $(ALL_OBJS)))
tests: $(TESTS)
$(ALL_APPS) $(ALL_OBJS): $(CONFIG)
@@ -77,7 +78,7 @@ $(OUT)/%.o: $(SRC_DIR)/%.c
@$(CC) -c $(CCFLAGS) -o $@ $<
.SECONDEXPANSION:
$(APPS): $(OBJS) $$@.o
$(APPS) $(TESTS): $(OBJS) $$@.o
@echo " LD $@"
@$(shell mkdir -p $(@D))
@$(CC) $^ $(LDFLAGS) -o $@
@@ -106,13 +107,10 @@ $(COV_BASE):
@lcov -q -c -i -d $(OUT) -o $(COV_BASE)
$(COV_DIR)/coverage.info coverage: $(TESTS) $(COV_BASE)
@for test in $(TESTS); do \
echo " TEST $$test"; \
$$test -q; \
echo " LCOV $$(basename $$test)"; \
lcov -q -c -d $(OUT) -o $(COV_DIR)$$(basename $$test).info -t $$(basename $$test); \
done
@lcov -q $$(for i in $$(ls -1 $(COV_DIR)*.info); do echo "-a $$i"; done) -o $(COV_DIR)coverage.info
$(call run_tests)
@lcov -q -c -d $(OUT) -o $(COV_DIR)results.info -t results
@lcov -q -a $(COV_DIR)results.info -o $(COV_DIR)coverage.info
@lcov --summary $(COV_DIR)coverage.info
coverage-report: coverage
@mkdir -p $(COV_DIR)/html/