Skip to content

[Exporters] Resolving Python errors and uVision build issues #2895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tools/export/sw4stm32.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from os.path import splitext, basename, join
from random import randint
from tools.utils import mkdir
from targets import Target


class Sw4STM32(Exporter):
Expand Down Expand Up @@ -80,7 +79,7 @@ def __generate_uid(self):
def generate(self):
fp_hardware = "no"
fp_abi = "soft"
core = Target.get_target(self.target).core
core = self.target.core
if core == "Cortex-M4F" or core == "Cortex-M7F":
fp_hardware = "fpv4-sp-d16"
fp_abi = "soft-fp"
Expand Down
7 changes: 4 additions & 3 deletions tools/export/uvision4.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from tools.export.exporters import Exporter, ExporterTargetsProperty
from tools.targets import TARGET_MAP, TARGET_NAMES
from tools.utils import remove_if_in

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

project_data['build_dir'] = project_data['build_dir'] + '\\' + 'uvision4'
Expand Down
8 changes: 5 additions & 3 deletions tools/export/uvision5.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from tools.export.exporters import Exporter, ExporterTargetsProperty
from tools.targets import TARGET_MAP, TARGET_NAMES
from tools.utils import remove_if_in

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

i = 0
Expand Down
7 changes: 4 additions & 3 deletions tools/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
from argparse import ArgumentParser
from os.path import normpath, realpath

from tools.paths import EXPORT_DIR, MBED_BASE, MBED_LIBRARIES
from tools.paths import EXPORT_DIR, MBED_HAL, MBED_LIBRARIES
from tools.export import EXPORTERS, mcu_ide_matrix
from tools.tests import TESTS, TEST_MAP
from tools.tests import test_known, test_name_known, Test
from tools.targets import TARGET_NAMES
from tools.utils import argparse_filestring_type, argparse_many, args_error
from tools.utils import argparse_force_lowercase_type
from tools.utils import argparse_force_uppercase_type
from tools.project_api import export_project
from tools.project_api import export_project, get_exporter_toolchain
from tools.options import extract_profile


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


src_paths = [test.source_dir]
lib_paths = test.dependencies
Expand Down
22 changes: 17 additions & 5 deletions tools/test/export/build_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
from tools.project import export
from Queue import Queue
from threading import Thread, Lock
from tools.project_api import print_results
from tools.project_api import print_results, get_exporter_toolchain
from tools.tests import test_name_known, test_known, Test
from tools.export.exporters import FailedBuildException, \
TargetNotSupportedException
from tools.utils import argparse_force_lowercase_type, \
argparse_many, columnate, args_error
argparse_many, columnate, args_error, \
argparse_filestring_type
from tools.options import extract_profile

print_lock = Lock()

Expand Down Expand Up @@ -72,13 +74,15 @@ def start(self) :

class ExportBuildTest(object):
"""Object to encapsulate logic for progen build testing"""
def __init__(self, tests):
def __init__(self, tests, parser, options):
"""
Initialize an instance of class ProgenBuildTest
Args:
tests: array of TestCase instances
"""
self.total = len(tests)
self.parser = parser
self.options = options
self.counter = 0
self.successes = []
self.failures = []
Expand Down Expand Up @@ -155,11 +159,13 @@ def perform_exports(self, test_case):
test_case.name))

try:
_, toolchain = get_exporter_toolchain(test_case.ide)
profile = extract_profile(self.parser, self.options, toolchain)
exporter = export(test_case.mcu, test_case.ide,
project_id=test_case.id, zip_proj=None,
clean=True, src=test_case.src,
export_path=join(EXPORT_DIR,name_str),
silent=True)
silent=True, build_profile=profile)
exporter.generated_files.append(join(EXPORT_DIR,name_str,test_case.log))
self.build_queue.put((exporter,test_case))
except TargetNotSupportedException:
Expand Down Expand Up @@ -243,6 +249,12 @@ def main():
help="Which version of mbed to test",
default=RELEASE_VERSIONS[-1])

parser.add_argument("--profile",
dest="profile",
action="append",
type=argparse_filestring_type,
default=[])

options = parser.parse_args()
# targets in chosen release
targetnames = [target[0] for target in
Expand Down Expand Up @@ -273,7 +285,7 @@ def main():
for test in v5_tests:
default_test.update({'name':test[0],'src':[test[1],ROOT]})
tests.append(copy(default_test))
test = ExportBuildTest(tests)
test = ExportBuildTest(tests, parser, options)
test.batch_tests(clean=options.clean)
print_results(test.successes, test.failures, test.skips)
sys.exit(len(test.failures))
Expand Down
4 changes: 4 additions & 0 deletions tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
from collections import OrderedDict
import logging

def remove_if_in(lst, thing):
if thing in lst:
lst.remove(thing)

def compile_worker(job):
"""Standard task runner used for compiling

Expand Down