Skip to content
Snippets Groups Projects
Commit df736be7 authored by Virgile Prevosto's avatar Virgile Prevosto Committed by Andre Maroneze
Browse files

lint

parent bc6b2c77
No related branches found
No related tags found
No related merge requests found
...@@ -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")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment