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

[Lint] adds 'make check-utf8'

parent 82e02b6c
No related branches found
No related tags found
No related merge requests found
......@@ -5,35 +5,75 @@
.git-blame-ignore-revs merge=union
Changelog merge=union
###############
# BINARY: set #
###############
# built-in macro that also unsets the "text" and "diff" attributes
##################################################
# BINARY/CHECK-SYNTAX/INDENT/EOL-EOF: set/-unset #
##################################################
*.ico binary -check-eoleof
*.icns binary -check-eoleof
# note: "binary" is a built-in macro that also
# unsets the "text" and "diff" attributes
*.eps binary -check-eoleof
*.ps binary -check-eoleof
*.gif binary -check-eoleof
*.jpg binary -check-eoleof
*.png binary -check-eoleof
*.svg binary -check-eoleof
# note: set "check-eoleof" and "check-utf8" by default to all files
* check-eoleof check-utf8
*.odg binary -check-eoleof
*.pdf binary -check-eoleof
# note: unset "-check-eoleof" and "-check-utf8" for "binary"
*.ico binary -check-eoleof -check-utf8
*.icns binary -check-eoleof -check-utf8
*.eot binary -check-eoleof
*.woff binary -check-eoleof
*.eps binary -check-eoleof -check-utf8
*.ps binary -check-eoleof -check-utf8
*.gif binary -check-eoleof -check-utf8
*.jpg binary -check-eoleof -check-utf8
*.png binary -check-eoleof -check-utf8
*.svg binary -check-eoleof -check-utf8
*.odg binary -check-eoleof -check-utf8
*.pdf binary -check-eoleof -check-utf8
*.eot binary -check-eoleof -check-utf8
*.woff binary -check-eoleof -check-utf8
###########################################
# CHECK-SYNTAX/INDENT/EOL-EOF: set/-unset #
###########################################
## Set "check-syntax" and "check-indent"
# note: "check-syntax" includes already "check-eoleof"
*.ml check-syntax check-indent -check-eoleof
*.mli check-syntax check-indent -check-eoleof
## Unset "-check-eoleof"
*.dot -check-eoleof
/tests/spec/unfinished-oneline-acsl-comment.i -check-eoleof
/doc/developer/check_api/run.oracle -check-eoleof
/src/plugins/server/tests/batch/wrong.json -check-eoleof
## Unset "-check-utf8"
/doc/acsl_tutorial_slides/script -check-utf8
/doc/developer/METADOC.txt -check-utf8
/doc/developer/TODO -check-utf8
/doc/index.html -check-utf8
/doc/makeLatex -check-utf8
/doc/scope/M.v -check-utf8
/doc/scope/Makefile -check-utf8
/doc/training/developer/macros.tex -check-utf8
/doc/value/README -check-utf8
/src/plugins/e-acsl/tests/builtin/utils -check-utf8
/src/plugins/e-acsl/tests/format/utils -check-utf8
/src/plugins/wp/doc/coqdoc/coqdoc.sty -check-utf8
/src/plugins/wp/doc/manual/wp_logicvar.tex -check-utf8
/src/plugins/wp/doc/manual/wp_store.tex -check-utf8
## Unset all: "-check-syntax -check-indent -check-eoleof -check-utf8"
# File names that cannot be checked (due to sh: 1: Syntax error: Unterminated quoted string)
/tests/syntax/foo\".c -check-syntax -check-indent -check-eoleof -check-utf8
/tests/syntax/oracle/foo\".res.oracle -check-syntax -check-indent -check-eoleof -check-utf8
#########################
# HEADER_SPEC: CEA_LGPL #
......
......@@ -23,10 +23,17 @@
################################
# Code prettyfication and lint #
################################
# make lint includes:
# - make check-utf8 (should be fixed manually): valid UTF-8 encoding
# - make check-eoleof: EOF preceded by an EOL
# - make check-syntax: EOF preceded by an EOL + no TAB + no BLANK at the end
# - make check-indent: valid indentation
################################
## Default variables
IS_UTF8 ?= iconv -f UTF-8
TO_UTF8 ?= iconv -t UTF-8
OCP_INDENT ?= ocp-indent
# Default values necessary for
......@@ -58,7 +65,7 @@ endif
################################
## CHECK $(OCP_INDENT)VERSION
## CHECK ocp-indent VERSION
.lint/check-ocp-indent-version:
if command -v $(OCP_INDENT) >/dev/null; then \
......@@ -85,8 +92,8 @@ ifeq ($(LINT.HAS_GIT),)
.PHONY:
lint:
echo "'make lint' requires git"
echo "but,that is not the case of 'make LINT_FILE=<file> check-syntax'"
echo "'make lint' requires a git repository but, that is not"
echo "the case for example with 'make LINT_FILE=<file> check-syntax'"
else
......@@ -112,6 +119,13 @@ ifeq ($(LINT_FILE),)
# No lint file given
.PHONY: check-utf8
check-utf8:
$(GIT) ls-files -z \
| $(GIT) check-attr --stdin -z check-utf8 \
| $(SED) -zne 'x;n;n;s/^set$$//;t print;b;:print;x;p' \
| xargs --null -IXX sh -c '$(LINT.make) LINT_FILE="XX" check-utf8 || exit 255'
.PHONY: check-eoleof
check-eoleof:
$(GIT) ls-files -z \
......@@ -139,6 +153,7 @@ else # LINT_FILE are given
LINT_FILE.list=$(addprefix .lint/,$(wildcard $(LINT_FILE)))
LINT_FILE.check-utf8= $(addsuffix .check-utf8,$(LINT_FILE.list))
LINT_FILE.check-eoleof= $(addsuffix .check-eoleof,$(LINT_FILE.list))
LINT_FILE.check-syntax= $(addsuffix .check-syntax,$(LINT_FILE.list))
LINT_FILE.check-indent= $(addsuffix .check-indent,$(LINT_FILE.list))
......@@ -149,6 +164,9 @@ LINT_FILE.fix-indent= $(addsuffix .fix-indent,$(LINT_FILE.list))
## check-XXX targets
.PHONY: check-utf8
check-utf8: $(LINT_FILE.check-utf8)
.PHONY: check-eoleof
check-eoleof: $(LINT_FILE.check-eoleof)
......@@ -171,6 +189,21 @@ fix-indent: $(LINT_FILE.fix-indent)
endif
###############################
## UTF8 ASPECT (should be fixed manually)
$(LINT_FILE.check-utf8): .lint/%.check-utf8: %
echo "Check UTF8: $<"
if ! $(IS_UTF8) $< > /dev/null; \
then \
echo "File $< uses an invalid UTF-8 encoding."; \
echo "Please fixe it manually, pearhaps with: $(TO_UTF8) --from-code=<NAME> $<";\
echo "The next command may help you to find that <NAME>: file $<";\
exit 1; \
fi
$(MKDIR) $(dir $@)
$(TOUCH) $@
###############################
## INDENTATION ASPECT
......@@ -188,6 +221,7 @@ $(LINT_FILE.check-indent): .lint/%.check-indent: % .lint/check-ocp-indent-versio
$(MKDIR) $(dir $@)
$(TOUCH) $@
.PHONY: $(LINT_FILE.fix-indent)
$(LINT_FILE.fix-indent): .lint/%.fix-indent: % .lint/check-ocp-indent-version
echo "Fixes indent: $<"
$(OCP_INDENT) -i $<
......@@ -214,6 +248,8 @@ $(LINT_FILE.check-eoleof): .lint/%.check-eoleof: %
$(MKDIR) $(dir $@)
$(TOUCH) $@
# The real target is a check-XXX one
.PHONY: $(LINT_FILE.fix-eoleof)
$(LINT_FILE.fix-eoleof): .lint/%.fix-eoleof: %
echo "Fixes EOL EOF: $<"
$(ISED) -e '$$a\' $<
......@@ -249,6 +285,8 @@ $(LINT_FILE.check-syntax): .lint/%.check-syntax: %
$(MKDIR) $(dir $@)
$(TOUCH) $@
# The real target is a check-XXX one
.PHONY: $(LINT_FILE.fix-syntax)
$(LINT_FILE.fix-syntax): .lint/%.fix-syntax: %
echo "Fixes syntax: $<"
$(ISED) -e 's/^ *\t\+/ /' $<
......
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