diff python/ppci/buildtasks.py @ 331:a78b41ff6ad2

Added better recipe files
author Windel Bouwman
date Fri, 07 Feb 2014 12:39:59 +0100
parents 8f6f3ace4e78
children 87feb8a23b4d
line wrap: on
line diff
--- a/python/ppci/buildtasks.py	Fri Feb 07 12:08:40 2014 +0100
+++ b/python/ppci/buildtasks.py	Fri Feb 07 12:39:59 2014 +0100
@@ -14,7 +14,13 @@
 from . import DiagnosticsManager
 
 
-class Assemble(Task):
+class BuildTask(Task):
+    def __init__(self, name):
+        super().__init__(name)
+        self.logger = logging.getLogger('buildtask')
+
+
+class Assemble(BuildTask):
     def __init__(self):
         super().__init__('Assemble')
 
@@ -22,7 +28,7 @@
         pass
 
 
-class Compile(Task):
+class Compile(BuildTask):
     """ Task that compiles source to some target """
     def __init__(self, sources, includes, target, output_object):
         super().__init__('Compile')
@@ -32,8 +38,7 @@
         self.output = output_object
 
     def run(self):
-        logger = logging.getLogger('zcc')
-        logger.info('Zcc started {}'.format(self.sources))
+        self.logger.info('Zcc started {}'.format(self.sources))
         diag = DiagnosticsManager()
         c3b = Builder(diag, self.target)
         cg = CodeGenerator(self.target)
@@ -43,7 +48,7 @@
                 return
 
             d = {'ircode':ircode}
-            logger.info('Verifying code {}'.format(ircode), extra=d)
+            self.logger.info('Verifying code {}'.format(ircode), extra=d)
             Verifier().verify(ircode)
 
             # Optimization passes:
@@ -56,7 +61,7 @@
 
             # Code generation:
             d = {'ircode':ircode}
-            logger.info('Starting code generation for {}'.format(ircode), extra=d)
+            self.logger.info('Starting code generation for {}'.format(ircode), extra=d)
             cg.generate(ircode, self.output)
 
         # TODO: fixup references, do this in another way?
@@ -66,7 +71,7 @@
             raise TaskError('Compile errors')
 
 
-class Link(Task):
+class Link(BuildTask):
     def __init__(self, objects, output_file):
         super().__init__('Link')
 
@@ -75,11 +80,13 @@
     pass
 
 
-def load_recipe(recipe, runner):
+def load_recipe(recipe_file, runner):
     """ Loads a recipe dictionary into a task runner """
-    if 'compile' in recipe:
-        #sources =
-        runner.add_task(Compile())
-    else:
-        raise Exception()
+    for command, value in recipe:
+        if command == 'compile':
+            sources = value['']
+            target = value['target']
+            runner.add_task(Compile())
+        else:
+            raise Exception()