Mercurial > lcfOS
comparison python/ppci/buildtasks.py @ 385:d056b552d3f4
Made better use of layout
author | Windel Bouwman |
---|---|
date | Thu, 01 May 2014 14:03:12 +0200 |
parents | 173e20a47fda |
children | 6ae782a085e0 |
comparison
equal
deleted
inserted
replaced
384:94f5b719ad0b | 385:d056b552d3f4 |
---|---|
5 """ | 5 """ |
6 | 6 |
7 import logging | 7 import logging |
8 | 8 |
9 from .tasks import Task, TaskError, register_task | 9 from .tasks import Task, TaskError, register_task |
10 from .buildfunctions import c3compile, link, assemble | 10 from .buildfunctions import c3compile, link, assemble, fix_object |
11 from pyyacc import ParserException | 11 from pyyacc import ParserException |
12 from . import CompilerError | 12 from . import CompilerError |
13 | 13 |
14 | 14 |
15 @register_task("empty") | 15 @register_task("empty") |
80 @register_task("link") | 80 @register_task("link") |
81 class LinkTask(Task): | 81 class LinkTask(Task): |
82 """ Link together a collection of object files """ | 82 """ Link together a collection of object files """ |
83 def run(self): | 83 def run(self): |
84 layout = self.relpath(self.get_argument('layout')) | 84 layout = self.relpath(self.get_argument('layout')) |
85 target = self.get_argument('target') | |
85 objects = self.open_file_set(self.get_argument('objects')) | 86 objects = self.open_file_set(self.get_argument('objects')) |
86 output_file = self.relpath(self.get_argument('output')) | 87 output_filename = self.relpath(self.get_argument('output')) |
87 | 88 |
88 try: | 89 try: |
89 output_obj = link(objects, layout) | 90 output_obj = link(objects, layout, target) |
90 except CompilerError as e: | 91 except CompilerError as e: |
91 raise TaskError(e.msg) | 92 raise TaskError(e.msg) |
92 # TODO: use layout here: | 93 |
93 code = output_obj.get_section('code').data | 94 # Store output: |
94 with open(output_file, 'wb') as f: | 95 with open(output_filename, 'w') as f: |
95 f.write(code) | 96 output_obj.save(f) |
96 | 97 |
97 | 98 |
99 @register_task("objcopy") | |
98 class ObjCopyTask(Task): | 100 class ObjCopyTask(Task): |
99 def run(self): | 101 def run(self): |
100 pass | 102 image_name = self.get_argument('imagename') |
103 output_filename = self.relpath(self.get_argument('output')) | |
104 object_filename = self.relpath(self.get_argument('objectfile')) | |
101 | 105 |
106 obj = fix_object(object_filename) | |
107 image = obj.get_image(image_name) | |
108 with open(output_filename, 'wb') as f: | |
109 f.write(image) | |
110 |