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
45f21d26
Commit
45f21d26
authored
2 years ago
by
Patrick Baudin
Browse files
Options
Downloads
Patches
Plain Diff
[Linting] Allows LINT_DIFF=<commit/branch> make <lint|check-xxx|fix-xxx>
parent
a0a7f3c5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
share/Makefile.linting
+16
-4
16 additions, 4 deletions
share/Makefile.linting
with
16 additions
and
4 deletions
share/Makefile.linting
+
16
−
4
View file @
45f21d26
...
@@ -33,8 +33,11 @@
...
@@ -33,8 +33,11 @@
# - make LINT_DIR=<subdir> <lint-target>
# - make LINT_DIR=<subdir> <lint-target>
# It is possible to force the action to given files:
# It is possible to force the action to given files:
# - make LINT_FILE=<file> <lint-target>
# - make LINT_FILE=<file> <lint-target>
# or to the files modified between HEAD and a specific branch/commit:
# - make LINT_DIFF=<branch/commit> <lint-target>
# Notes:
# Notes:
# - when LINT_FILE is given, .gitattributes and LINT_DIR are ignored;
# - when LINT_FILE is given, .gitattributes, LINT_DIFF and LINT_DIR are ignored;
# - when LINT_DIFF is given, LINT_DIR is ignored (but .gitattributes is used);
# - to use fix-utf8 target, the variable LINT_FROM_ENCODING=<from-encoding-name>
# - to use fix-utf8 target, the variable LINT_FROM_ENCODING=<from-encoding-name>
# has to be set.
# has to be set.
...
@@ -57,6 +60,8 @@ CLANG_FORMAT ?= clang-format
...
@@ -57,6 +60,8 @@ 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>`
# Otherwise theses variables are defined into share/Makefile.common
# Otherwise theses variables are defined into share/Makefile.common
GREP
?=
grep
TR
?=
tr
SED
?=
LC_ALL
=
C
sed
SED
?=
LC_ALL
=
C
sed
ISED
?=
sed
-i
ISED
?=
sed
-i
FIND
?=
find
FIND
?=
find
...
@@ -119,7 +124,7 @@ endif
...
@@ -119,7 +124,7 @@ endif
echo
"error:
$(
CLANG_FORMAT
)
must be installed"
;
\
echo
"error:
$(
CLANG_FORMAT
)
must be installed"
;
\
exit
1
;
\
exit
1
;
\
fi
;
fi
;
mkdir
-p
$(
dir
$@
)
$(
MKDIR
)
$(
dir
$@
)
$(
TOUCH
)
$@
$(
TOUCH
)
$@
###############
###############
...
@@ -178,6 +183,13 @@ ifeq ($(LINT_FILE),)
...
@@ -178,6 +183,13 @@ ifeq ($(LINT_FILE),)
LINT.dir
=
$(
wildcard
$(
LINT_DIR
))
LINT.dir
=
$(
wildcard
$(
LINT_DIR
))
ifeq
($(LINT_DIFF),)
FILE_LIST
=
$(
GIT
)
ls-files
$(
LINT.dir
)
-z
else
$(info [LINT] Looking at files modified from branch/commit
:
'$(LINT_DIFF)')
FILE_LIST
=
$(
GIT
)
diff
--name-status
--cached
$(
LINT_DIFF
)
|
$(
GREP
)
-v
"^D"
|
$(
SED
)
"s/^.[
\t
]*//"
|
$(
TR
)
'\n'
'\000'
endif
#### check-XXX targets
#### check-XXX targets
# Same list on both lines
# Same list on both lines
...
@@ -188,7 +200,7 @@ LINT.check-targets= \
...
@@ -188,7 +200,7 @@ LINT.check-targets= \
# Generic rule
# Generic rule
$(LINT.check-targets)
:
$(LINT.check-targets)
:
echo
"[LINT] Checking from GIT attribute
$@
..."
echo
"[LINT] Checking from GIT attribute
$@
..."
$(
GIT
)
ls-files
$(
LINT.dir
)
-z
\
$(
FILE_LIST
)
\
|
$(
GIT
)
check-attr
--stdin
-z
$@
\
|
$(
GIT
)
check-attr
--stdin
-z
$@
\
|
$(
SED
)
-zne
'x;n;n;s/^set$$//;t print;b;:print;x;p'
\
|
$(
SED
)
-zne
'x;n;n;s/^set$$//;t print;b;:print;x;p'
\
|
$(
XARGS
)
-0
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX" $@ || exit 255'
|
$(
XARGS
)
-0
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX" $@ || exit 255'
...
@@ -203,7 +215,7 @@ LINT.fix-targets= \
...
@@ -203,7 +215,7 @@ LINT.fix-targets= \
# Generic rule
# Generic rule
$(LINT.fix-targets)
:
$(LINT.fix-targets)
:
echo
"[LINT] Fixing from GIT attribute
$(
patsubst fix-%,check-%,
$@
)
..."
echo
"[LINT] Fixing from GIT attribute
$(
patsubst fix-%,check-%,
$@
)
..."
$(
GIT
)
ls-files
$(
LINT.dir
)
-z
\
$(
FILE_LIST
)
\
|
$(
GIT
)
check-attr
--stdin
-z
$(
patsubst fix-%,check-%,
$@
)
\
|
$(
GIT
)
check-attr
--stdin
-z
$(
patsubst fix-%,check-%,
$@
)
\
|
$(
SED
)
-zne
'x;n;n;s/^set$$//;t print;b;:print;x;p'
\
|
$(
SED
)
-zne
'x;n;n;s/^set$$//;t print;b;:print;x;p'
\
|
$(
XARGS
)
-0
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX" $@ || exit 255'
|
$(
XARGS
)
-0
-IXX
sh
-c
'
$(
LINT.make
)
LINT_FILE="XX" $@ || exit 255'
...
...
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