forked from cesanta/mjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.mk
More file actions
42 lines (37 loc) · 1.42 KB
/
common.mk
File metadata and controls
42 lines (37 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
GO_PACKAGES = cesanta.com/common/... \
cesanta.com/fw/... \
cesanta.com/mos/... \
cesanta.com/ourci/... \
cesanta.com/projects/breez/...
FORMAT_FILES ?= '*.[ch]'
REPO_ABS_PATH := $(shell cd $(REPO_ROOT) && pwd)
# Additional filter shell command for files to format; it could be for example
# "grep -v foobar", or even "grep -v foo | grep -v bar" (without quotes).
FORMAT_FILES_FILTER_CMD ?=
ifneq ("$(FORMAT_FILES_FILTER_CMD)","")
FORMAT_FILES_FILTER_CMD += |
endif
CLANG = clang
ifneq ("$(wildcard /usr/bin/clang-3.6)","")
CLANG:=/usr/bin/clang-3.6
endif
# installable with: `brew install llvm36 --with-clang`
ifneq ("$(wildcard /usr/local/bin/clang-format-3.6)","")
CLANG_FORMAT = /usr/local/bin/clang-format-3.6
else ifneq ("$(wildcard /usr/bin/clang-format-3.6)","")
CLANG_FORMAT = /usr/bin/clang-format-3.6
else
CLANG_FORMAT = docker run --rm \
-v $(REPO_ABS_PATH):$(REPO_ABS_PATH) \
$(DOCKER_USER_ARG) \
docker.cesanta.com/bob \
/usr/bin/clang-format-3.6
endif
format:
@echo "Formatting $$(basename $(CURDIR)) $(REPO_ROOT)"
@test -d "$(REPO_ROOT)" && true || { echo "Define REPO_ROOT Makefile variable, REPO_ROOT/common.mk wants it." ; false ; }
@git --git-dir $(REPO_ABS_PATH)/.git --work-tree $(REPO_ROOT) \
ls-files --full-name $(FORMAT_FILES) | \
$(FORMAT_FILES_FILTER_CMD) \
xargs -IFILE echo $(REPO_ABS_PATH)/FILE | \
xargs -t $(CLANG_FORMAT) -i