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
df736be7
Commit
df736be7
authored
2 years ago
by
Virgile Prevosto
Committed by
Andre Maroneze
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
lint
parent
bc6b2c77
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/machdeps/make_machdep/make_machdep.py
+16
-9
16 additions, 9 deletions
share/machdeps/make_machdep/make_machdep.py
with
16 additions
and
9 deletions
share/machdeps/make_machdep/make_machdep.py
+
16
−
9
View file @
df736be7
...
@@ -151,6 +151,7 @@ def print_machdep(machdep):
...
@@ -151,6 +151,7 @@ def print_machdep(machdep):
args
.
dest_file
=
sys
.
stdout
args
.
dest_file
=
sys
.
stdout
yaml
.
dump
(
machdep
,
args
.
dest_file
,
indent
=
4
,
sort_keys
=
True
)
yaml
.
dump
(
machdep
,
args
.
dest_file
,
indent
=
4
,
sort_keys
=
True
)
def
make_machdep
():
def
make_machdep
():
machdep
=
{}
machdep
=
{}
for
key
in
schema
.
keys
():
for
key
in
schema
.
keys
():
...
@@ -238,7 +239,7 @@ def find_value(name, typ, output):
...
@@ -238,7 +239,7 @@ def find_value(name, typ, output):
def
conversion
(
x
):
def
conversion
(
x
):
return
x
return
x
default
=
''
default
=
""
else
:
else
:
warnings
.
warn
(
f
"
unexpected type
'
{
typ
}
'
for field
'
{
name
}
'
, skipping
"
)
warnings
.
warn
(
f
"
unexpected type
'
{
typ
}
'
for field
'
{
name
}
'
, skipping
"
)
...
@@ -349,22 +350,27 @@ machdep["custom_defs"] = ""
...
@@ -349,22 +350,27 @@ machdep["custom_defs"] = ""
# in case we have all the predefined macros, custom_defs will be very long.
# in case we have all the predefined macros, custom_defs will be very long.
# we thus want to output it as a literal block, not a simple string.
# we thus want to output it as a literal block, not a simple string.
# For that, use a custom object and tell PyYaml to output it in a particular way
# For that, use a custom object and tell PyYaml to output it in a particular way
# Based on SO's answer:
# Based on SO's answer:
class
custom_defs
(
str
):
pass
class
custom_defs
(
str
):
pass
def
change_style
(
style
,
representer
):
def
change_style
(
style
,
representer
):
def
new_representer
(
dumper
,
data
):
def
new_representer
(
dumper
,
data
):
scalar
=
representer
(
dumper
,
data
)
scalar
=
representer
(
dumper
,
data
)
scalar
.
style
=
style
scalar
.
style
=
style
return
scalar
return
scalar
return
new_representer
return
new_representer
from
yaml.representer
import
Representer
from
yaml.representer
import
Representer
custom_defs_representer
=
change_style
(
'
|
'
,
Representer
.
represent_str
)
custom_defs_representer
=
change_style
(
"
|
"
,
Representer
.
represent_str
)
yaml
.
add_representer
(
custom_defs
,
custom_defs_representer
)
yaml
.
add_representer
(
custom_defs
,
custom_defs_representer
)
cmd
=
compilation_command
+
[
"
-dM
"
,
"
-E
"
,
"
-
"
]
cmd
=
compilation_command
+
[
"
-dM
"
,
"
-E
"
,
"
-
"
]
if
args
.
verbose
:
if
args
.
verbose
:
...
@@ -375,11 +381,12 @@ if proc.returncode == 0:
...
@@ -375,11 +381,12 @@ if proc.returncode == 0:
for
line
in
proc
.
stdout
.
splitlines
():
for
line
in
proc
.
stdout
.
splitlines
():
# Preprocessor emits a warning if we're trying to #undef
# Preprocessor emits a warning if we're trying to #undef
# standard macros. Leave them alone.
# standard macros. Leave them alone.
if
re
.
match
(
r
"
#define *__STDC
"
,
line
):
continue
if
re
.
match
(
r
"
#define *__STDC
"
,
line
):
macro
=
re
.
match
(
r
"
#define *(\w+)
"
,
line
)
continue
macro
=
re
.
match
(
r
"
#define *(\w+)
"
,
line
)
if
macro
:
if
macro
:
lines
+=
f
"
#undef
{
macro
.
group
(
1
)
}
\n
"
lines
+=
f
"
#undef
{
macro
.
group
(
1
)
}
\n
"
lines
+=
f
"
{
line
.
strip
()
}
\n
"
lines
+=
f
"
{
line
.
strip
()
}
\n
"
machdep
[
"
custom_defs
"
]
=
custom_defs
(
lines
)
machdep
[
"
custom_defs
"
]
=
custom_defs
(
lines
)
else
:
else
:
warnings
.
warn
(
f
"
could not determine predefined macros
"
)
warnings
.
warn
(
f
"
could not determine predefined macros
"
)
...
...
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