Skip to content

Commit

Permalink
separate out make system changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Walker committed Mar 13, 2020
1 parent 6f43121 commit bdcc707
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
33 changes: 32 additions & 1 deletion .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

Expand All @@ -21,36 +22,62 @@ endif

CLANG_FORMAT := $(shell command -v clang-format 2> /dev/null)
ifdef CLANG_FORMAT
CLANG_FORMAT += -style=Chromium -i
CLANG_FORMAT += -i
endif

CLANG_TIDY := $(shell command -v clang-tidy 2> /dev/null)
ifdef CLANG_TIDY
CLANG_TIDY += -checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus*
endif

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

ifdef GCOV
GCOV_FLAGS=-fprofile-arcs -ftest-coverage
endif

# search up in the tree from where the makefile lives for overrides, other definitions
__updirs=$(if $1,$(if $2,$(if $(subst /,,$(abspath $2)),$(or $(wildcard $2$1),$(call __updirs,$1,$2../))),$(call __updirs,$1,./)))
-include $(call __updirs,.yams.min)

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

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

$(Test_Dir)/%_q: $(Test_Dir)/%.c
ifdef CLANG_FORMAT
$(_@)$(CLANG_FORMAT) $<
endif
$(_@)$(CC) $< -o $@ $(Module_Test_C_Flags) -L/usr/local/lib $($(*F)_FLAGS) $(GCOV_FLAGS)
ifdef CLANG_TIDY
$(_@)$(CLANG_TIDY) $< -- $(Module_Test_C_Flags)
endif
@echo "Building tests <= $<"

$(Test_Dir)/%_q: $(Test_Dir)/%.cpp
ifdef CLANG_FORMAT
$(_@)$(CLANG_FORMAT) $<
endif
$(_@)$(CXX) $< -o $@ $(Module_Test_C_Flags) -L/usr/local/lib $($(*F)_FLAGS) $(GCOV_FLAGS)
ifdef CLANG_TIDY
$(_@)$(CLANG_TIDY) $< -- $(Module_Test_C_Flags)
endif
@echo "Building tests <= $<"

run_tests: $(Tests_C_Exe) $(Tests_CPP_Exe)
Expand All @@ -69,3 +96,7 @@ my_clean:
$(_@)rm -f $(Tests_C_Exe) $(Tests_CPP_Exe) $(Test_Dir)/*.gcda $(Test_Dir)/*.gcno $(Test_Dir)/*.gcov
$(_@)rm -rf $(Test_Dir)/*.dSYM

.PHONY: _DEBUG_%
_DEBUG_%:
@echo $*='"$($(*))"'

27 changes: 27 additions & 0 deletions src/.yams.min
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

VALGRIND := $(shell command -v valgrind 2> /dev/null)

ifdef VALGRIND
VALGRIND += --leak-check=yes -q
endif

CPPCHECK := $(shell command -v cppcheck 2> /dev/null)
ifdef CPPCHECK
CPPCHECK += -q --error-exitcode=1
endif

CLANG_FORMAT := $(shell command -v clang-format 2> /dev/null)
ifdef CLANG_FORMAT
CLANG_FORMAT += -i
endif

CLANG_TIDY := $(shell command -v clang-tidy 2> /dev/null)
ifdef CLANG_TIDY
CLANG_TIDY += -checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus*
endif

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

ifdef GCOV
GCOV_FLAGS=-fprofile-arcs -ftest-coverage
endif
3 changes: 3 additions & 0 deletions src/lwip/.yams.min
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# don't tidy or format third_party lwip
CLANG_FORMAT=
CLANG_TIDY=

0 comments on commit bdcc707

Please sign in to comment.