aboutsummaryrefslogtreecommitdiff
path: root/sim/common
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-07-06 21:18:58 -0400
committerMike Frysinger <vapier@gentoo.org>2021-08-19 21:05:28 -0400
commit082cf6944a66f79014379afe6ea60e82611e5411 (patch)
tree971da2e8dead61c3ad6038b06d516fb7c8a484bc /sim/common
parentf28b723787e28e6aa730f1987b054f46e606f2f5 (diff)
downloadgdb-082cf6944a66f79014379afe6ea60e82611e5411.zip
gdb-082cf6944a66f79014379afe6ea60e82611e5411.tar.gz
gdb-082cf6944a66f79014379afe6ea60e82611e5411.tar.bz2
sim: nltvals: switch output mode to a directory
In preparation for this script generating more files, change the output argument to specify a directory. This drops the stdout behavior, but since no one really runs this tool directly, it's not a big deal.
Diffstat (limited to 'sim/common')
-rwxr-xr-xsim/common/gennltvals.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/sim/common/gennltvals.py b/sim/common/gennltvals.py
index b3e558d..db3ff64 100755
--- a/sim/common/gennltvals.py
+++ b/sim/common/gennltvals.py
@@ -160,7 +160,7 @@ def get_parser() -> argparse.ArgumentParser:
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument(
'-o', '--output', type=Path,
- help='write to the specified file instead of stdout')
+ help='write to the specified directory')
parser.add_argument(
'--cpp', type=str, default='cpp',
help='the preprocessor to use')
@@ -178,8 +178,14 @@ def parse_args(argv: List[str]) -> argparse.Namespace:
parser = get_parser()
opts = parser.parse_args(argv)
+ if opts.output is None:
+ # Default to where the script lives.
+ opts.output = Path(__file__).resolve().parent
+
if opts.srcroot is None:
opts.srcroot = Path(__file__).resolve().parent.parent.parent
+ else:
+ opts.srcroot = opts.srcroot.resolve()
if opts.newlib is None:
# Try to find newlib relative to our source tree.
@@ -202,10 +208,7 @@ def main(argv: List[str]) -> int:
"""The main entry point for scripts."""
opts = parse_args(argv)
- if opts.output is not None:
- output = open(opts.output, 'w', encoding='utf-8')
- else:
- output = sys.stdout
+ output = (opts.output / 'nltvals.def').open('w', encoding='utf-8')
gen(output, opts.newlib, opts.cpp)
return 0