Mercurial > lcfOS
diff python/zcc.py @ 377:9667d78ba79e
Switched to xml for project description
author | Windel Bouwman |
---|---|
date | Fri, 11 Apr 2014 15:47:50 +0200 |
parents | 39bf68bf1891 |
children | 6df89163e114 |
line wrap: on
line diff
--- a/python/zcc.py Tue Mar 25 19:36:51 2014 +0100 +++ b/python/zcc.py Fri Apr 11 15:47:50 2014 +0200 @@ -5,8 +5,8 @@ import argparse import logging -from ppci.buildtasks import Compile, Assemble, Link from ppci.tasks import TaskRunner +import ppci.buildtasks from ppci.report import RstFormatter from ppci.objectfile import ObjectFile from ppci.target.target_list import targets, targetnames @@ -27,24 +27,14 @@ parser.add_argument('--log', help='Log level (INFO,DEBUG,[WARN])', type=logLevel, default='INFO') - parser.add_argument('--display-build-steps', action='store_true') parser.add_argument('--report', help='Specify a file to write the compile report to', type=argparse.FileType('w')) - sub_parsers = parser.add_subparsers(title='commands', - description='possible commands', dest='command') - recipe_parser = sub_parsers.add_parser('recipe', help="Bake recipe") - recipe_parser.add_argument('recipe_file', help='recipe file') + parser.add_argument('--buildfile', + help='use buildfile, otherwise build.xml is the default', + default='build.xml') - compile_parser = sub_parsers.add_parser('compile', help="compile source") - compile_parser.add_argument('source', type=argparse.FileType('r'), - help='the source file to build', nargs="+") - compile_parser.add_argument('-i', '--imp', type=argparse.FileType('r'), - help='Possible import module', action='append', default=[]) - compile_parser.add_argument('--target', help="Backend selection", - choices=targetnames, required=True) - compile_parser.add_argument('-o', '--output', help='Output file', - metavar='filename') + parser.add_argument('targets', metavar='target', nargs='*') return parser @@ -61,22 +51,14 @@ fh.setFormatter(RstFormatter()) logging.getLogger().addHandler(fh) + recipe_loader = RecipeLoader() + try: + project = recipe_loader.load_file(args.buildfile) + except OSError as e: + res = 1 + runner = TaskRunner() - if args.command == 'compile': - tg = targets[args.target] - output = ObjectFile() - runner.add_task(Compile(args.source, args.imp, tg, output)) - elif args.command == 'recipe': - recipe_loader = RecipeLoader(runner) - recipe_loader.load_file(args.recipe_file) - else: - raise NotImplementedError('Invalid option') - - if args.display_build_steps: - runner.display() - res = 0 - else: - res = runner.run_tasks() + res = runner.run(project, args.targets) if args.report: logging.getLogger().removeHandler(fh) @@ -89,7 +71,4 @@ if __name__ == '__main__': parser = make_parser() arguments = parser.parse_args() - if not arguments.command: - parser.print_usage() - sys.exit(1) sys.exit(main(arguments))