Skip to content

Commit 5713435

Browse files
authored
Merge pull request #2895 from bridadan/build-test-fix
[Exporters] Resolving Python errors and uVision build issues
2 parents 45d47b9 + fe1cd87 commit 5713435

File tree

6 files changed

+35
-16
lines changed

6 files changed

+35
-16
lines changed

tools/export/sw4stm32.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from os.path import splitext, basename, join
1919
from random import randint
2020
from tools.utils import mkdir
21-
from targets import Target
2221

2322

2423
class Sw4STM32(Exporter):
@@ -80,7 +79,7 @@ def __generate_uid(self):
8079
def generate(self):
8180
fp_hardware = "no"
8281
fp_abi = "soft"
83-
core = Target.get_target(self.target).core
82+
core = self.target.core
8483
if core == "Cortex-M4F" or core == "Cortex-M7F":
8584
fp_hardware = "fpv4-sp-d16"
8685
fp_abi = "soft-fp"

tools/export/uvision4.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from tools.export.exporters import Exporter, ExporterTargetsProperty
2121
from tools.targets import TARGET_MAP, TARGET_NAMES
22+
from tools.utils import remove_if_in
2223

2324
# If you wish to add a new target, add it to project_generator_definitions, and then
2425
# define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
@@ -87,11 +88,11 @@ def generate(self):
8788
+ self.flags['c_flags']
8889
+ self.flags['cxx_flags']))
8990
# not compatible with c99 flag set in the template
90-
project_data['misc']['c_flags'].remove("--c99")
91+
remove_if_in(project_data['misc']['c_flags'], "--c99")
9192
# cpp is not required as it's implicit for cpp files
92-
project_data['misc']['c_flags'].remove("--cpp")
93+
remove_if_in(project_data['misc']['c_flags'], "--cpp")
9394
# we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it
94-
project_data['misc']['c_flags'].remove("--no_vla")
95+
remove_if_in(project_data['misc']['c_flags'], "--no_vla")
9596
project_data['misc']['ld_flags'] = self.flags['ld_flags']
9697

9798
project_data['build_dir'] = project_data['build_dir'] + '\\' + 'uvision4'

tools/export/uvision5.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from tools.export.exporters import Exporter, ExporterTargetsProperty
2121
from tools.targets import TARGET_MAP, TARGET_NAMES
22+
from tools.utils import remove_if_in
2223

2324
# If you wish to add a new target, add it to project_generator_definitions, and then
2425
# define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
@@ -83,11 +84,12 @@ def generate(self):
8384
+ self.flags['c_flags']
8485
+ self.flags['cxx_flags']))
8586
# not compatible with c99 flag set in the template
86-
project_data['misc']['c_flags'].remove("--c99")
87+
remove_if_in(project_data['misc']['c_flags'], "--c99")
8788
# cpp is not required as it's implicit for cpp files
88-
project_data['misc']['c_flags'].remove("--cpp")
89+
remove_if_in(project_data['misc']['c_flags'], "--cpp")
8990
# we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it
90-
project_data['misc']['c_flags'].remove("--no_vla")
91+
remove_if_in(project_data['misc']['c_flags'], "--no_vla")
92+
# not compatible with c99 flag set in the template
9193
project_data['misc']['ld_flags'] = self.flags['ld_flags']
9294

9395
i = 0

tools/project.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
from argparse import ArgumentParser
1111
from os.path import normpath, realpath
1212

13-
from tools.paths import EXPORT_DIR, MBED_BASE, MBED_LIBRARIES
13+
from tools.paths import EXPORT_DIR, MBED_HAL, MBED_LIBRARIES
1414
from tools.export import EXPORTERS, mcu_ide_matrix
1515
from tools.tests import TESTS, TEST_MAP
1616
from tools.tests import test_known, test_name_known, Test
1717
from tools.targets import TARGET_NAMES
1818
from tools.utils import argparse_filestring_type, argparse_many, args_error
1919
from tools.utils import argparse_force_lowercase_type
2020
from tools.utils import argparse_force_uppercase_type
21-
from tools.project_api import export_project
21+
from tools.project_api import export_project, get_exporter_toolchain
2222
from tools.options import extract_profile
2323

