diff python/ppci/buildtasks.py @ 334:6f4753202b9a

Added more recipes
author Windel Bouwman
date Thu, 13 Feb 2014 22:02:08 +0100
parents 87feb8a23b4d
children 582a1aaa3983
line wrap: on
line diff
--- a/python/ppci/buildtasks.py	Sun Feb 09 15:27:57 2014 +0100
+++ b/python/ppci/buildtasks.py	Thu Feb 13 22:02:08 2014 +0100
@@ -12,24 +12,33 @@
 from .transform import CleanPass, RemoveAddZero
 from .tasks import Task
 from . import DiagnosticsManager
-
+from .assembler import Assembler
+from .objectfile import ObjectFile
+from .linker import Linker
+import outstream
 
 class BuildTask(Task):
+    """ Base task for all kind of weird build tasks """
     def __init__(self, name):
         super().__init__(name)
         self.logger = logging.getLogger('buildtask')
 
 
 class Assemble(BuildTask):
-    def __init__(self):
+    """ Task that can runs the assembler over the source and enters the 
+        output into an object file """
+    def __init__(self, source, target, output_object):
         super().__init__('Assemble')
+        self.source = source
+        self.assembler = Assembler(target=target)
+        self.output = output_object
 
     def run(self):
-        pass
+        self.assembler.assemble(self.source)
 
 
 class Compile(BuildTask):
-    """ Task that compiles source to some target """
+    """ Task that compiles C3 source for some target into an object file """
     def __init__(self, sources, includes, target, output_object):
         super().__init__('Compile')
         self.sources = sources
@@ -38,7 +47,7 @@
         self.output = output_object
 
     def run(self):
-        self.logger.info('Zcc started {}'.format(self.sources))
+        self.logger.debug('Compile started')
         diag = DiagnosticsManager()
         c3b = Builder(diag, self.target)
         cg = CodeGenerator(self.target)
@@ -48,7 +57,7 @@
                 return
 
             d = {'ircode':ircode}
-            self.logger.info('Verifying code {}'.format(ircode), extra=d)
+            self.logger.debug('Verifying code {}'.format(ircode), extra=d)
             Verifier().verify(ircode)
 
             # Optimization passes:
@@ -61,23 +70,31 @@
 
             # Code generation:
             d = {'ircode':ircode}
-            self.logger.info('Starting code generation for {}'.format(ircode), extra=d)
-            cg.generate(ircode, self.output)
+            self.logger.debug('Starting code generation for {}'.format(ircode), extra=d)
+            o = outstream.TextOutputStream()
+            cg.generate(ircode, o)
 
-        # TODO: fixup references, do this in another way?
-        self.output.backpatch()
         if not c3b.ok:
             diag.printErrors()
             raise TaskError('Compile errors')
 
 
 class Link(BuildTask):
+    """ Link together a collection of object files """
     def __init__(self, objects, output_file):
         super().__init__('Link')
+        self.objects = objects
+        self.linker = Linker()
+        self.duration = 0.1337
+
+    def run(self):
+        print('LNK')
+        print('LNK', self.objects)
+        print('LNK')
+        print('LNK')
+        self.linker.link(self.objects)
 
 
 class ObjCopy(Task):
     pass
 
-
-