Files
revng-revng/python/revng/cli/revng.py
T
Alessandro Di Federico af6305725d Rewrite revng driver infrastructure
It really needed some fresh air.
2022-03-17 16:46:00 +01:00

40 lines
1.4 KiB
Python
Executable File

import sys
import os
from .commands_registry import commands_registry, Options
from .support import collect_files
def run_revng_command(arguments, options: Options):
# Import built-in commands
from .lift import LiftCommand
from .translate import TranslateCommand
from .opt import IROptCommand
from .pipeline import PipelineCommand
if options.verbose:
sys.stderr.write("{}\n\n".format(" \\\n ".join([sys.argv[0]] + arguments)))
# Collect search prefixes
prefixes = []
for arg, next_arg in zip(arguments, arguments[1:] + [""]):
if arg.startswith("--prefix="):
prefixes += arg[len("--prefix=") :]
elif arg == "--prefix" and next_arg != "":
prefixes += next_arg
script_path = os.path.dirname(os.path.realpath(__file__))
options.search_prefixes = prefixes + [os.path.join(script_path, "..", "..", "..", "..")]
# Register external commands
prefix = "revng-"
for executable in collect_files(options.search_prefixes, ["libexec", "revng"], f"{prefix}*"):
name = os.path.basename(executable)[len(prefix) :]
if not commands_registry.has_command(name):
commands_registry.register_external_command(name, executable)
return commands_registry.run(arguments, options)
def main():
return run_revng_command(sys.argv[1:], Options(None, [], [], [], False))