Skip to content

Commit

Permalink
Update cxx_rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Walker committed Mar 4, 2020
1 parent e1441f1 commit 07b9bd0
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions .yams/cpp_rules.min
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_@=@
Common_C_Flags = -DHAVE_CONFIG_H -g -O2

Module_C_Flags += $(Common_C_Flags) $(Module_Includes)
Expand Down Expand Up @@ -28,55 +29,64 @@ ifdef CLANG_FORMAT
CLANG_FORMAT += -style=Chromium -i
endif


GCOV := $(shell command -v gcov 2> /dev/null)

ifdef GCOV
GCOV_FLAGS=-fprofile-arcs -ftest-coverage -fprofile-dir="$(Test_Dir)"
endif

%.o: %.c
@$(CC) $(Module_C_Flags) -c $< -o $@
$(_@)$(CC) $(Module_C_Flags) -c $< -o $@
ifdef CPPCHECK
@$(CPPCHECK) $(Module_Includes) $<
$(_@)$(CPPCHECK) $(Module_Includes) $<
endif
@echo "CC <= $<"

%.o: %.cpp
@$(CXX) $(Module_C_Flags) -c $< -o $@
$(_@)$(CXX) $(Module_C_Flags) -c $< -o $@
ifdef CPPCHECK
@$(CPPCHECK) $(Module_Includes) $<
$(_@)$(CPPCHECK) $(Module_Includes) $<
endif
@echo "CXX <= $<"

$(Test_Dir)/%_q: $(Test_Dir)/%.c
ifdef CLANG_FORMAT
@$(CLANG_FORMAT) $<
$(_@)$(CLANG_FORMAT) $<
endif
@$(CC) $< -o $@ $(Module_Test_C_Flags) -L/usr/local/lib $($(*F)_FLAGS) -fprofile-arcs -ftest-coverage -fprofile-dir="$(Test_Dir)"
$(_@)$(CC) $< -o $@ $(Module_Test_C_Flags) -L/usr/local/lib $($(*F)_FLAGS) $(GCOV_FLAGS)
ifdef CPPCHECK
@$(CPPCHECK) $(Module_Test_Includes) $($(*F)_Inc_FLAGS) $<
$(_@)$(CPPCHECK) $(Module_Test_Includes) $($(*F)_Inc_FLAGS) $<
endif
ifdef GCOV
$(_@)mv $(*F).gc* $(Test_Dir)
endif
@mv $(*F).gc* $(Test_Dir)
@echo "Building tests <= $<"

$(Test_Dir)/%_q: $(Test_Dir)/%.cpp
ifdef CLANG_FORMAT
@$(CLANG_FORMAT) $<
$(_@)$(CLANG_FORMAT) $<
endif
@$(CXX) $< -o $@ $(Module_Test_C_Flags) -L/usr/local/lib $($(*F)_FLAGS) -fprofile-arcs -ftest-coverage -fprofile-dir="$(Test_Dir)"
$(_@)$(CXX) $< -o $@ $(Module_Test_C_Flags) -L/usr/local/lib $($(*F)_FLAGS) $(GCOV_FLAGS)
ifdef CPPCHECK
@$(CPPCHECK) $(Module_Test_Includes) $($(*F)_Inc_FLAGS) $<
$(_@)$(CPPCHECK) $(Module_Test_Includes) $($(*F)_Inc_FLAGS) $<
endif
ifdef GCOV
$(_@)mv $(*F).gc* $(Test_Dir)
endif
@mv $(*F).gc* $(Test_Dir)
@echo "Building tests <= $<"

run_tests: $(Tests_C_Exe) $(Tests_CPP_Exe)
@echo "Running tests <= $<"
@$(foreach f,$^,$(VALGRIND) ./$(f);)
$(_@)$(foreach f,$^,$(VALGRIND) ./$(f);)
ifneq ($(and $(GCOV),$(Tests_C_Files)),)
@$(GCOV) $(Tests_C_Files)
$(_@)$(GCOV) $(Tests_C_Files)
endif
ifneq ($(and $(GCOV),$(Tests_CPP_Files)),)
@$(GCOV) $(Tests_CPP_Files)
$(_@)$(GCOV) $(Tests_CPP_Files)
endif

my_clean:
@rm -f $(C_Objects) $(CPP_Objects)
@rm -f $(Tests_C_Exe) $(Tests_CPP_Exe) $(Test_Dir)/*.gcda $(Test_Dir)/*.gcno $(Test_Dir)/*.gcov
@rm -rf $(Test_Dir)/*.dSYM
$(_@)rm -f $(C_Objects) $(CPP_Objects)
$(_@)rm -f $(Tests_C_Exe) $(Tests_CPP_Exe) $(Test_Dir)/*.gcda $(Test_Dir)/*.gcno $(Test_Dir)/*.gcov
$(_@)rm -rf $(Test_Dir)/*.dSYM

0 comments on commit 07b9bd0

Please sign in to comment.