|
7 | 7 | from argparse import ArgumentParser |
8 | 8 | from os import path |
9 | 9 |
|
10 | | -from tools.paths import EXPORT_DIR, EXPORT_WORKSPACE, EXPORT_TMP |
11 | | -from tools.paths import MBED_BASE, MBED_LIBRARIES |
12 | | -from tools.export import export, setup_user_prj, EXPORTERS, mcu_ide_matrix |
13 | | -from tools.utils import args_error, mkdir |
14 | | -from tools.tests import TESTS, Test, TEST_MAP |
| 10 | +from tools.paths import EXPORT_DIR |
| 11 | +from tools.export import export, EXPORTERS, mcu_ide_matrix |
| 12 | +from tools.tests import TESTS, TEST_MAP |
15 | 13 | from tools.tests import test_known, test_name_known |
16 | 14 | from tools.targets import TARGET_NAMES |
17 | | -from tools.libraries import LIBRARIES |
18 | | -from utils import argparse_lowercase_type, argparse_uppercase_type, argparse_filestring_type, argparse_many |
| 15 | +from utils import argparse_filestring_type, argparse_many |
19 | 16 | from utils import argparse_force_lowercase_type, argparse_force_uppercase_type |
| 17 | +from project_api import setup_project, perform_export, print_results, get_lib_symbols |
20 | 18 |
|
21 | 19 |
|
22 | 20 |
|
|
129 | 127 | # Export results |
130 | 128 | successes = [] |
131 | 129 | failures = [] |
132 | | - zip = True |
133 | | - clean = True |
134 | 130 |
|
135 | 131 | # source_dir = use relative paths, otherwise sources are copied |
136 | 132 | sources_relative = True if options.source_dir else False |
137 | 133 |
|
138 | 134 | for mcu in options.mcu: |
139 | 135 | # Program Number or name |
140 | 136 | p, src, ide = options.program, options.source_dir, options.ide |
| 137 | + project_dir, project_name, project_temp = setup_project(mcu, ide, p, src, options.build) |
141 | 138 |
|
142 | | - if src: |
143 | | - # --source is used to generate IDE files to toolchain directly in the source tree and doesn't generate zip file |
144 | | - project_dir = options.source_dir |
145 | | - project_name = TESTS[p] if p else "Unnamed_project" |
146 | | - project_temp = path.join(options.source_dir[0], 'projectfiles', '%s_%s' % (ide, mcu)) |
147 | | - mkdir(project_temp) |
148 | | - lib_symbols = [] |
149 | | - if options.macros: |
150 | | - lib_symbols += options.macros |
151 | | - zip = False # don't create zip |
152 | | - clean = False # don't cleanup because we use the actual source tree to generate IDE files |
153 | | - else: |
154 | | - test = Test(p) |
155 | | - |
156 | | - # Some libraries have extra macros (called by exporter symbols) to we need to pass |
157 | | - # them to maintain compilation macros integrity between compiled library and |
158 | | - # header files we might use with it |
159 | | - lib_symbols = [] |
160 | | - if options.macros: |
161 | | - lib_symbols += options.macros |
162 | | - for lib in LIBRARIES: |
163 | | - if lib['build_dir'] in test.dependencies: |
164 | | - lib_macros = lib.get('macros', None) |
165 | | - if lib_macros is not None: |
166 | | - lib_symbols.extend(lib_macros) |
167 | | - |
168 | | - if not options.build: |
169 | | - # Substitute the library builds with the sources |
170 | | - # TODO: Substitute also the other library build paths |
171 | | - if MBED_LIBRARIES in test.dependencies: |
172 | | - test.dependencies.remove(MBED_LIBRARIES) |
173 | | - test.dependencies.append(MBED_BASE) |
174 | | - |
175 | | - # Build the project with the same directory structure of the mbed online IDE |
176 | | - project_name = test.id |
177 | | - project_dir = [join(EXPORT_WORKSPACE, project_name)] |
178 | | - project_temp = EXPORT_TMP |
179 | | - setup_user_prj(project_dir[0], test.source_dir, test.dependencies) |
| 139 | + zip = src is [] # create zip when no src_dir provided |
| 140 | + clean = src is [] # don't clean when source is provided, use acrual source tree for IDE files |
180 | 141 |
|
181 | 142 | # Export to selected toolchain |
| 143 | + lib_symbols = get_lib_symbols(options.macros, src, p) |
182 | 144 | tmp_path, report = export(project_dir, project_name, ide, mcu, project_dir[0], project_temp, clean=clean, make_zip=zip, extra_symbols=lib_symbols, sources_relative=sources_relative) |
183 | 145 | if report['success']: |
184 | 146 | if not zip: |
|
191 | 153 | failures.append("%s::%s\t%s"% (mcu, ide, report['errormsg'])) |
192 | 154 |
|
193 | 155 | # Prints export results |
194 | | - print |
195 | | - if len(successes) > 0: |
196 | | - print "Successful exports:" |
197 | | - for success in successes: |
198 | | - print " * %s"% success |
199 | | - if len(failures) > 0: |
200 | | - print "Failed exports:" |
201 | | - for failure in failures: |
202 | | - print " * %s"% failure |
| 156 | + print_results(successes, failures) |
0 commit comments