2424

@@ -53,7 +53,8 @@ def setup_project(ide, target, program=None, source_dir=None, build=None, export
5353
# Substitute the mbed library builds with their sources
5454
if MBED_LIBRARIES in test.dependencies:
5555
test.dependencies.remove(MBED_LIBRARIES)
56-
test.dependencies.append(MBED_BASE)
56+
test.dependencies.append(MBED_HAL)
57+
5758

5859
src_paths = [test.source_dir]
5960
lib_paths = test.dependencies

tools/test/export/build_test.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@
3636
from tools.project import export
3737
from Queue import Queue
3838
from threading import Thread, Lock
39-
from tools.project_api import print_results
39+
from tools.project_api import print_results, get_exporter_toolchain
4040
from tools.tests import test_name_known, test_known, Test
4141
from tools.export.exporters import FailedBuildException, \
4242
TargetNotSupportedException
4343
from tools.utils import argparse_force_lowercase_type, \
44-
argparse_many, columnate, args_error
44+
argparse_many, columnate, args_error, \
45+
argparse_filestring_type
46+
from tools.options import extract_profile
4547

4648
print_lock = Lock()
4749

@@ -72,13 +74,15 @@ def start(self) :
7274

7375
class ExportBuildTest(object):
7476
"""Object to encapsulate logic for progen build testing"""
75-
def __init__(self, tests):
77+
def __init__(self, tests, parser, options):
7678
"""
7779
Initialize an instance of class ProgenBuildTest
7880
Args:
7981
tests: array of TestCase instances
8082
"""
8183
self.total = len(tests)
84+
self.parser = parser
85+
self.options = options
8286
self.counter = 0
8387
self.successes = []
8488
self.failures = []
@@ -155,11 +159,13 @@ def perform_exports(self, test_case):
155159
test_case.name))
156160

157161
try:
162+
_, toolchain = get_exporter_toolchain(test_case.ide)
163+
profile = extract_profile(self.parser, self.options, toolchain)
158164
exporter = export(test_case.mcu, test_case.ide,
159165
project_id=test_case.id, zip_proj=None,
160166
clean=True, src=test_case.src,
161167
export_path=join(EXPORT_DIR,name_str),
162-
silent=True)
168+
silent=True, build_profile=profile)
163169
exporter.generated_files.append(join(EXPORT_DIR,name_str,test_case.log))
164170
self.build_queue.put((exporter,test_case))
165171
except TargetNotSupportedException:
@@ -243,6 +249,12 @@ def main():
243249
help="Which version of mbed to test",
244250
default=RELEASE_VERSIONS[-1])
245251

252+
parser.add_argument("--profile",
253+
dest="profile",
254+
action="append",
255+
type=argparse_filestring_type,
256+
default=[])
257+
246258
options = parser.parse_args()
247259
# targets in chosen release
248260
targetnames = [target[0] for target in
@@ -273,7 +285,7 @@ def main():
273285
for test in v5_tests:
274286
default_test.update({'name':test[0],'src':[test[1],ROOT]})
275287
tests.append(copy(default_test))
276-
test = ExportBuildTest(tests)
288+
test = ExportBuildTest(tests, parser, options)
277289
test.batch_tests(clean=options.clean)
278290
print_results(test.successes, test.failures, test.skips)
279291
sys.exit(len(test.failures))

tools/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
from collections import OrderedDict
2929
import logging
3030

31+
def remove_if_in(lst, thing):
32+
if thing in lst:
33+
lst.remove(thing)
34+
3135
def compile_worker(job):
3236
"""Standard task runner used for compiling
3337

0 commit comments

Comments
 (0)