mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
revng driver: introduce --dry-run
This commit is contained in:
@@ -42,6 +42,9 @@ class CommandsRegistry:
|
||||
def __init__(self):
|
||||
parser = argparse.ArgumentParser(description="revng driver.")
|
||||
parser.add_argument("--version", action="store_true", help="Display version information.")
|
||||
parser.add_argument(
|
||||
"--dry-run", action="store_true", help="Do not execute any external command."
|
||||
)
|
||||
parser.add_argument("--verbose", action="store_true", help="Log all executed commands.")
|
||||
parser.add_argument(
|
||||
"--perf", action="store_true", help="Run programs under perf (for use with hotspot)."
|
||||
@@ -88,6 +91,8 @@ class CommandsRegistry:
|
||||
options.remaining_args = rest
|
||||
if not options.verbose:
|
||||
options.verbose = args.verbose
|
||||
if not options.dry_run:
|
||||
options.dry_run = args.dry_run
|
||||
|
||||
if len(options.command_prefix) == 0:
|
||||
assert (args.gdb + args.lldb + args.valgrind + args.callgrind) <= 1
|
||||
|
||||
@@ -16,6 +16,9 @@ def run_revng_command(arguments, options: Options):
|
||||
if options.verbose:
|
||||
sys.stderr.write("{}\n\n".format(" \\\n ".join([sys.argv[0]] + arguments)))
|
||||
|
||||
if options.dry_run:
|
||||
return 0
|
||||
|
||||
# Collect search prefixes
|
||||
prefixes = []
|
||||
for arg, next_arg in zip(arguments, arguments[1:] + [""]):
|
||||
@@ -37,4 +40,4 @@ def run_revng_command(arguments, options: Options):
|
||||
|
||||
|
||||
def main():
|
||||
return run_revng_command(sys.argv[1:], Options(None, [], [], [], False))
|
||||
return run_revng_command(sys.argv[1:], Options(None, [], [], [], False, False))
|
||||
|
||||
@@ -25,6 +25,7 @@ class Options:
|
||||
search_prefixes: List[str]
|
||||
command_prefix: List[str]
|
||||
verbose: bool
|
||||
dry_run: bool
|
||||
|
||||
|
||||
def shlex_join(split_command):
|
||||
@@ -55,6 +56,9 @@ def run(command, options: Options):
|
||||
program_path = relative(command[0])
|
||||
sys.stderr.write("{}\n\n".format(" \\\n ".join([program_path] + command[1:])))
|
||||
|
||||
if options.dry_run:
|
||||
return 0
|
||||
|
||||
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
||||
environment = dict(os.environ)
|
||||
p = subprocess.Popen(
|
||||
|
||||
Reference in New Issue
Block a user