Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
e9833543
Commit
e9833543
authored
2 years ago
by
Patrick Baudin
Browse files
Options
Downloads
Patches
Plain Diff
[Lint] improves targets fix-XXX
parent
8b27415a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
share/Makefile.linting
+84
-17
84 additions, 17 deletions
share/Makefile.linting
with
84 additions
and
17 deletions
share/Makefile.linting
+
84
−
17
View file @
e9833543
...
...
@@ -25,18 +25,25 @@
################################
# make lint includes:
# - make check-utf8
(should be fixed manually)
: valid UTF-8 encoding
# - make check-utf8: 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
# For all these targets, it is possible to restrict the search to a sub-directory:
# For all these targets
(and the coresponding fix-XXX)
, it is possible to restrict the search to a sub-directory:
# - make LINT_DIR=<subdir> <lint-target>
# It is possible to force the action to given files:
# - make LINT_FILE=<subdir> <lint-target>
# Note:
# - when LINT_FILE is given, .gitattributes and LINT_DIR are ignored;
# - to use fix-utf8 taget, the variable LINT_FROM_CODE=<from-encoding-name>
# has to be set.
################################
## Default variables
IS_UTF8
?=
iconv
-f
UTF-8
-t
UTF-8
TO_UTF8
?=
iconv
-f
<NAME>
-t
UTF-8
TO_UTF8
?=
iconv
-t
UTF-8
-f
OCP_INDENT
?=
ocp-indent
# Default values necessary for
...
...
@@ -126,33 +133,70 @@ ifeq ($(LINT_FILE),)
# No lint file given
LINT.dir
=
$(
wildcard
$(
LINT_DIR
))
.PHONY
:
check-utf8
check-utf8
:
echo
"Checking UTF8..."
$(
GIT
)
ls-files
$(
LINT.dir
)
-z
\
|
$(
GIT
)
check-attr
--stdin
-z
$@
\
|
$(
SED
)
-zne
'x;n;n;s/^set$$//;t print;b;:print;x;p'
\
| xargs
--null
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX" $@ || exit 255'
.PHONY
:
fix-utf8
fix-utf8
:
echo
"Fixing UTF8..."
$(
GIT
)
ls-files
$(
LINT.dir
)
-z
\
|
$(
GIT
)
check-attr
--stdin
-z
check-
utf8
\
|
$(
GIT
)
check-attr
--stdin
-z
$(
patsubst fix-%,
check-
%,
$@
)
\
|
$(
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'
| xargs
--null
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX"
$@
|| exit 255'
.PHONY
:
check-eoleof
check-eoleof
:
echo
"Checking EOL EOF..."
$(
GIT
)
ls-files
$(
LINT.dir
)
-z
\
|
$(
GIT
)
check-attr
--stdin
-z
$@
\
|
$(
SED
)
-zne
'x;n;n;s/^set$$//;t print;b;:print;x;p'
\
| xargs
--null
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX" $@ || exit 255'
.PHONY
:
fix-eoleof
fix-eoleof
:
echo
"Fixing EOL EOF..."
$(
GIT
)
ls-files
$(
LINT.dir
)
-z
\
|
$(
GIT
)
check-attr
--stdin
-z
check-eoleof
\
|
$(
GIT
)
check-attr
--stdin
-z
$(
patsubst fix-%,check-%,
$@
)
\
|
$(
SED
)
-zne
'x;n;n;s/^set$$//;t print;b;:print;x;p'
\
| xargs
--null
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX"
check-eoleof
|| exit 255'
| xargs
--null
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX"
$@
|| exit 255'
.PHONY
:
check-syntax
check-syntax
:
echo
"Checking syntax..."
$(
GIT
)
ls-files
$(
LINT.dir
)
-z
\
|
$(
GIT
)
check-attr
--stdin
-z
$@
\
|
$(
SED
)
-zne
'x;n;n;s/^set$$//;t print;b;:print;x;p'
\
| xargs
--null
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX" $@ || exit 255'
.PHONY
:
fix-syntax
fix-syntax
:
echo
"Fixing syntax..."
$(
GIT
)
ls-files
$(
LINT.dir
)
-z
\
|
$(
GIT
)
check-attr
--stdin
-z
check-syntax
\
|
$(
GIT
)
check-attr
--stdin
-z
$(
patsubst fix-%,check-%,
$@
)
\
|
$(
SED
)
-zne
'x;n;n;s/^set$$//;t print;b;:print;x;p'
\
| xargs
--null
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX"
check-syntax
|| exit 255'
| xargs
--null
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX"
$@
|| exit 255'
.PHONY
:
check-indent
check-indent
:
echo
"Checking indent..."
$(
GIT
)
ls-files
$(
LINT.dir
)
-z
\
|
$(
GIT
)
check-attr
--stdin
-z
check-indent
\
|
$(
GIT
)
check-attr
--stdin
-z
$@
\
|
$(
SED
)
-zne
'x;n;n;s/^set$$//;t print;b;:print;x;p'
\
| xargs
--null
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX" check-indent || exit 255'
| xargs
--null
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX" $@ || exit 255'
.PHONY
:
fix-indent
fix-indent
:
echo
"Fixing indent..."
$(
GIT
)
ls-files
$(
LINT.dir
)
-z
\
|
$(
GIT
)
check-attr
--stdin
-z
$(
patsubs fix-,check-,
$@
)
\
|
$(
SED
)
-zne
'x;n;n;s/^set$$//;t print;b;:print;x;p'
\
| xargs
--null
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX" $@ || exit 255'
else
# LINT_FILE are given
...
...
@@ -165,6 +209,7 @@ 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
))
LINT_FILE.fix-utf8
=
$(
addsuffix .fix-utf8,
$(
LINT_FILE.list
))
LINT_FILE.fix-eoleof
=
$(
addsuffix .fix-eoleof,
$(
LINT_FILE.list
))
LINT_FILE.fix-syntax
=
$(
addsuffix .fix-syntax,
$(
LINT_FILE.list
))
LINT_FILE.fix-indent
=
$(
addsuffix .fix-indent,
$(
LINT_FILE.list
))
...
...
@@ -185,33 +230,55 @@ check-indent: $(LINT_FILE.check-indent)
## fix-XXX targets
.PHONY
:
fix-
syntax
fix-
syntax
:
$(LINT_FILE.fix-
syntax
)
.PHONY
:
fix-
utf8
fix-
utf8
:
$(LINT_FILE.fix-
utf8
)
.PHONY
:
fix-eoleof
fix-eoleof
:
$(LINT_FILE.fix-eoleof)
.PHONY
:
fix-syntax
fix-syntax
:
$(LINT_FILE.fix-syntax)
.PHONY
:
fix-indent
fix-indent
:
$(LINT_FILE.fix-indent)
endif
###############################
## UTF8 ASPECT
(should be fixed manually)
## UTF8 ASPECT
$(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:"
;
\
echo
"
$(
TO_UTF8
)
--from-code=<NAME>
$<
-o fixed ; mv fixed
$<
"
;
\
echo
"The next command may help you to find that <NAME>: file
$<
"
;
\
echo
"Please fixe it manualy or in running: make LINT_FROM_CODE=<ENCODING-NAME> LINT_FILE=
$<
fix-utf8"
;
\
echo
"The next command may help you to find that <ENCODING-NAME>: file
$<
"
;
\
exit
1
;
\
fi
$(
MKDIR
)
$(
dir
$@
)
$(
TOUCH
)
$@
ifneq
($(LINT_FROM_CODE),)
.PHONY
:
$(LINT_FILE.fix-utf8)
$(LINT_FILE.fix-utf8)
:
.lint/%.fix-utf8: %
if
!
$(
IS_UTF8
)
$<
>
/dev/null 2> /dev/null
;
\
then
\
echo
"Fixes UTF8 (from
$(
LINT_FROM_CODE
)
):
$<
"
;
\
if
!
$(
TO_UTF8
)
$(
LINT_FROM_CODE
)
$<
>
$<
.tmp
;
then
exit
1
;
fi
;
\
$(
MV
)
$<
.tmp
$<
;
\
fi
$(
MKDIR
)
$(
dir
$@
)
$(
TOUCH
)
.lint/
$<
.check-utf8
# no more need of check-indent
else
$(LINT_FILE.fix-utf8)
:
.lint/%.fix-utf8: % .lint/check-ocp-indent-version
$(
error
"Target fix-utf8 requires to define LINT_FROM_CODE variable"
)
endif
# LINT_FROM_ENCODING
###############################
## INDENTATION ASPECT
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment