Commit 7d7aad4b authored by Tristan Gingold's avatar Tristan Gingold

__main__: add a top-level function to support a testsuite.

parent 81895179
...@@ -32,7 +32,7 @@ from .module_pool import ModulePool ...@@ -32,7 +32,7 @@ from .module_pool import ModulePool
from ._version import __version__ from ._version import __version__
def main(): def hdlmake(args):
"""This is the main function, where HDLMake starts. """This is the main function, where HDLMake starts.
Here, we make the next processes: Here, we make the next processes:
-- parse command -- parse command
...@@ -48,7 +48,7 @@ def main(): ...@@ -48,7 +48,7 @@ def main():
# #
# PARSE & GET OPTIONS # PARSE & GET OPTIONS
# #
options = _get_options(sys, parser) options = _get_options(args, parser)
# Create a ModulePool object, this will become our workspace # Create a ModulePool object, this will become our workspace
modules_pool = ModulePool(options) modules_pool = ModulePool(options)
...@@ -62,7 +62,6 @@ def _action_runner(modules_pool): ...@@ -62,7 +62,6 @@ def _action_runner(modules_pool):
options = modules_pool.options options = modules_pool.options
if options.command == "manifest-help": if options.command == "manifest-help":
ManifestParser().print_help() ManifestParser().print_help()
quit(0)
elif options.command == "makefile": elif options.command == "makefile":
modules_pool.makefile() modules_pool.makefile()
elif options.command == "fetch": elif options.command == "fetch":
...@@ -190,18 +189,22 @@ def _get_parser(): ...@@ -190,18 +189,22 @@ def _get_parser():
return parser return parser
def _get_options(sys_aux, parser): def _get_options(args, parser):
"""Function that decodes and set the provided command user options""" """Function that decodes and set the provided command user options"""
options = None options = None
if len(sys_aux.argv[1:]) == 0: if len(args) == 0:
options = parser.parse_args(['makefile']) options = parser.parse_args(['makefile'])
elif len(sys_aux.argv[1:]) == 2 and ( elif len(args) == 2 and (
sys_aux.argv[1] == '-f' or sys_aux.argv[1] == '--filename'): args[0] == '-f' or args[0] == '--filename'):
options = parser.parse_args(['makefile'] + sys_aux.argv[1:]) options = parser.parse_args(['makefile'] + args)
else: else:
options = parser.parse_args(sys_aux.argv[1:]) options = parser.parse_args(args)
return options return options
def main():
"""Entry point used by the executable"""
hdlmake(sys.argv[1:])
if __name__ == "__main__": if __name__ == "__main__":
main() main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment