Mercurial > lcfOS
diff python/zcc.py @ 342:86b02c98a717 devel
Moved target directory
author | Windel Bouwman |
---|---|
date | Sat, 01 Mar 2014 15:40:31 +0100 |
parents | d1ecc493384e |
children | 442fb043d149 |
line wrap: on
line diff
--- a/python/zcc.py Fri Feb 28 18:07:14 2014 +0100 +++ b/python/zcc.py Sat Mar 01 15:40:31 2014 +0100 @@ -4,13 +4,13 @@ import os import argparse import logging -import yaml from ppci.buildtasks import Compile, Assemble, Link from ppci.tasks import TaskRunner from ppci.report import RstFormatter from ppci.objectfile import ObjectFile -from target.target_list import target_list +from ppci.target.target_list import target_list +from ppci.recipe import RecipeLoader import ppci @@ -51,64 +51,6 @@ return parser -class RecipeLoader: - """ Loads a recipe into a runner from a dictionary or file """ - def __init__(self): - self.directive_handlers = {} - for a in dir(self): - if a.startswith('handle_'): - f = getattr(self, a) - self.directive_handlers[a[7:]] = f - - def load_file(self, recipe_file, runner): - """ Loads a recipe dictionary into a task runner """ - self.recipe_dir = os.path.abspath(os.path.dirname(recipe_file)) - with open(recipe_file, 'r') as f: - recipe = yaml.load(f) - self.runner = runner - self.load_dict(recipe) - - def relpath(self, filename): - return os.path.join(self.recipe_dir, filename) - - def openfile(self, filename): - return open(self.relpath(filename), 'r') - - def handle_compile(self, value): - sources = [self.openfile(s) for s in value['sources']] - includes = [self.openfile(i) for i in value['includes']] - target = targets[value['machine']] - output = ObjectFile() - task = Compile(sources, includes, target, output) - self.runner.add_task(task) - return task - - def handle_assemble(self, value): - asm_src = self.openfile(value['source']) - target = targets[value['machine']] - output = ObjectFile() - task = Assemble(asm_src, target, output) - self.runner.add_task(task) - return task - - def handle_link(self, value): - inputs = value['inputs'] - objs = [] - for i in inputs: - task = self.load_dict(i) - objs.append(task.output) - layout = value['layout'] - output = self.relpath(value['output']) - self.runner.add_task(Link(objs, layout, output)) - - def handle_apps(self, value): - for a in value: - self.load_dict(a) - - def load_dict(self, recipe): - for command, value in recipe.items(): - return self.directive_handlers[command](value) - def main(args): # Configure some logging: