comparison python/ppci/buildtasks.py @ 336:d1ecc493384e

Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
author Windel Bouwman
date Wed, 19 Feb 2014 22:32:15 +0100
parents 582a1aaa3983
children b00219172a42
comparison
equal deleted inserted replaced
335:582a1aaa3983 336:d1ecc493384e
29 """ Task that can runs the assembler over the source and enters the 29 """ Task that can runs the assembler over the source and enters the
30 output into an object file """ 30 output into an object file """
31 def __init__(self, source, target, output_object): 31 def __init__(self, source, target, output_object):
32 super().__init__('Assemble') 32 super().__init__('Assemble')
33 self.source = source 33 self.source = source
34 self.assembler = Assembler(target=target)
35 self.output = output_object 34 self.output = output_object
35 self.ostream = outstream.BinaryOutputStream(self.output)
36 self.assembler = Assembler(target, self.ostream)
36 37
37 def run(self): 38 def run(self):
39 self.ostream.selectSection('code')
38 self.assembler.assemble(self.source) 40 self.assembler.assemble(self.source)
39 41
40 42
41 class Compile(BuildTask): 43 class Compile(BuildTask):
42 """ Task that compiles C3 source for some target into an object file """ 44 """ Task that compiles C3 source for some target into an object file """
80 raise TaskError('Compile errors') 82 raise TaskError('Compile errors')
81 83
82 84
83 class Link(BuildTask): 85 class Link(BuildTask):
84 """ Link together a collection of object files """ 86 """ Link together a collection of object files """
85 def __init__(self, objects, output_file): 87 def __init__(self, objects, layout, output_file):
86 super().__init__('Link') 88 super().__init__('Link')
87 self.objects = objects 89 self.objects = objects
88 self.linker = Linker() 90 self.linker = Linker()
89 self.duration = 0.1337 91 self.duration = 0.1337
92 self.layout = layout
93 self.output_file = output_file
90 94
91 def run(self): 95 def run(self):
92 self.linker.link(self.objects) 96 output_obj = self.linker.link(self.objects, self.layout)
97 code = output_obj.get_section('code').data
98 with open(self.output_file, 'wb') as f:
99 f.write(code)
93 100
94 101
95 class ObjCopy(Task): 102 class ObjCopy(BuildTask):
96 pass 103 def __init__(self, objects, output_file):
104 super().__init__('ObjCopy')
97 105