Skip to content

Commit

Permalink
[build] add make target "tidy" for running clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaefer committed Dec 3, 2015
1 parent 678a5ca commit 0c8eeea
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Checks: '-clang-analyzer-security.insecureAPI.rand'
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ run-valgrind-linux: linux

# Generates a compilation database with ninja for use in clang tooling
compdb: ; $(RUN) Ninja/compdb
tidy: ; $(RUN) tidy

.PHONY: android android-lib
# Builds a particular android architecture.
Expand Down
19 changes: 19 additions & 0 deletions scripts/clang-tidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -e
set -o pipefail

export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason"

command -v ${CLANG_TIDY:-clang-tidy} >/dev/null 2>&1 || {
echo "Can't find ${CLANG_TIDY:-clang-tidy} in PATH."
if [ -z ${CLANG_TIDY} ]; then
echo "Alternatively, you can set CLANG_TIDY to point to clang-tidy."
fi
exit 1
}

cd build/${HOST}-${HOST_VERSION}/${BUILDTYPE}

git ls-files '../../../src/mbgl/*.cpp' '../../../platform/*.cpp' '../../../test/*.cpp' | \
xargs -I{} -P ${JOBS} ${CLANG_TIDY:-clang-tidy} -header-filter='\/mbgl\/' {}
14 changes: 11 additions & 3 deletions scripts/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ ifeq (,$(V))
endif

# Determine host platform
HOST ?= $(BUILD)
export HOST ?= $(BUILD)

# Defines host defaults
include scripts/$(HOST)/defaults.mk

HOST_VERSION ?= $(BUILD_VERSION)
export HOST_VERSION ?= $(BUILD_VERSION)

# Optionally include version-specific host defaults
-include scripts/$(HOST)/$(HOST_VERSION)/defaults.mk
Expand All @@ -20,7 +20,7 @@ ifneq (,$(wildcard scripts/$(HOST)/$(HOST_VERSION)/configure.sh))
CONFIGURE_FILES += scripts/$(HOST)/$(HOST_VERSION)/configure.sh
endif

HOST_SLUG = $(HOST)-$(HOST_VERSION)
export HOST_SLUG = $(HOST)-$(HOST_VERSION)
CONFIGURE_FILES = scripts/$(HOST)/configure.sh
ifneq (,$(wildcard scripts/$(HOST)/$(HOST_VERSION)/configure.sh))
CONFIGURE_FILES += scripts/$(HOST)/$(HOST_VERSION)/configure.sh
Expand Down Expand Up @@ -153,6 +153,14 @@ Ninja/compdb: Ninja/__project__
$(QUIET)$(ENV) deps/ninja/ninja-$(HOST) -C build/$(HOST_SLUG)/$(BUILDTYPE) \
-t compdb cc cc_s cxx objc objcxx > $(OUTPUT)

#### Tidy ######################################################################

tidy: Ninja/compdb
@printf "$(TEXT_BOLD)$(COLOR_GREEN)* Generating header files...$(FORMAT_END)\n"
$(QUIET)$(ENV) deps/ninja/ninja-$(HOST) -C build/$(HOST_SLUG)/$(BUILDTYPE) version shaders
@printf "$(TEXT_BOLD)$(COLOR_GREEN)* Running tidy...$(FORMAT_END)\n"
@./scripts/clang-tidy.sh

#### Run tests #################################################################

test-%: Makefile/test
Expand Down

0 comments on commit 0c8eeea

Please sign in to comment.