Skip to content

Commit

Permalink
Rules for clang analyzer
Browse files Browse the repository at this point in the history
do "make scan" for a LONG build, with lots of scanning,
and (for now) a number of errors.
  • Loading branch information
alandekok committed Oct 14, 2013
1 parent 445c751 commit 85d2e52
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions scripts/boiler.mk
Expand Up @@ -132,6 +132,11 @@ ${FILTER_DEPENDS}
endef
endif

define ADD_ANALYZE_RULE
$${BUILD_DIR}/plist/%.plist: ${1} ${JLIBTOOL}
${2}
endef

# ADD_TARGET_DIR - Parameterized "function" that makes a link from
# TARGET_DIR to the executable or library in the BUILD_DIR directory.
#
Expand Down Expand Up @@ -245,6 +250,15 @@ define COMPILE_C_CMDS
${SRC_INCDIRS} ${SRC_DEFS} ${DEFS} $<)
endef

# ANALYZE_C_CMDS - Commands for analyzing C source code with clang.
define ANALYZE_C_CMDS
@mkdir -p $(dir $@)
@$(ECHO) SCAN $<
@$(strip ${COMPILE.c} --analyze -c $< ${CFLAGS} ${SRC_CFLAGS} ${INCDIRS} \
${SRC_INCDIRS} ${SRC_DEFS} ${DEFS}) || (rm -f $@ && false)
@touch $@
endef

# COMPILE_CXX_CMDS - Commands for compiling C++ source code.
define COMPILE_CXX_CMDS
@mkdir -p $(dir $@)
Expand Down Expand Up @@ -367,6 +381,10 @@ define INCLUDE_SUBMAKEFILE
OBJS := $$(addprefix $${BUILD_DIR}/objs/,\
$$(addsuffix .${OBJ_EXT},$$(basename $${SOURCES})))

PLISTS := $$(addprefix $${BUILD_DIR}/plist/,\
$$(addsuffix .plist,$$(basename $${SOURCES})))
ALL_PLISTS += ${PLISTS}

# Add the objects to the current target's list of objects, and create
# target-specific variables for the objects based on any source
# variables that were defined.
Expand All @@ -382,6 +400,12 @@ define INCLUDE_SUBMAKEFILE
$${OBJS}: SRC_DEFS := $$(addprefix -D,$${SRC_DEFS})
$${OBJS}: SRC_INCDIRS := $$(addprefix -I,$${SRC_INCDIRS})
$${OBJS}: ${1}

$${PLISTS}: SRC_CFLAGS := $${SRC_CFLAGS}
$${PLISTS}: SRC_CXXFLAGS := $${SRC_CXXFLAGS}
$${PLISTS}: SRC_DEFS := $$(addprefix -D,$${SRC_DEFS})
$${PLISTS}: SRC_INCDIRS := $$(addprefix -I,$${SRC_INCDIRS})
$${PLISTS}: ${1}
endif
endif

Expand Down Expand Up @@ -559,6 +583,11 @@ INCDIRS := $(addprefix -I,$(call CANONICAL_PATH,${INCDIRS}))
$(foreach EXT,${C_SRC_EXTS},\
$(eval $(call ADD_OBJECT_RULE,${EXT},$${COMPILE_C_CMDS})))

ifeq "$(CC)" "clang"
$(foreach EXT,${C_SRC_EXTS},\
$(eval $(call ADD_ANALYZE_RULE,${EXT},$${ANALYZE_C_CMDS})))
endif

# Add pattern rule(s) for creating compiled object code from C++ source.
$(foreach EXT,${CXX_SRC_EXTS},\
$(eval $(call ADD_OBJECT_RULE,${EXT},$${COMPILE_CXX_CMDS})))
Expand All @@ -570,3 +599,5 @@ ifneq "$(MAKECMDGOALS)" "clean"
$(foreach TGT,${ALL_TGTS},\
$(eval -include ${${TGT}_DEPS}))
endif

scan: ${ALL_PLISTS}

0 comments on commit 85d2e52

Please sign in to comment.