Skip to content
Snippets Groups Projects
Commit 6bd10f15 authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[machdep] minor improvements to generator

- fix f-string as reported by @maroneze
- --verbose is now reflected in `logging` level as well.
parent 63a318ae
No related branches found
No related tags found
No related merge requests found
...@@ -49,8 +49,6 @@ from yaml.representer import Representer ...@@ -49,8 +49,6 @@ from yaml.representer import Representer
my_path = Path(sys.argv[0]).parent my_path = Path(sys.argv[0]).parent
logging.basicConfig(format="%(levelname)s: %(message)s")
parser = argparse.ArgumentParser(prog="make_machdep") parser = argparse.ArgumentParser(prog="make_machdep")
parser.add_argument("-v", "--verbose", action="store_true") parser.add_argument("-v", "--verbose", action="store_true")
parser.add_argument("-o", type=argparse.FileType("w"), dest="dest_file") parser.add_argument("-o", type=argparse.FileType("w"), dest="dest_file")
...@@ -104,6 +102,11 @@ parser.add_argument( ...@@ -104,6 +102,11 @@ parser.add_argument(
args, other_args = parser.parse_known_args() args, other_args = parser.parse_known_args()
if args.verbose:
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.INFO)
else:
logging.basicConfig(format="%(levelname)s: %(message)s")
if not args.compiler_flags: if not args.compiler_flags:
args.compiler_flags = ["-c"] args.compiler_flags = ["-c"]
...@@ -347,7 +350,7 @@ for f, typ in source_files: ...@@ -347,7 +350,7 @@ for f, typ in source_files:
name = p.stem name = p.stem
if proc.returncode != 0: if proc.returncode != 0:
logging.warning( logging.warning(
f"error in preprocessing value '{p}', some value might not be filled\ncompiler output is:{proc.stderr.decode()}" f"error in preprocessing value '{p}', some values might not be filled\ncompiler output is:{proc.stderr.decode()}"
) )
if name in machdep: if name in machdep:
machdep[name] = {} machdep[name] = {}
...@@ -419,7 +422,7 @@ if proc.returncode == 0: ...@@ -419,7 +422,7 @@ if proc.returncode == 0:
lines += f"{line.strip()}\n" lines += f"{line.strip()}\n"
machdep["custom_defs"] = custom_defs(lines) machdep["custom_defs"] = custom_defs(lines)
else: else:
logging.warning("could not determine predefined macros. compiler output is:\n{proc.stderr}") logging.warning(f"could not determine predefined macros. compiler output is:\n{proc.stderr}")
if args.from_file and args.in_place: if args.from_file and args.in_place:
machdep["machdep_name"] = Path(args.from_file).stem machdep["machdep_name"] = Path(args.from_file).stem
......
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