From b36052691e92f2e94a5857a5bd7919d9406e0f90 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Thu, 17 Jun 2021 13:51:41 +0100 Subject: [PATCH] runfvp: pass arbitrary options after -- to the FVP binary To allow passing arbitrary options to the FVP binary, split the passed options on --. Anything before the separator is handled by runfvp, anything afterwards is passed as-is to the FVP binary. Change-Id: I686b2fb79d217e26988753be7bd067c638d69eac Signed-off-by: Ross Burton Signed-off-by: Jon Mason --- scripts/runfvp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/runfvp b/scripts/runfvp index 4ef0bfc6..47612701 100755 --- a/scripts/runfvp +++ b/scripts/runfvp @@ -46,9 +46,18 @@ def runfvp(args): group.add_argument("-c", "--console", action="store_true", help="Attach the first uart to stdin/stdout") parser.add_argument("-C", "--parameter", action="append", default=[], help="Extra configuration parameters for FVP") parser.add_argument("--verbose", action="store_true", help="Output verbose logging") + parser.usage = f"{parser.format_usage().strip()} -- [ arguments passed to FVP ]" # TODO option for telnet vs netcat - args = parser.parse_args() + try: + i = sys.argv.index("--") + arguments = sys.argv[1:i] + fvp_args = sys.argv[i+1:] + except ValueError: + arguments = sys.argv[1:] + fvp_args = [] + + args = parser.parse_args(args=arguments) logging.basicConfig(level=args.verbose and logging.DEBUG or logging.WARNING) logger.debug(f"Parsed arguments are {vars(args)}") @@ -120,10 +129,13 @@ def runfvp(args): cli.extend(config["args"]) - # Finally add the user's extra arguments + # Add any explicit --parameter calls for param in args.parameter: cli.extend(["--parameter", param]) + # Finally add the user's extra arguments + cli.extend(fvp_args) + logger.debug(f"Constructed FVP call: {cli}") if args.console: expected_terminal = config["console"]