Skip to content
Snippets Groups Projects
Commit a0f971f4 authored by Patrick Baudin's avatar Patrick Baudin
Browse files

[Lint] using CLANG_FORMAT variable

parent 85498319
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,8 @@ ...@@ -50,7 +50,8 @@
IS_UTF8 ?= iconv -f UTF-8 -t UTF-8 IS_UTF8 ?= iconv -f UTF-8 -t UTF-8
TO_UTF8 ?= iconv -t UTF-8 -f TO_UTF8 ?= iconv -t UTF-8 -f
OCP_INDENT ?= ocp-indent OCP_INDENT ?= ocp-indent
CLANG_FORMAT ?= clang-format
# Default values necessary for # Default values necessary for
# LINT_MAKEFILE=<this-makefile> make -f <this-makefile> <lint-target>` # LINT_MAKEFILE=<this-makefile> make -f <this-makefile> <lint-target>`
...@@ -104,8 +105,8 @@ endif ...@@ -104,8 +105,8 @@ endif
$(TOUCH) $@ $(TOUCH) $@
.lint/check-clang-format-installed: .lint/check-clang-format-installed:
if ! command -v clang-format >/dev/null; then \ if ! command -v $(CLANG_FORMAT) >/dev/null; then \
echo "error: clang-format must be installed"; \ echo "error: $(CLANG_FORMAT) must be installed"; \
exit 1; \ exit 1; \
fi; fi;
mkdir -p $(dir $@) mkdir -p $(dir $@)
...@@ -343,14 +344,14 @@ $(LINT_FILE.fix-ml-indent): .lint/%.fix-indent: % .lint/check-ocp-indent-version ...@@ -343,14 +344,14 @@ $(LINT_FILE.fix-ml-indent): .lint/%.fix-indent: % .lint/check-ocp-indent-version
$(LINT_FILE.check-c-indent): .lint/%.check-indent: % .lint/check-clang-format-installed $(LINT_FILE.check-c-indent): .lint/%.check-indent: % .lint/check-clang-format-installed
echo "Check C indent: $<" echo "Check C indent: $<"
clang-format --dry-run -Werror $< $(CLANG_FORMAT) --dry-run -Werror $<
$(MKDIR) $(dir $@) $(MKDIR) $(dir $@)
$(TOUCH) $@ $(TOUCH) $@
.PHONY: $(LINT_FILE.fix-c-indent) .PHONY: $(LINT_FILE.fix-c-indent)
$(LINT_FILE.fix-c-indent): .lint/%.fix-indent: % .lint/check-clang-format-installed $(LINT_FILE.fix-c-indent): .lint/%.fix-indent: % .lint/check-clang-format-installed
echo "Fixes C indent: $<" echo "Fixes C indent: $<"
clang-format -i $< $(CLANG_FORMAT) -i $<
$(MKDIR) $(dir $@) $(MKDIR) $(dir $@)
$(TOUCH) .lint/$<.check-indent # no more need of check-indent $(TOUCH) .lint/$<.check-indent # no more need of check-indent
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment