From 07b9bd043ef68d5d472090d932b989a6a7c0c152 Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Wed, 4 Mar 2020 11:39:11 -0800 Subject: [PATCH] Update cxx_rules --- .yams/cpp_rules.min | 46 +++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/.yams/cpp_rules.min b/.yams/cpp_rules.min index 78cc1bdd28bbd3..0e9a8045ea812c 100644 --- a/.yams/cpp_rules.min +++ b/.yams/cpp_rules.min @@ -1,3 +1,4 @@ +_@=@ Common_C_Flags = -DHAVE_CONFIG_H -g -O2 Module_C_Flags += $(Common_C_Flags) $(Module_Includes) @@ -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