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
129f21cd
Commit
129f21cd
authored
4 years ago
by
Andre Maroneze
Browse files
Options
Downloads
Patches
Plain Diff
[Analysis-scripts] fix and update normalize-jcdb
parent
49eaa67c
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+2
-0
2 additions, 0 deletions
Makefile
bin/frama-c-script
+1
-33
1 addition, 33 deletions
bin/frama-c-script
headers/header_spec.txt
+1
-0
1 addition, 0 deletions
headers/header_spec.txt
share/analysis-scripts/normalize_jcdb.py
+79
-0
79 additions, 0 deletions
share/analysis-scripts/normalize_jcdb.py
with
83 additions
and
33 deletions
Makefile
+
2
−
0
View file @
129f21cd
...
...
@@ -270,6 +270,7 @@ DISTRIB_FILES:=\
share/analysis-scripts/list_files.py
\
share/analysis-scripts/make_template.py
\
share/analysis-scripts/make_wrapper.py
\
share/analysis-scripts/normalize_jcdb.py
\
share/analysis-scripts/parse-coverage.sh
\
share/analysis-scripts/prologue.mk
\
share/analysis-scripts/README.md
\
...
...
@@ -1955,6 +1956,7 @@ install:: install-lib-$(OCAMLBEST)
share/analysis-scripts/list_files.py
\
share/analysis-scripts/make_template.py
\
share/analysis-scripts/make_wrapper.py
\
share/analysis-scripts/normalize_jcdb.py
\
share/analysis-scripts/parse-coverage.sh
\
share/analysis-scripts/prologue.mk
\
share/analysis-scripts/README.md
\
...
...
This diff is collapsed.
Click to expand it.
bin/frama-c-script
+
1
−
33
View file @
129f21cd
...
...
@@ -208,38 +208,6 @@ configure_for_frama_c() {
CPP="gcc -E -nostdinc -fno-builtin -I${FRAMAC_SHARE}/libc -D__FC_MACHDEP_${MACHDEP}" ./configure "$@"
}
normalize_jcdb() {
path=""
if [ "$#" -eq 0 ]; then
path="./compile_commands.json"
else
path="$1"
fi
if [ ! -e "$path" ]; then
echo "error: cannot find file: $path";
exit 1
fi
sed "s|$PWD/||g" "$path" > "${path}.tmp"
cmp -s "$path" "${path}.tmp"
if [ $? -eq 0 ]; then
echo "No changes to be applied to $path"
rm "${path}.tmp"
else
echo "Differences to be applied to $path:"
diff -u0 "$path" "${path}.tmp"
read -p "Normalize $path? [y/N] " yn
case $yn in
[Yy])
mv "${path}.tmp" "$path"
echo "Normalization applied to $path"
;;
*)
echo "Exiting without overwriting."
exit 0;;
esac
fi
}
case "$command" in
"help" | "-help" | "--help" | "-h")
usage 0;
...
...
@@ -279,7 +247,7 @@ case "$command" in
;;
"normalize-jcdb")
shift;
normalize_jcdb "$@";
${FRAMAC_SHARE}/analysis-scripts/
normalize_jcdb
.py
"$@";
;;
*)
echo "error: unrecognized command: $command";
...
...
This diff is collapsed.
Click to expand it.
headers/header_spec.txt
+
1
−
0
View file @
129f21cd
...
...
@@ -127,6 +127,7 @@ share/analysis-scripts/git_utils.py: .ignore
share/analysis-scripts/list_files.py: .ignore
share/analysis-scripts/make_template.py: .ignore
share/analysis-scripts/make_wrapper.py: .ignore
share/analysis-scripts/normalize_jcdb.py: .ignore
share/analysis-scripts/parse-coverage.sh: .ignore
share/analysis-scripts/prologue.mk: CEA_LGPL
share/analysis-scripts/README.md: .ignore
...
...
This diff is collapsed.
Click to expand it.
share/analysis-scripts/normalize_jcdb.py
0 → 100755
+
79
−
0
View file @
129f21cd
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
##########################################################################
# #
# This file is part of Frama-C. #
# #
# Copyright (C) 2007-2020 #
# CEA (Commissariat à l'énergie atomique et aux énergies #
# alternatives) #
# #
# you can redistribute it and/or modify it under the terms of the GNU #
# Lesser General Public License as published by the Free Software #
# Foundation, version 2.1. #
# #
# It is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. #
# #
# See the GNU Lesser General Public License version 2.1 #
# for more details (enclosed in the file licenses/LGPLv2.1). #
# #
##########################################################################
# This script removes absolute path references in a JSON Compilation Database.
#
# See: http://clang.llvm.org/docs/JSONCompilationDatabase.html
import
sys
import
os
import
json
import
re
from
pathlib
import
Path
MIN_PYTHON
=
(
3
,
6
)
# for automatic Path conversions
if
sys
.
version_info
<
MIN_PYTHON
:
sys
.
exit
(
"
Python %s.%s or later is required.
\n
"
%
MIN_PYTHON
)
if
len
(
sys
.
argv
)
<
2
:
# no argument, assume default name
arg
=
Path
(
"
compile_commands.json
"
)
else
:
arg
=
Path
(
sys
.
argv
[
1
])
if
not
arg
.
exists
():
print
(
f
"
error: file
'
{
arg
}
'
not found
"
)
sys
.
exit
(
f
"
usage:
{
sys
.
argv
[
0
]
}
[compile_commands.json]
"
)
jcdb_json
=
json
.
loads
(
open
(
arg
).
read
())
jcdb_dir
=
arg
.
parent
out_json
=
{}
nb_diffs
=
0
for
entry
in
jcdb_json
:
if
"
file
"
in
entry
and
os
.
path
.
isabs
(
entry
[
"
file
"
]):
old_entry
=
entry
[
"
file
"
]
entry
[
"
file
"
]
=
os
.
path
.
relpath
(
entry
[
"
file
"
],
jcdb_dir
)
if
old_entry
!=
entry
[
"
file
"
]:
nb_diffs
+=
1
else
:
print
(
f
"
warning: absolute path could not be normalized:
{
entry
[
'
file
'
]
}
"
)
elif
"
directory
"
in
entry
and
os
.
path
.
isabs
(
entry
[
"
directory
"
]):
old_entry
=
entry
[
"
directory
"
]
entry
[
"
directory
"
]
=
os
.
path
.
relpath
(
entry
[
"
directory
"
],
jcdb_dir
)
if
old_entry
!=
entry
[
"
directory
"
]:
nb_diffs
+=
1
else
:
print
(
f
"
warning: absolute path could not be normalized:
{
entry
[
'
directory
'
]
}
"
)
if
nb_diffs
==
0
:
print
(
f
"
No changes to be applied to
{
arg
}
"
)
else
:
yn
=
input
(
f
"
{
nb_diffs
}
replacements to be applied. Normalize
{
arg
}
? [y/N]
"
)
if
yn
.
lower
()
==
"
y
"
:
with
open
(
arg
,
'
w
'
,
encoding
=
'
utf-8
'
)
as
outfile
:
json
.
dump
(
jcdb_json
,
outfile
,
ensure_ascii
=
False
,
indent
=
4
)
print
(
f
"
Normalization applied to
{
arg
}
"
)
else
:
print
(
"
Exiting without overwriting.
"
)
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