mirror of
https://github.com/Mercantec-GHC/h5-projekt-mst.git
synced 2026-08-27 05:37:39 +02:00
dont rebuild on test
This commit is contained in:
parent
45bb17b3e8
commit
24f935587a
3
.github/workflows/verify.yml
vendored
3
.github/workflows/verify.yml
vendored
@ -28,4 +28,7 @@ jobs:
|
|||||||
- name: build
|
- name: build
|
||||||
working-directory: ./backend
|
working-directory: ./backend
|
||||||
run: make all LD=clang++-22 CXX=clang++-22
|
run: make all LD=clang++-22 CXX=clang++-22
|
||||||
|
- name: test
|
||||||
|
working-directory: ./backend
|
||||||
|
run: make test
|
||||||
|
|
||||||
|
|||||||
@ -33,26 +33,33 @@ obj_dir = $(build_dir)/obj
|
|||||||
src_dir = src
|
src_dir = src
|
||||||
test_dir = tests
|
test_dir = tests
|
||||||
|
|
||||||
sources = $(shell find $(src_dir) -name '*.cpp' -and -not -name 'main.cpp')
|
sources_without_main = $(shell find $(src_dir) -name '*.cpp' -and -not -name 'main.cpp')
|
||||||
sources_with_main=$(sources) src/main.cpp
|
main_source = src/main.cpp
|
||||||
|
sources = $(sources_without_main) $(main_source)
|
||||||
|
|
||||||
tests = $(shell find $(test_dir) -name '*.cpp')
|
objects_without_main = $(sources_without_main:%.cpp=$(obj_dir)/%.o)
|
||||||
|
main_object = $(main_source:%.cpp=$(obj_dir)/%.o)
|
||||||
|
objects = $(objects_without_main) $(main_object)
|
||||||
|
|
||||||
target = $(build_dir)/backend
|
target = $(build_dir)/backend
|
||||||
|
|
||||||
all: $(target)
|
test_sources = $(shell find $(test_dir) -name '*.cpp')
|
||||||
|
test_objects = $(test_sources:$(test_dir)/%.cpp=$(obj_dir)/$(test_dir)/%.o)
|
||||||
|
test_targets = $(test_sources:$(test_dir)/%.cpp=$(build_dir)/$(test_dir)/test_%)
|
||||||
|
|
||||||
$(target): $(sources_with_main:%.cpp=$(obj_dir)/%.o)
|
all: $(target) $(test_targets)
|
||||||
|
|
||||||
|
$(target): $(objects)
|
||||||
$(LD) -o $@ $(CXXFLAGS) $(LDFLAGS) $^
|
$(LD) -o $@ $(CXXFLAGS) $(LDFLAGS) $^
|
||||||
|
|
||||||
$(obj_dir)/%.o:%.cpp
|
$(obj_dir)/%.o:%.cpp
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
$(CXX) $< -c -o $@ -MMD -MP $(CXXFLAGS)
|
$(CXX) $< -c -o $@ -MMD -MP $(CXXFLAGS)
|
||||||
|
|
||||||
test: $(tests:tests/%.cpp=$(build_dir)/tests/test_%)
|
test: $(test_targets)
|
||||||
printf "%s\n" $^ | xargs -I % sh -c 'echo "- %..." && ./% && echo "- %: OK" || (echo "- %: FAILED" && exit 1)'
|
printf "%s\n" $^ | xargs -I % sh -c 'echo "- %..." && ./% && echo "- %: OK" || (echo "- %: FAILED" && exit 1)'
|
||||||
|
|
||||||
$(build_dir)/tests/test_%: $(obj_dir)/tests/%.o $(sources:%.cpp=$(obj_dir)/%.o)
|
$(build_dir)/$(test_dir)/test_%: $(test_objects) $(objects_without_main)
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
$(LD) -o $@ $(CXXFLAGS) $(LDFLAGS) $^
|
$(LD) -o $@ $(CXXFLAGS) $(LDFLAGS) $^
|
||||||
|
|
||||||
@ -65,5 +72,5 @@ check:
|
|||||||
clean:
|
clean:
|
||||||
rm -rf $(build_dir)
|
rm -rf $(build_dir)
|
||||||
|
|
||||||
-include $(sources_with_main:%.cpp=$(obj_dir)/%.d) $(tests:%.cpp=$(obj_dir)/%.d)
|
-include $(sources:%.cpp=$(obj_dir)/%.d) $(tests:%.cpp=$(obj_dir)/%.d)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user