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
78d54196
Commit
78d54196
authored
2 years ago
by
Patrick Baudin
Browse files
Options
Downloads
Patches
Plain Diff
[Headers] adds targets related to commits
parent
343a7815
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.headers
+82
-0
82 additions, 0 deletions
share/Makefile.headers
with
82 additions
and
0 deletions
share/Makefile.headers
+
82
−
0
View file @
78d54196
...
...
@@ -204,6 +204,88 @@ headers: $(FRAMAC_HDRCK)
$(
error
"Please set HEADER_SPEC variable to a file containing the header specification."
)
else
ifneq
($(HDRCK.HAS_GIT),)
define
HDRCK.file-list-from-git-diff
$(GIT)
diff
--name-status
$(1)
|
$(GREP)
-v
"^D"
|
$(SED)
"s/^.[ \t]*//"
|
$(TR)
'\n'
'\000'
|
$(HDRCK.FILE_ATTR)
endef
HDRCK.main-targets
=
check-headers headers
define
HDRCK.file-list-filter-with-git-diff
HDRCK.$(1)-filter-targets
=
$$(
addsuffix .
$(
1
)
,
$$(
HDRCK.main-targets
))
.PHONY
:
$(LINT.$(1)-filter-targets)
$$(HDRCK.$(1)-filter-targets)
::
HDRCK.SPEC=$$(call HDRCK.file-list-from-git-diff
,
$(2))
$$(HDRCK.$(1)-filter-targets)
::
%.$(1) : $(3) %
@
echo
[
HDRCK] Done:
HDRCK_DIFF
=
\"
$(
2
)
\"
make
$$(
basename
$$
@
)
@
echo
[
HDRCK] checked file list:
$$(
GIT
)
diff
--name-status
$(
2
)
endef
ifneq
($(HEADER_DIFF),)
$(info [HDRCK] Looking at files modified from branch/commit
:
'$(HEADER_DIFF)')
HDRCK.SPEC
=
$(
call LINT.file-list-from-git-diff,
$(
HEADER_DIFF
))
$(info
$(HEADER.FILE_LIST))
endif
# $(HEADER_DIFF)
#### rules for make <headers-target>.before-push
## looks at files modified from origin/$(git branch --show-current) and checks that there is no staged nor unstaged files
PHONY
:
HDRCK.checked-unmodified-ok
HDRCK.checked-unmodified-ok
:
$(
eval
HDRCK.checked-unmodified :
=
$(
shell
$(
GIT
)
diff
--name-status
HEAD |
$(
WC
)
-l
))
if
[
0
!=
$(
HDRCK.checked-unmodified
)
]
;
then
\
echo
"[HDRCK] Staged or unstaged files=
$(
HDRCK.checked-unmodified
)
:"
;
\
$(
GIT
)
diff
--name-status
HEAD
;
\
echo
"[HDRCK] Error: may check some staged or unstaged file versions"
;
\
exit
1
;
\
fi
;
$(
eval
$(
call HDRCK.file-list-filter-with-git-diff,before-push,--cached origin/
$(
shell git branch
--show-current
)
,HDRCK.checked-unmodified-ok
))
#### rules for make <headers-target>.unstaged
## looks at unstaged files
$(
eval
$(
call HDRCK.file-list-filter-with-git-diff,unstaged,
))
#### rules for make <headers-target>.before-commit
## looks at staged files and checks that there is no unstaged files
PHONY
:
HDRCK.checked-unstaged-ok
HDRCK.checked-unstaged-ok
:
$(
eval
HDRCK.checked-unstaged :
=
$(
shell
$(
GIT
)
diff
--name-status
|
$(
WC
)
-l
))
if
[
0
!=
$(
HDRCK.checked-unstaged
)
]
;
then
\
echo
"[HDRCK] Unstaged files=
$(
HDRCK.checked-unstaged
)
:"
;
\
$(
GIT
)
diff
--name-status
;
\
echo
"[HDRCK] Error: may check some unstaged version files version."
;
\
exit
1
;
\
fi
;
$(
eval
$(
call HDRCK.file-list-filter-with-git-diff,before-commit,--cached HEAD,HDRCK.checked-unstaged-ok
))
#### rules for make <headers-target>.before-commit-a
## looks at unstaged and staged files
$(
eval
$(
call HDRCK.file-list-filter-with-git-diff,before-commit-a,HEAD,
))
#### rules for make <headers-target>.before-commit-a--ammend
## looks at unstaged, staged and previously committed files
$(
eval
$(
call HDRCK.file-list-filter-with-git-diff,before-commit-a--ammend,HEAD~1,
))
#### rules for make <headers-target>.before-commit--amend
## looks at staged and previously committed files and checks that there is no unstaged files
$(
eval
$(
call HDRCK.file-list-filter-with-git-diff,before-commit--ammend,HEAD~1,HDRCK.checked-unstaged-ok
))
#### rules for make <headers-target>.previous-commit
## looks at files of the last commit and checks that there is no staged nor unstaged files
$(
eval
$(
call HDRCK.file-list-filter-with-git-diff,previous-commit,HEAD~1,HDRCK.checked-unmodified-ok
))
endif
# $(HDRCK.HAS_GIT)
.PHONY
:
check-headers
check-headers
:
$(FRAMAC_HDRCK)
$(
HDRCK.SPEC
)
|
$(
HDRCK.CMD
)
$(
HDRCK.OPTS
)
$(
HDRCK_EXTRA
)
...
...
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