mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #5848 from theotherjimmy/compile-py3
Python2+3: mbed compile, mbed test --compile, python unit testspull/6042/head
commit
c679dee286
13
.travis.yml
13
.travis.yml
|
@ -10,7 +10,7 @@ env:
|
||||||
--data @- << DATA\n{
|
--data @- << DATA\n{
|
||||||
"state": "$0",
|
"state": "$0",
|
||||||
"description": "$1",
|
"description": "$1",
|
||||||
"context": "travis-ci/$NAME",
|
"context": "travis-ci/$NAME/$(python --version)",
|
||||||
"target_url": "https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID"
|
"target_url": "https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID"
|
||||||
}\nDATA'
|
}\nDATA'
|
||||||
|
|
||||||
|
@ -73,6 +73,10 @@ matrix:
|
||||||
|
|
||||||
- env:
|
- env:
|
||||||
- NAME=tools
|
- NAME=tools
|
||||||
|
python:
|
||||||
|
- '2.7'
|
||||||
|
- '3.5'
|
||||||
|
- '3.6'
|
||||||
install:
|
install:
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
- sudo apt-get install gcc-arm-embedded
|
- sudo apt-get install gcc-arm-embedded
|
||||||
|
@ -175,7 +179,7 @@ matrix:
|
||||||
- mkdir BUILD
|
- mkdir BUILD
|
||||||
script:
|
script:
|
||||||
# Run local mbed 2 testing
|
# Run local mbed 2 testing
|
||||||
- python2 -u tools/build_travis.py --vendor "${NAME#mbed2-}"
|
- python -u tools/build_travis.py --vendor "${NAME#mbed2-}"
|
||||||
- <<: *mbed-2
|
- <<: *mbed-2
|
||||||
env: NAME=mbed2-STM
|
env: NAME=mbed2-STM
|
||||||
- <<: *mbed-2
|
- <<: *mbed-2
|
||||||
|
@ -190,3 +194,8 @@ matrix:
|
||||||
env: NAME=mbed2-NUVOTON
|
env: NAME=mbed2-NUVOTON
|
||||||
- <<: *mbed-2
|
- <<: *mbed-2
|
||||||
env: NAME=mbed2-RENESAS
|
env: NAME=mbed2-RENESAS
|
||||||
|
# Change python version here only because 3x the other jobs does not add any more coverage
|
||||||
|
python:
|
||||||
|
- '2.7'
|
||||||
|
- '3.5'
|
||||||
|
- '3.6'
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
from urllib2 import urlopen, URLError
|
try:
|
||||||
|
from urllib2 import urlopen, URLError
|
||||||
|
except ImportError:
|
||||||
|
from urllib.request import urlopen, URLError
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from os.path import join, dirname, basename
|
from os.path import join, dirname, basename
|
||||||
from os import makedirs
|
from os import makedirs
|
||||||
from errno import EEXIST
|
from errno import EEXIST
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import Queue
|
try:
|
||||||
|
from Queue import Queue
|
||||||
|
except ImportError:
|
||||||
|
from queue import Queue
|
||||||
from re import compile, sub
|
from re import compile, sub
|
||||||
from sys import stderr, stdout
|
from sys import stderr, stdout
|
||||||
from itertools import takewhile
|
from itertools import takewhile
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function, division, absolute_import
|
||||||
import argparse
|
import argparse
|
||||||
from os.path import basename
|
from os.path import basename
|
||||||
from tools.arm_pack_manager import Cache
|
from tools.arm_pack_manager import Cache
|
||||||
|
@ -5,7 +6,7 @@ from os.path import basename, join, dirname, exists
|
||||||
from os import makedirs
|
from os import makedirs
|
||||||
from itertools import takewhile
|
from itertools import takewhile
|
||||||
from fuzzywuzzy import process
|
from fuzzywuzzy import process
|
||||||
from tools.arm_pack_manager import Cache
|
from .arm_pack_manager import Cache
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='A Handy little utility for keeping your cache of pack files up to date.')
|
parser = argparse.ArgumentParser(description='A Handy little utility for keeping your cache of pack files up to date.')
|
||||||
subparsers = parser.add_subparsers(title="Commands")
|
subparsers = parser.add_subparsers(title="Commands")
|
||||||
|
@ -69,7 +70,7 @@ def fuzzy_find(matches, urls) :
|
||||||
for key, value in process.extract(match, urls, limit=None) :
|
for key, value in process.extract(match, urls, limit=None) :
|
||||||
choices.setdefault(key, 0)
|
choices.setdefault(key, 0)
|
||||||
choices[key] += value
|
choices[key] += value
|
||||||
choices = sorted([(v, k) for k, v in choices.iteritems()], reverse=True)
|
choices = sorted([(v, k) for k, v in choices.items()], reverse=True)
|
||||||
if not choices : return []
|
if not choices : return []
|
||||||
elif len(choices) == 1 : return [choices[0][1]]
|
elif len(choices) == 1 : return [choices[0][1]]
|
||||||
elif choices[0][0] > choices[1][0] : choices = choices[:1]
|
elif choices[0][0] > choices[1][0] : choices = choices[:1]
|
||||||
|
@ -133,12 +134,12 @@ def command_find_part (cache, matches, long=False, intersection=True,
|
||||||
aliases = sum([fuzzy_find([m], cache.aliases.keys()) for m in matches], [])
|
aliases = sum([fuzzy_find([m], cache.aliases.keys()) for m in matches], [])
|
||||||
if print_parts:
|
if print_parts:
|
||||||
for part in choices :
|
for part in choices :
|
||||||
print part
|
print(part)
|
||||||
if long :
|
if long :
|
||||||
pp.pprint(cache.index[part])
|
pp.pprint(cache.index[part])
|
||||||
if print_aliases:
|
if print_aliases:
|
||||||
for alias in aliases :
|
for alias in aliases :
|
||||||
print alias
|
print(alias)
|
||||||
if long :
|
if long :
|
||||||
pp.pprint(cache.index[cache.aliases[alias]])
|
pp.pprint(cache.index[cache.aliases[alias]])
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ def command_dump_parts (cache, out, parts, intersection=False) :
|
||||||
else :
|
else :
|
||||||
for part in parts :
|
for part in parts :
|
||||||
index.update(dict(cache.find_device(part)))
|
index.update(dict(cache.find_device(part)))
|
||||||
for n, p in index.iteritems() :
|
for n, p in index.items() :
|
||||||
try :
|
try :
|
||||||
if not exists(join(out, dirname(p['algorithm']['file']))) :
|
if not exists(join(out, dirname(p['algorithm']['file']))) :
|
||||||
makedirs(join(out, dirname(p['algorithm']['file'])))
|
makedirs(join(out, dirname(p['algorithm']['file'])))
|
||||||
|
|
|
@ -17,6 +17,8 @@ limitations under the License.
|
||||||
|
|
||||||
LIBRARIES BUILD
|
LIBRARIES BUILD
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function, division, absolute_import
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from time import time
|
from time import time
|
||||||
from os.path import join, abspath, dirname
|
from os.path import join, abspath, dirname
|
||||||
|
@ -130,7 +132,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# Only prints matrix of supported toolchains
|
# Only prints matrix of supported toolchains
|
||||||
if options.supported_toolchains:
|
if options.supported_toolchains:
|
||||||
print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
|
print(mcu_toolchain_matrix(platform_filter=options.general_filter_regex))
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,7 +186,7 @@ if __name__ == '__main__':
|
||||||
tt_id = "%s::%s" % (toolchain, target)
|
tt_id = "%s::%s" % (toolchain, target)
|
||||||
if toolchain not in TARGET_MAP[target].supported_toolchains:
|
if toolchain not in TARGET_MAP[target].supported_toolchains:
|
||||||
# Log this later
|
# Log this later
|
||||||
print "%s skipped: toolchain not supported" % tt_id
|
print("%s skipped: toolchain not supported" % tt_id)
|
||||||
skipped.append(tt_id)
|
skipped.append(tt_id)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
@ -224,26 +226,24 @@ if __name__ == '__main__':
|
||||||
successes.append(tt_id)
|
successes.append(tt_id)
|
||||||
else:
|
else:
|
||||||
skipped.append(tt_id)
|
skipped.append(tt_id)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
failures.append(tt_id)
|
failures.append(tt_id)
|
||||||
print e
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
# Write summary of the builds
|
# Write summary of the builds
|
||||||
print
|
print("\nCompleted in: (%.2f)s\n" % (time() - start))
|
||||||
print "Completed in: (%.2f)s" % (time() - start)
|
|
||||||
print
|
|
||||||
|
|
||||||
for report, report_name in [(successes, "Build successes:"),
|
for report, report_name in [(successes, "Build successes:"),
|
||||||
(skipped, "Build skipped:"),
|
(skipped, "Build skipped:"),
|
||||||
(failures, "Build failures:"),
|
(failures, "Build failures:"),
|
||||||
]:
|
]:
|
||||||
if report:
|
if report:
|
||||||
print print_build_results(report, report_name),
|
print(print_build_results(report, report_name))
|
||||||
|
|
||||||
if failures:
|
if failures:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -14,12 +14,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function, division, absolute_import
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
import datetime
|
import datetime
|
||||||
import uuid
|
import uuid
|
||||||
from types import ListType
|
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
from os.path import join, exists, dirname, basename, abspath, normpath, splitext
|
from os.path import join, exists, dirname, basename, abspath, normpath, splitext
|
||||||
from os.path import relpath
|
from os.path import relpath
|
||||||
|
@ -27,20 +27,22 @@ from os import linesep, remove, makedirs
|
||||||
from time import time
|
from time import time
|
||||||
from intelhex import IntelHex
|
from intelhex import IntelHex
|
||||||
from json import load, dump
|
from json import load, dump
|
||||||
from tools.arm_pack_manager import Cache
|
|
||||||
|
|
||||||
from tools.utils import mkdir, run_cmd, run_cmd_ext, NotSupportedException,\
|
|
||||||
ToolException, InvalidReleaseTargetException, intelhex_offset
|
|
||||||
from tools.paths import MBED_CMSIS_PATH, MBED_TARGETS_PATH, MBED_LIBRARIES,\
|
|
||||||
MBED_HEADER, MBED_DRIVERS, MBED_PLATFORM, MBED_HAL, MBED_CONFIG_FILE,\
|
|
||||||
MBED_LIBRARIES_DRIVERS, MBED_LIBRARIES_PLATFORM, MBED_LIBRARIES_HAL,\
|
|
||||||
BUILD_DIR
|
|
||||||
from tools.targets import TARGET_NAMES, TARGET_MAP
|
|
||||||
from tools.libraries import Library
|
|
||||||
from tools.toolchains import TOOLCHAIN_CLASSES
|
|
||||||
from jinja2 import FileSystemLoader
|
from jinja2 import FileSystemLoader
|
||||||
from jinja2.environment import Environment
|
from jinja2.environment import Environment
|
||||||
from tools.config import Config
|
|
||||||
|
from .arm_pack_manager import Cache
|
||||||
|
from .utils import (mkdir, run_cmd, run_cmd_ext, NotSupportedException,
|
||||||
|
ToolException, InvalidReleaseTargetException,
|
||||||
|
intelhex_offset)
|
||||||
|
from .paths import (MBED_CMSIS_PATH, MBED_TARGETS_PATH, MBED_LIBRARIES,
|
||||||
|
MBED_HEADER, MBED_DRIVERS, MBED_PLATFORM, MBED_HAL,
|
||||||
|
MBED_CONFIG_FILE, MBED_LIBRARIES_DRIVERS,
|
||||||
|
MBED_LIBRARIES_PLATFORM, MBED_LIBRARIES_HAL,
|
||||||
|
BUILD_DIR)
|
||||||
|
from .targets import TARGET_NAMES, TARGET_MAP
|
||||||
|
from .libraries import Library
|
||||||
|
from .toolchains import TOOLCHAIN_CLASSES
|
||||||
|
from .config import Config
|
||||||
|
|
||||||
RELEASE_VERSIONS = ['2', '5']
|
RELEASE_VERSIONS = ['2', '5']
|
||||||
|
|
||||||
|
@ -124,7 +126,7 @@ def get_config(src_paths, target, toolchain_name):
|
||||||
toolchain_name - the string that identifies the build tools
|
toolchain_name - the string that identifies the build tools
|
||||||
"""
|
"""
|
||||||
# Convert src_paths to a list if needed
|
# Convert src_paths to a list if needed
|
||||||
if type(src_paths) != ListType:
|
if not isinstance(src_paths, list):
|
||||||
src_paths = [src_paths]
|
src_paths = [src_paths]
|
||||||
|
|
||||||
# Pass all params to the unified prepare_resources()
|
# Pass all params to the unified prepare_resources()
|
||||||
|
@ -404,7 +406,7 @@ def scan_resources(src_paths, toolchain, dependencies_paths=None,
|
||||||
|
|
||||||
# Add additional include directories if passed
|
# Add additional include directories if passed
|
||||||
if inc_dirs:
|
if inc_dirs:
|
||||||
if type(inc_dirs) == ListType:
|
if isinstance(inc_dirs, list):
|
||||||
resources.inc_dirs.extend(inc_dirs)
|
resources.inc_dirs.extend(inc_dirs)
|
||||||
else:
|
else:
|
||||||
resources.inc_dirs.append(inc_dirs)
|
resources.inc_dirs.append(inc_dirs)
|
||||||
|
@ -462,7 +464,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Convert src_path to a list if needed
|
# Convert src_path to a list if needed
|
||||||
if type(src_paths) != ListType:
|
if not isinstance(src_paths, list):
|
||||||
src_paths = [src_paths]
|
src_paths = [src_paths]
|
||||||
# Extend src_paths wiht libraries_paths
|
# Extend src_paths wiht libraries_paths
|
||||||
if libraries_paths is not None:
|
if libraries_paths is not None:
|
||||||
|
@ -533,9 +535,9 @@ def build_project(src_paths, build_path, target, toolchain_name,
|
||||||
memap_bars = memap_instance.generate_output('bars',
|
memap_bars = memap_instance.generate_output('bars',
|
||||||
real_stats_depth, None,
|
real_stats_depth, None,
|
||||||
getattr(toolchain.target, 'device_name', None))
|
getattr(toolchain.target, 'device_name', None))
|
||||||
print memap_bars
|
print(memap_bars)
|
||||||
else:
|
else:
|
||||||
print memap_table
|
print(memap_table)
|
||||||
|
|
||||||
# Write output to file in JSON format
|
# Write output to file in JSON format
|
||||||
map_out = join(build_path, name + "_map.json")
|
map_out = join(build_path, name + "_map.json")
|
||||||
|
@ -619,7 +621,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Convert src_path to a list if needed
|
# Convert src_path to a list if needed
|
||||||
if type(src_paths) != ListType:
|
if not isinstance(src_paths, list):
|
||||||
src_paths = [src_paths]
|
src_paths = [src_paths]
|
||||||
|
|
||||||
# Build path
|
# Build path
|
||||||
|
@ -788,7 +790,7 @@ def build_lib(lib_id, target, toolchain_name, verbose=False,
|
||||||
inc_dirs = lib.inc_dirs
|
inc_dirs = lib.inc_dirs
|
||||||
inc_dirs_ext = lib.inc_dirs_ext
|
inc_dirs_ext = lib.inc_dirs_ext
|
||||||
|
|
||||||
if type(src_paths) != ListType:
|
if not isinstance(src_paths, list):
|
||||||
src_paths = [src_paths]
|
src_paths = [src_paths]
|
||||||
|
|
||||||
# The first path will give the name to the library
|
# The first path will give the name to the library
|
||||||
|
|
|
@ -154,7 +154,7 @@ if __name__ == '__main__':
|
||||||
test_builds = {}
|
test_builds = {}
|
||||||
total_build_success = True
|
total_build_success = True
|
||||||
|
|
||||||
for target_name, target_toolchains in build_config.iteritems():
|
for target_name, target_toolchains in build_config.items():
|
||||||
target = TARGET_MAP[target_name]
|
target = TARGET_MAP[target_name]
|
||||||
|
|
||||||
for target_toolchain in target_toolchains:
|
for target_toolchain in target_toolchains:
|
||||||
|
|
|
@ -18,6 +18,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function, division, absolute_import
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -382,11 +383,12 @@ def run_builds(dry_run, vendor):
|
||||||
toolchain_list = build["toolchains"]
|
toolchain_list = build["toolchains"]
|
||||||
if type(toolchain_list) != type([]): toolchain_list = [toolchain_list]
|
if type(toolchain_list) != type([]): toolchain_list = [toolchain_list]
|
||||||
for toolchain in toolchain_list:
|
for toolchain in toolchain_list:
|
||||||
cmdline = "python tools/build.py -m %s -t %s -c --silent "% (build["target"], toolchain)
|
cmdline = ("%s tools/build.py -m %s -t %s -c --silent "%
|
||||||
|
(sys.executable, build["target"], toolchain))
|
||||||
libs = build.get("libs", [])
|
libs = build.get("libs", [])
|
||||||
if libs:
|
if libs:
|
||||||
cmdline = cmdline + " ".join(["--" + l for l in libs])
|
cmdline = cmdline + " ".join(["--" + l for l in libs])
|
||||||
print "Executing: " + cmdline
|
print("Executing: %s" % cmdline)
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
if os.system(cmdline) != 0:
|
if os.system(cmdline) != 0:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -408,19 +410,15 @@ def run_test_linking(dry_run, vendor):
|
||||||
for test_lib in tests:
|
for test_lib in tests:
|
||||||
test_names = tests[test_lib]
|
test_names = tests[test_lib]
|
||||||
test_lib_switch = "--" + test_lib if test_lib else ""
|
test_lib_switch = "--" + test_lib if test_lib else ""
|
||||||
cmdline = "python tools/make.py -m %s -t %s -c --silent %s -n %s " % (link["target"], toolchain, test_lib_switch, ",".join(test_names))
|
cmdline = ("%s tools/make.py -m %s -t %s -c --silent %s "
|
||||||
print "Executing: " + cmdline
|
"-n %s" % (sys.executable, link["target"],
|
||||||
|
toolchain, test_lib_switch,
|
||||||
|
",".join(test_names)))
|
||||||
|
print("Executing: %s" % cmdline)
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
if os.system(cmdline) != 0:
|
if os.system(cmdline) != 0:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def run_test_testsuite(dry_run, vendor):
|
|
||||||
cmdline = "python tools/singletest.py --version"
|
|
||||||
print "Executing: " + cmdline
|
|
||||||
if not dry_run:
|
|
||||||
if os.system(cmdline) != 0:
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
|
|
||||||
|
@ -434,4 +432,3 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
run_builds("-s" in sys.argv, options.vendor)
|
run_builds("-s" in sys.argv, options.vendor)
|
||||||
run_test_linking("-s" in sys.argv, options.vendor)
|
run_test_linking("-s" in sys.argv, options.vendor)
|
||||||
run_test_testsuite("-s" in sys.argv, options.vendor)
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function, division, absolute_import
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from six import moves
|
from six import moves
|
||||||
|
@ -28,12 +29,16 @@ from intelhex import IntelHex
|
||||||
from jinja2 import FileSystemLoader, StrictUndefined
|
from jinja2 import FileSystemLoader, StrictUndefined
|
||||||
from jinja2.environment import Environment
|
from jinja2.environment import Environment
|
||||||
from jsonschema import Draft4Validator, RefResolver
|
from jsonschema import Draft4Validator, RefResolver
|
||||||
# Implementation of mbed configuration mechanism
|
|
||||||
from tools.utils import json_file_to_dict, intelhex_offset
|
|
||||||
from tools.arm_pack_manager import Cache
|
|
||||||
from tools.targets import CUMULATIVE_ATTRIBUTES, TARGET_MAP, \
|
|
||||||
generate_py_target, get_resolution_order
|
|
||||||
|
|
||||||
|
from ..utils import json_file_to_dict, intelhex_offset
|
||||||
|
from ..arm_pack_manager import Cache
|
||||||
|
from ..targets import (CUMULATIVE_ATTRIBUTES, TARGET_MAP, generate_py_target,
|
||||||
|
get_resolution_order, Target)
|
||||||
|
|
||||||
|
try:
|
||||||
|
unicode
|
||||||
|
except NameError:
|
||||||
|
unicode = str
|
||||||
PATH_OVERRIDES = set(["target.bootloader_img"])
|
PATH_OVERRIDES = set(["target.bootloader_img"])
|
||||||
BOOTLOADER_OVERRIDES = set(["target.bootloader_img", "target.restrict_size",
|
BOOTLOADER_OVERRIDES = set(["target.bootloader_img", "target.restrict_size",
|
||||||
"target.mbed_app_start", "target.mbed_app_size"])
|
"target.mbed_app_start", "target.mbed_app_size"])
|
||||||
|
@ -432,15 +437,14 @@ class Config(object):
|
||||||
self.lib_config_data = {}
|
self.lib_config_data = {}
|
||||||
# Make sure that each config is processed only once
|
# Make sure that each config is processed only once
|
||||||
self.processed_configs = {}
|
self.processed_configs = {}
|
||||||
if isinstance(tgt, basestring):
|
if isinstance(tgt, Target):
|
||||||
|
self.target = tgt
|
||||||
|
else:
|
||||||
if tgt in TARGET_MAP:
|
if tgt in TARGET_MAP:
|
||||||
self.target = TARGET_MAP[tgt]
|
self.target = TARGET_MAP[tgt]
|
||||||
else:
|
else:
|
||||||
self.target = generate_py_target(
|
self.target = generate_py_target(
|
||||||
self.app_config_data.get("custom_targets", {}), tgt)
|
self.app_config_data.get("custom_targets", {}), tgt)
|
||||||
|
|
||||||
else:
|
|
||||||
self.target = tgt
|
|
||||||
self.target = deepcopy(self.target)
|
self.target = deepcopy(self.target)
|
||||||
self.target_labels = self.target.labels
|
self.target_labels = self.target.labels
|
||||||
for override in BOOTLOADER_OVERRIDES:
|
for override in BOOTLOADER_OVERRIDES:
|
||||||
|
@ -465,7 +469,7 @@ class Config(object):
|
||||||
continue
|
continue
|
||||||
full_path = os.path.normpath(os.path.abspath(config_file))
|
full_path = os.path.normpath(os.path.abspath(config_file))
|
||||||
# Check that we didn't already process this file
|
# Check that we didn't already process this file
|
||||||
if self.processed_configs.has_key(full_path):
|
if full_path in self.processed_configs:
|
||||||
continue
|
continue
|
||||||
self.processed_configs[full_path] = True
|
self.processed_configs[full_path] = True
|
||||||
# Read the library configuration and add a "__full_config_path"
|
# Read the library configuration and add a "__full_config_path"
|
||||||
|
@ -496,7 +500,7 @@ class Config(object):
|
||||||
|
|
||||||
# If there's already a configuration for a module with the same
|
# If there's already a configuration for a module with the same
|
||||||
# name, exit with error
|
# name, exit with error
|
||||||
if self.lib_config_data.has_key(cfg["name"]):
|
if cfg["name"] in self.lib_config_data:
|
||||||
raise ConfigException(
|
raise ConfigException(
|
||||||
"Library name '%s' is not unique (defined in '%s' and '%s')"
|
"Library name '%s' is not unique (defined in '%s' and '%s')"
|
||||||
% (cfg["name"], full_path,
|
% (cfg["name"], full_path,
|
||||||
|
@ -662,7 +666,7 @@ class Config(object):
|
||||||
# Check for invalid cumulative overrides in libraries
|
# Check for invalid cumulative overrides in libraries
|
||||||
if (unit_kind == 'library' and
|
if (unit_kind == 'library' and
|
||||||
any(attr.startswith('target.extra_labels') for attr
|
any(attr.startswith('target.extra_labels') for attr
|
||||||
in overrides.iterkeys())):
|
in overrides.keys())):
|
||||||
raise ConfigException(
|
raise ConfigException(
|
||||||
"Target override 'target.extra_labels' in " +
|
"Target override 'target.extra_labels' in " +
|
||||||
ConfigParameter.get_display_name(unit_name, unit_kind,
|
ConfigParameter.get_display_name(unit_name, unit_kind,
|
||||||
|
@ -670,7 +674,7 @@ class Config(object):
|
||||||
" is only allowed at the application level")
|
" is only allowed at the application level")
|
||||||
|
|
||||||
# Parse out cumulative overrides
|
# Parse out cumulative overrides
|
||||||
for attr, cumulatives in self.cumulative_overrides.iteritems():
|
for attr, cumulatives in self.cumulative_overrides.items():
|
||||||
if 'target.'+attr in overrides:
|
if 'target.'+attr in overrides:
|
||||||
key = 'target.' + attr
|
key = 'target.' + attr
|
||||||
if not isinstance(overrides[key], list):
|
if not isinstance(overrides[key], list):
|
||||||
|
@ -729,7 +733,7 @@ class Config(object):
|
||||||
unit_kind,
|
unit_kind,
|
||||||
label)))))
|
label)))))
|
||||||
|
|
||||||
for cumulatives in self.cumulative_overrides.itervalues():
|
for cumulatives in self.cumulative_overrides.values():
|
||||||
cumulatives.update_target(self.target)
|
cumulatives.update_target(self.target)
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
|
@ -15,6 +15,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -67,8 +68,8 @@ def main():
|
||||||
|
|
||||||
# Only prints matrix of supported toolchains
|
# Only prints matrix of supported toolchains
|
||||||
if options.supported_toolchains:
|
if options.supported_toolchains:
|
||||||
print mcu_toolchain_matrix(
|
print(mcu_toolchain_matrix(
|
||||||
platform_filter=options.general_filter_regex)
|
platform_filter=options.general_filter_regex))
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# If auto_detect attribute is present, we assume other auto-detection
|
# If auto_detect attribute is present, we assume other auto-detection
|
||||||
|
@ -81,23 +82,23 @@ def main():
|
||||||
for mut in muts.values():
|
for mut in muts.values():
|
||||||
if re.match(mcu_filter, mut['mcu']):
|
if re.match(mcu_filter, mut['mcu']):
|
||||||
interface_version = get_interface_version(mut['disk'])
|
interface_version = get_interface_version(mut['disk'])
|
||||||
print ""
|
print("")
|
||||||
print "[mbed] Detected %s, port %s, mounted %s, interface version %s:" % \
|
print("[mbed] Detected %s, port %s, mounted %s, interface "
|
||||||
(mut['mcu'], mut['port'], mut['disk'], interface_version)
|
"version %s:" %
|
||||||
|
(mut['mcu'], mut['port'], mut['disk'], interface_version))
|
||||||
print "[mbed] Supported toolchains for %s" % mut['mcu']
|
print("[mbed] Supported toolchains for %s" % mut['mcu'])
|
||||||
print mcu_toolchain_matrix(platform_filter=mut['mcu'])
|
print(mcu_toolchain_matrix(platform_filter=mut['mcu']))
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
if count == 0:
|
if count == 0:
|
||||||
print "[mbed] No mbed targets were detected on your system."
|
print("[mbed] No mbed targets were detected on your system.")
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print "\n[CTRL+c] exit"
|
print("\n[CTRL+c] exit")
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
print "[ERROR] %s" % str(exc)
|
print("[ERROR] %s" % str(exc))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def get_interface_version(mount_point):
|
def get_interface_version(mount_point):
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import print_function, division, absolute_import
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from os.path import join, abspath, dirname, exists
|
from os.path import join, abspath, dirname, exists
|
||||||
from os.path import basename, relpath, normpath, splitext
|
from os.path import basename, relpath, normpath, splitext
|
||||||
|
@ -22,50 +24,43 @@ from os import makedirs, walk
|
||||||
import copy
|
import copy
|
||||||
from shutil import rmtree, copyfile
|
from shutil import rmtree, copyfile
|
||||||
import zipfile
|
import zipfile
|
||||||
ROOT = abspath(join(dirname(__file__), ".."))
|
|
||||||
sys.path.insert(0, ROOT)
|
|
||||||
|
|
||||||
from tools.build_api import prepare_toolchain
|
from ..build_api import prepare_toolchain, scan_resources
|
||||||
from tools.build_api import scan_resources
|
from ..toolchains import Resources
|
||||||
from tools.toolchains import Resources
|
from ..targets import TARGET_NAMES
|
||||||
from tools.export import lpcxpresso, ds5_5, iar, makefile
|
from . import (lpcxpresso, ds5_5, iar, makefile, embitz, coide, kds, simplicity,
|
||||||
from tools.export import embitz, coide, kds, simplicity, atmelstudio, mcuxpresso
|
atmelstudio, mcuxpresso, sw4stm32, e2studio, zip, cmsis, uvision,
|
||||||
from tools.export import sw4stm32, e2studio, zip, cmsis, uvision, cdt, vscode
|
cdt, vscode, gnuarmeclipse, qtcreator, cmake, nb)
|
||||||
from tools.export import gnuarmeclipse
|
|
||||||
from tools.export import qtcreator
|
|
||||||
from tools.export import cmake
|
|
||||||
from tools.export import nb
|
|
||||||
from tools.targets import TARGET_NAMES
|
|
||||||
|
|
||||||
EXPORTERS = {
|
EXPORTERS = {
|
||||||
'uvision5': uvision.Uvision,
|
u'uvision5': uvision.Uvision,
|
||||||
'uvision': uvision.Uvision,
|
u'uvision': uvision.Uvision,
|
||||||
'lpcxpresso': lpcxpresso.LPCXpresso,
|
u'lpcxpresso': lpcxpresso.LPCXpresso,
|
||||||
'gcc_arm': makefile.GccArm,
|
u'gcc_arm': makefile.GccArm,
|
||||||
'make_gcc_arm': makefile.GccArm,
|
u'make_gcc_arm': makefile.GccArm,
|
||||||
'make_armc5': makefile.Armc5,
|
u'make_armc5': makefile.Armc5,
|
||||||
'make_armc6': makefile.Armc6,
|
u'make_armc6': makefile.Armc6,
|
||||||
'make_iar': makefile.IAR,
|
u'make_iar': makefile.IAR,
|
||||||
'ds5_5': ds5_5.DS5_5,
|
u'ds5_5': ds5_5.DS5_5,
|
||||||
'iar': iar.IAR,
|
u'iar': iar.IAR,
|
||||||
'embitz' : embitz.EmBitz,
|
u'embitz' : embitz.EmBitz,
|
||||||
'coide' : coide.CoIDE,
|
u'coide' : coide.CoIDE,
|
||||||
'kds' : kds.KDS,
|
u'kds' : kds.KDS,
|
||||||
'simplicityv3' : simplicity.SimplicityV3,
|
u'simplicityv3' : simplicity.SimplicityV3,
|
||||||
'atmelstudio' : atmelstudio.AtmelStudio,
|
u'atmelstudio' : atmelstudio.AtmelStudio,
|
||||||
'sw4stm32' : sw4stm32.Sw4STM32,
|
u'sw4stm32' : sw4stm32.Sw4STM32,
|
||||||
'e2studio' : e2studio.E2Studio,
|
u'e2studio' : e2studio.E2Studio,
|
||||||
'eclipse_gcc_arm' : cdt.EclipseGcc,
|
u'eclipse_gcc_arm' : cdt.EclipseGcc,
|
||||||
'eclipse_iar' : cdt.EclipseIAR,
|
u'eclipse_iar' : cdt.EclipseIAR,
|
||||||
'eclipse_armc5' : cdt.EclipseArmc5,
|
u'eclipse_armc5' : cdt.EclipseArmc5,
|
||||||
'gnuarmeclipse': gnuarmeclipse.GNUARMEclipse,
|
u'gnuarmeclipse': gnuarmeclipse.GNUARMEclipse,
|
||||||
'netbeans': nb.GNUARMNetbeans,
|
u'mcuxpresso': mcuxpresso.MCUXpresso,
|
||||||
'mcuxpresso': mcuxpresso.MCUXpresso,
|
u'netbeans': nb.GNUARMNetbeans,
|
||||||
'qtcreator': qtcreator.QtCreator,
|
u'qtcreator': qtcreator.QtCreator,
|
||||||
'vscode_gcc_arm' : vscode.VSCodeGcc,
|
u'vscode_gcc_arm' : vscode.VSCodeGcc,
|
||||||
'vscode_iar' : vscode.VSCodeIAR,
|
u'vscode_iar' : vscode.VSCodeIAR,
|
||||||
'vscode_armc5' : vscode.VSCodeArmc5,
|
u'vscode_armc5' : vscode.VSCodeArmc5,
|
||||||
'cmake_gcc_arm': cmake.GccArm
|
u'cmake_gcc_arm': cmake.GccArm
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN = """
|
ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN = """
|
||||||
|
@ -226,7 +221,7 @@ def zip_export(file_name, prefix, resources, project_files, inc_repos):
|
||||||
with zipfile.ZipFile(file_name, "w") as zip_file:
|
with zipfile.ZipFile(file_name, "w") as zip_file:
|
||||||
for prj_file in project_files:
|
for prj_file in project_files:
|
||||||
zip_file.write(prj_file, join(prefix, basename(prj_file)))
|
zip_file.write(prj_file, join(prefix, basename(prj_file)))
|
||||||
for loc, res in resources.iteritems():
|
for loc, res in resources.items():
|
||||||
to_zip = (
|
to_zip = (
|
||||||
res.headers + res.s_sources + res.c_sources +\
|
res.headers + res.s_sources + res.c_sources +\
|
||||||
res.cpp_sources + res.libraries + res.hex_files + \
|
res.cpp_sources + res.libraries + res.hex_files + \
|
||||||
|
@ -320,7 +315,7 @@ def export_project(src_paths, export_path, target, ide, libraries_paths=None,
|
||||||
|
|
||||||
# Call unified scan_resources
|
# Call unified scan_resources
|
||||||
resource_dict = {loc: scan_resources(path, toolchain, inc_dirs=inc_dirs, collect_ignores=True)
|
resource_dict = {loc: scan_resources(path, toolchain, inc_dirs=inc_dirs, collect_ignores=True)
|
||||||
for loc, path in src_paths.iteritems()}
|
for loc, path in src_paths.items()}
|
||||||
resources = Resources()
|
resources = Resources()
|
||||||
toolchain.build_dir = export_path
|
toolchain.build_dir = export_path
|
||||||
config_header = toolchain.get_config_header()
|
config_header = toolchain.get_config_header()
|
||||||
|
@ -329,12 +324,12 @@ def export_project(src_paths, export_path, target, ide, libraries_paths=None,
|
||||||
|
|
||||||
if zip_proj:
|
if zip_proj:
|
||||||
subtract_basepath(resources, ".")
|
subtract_basepath(resources, ".")
|
||||||
for loc, res in resource_dict.iteritems():
|
for loc, res in resource_dict.items():
|
||||||
temp = copy.deepcopy(res)
|
temp = copy.deepcopy(res)
|
||||||
subtract_basepath(temp, ".", loc)
|
subtract_basepath(temp, ".", loc)
|
||||||
resources.add(temp)
|
resources.add(temp)
|
||||||
else:
|
else:
|
||||||
for _, res in resource_dict.iteritems():
|
for _, res in resource_dict.items():
|
||||||
resources.add(res)
|
resources.add(res)
|
||||||
|
|
||||||
# Change linker script if specified
|
# Change linker script if specified
|
||||||
|
@ -347,7 +342,7 @@ def export_project(src_paths, export_path, target, ide, libraries_paths=None,
|
||||||
files.append(config_header)
|
files.append(config_header)
|
||||||
if zip_proj:
|
if zip_proj:
|
||||||
for resource in resource_dict.values():
|
for resource in resource_dict.values():
|
||||||
for label, res in resource.features.iteritems():
|
for label, res in resource.features.items():
|
||||||
if label not in toolchain.target.features:
|
if label not in toolchain.target.features:
|
||||||
resource.add(res)
|
resource.add(res)
|
||||||
if isinstance(zip_proj, basestring):
|
if isinstance(zip_proj, basestring):
|
||||||
|
|
|
@ -74,13 +74,13 @@ class CoIDE(Exporter):
|
||||||
def generate(self):
|
def generate(self):
|
||||||
self.resources.win_to_unix()
|
self.resources.win_to_unix()
|
||||||
source_files = []
|
source_files = []
|
||||||
for r_type, n in CoIDE.FILE_TYPES.iteritems():
|
for r_type, n in CoIDE.FILE_TYPES.items():
|
||||||
for file in getattr(self.resources, r_type):
|
for file in getattr(self.resources, r_type):
|
||||||
source_files.append({
|
source_files.append({
|
||||||
'name': basename(file), 'type': n, 'path': file
|
'name': basename(file), 'type': n, 'path': file
|
||||||
})
|
})
|
||||||
header_files = []
|
header_files = []
|
||||||
for r_type, n in CoIDE.FILE_TYPES2.iteritems():
|
for r_type, n in CoIDE.FILE_TYPES2.items():
|
||||||
for file in getattr(self.resources, r_type):
|
for file in getattr(self.resources, r_type):
|
||||||
header_files.append({
|
header_files.append({
|
||||||
'name': basename(file), 'type': n, 'path': file
|
'name': basename(file), 'type': n, 'path': file
|
||||||
|
|
|
@ -50,7 +50,7 @@ class DS5_5(Exporter):
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
source_files = []
|
source_files = []
|
||||||
for r_type, n in DS5_5.FILE_TYPES.iteritems():
|
for r_type, n in DS5_5.FILE_TYPES.items():
|
||||||
for file in getattr(self.resources, r_type):
|
for file in getattr(self.resources, r_type):
|
||||||
source_files.append({
|
source_files.append({
|
||||||
'name': basename(file), 'type': n, 'path': file
|
'name': basename(file), 'type': n, 'path': file
|
||||||
|
|
|
@ -52,7 +52,7 @@ class EmBitz(Exporter):
|
||||||
def generate(self):
|
def generate(self):
|
||||||
self.resources.win_to_unix()
|
self.resources.win_to_unix()
|
||||||
source_files = []
|
source_files = []
|
||||||
for r_type, n in self.FILE_TYPES.iteritems():
|
for r_type, n in self.FILE_TYPES.items():
|
||||||
for file in getattr(self.resources, r_type):
|
for file in getattr(self.resources, r_type):
|
||||||
source_files.append({
|
source_files.append({
|
||||||
'name': file, 'type': n
|
'name': file, 'type': n
|
||||||
|
|
|
@ -104,7 +104,7 @@ class Exporter(object):
|
||||||
"""
|
"""
|
||||||
config_header = self.toolchain.get_config_header()
|
config_header = self.toolchain.get_config_header()
|
||||||
flags = {key + "_flags": copy.deepcopy(value) for key, value
|
flags = {key + "_flags": copy.deepcopy(value) for key, value
|
||||||
in self.toolchain.flags.iteritems()}
|
in self.toolchain.flags.items()}
|
||||||
asm_defines = self.toolchain.get_compile_options(
|
asm_defines = self.toolchain.get_compile_options(
|
||||||
self.toolchain.get_symbols(for_asm=True),
|
self.toolchain.get_symbols(for_asm=True),
|
||||||
filter(None, self.resources.inc_dirs),
|
filter(None, self.resources.inc_dirs),
|
||||||
|
|
|
@ -92,7 +92,7 @@ class GNUARMEclipse(Exporter):
|
||||||
|
|
||||||
config_header = self.toolchain.get_config_header()
|
config_header = self.toolchain.get_config_header()
|
||||||
flags = {key + "_flags": copy.deepcopy(value) for key, value
|
flags = {key + "_flags": copy.deepcopy(value) for key, value
|
||||||
in self.toolchain.flags.iteritems()}
|
in self.toolchain.flags.items()}
|
||||||
if config_header:
|
if config_header:
|
||||||
config_header = relpath(config_header,
|
config_header = relpath(config_header,
|
||||||
self.resources.file_basepath[config_header])
|
self.resources.file_basepath[config_header])
|
||||||
|
@ -117,7 +117,7 @@ class GNUARMEclipse(Exporter):
|
||||||
config_header = self.toolchain.get_config_header()
|
config_header = self.toolchain.get_config_header()
|
||||||
|
|
||||||
flags = {key + "_flags": copy.deepcopy(value) for key, value
|
flags = {key + "_flags": copy.deepcopy(value) for key, value
|
||||||
in toolchain.flags.iteritems()}
|
in toolchain.flags.items()}
|
||||||
if config_header:
|
if config_header:
|
||||||
config_header = relpath(config_header,
|
config_header = relpath(config_header,
|
||||||
self.resources.file_basepath[config_header])
|
self.resources.file_basepath[config_header])
|
||||||
|
|
|
@ -6,7 +6,7 @@ mbedclean:
|
||||||
$(RM) $(SECONDARY_FLASH)$(SECONDARY_SIZE) {{name}}.* linker-script-*.ld
|
$(RM) $(SECONDARY_FLASH)$(SECONDARY_SIZE) {{name}}.* linker-script-*.ld
|
||||||
-@echo ' '
|
-@echo ' '
|
||||||
|
|
||||||
{% for config, data in options.iteritems() %}
|
{% for config, data in options.items() %}
|
||||||
linker-script-{{config}}.ld: ../{{ld_script}}
|
linker-script-{{config}}.ld: ../{{ld_script}}
|
||||||
{{data.cpp_cmd}} {{data.ld.other}} $< -o $@
|
{{data.cpp_cmd}} {{data.ld.other}} $< -o $@
|
||||||
{{name}}.elf: linker-script-{{config}}.ld
|
{{name}}.elf: linker-script-{{config}}.ld
|
||||||
|
|
|
@ -140,7 +140,7 @@ class Makefile(Exporter):
|
||||||
def format_flags(self):
|
def format_flags(self):
|
||||||
"""Format toolchain flags for Makefile"""
|
"""Format toolchain flags for Makefile"""
|
||||||
flags = {}
|
flags = {}
|
||||||
for k, v in self.flags.iteritems():
|
for k, v in self.flags.items():
|
||||||
if k in ['asm_flags', 'c_flags', 'cxx_flags']:
|
if k in ['asm_flags', 'c_flags', 'cxx_flags']:
|
||||||
flags[k] = map(lambda x: x.replace('"', '\\"'), v)
|
flags[k] = map(lambda x: x.replace('"', '\\"'), v)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -6,7 +6,7 @@ mbedclean:
|
||||||
$(RM) $(EXECUTABLES) {{name}}.* linker-script-*.ld
|
$(RM) $(EXECUTABLES) {{name}}.* linker-script-*.ld
|
||||||
-@echo ' '
|
-@echo ' '
|
||||||
|
|
||||||
{% for config, data in options.iteritems() %}
|
{% for config, data in options.items() %}
|
||||||
linker-script-{{config}}.ld: ../{{ld_script}}
|
linker-script-{{config}}.ld: ../{{ld_script}}
|
||||||
{{data.cpp_cmd}} {{data.ld.other}} $< -o $@
|
{{data.cpp_cmd}} {{data.ld.other}} $< -o $@
|
||||||
{{name}}.elf: linker-script-{{config}}.ld
|
{{name}}.elf: linker-script-{{config}}.ld
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
PREPROC_CMD ?= {{cpp_cmd}}
|
PREPROC_CMD ?= {{cpp_cmd}}
|
||||||
|
|
||||||
ldclean:
|
ldclean:
|
||||||
{% for config, opts in options.iteritems() %}
|
{% for config, opts in options.items() %}
|
||||||
$(RM) {{opts['ld']['script']}}
|
$(RM) {{opts['ld']['script']}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% for config, opts in options.iteritems() %}
|
{% for config, opts in options.items() %}
|
||||||
{{opts['ld']['script']}}: ../{{ld_script}}
|
{{opts['ld']['script']}}: ../{{ld_script}}
|
||||||
$(PREPROC_CMD) {{opts.ld.other}} $< -o $@
|
$(PREPROC_CMD) {{opts.ld.other}} $< -o $@
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ class Uvision(Exporter):
|
||||||
'name': self.project_name,
|
'name': self.project_name,
|
||||||
# project_files => dict of generators - file group to generator of
|
# project_files => dict of generators - file group to generator of
|
||||||
# UVFile tuples defined above
|
# UVFile tuples defined above
|
||||||
'project_files': sorted(list(self.format_src(srcs).iteritems()),
|
'project_files': sorted(list(self.format_src(srcs).items()),
|
||||||
key=lambda (group, _): group.lower()),
|
key=lambda (group, _): group.lower()),
|
||||||
'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'),
|
'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'),
|
||||||
'device': DeviceUvision(self.target),
|
'device': DeviceUvision(self.target),
|
||||||
|
|
|
@ -22,7 +22,10 @@ import struct
|
||||||
import binascii
|
import binascii
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import StringIO
|
try:
|
||||||
|
from StringIO import StringIO
|
||||||
|
except ImportError:
|
||||||
|
from io import StringIO
|
||||||
import jinja2
|
import jinja2
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from itertools import count
|
from itertools import count
|
||||||
|
@ -124,7 +127,7 @@ class PackFlashAlgo(object):
|
||||||
if fmt == "hex":
|
if fmt == "hex":
|
||||||
blob = binascii.b2a_hex(self.algo_data)
|
blob = binascii.b2a_hex(self.algo_data)
|
||||||
line_list = []
|
line_list = []
|
||||||
for i in xrange(0, len(blob), group_size):
|
for i in range(0, len(blob), group_size):
|
||||||
line_list.append('"' + blob[i:i + group_size] + '"')
|
line_list.append('"' + blob[i:i + group_size] + '"')
|
||||||
return ("\n" + padding).join(line_list)
|
return ("\n" + padding).join(line_list)
|
||||||
elif fmt == "c":
|
elif fmt == "c":
|
||||||
|
@ -311,7 +314,7 @@ class ElfFileSimple(ELFFile):
|
||||||
|
|
||||||
def __init__(self, data):
|
def __init__(self, data):
|
||||||
"""Construct a ElfFileSimple from bytes or a bytearray"""
|
"""Construct a ElfFileSimple from bytes or a bytearray"""
|
||||||
super(ElfFileSimple, self).__init__(StringIO.StringIO(data))
|
super(ElfFileSimple, self).__init__(StringIO(data))
|
||||||
self.symbols = self._read_symbol_table()
|
self.symbols = self._read_symbol_table()
|
||||||
|
|
||||||
def _read_symbol_table(self):
|
def _read_symbol_table(self):
|
||||||
|
|
|
@ -30,14 +30,14 @@ def hook_tool(function):
|
||||||
return function(t_self, *args, **kwargs)
|
return function(t_self, *args, **kwargs)
|
||||||
_RUNNING_HOOKS[tool] = True
|
_RUNNING_HOOKS[tool] = True
|
||||||
# If this tool isn't hooked, return original function
|
# If this tool isn't hooked, return original function
|
||||||
if not _HOOKS.has_key(tool):
|
if tool not in _HOOKS:
|
||||||
res = function(t_self, *args, **kwargs)
|
res = function(t_self, *args, **kwargs)
|
||||||
_RUNNING_HOOKS[tool] = False
|
_RUNNING_HOOKS[tool] = False
|
||||||
return res
|
return res
|
||||||
tooldesc = _HOOKS[tool]
|
tooldesc = _HOOKS[tool]
|
||||||
setattr(t_self, tool_flag, False)
|
setattr(t_self, tool_flag, False)
|
||||||
# If there is a replace hook, execute the replacement instead
|
# If there is a replace hook, execute the replacement instead
|
||||||
if tooldesc.has_key("replace"):
|
if "replace" in tooldesc:
|
||||||
res = tooldesc["replace"](t_self, *args, **kwargs)
|
res = tooldesc["replace"](t_self, *args, **kwargs)
|
||||||
# If the replacement has set the "done" flag, exit now
|
# If the replacement has set the "done" flag, exit now
|
||||||
# Otherwise continue as usual
|
# Otherwise continue as usual
|
||||||
|
@ -45,12 +45,12 @@ def hook_tool(function):
|
||||||
_RUNNING_HOOKS[tool] = False
|
_RUNNING_HOOKS[tool] = False
|
||||||
return res
|
return res
|
||||||
# Execute pre-function before main function if specified
|
# Execute pre-function before main function if specified
|
||||||
if tooldesc.has_key("pre"):
|
if "pre" in tooldesc:
|
||||||
tooldesc["pre"](t_self, *args, **kwargs)
|
tooldesc["pre"](t_self, *args, **kwargs)
|
||||||
# Execute the main function now
|
# Execute the main function now
|
||||||
res = function(t_self, *args, **kwargs)
|
res = function(t_self, *args, **kwargs)
|
||||||
# Execute post-function after main function if specified
|
# Execute post-function after main function if specified
|
||||||
if tooldesc.has_key("post"):
|
if "post" in tooldesc:
|
||||||
post_res = tooldesc["post"](t_self, *args, **kwargs)
|
post_res = tooldesc["post"](t_self, *args, **kwargs)
|
||||||
_RUNNING_HOOKS[tool] = False
|
_RUNNING_HOOKS[tool] = False
|
||||||
return post_res or res
|
return post_res or res
|
||||||
|
@ -173,7 +173,7 @@ class Hook(object):
|
||||||
hook_type - one of the _HOOK_TYPES
|
hook_type - one of the _HOOK_TYPES
|
||||||
cmdline - the initial command line
|
cmdline - the initial command line
|
||||||
"""
|
"""
|
||||||
if self._cmdline_hooks.has_key(hook_type):
|
if hook_type in self._cmdline_hooks:
|
||||||
cmdline = self._cmdline_hooks[hook_type](
|
cmdline = self._cmdline_hooks[hook_type](
|
||||||
self.toolchain.__class__.__name__, cmdline)
|
self.toolchain.__class__.__name__, cmdline)
|
||||||
return cmdline
|
return cmdline
|
||||||
|
|
|
@ -15,25 +15,25 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from host_registry import HostRegistry
|
from .host_registry import HostRegistry
|
||||||
|
|
||||||
# Host test supervisors
|
# Host test supervisors
|
||||||
from echo import EchoTest
|
from .echo import EchoTest
|
||||||
from rtc_auto import RTCTest
|
from .rtc_auto import RTCTest
|
||||||
from stdio_auto import StdioTest
|
from .stdio_auto import StdioTest
|
||||||
from hello_auto import HelloTest
|
from .hello_auto import HelloTest
|
||||||
from detect_auto import DetectPlatformTest
|
from .detect_auto import DetectPlatformTest
|
||||||
from default_auto import DefaultAuto
|
from .default_auto import DefaultAuto
|
||||||
from dev_null_auto import DevNullTest
|
from .dev_null_auto import DevNullTest
|
||||||
from wait_us_auto import WaitusTest
|
from .wait_us_auto import WaitusTest
|
||||||
from tcpecho_server_auto import TCPEchoServerTest
|
from .tcpecho_server_auto import TCPEchoServerTest
|
||||||
from udpecho_server_auto import UDPEchoServerTest
|
from .udpecho_server_auto import UDPEchoServerTest
|
||||||
from tcpecho_client_auto import TCPEchoClientTest
|
from .tcpecho_client_auto import TCPEchoClientTest
|
||||||
from udpecho_client_auto import UDPEchoClientTest
|
from .udpecho_client_auto import UDPEchoClientTest
|
||||||
from wfi_auto import WFITest
|
from .wfi_auto import WFITest
|
||||||
from serial_nc_rx_auto import SerialNCRXTest
|
from .serial_nc_rx_auto import SerialNCRXTest
|
||||||
from serial_nc_tx_auto import SerialNCTXTest
|
from .serial_nc_tx_auto import SerialNCTXTest
|
||||||
from serial_complete_auto import SerialCompleteTest
|
from .serial_complete_auto import SerialCompleteTest
|
||||||
|
|
||||||
# Populate registry with supervising objects
|
# Populate registry with supervising objects
|
||||||
HOSTREGISTRY = HostRegistry()
|
HOSTREGISTRY = HostRegistry()
|
||||||
|
|
|
@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ class DefaultAuto():
|
||||||
return selftest.RESULT_IO_SERIAL
|
return selftest.RESULT_IO_SERIAL
|
||||||
stdout.write(c)
|
stdout.write(c)
|
||||||
stdout.flush()
|
stdout.flush()
|
||||||
except KeyboardInterrupt, _:
|
except KeyboardInterrupt:
|
||||||
selftest.notify("\r\n[CTRL+C] exit")
|
selftest.notify("\r\n[CTRL+C] exit")
|
||||||
result = selftest.RESULT_ERROR
|
result = selftest.RESULT_ERROR
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -14,26 +14,27 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import host_test_registry
|
from . import host_test_registry
|
||||||
|
|
||||||
# This plugins provide 'flashing' methods to host test scripts
|
# This plugins provide 'flashing' methods to host test scripts
|
||||||
import module_copy_mbed
|
from . import module_copy_mbed
|
||||||
import module_copy_shell
|
from . import module_copy_shell
|
||||||
import module_copy_silabs
|
from . import module_copy_silabs
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import module_copy_smart
|
from . import module_copy_smart
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#import module_copy_firefox
|
#import module_copy_firefox
|
||||||
import module_copy_mps2
|
from . import module_copy_mps2
|
||||||
|
|
||||||
# Plugins used to reset certain platform
|
# Plugins used to reset certain platform
|
||||||
import module_reset_mbed
|
from . import module_reset_mbed
|
||||||
import module_reset_silabs
|
from . import module_reset_silabs
|
||||||
import module_reset_mps2
|
from . import module_reset_mps2
|
||||||
|
|
||||||
|
|
||||||
# Plugin registry instance
|
# Plugin registry instance
|
||||||
|
@ -77,4 +78,4 @@ def get_plugin_caps(type):
|
||||||
def print_plugin_info():
|
def print_plugin_info():
|
||||||
""" Prints plugins' information in user friendly way
|
""" Prints plugins' information in user friendly way
|
||||||
"""
|
"""
|
||||||
print HOST_TEST_PLUGIN_REGISTRY
|
print(HOST_TEST_PLUGIN_REGISTRY)
|
||||||
|
|
|
@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from os import access, F_OK
|
from os import access, F_OK
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
|
@ -58,16 +59,13 @@ class HostTestPluginBase:
|
||||||
def print_plugin_error(self, text):
|
def print_plugin_error(self, text):
|
||||||
""" Function prints error in console and exits always with False
|
""" Function prints error in console and exits always with False
|
||||||
"""
|
"""
|
||||||
print "Plugin error: %s::%s: %s"% (self.name, self.type, text)
|
print("Plugin error: %s::%s: %s" % (self.name, self.type, text))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def print_plugin_info(self, text, NL=True):
|
def print_plugin_info(self, text, NL=True):
|
||||||
""" Function prints notification in console and exits always with True
|
""" Function prints notification in console and exits always with True
|
||||||
"""
|
"""
|
||||||
if NL:
|
print("Plugin info: %s::%s: %s"% (self.name, self.type, text))
|
||||||
print "Plugin info: %s::%s: %s"% (self.name, self.type, text)
|
|
||||||
else:
|
|
||||||
print "Plugin info: %s::%s: %s"% (self.name, self.type, text),
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def print_plugin_char(self, char):
|
def print_plugin_char(self, char):
|
||||||
|
|
|
@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
class HostTestRegistry:
|
class HostTestRegistry:
|
||||||
""" Simple class used to register and store
|
""" Simple class used to register and store
|
||||||
|
@ -23,7 +24,7 @@ class HostTestRegistry:
|
||||||
PLUGINS = {} # 'Plugin Name' : Plugin Object
|
PLUGINS = {} # 'Plugin Name' : Plugin Object
|
||||||
|
|
||||||
def print_error(self, text):
|
def print_error(self, text):
|
||||||
print "Plugin load failed. Reason: %s"% text
|
print("Plugin load failed. Reason: %s" % text)
|
||||||
|
|
||||||
def register_plugin(self, plugin):
|
def register_plugin(self, plugin):
|
||||||
""" Registers and stores plugin inside registry for further use.
|
""" Registers and stores plugin inside registry for further use.
|
||||||
|
|
|
@ -14,9 +14,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from shutil import copy
|
from shutil import copy
|
||||||
from host_test_plugins import HostTestPluginBase
|
from .host_test_plugins import HostTestPluginBase
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ class HostTestPluginCopyMethod_Mbed(HostTestPluginBase):
|
||||||
destination_disk += '/'
|
destination_disk += '/'
|
||||||
try:
|
try:
|
||||||
copy(image_path, destination_disk)
|
copy(image_path, destination_disk)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.print_plugin_error("shutil.copy('%s', '%s')"% (image_path, destination_disk))
|
self.print_plugin_error("shutil.copy('%s', '%s')"% (image_path, destination_disk))
|
||||||
self.print_plugin_error("Error: %s"% str(e))
|
self.print_plugin_error("Error: %s"% str(e))
|
||||||
result = False
|
result = False
|
||||||
|
|
|
@ -14,12 +14,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import os, shutil
|
import os, shutil
|
||||||
from os.path import join
|
from os.path import join
|
||||||
from host_test_plugins import HostTestPluginBase
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
from .host_test_plugins import HostTestPluginBase
|
||||||
|
|
||||||
|
|
||||||
class HostTestPluginCopyMethod_MPS2(HostTestPluginBase):
|
class HostTestPluginCopyMethod_MPS2(HostTestPluginBase):
|
||||||
|
|
|
@ -14,12 +14,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from os.path import join, basename
|
from os.path import join, basename
|
||||||
from host_test_plugins import HostTestPluginBase
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
from .host_test_plugins import HostTestPluginBase
|
||||||
|
|
||||||
class HostTestPluginCopyMethod_Shell(HostTestPluginBase):
|
class HostTestPluginCopyMethod_Shell(HostTestPluginBase):
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from host_test_plugins import HostTestPluginBase
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
from .host_test_plugins import HostTestPluginBase
|
||||||
|
|
||||||
|
|
||||||
class HostTestPluginCopyMethod_Silabs(HostTestPluginBase):
|
class HostTestPluginCopyMethod_Silabs(HostTestPluginBase):
|
||||||
|
|
|
@ -14,8 +14,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from host_test_plugins import HostTestPluginBase
|
from .host_test_plugins import HostTestPluginBase
|
||||||
|
|
||||||
|
|
||||||
class HostTestPluginResetMethod_Mbed(HostTestPluginBase):
|
class HostTestPluginResetMethod_Mbed(HostTestPluginBase):
|
||||||
|
|
|
@ -14,10 +14,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from host_test_plugins import HostTestPluginBase
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
from .host_test_plugins import HostTestPluginBase
|
||||||
|
|
||||||
# Note: This plugin is not fully functional, needs improvements
|
# Note: This plugin is not fully functional, needs improvements
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from host_test_plugins import HostTestPluginBase
|
from .host_test_plugins import HostTestPluginBase
|
||||||
|
|
||||||
|
|
||||||
class HostTestPluginResetMethod_SiLabs(HostTestPluginBase):
|
class HostTestPluginResetMethod_SiLabs(HostTestPluginBase):
|
||||||
|
|
|
@ -14,17 +14,21 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import socket
|
import socket
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
from SocketServer import BaseRequestHandler, TCPServer
|
try:
|
||||||
|
from SocketServer import BaseRequestHandler, TCPServer
|
||||||
|
except ImportError:
|
||||||
|
from socketserver import BaseRequestHandler, TCPServer
|
||||||
|
|
||||||
class TCPEchoClient_Handler(BaseRequestHandler):
|
class TCPEchoClient_Handler(BaseRequestHandler):
|
||||||
def handle(self):
|
def handle(self):
|
||||||
""" One handle per connection
|
""" One handle per connection
|
||||||
"""
|
"""
|
||||||
print "HOST: Connection received...",
|
print("HOST: Connection received...")
|
||||||
count = 1;
|
count = 1;
|
||||||
while True:
|
while True:
|
||||||
data = self.request.recv(1024)
|
data = self.request.recv(1024)
|
||||||
|
@ -32,7 +36,7 @@ class TCPEchoClient_Handler(BaseRequestHandler):
|
||||||
self.request.sendall(data)
|
self.request.sendall(data)
|
||||||
if '{{end}}' in str(data):
|
if '{{end}}' in str(data):
|
||||||
print
|
print
|
||||||
print str(data)
|
print(str(data))
|
||||||
else:
|
else:
|
||||||
if not count % 10:
|
if not count % 10:
|
||||||
sys.stdout.write('.')
|
sys.stdout.write('.')
|
||||||
|
@ -82,6 +86,7 @@ class TCPEchoClientTest():
|
||||||
|
|
||||||
# Returning none will suppress host test from printing success code
|
# Returning none will suppress host test from printing success code
|
||||||
server = TCPServer((SERVER_IP, SERVER_PORT), TCPEchoClient_Handler)
|
server = TCPServer((SERVER_IP, SERVER_PORT), TCPEchoClient_Handler)
|
||||||
print "HOST: Listening for TCP connections: " + SERVER_IP + ":" + str(SERVER_PORT)
|
print("HOST: Listening for TCP connections: %s:%s" %
|
||||||
|
(SERVER_IP, str(SERVER_PORT)))
|
||||||
self.send_server_ip_port(selftest, SERVER_IP, SERVER_PORT)
|
self.send_server_ip_port(selftest, SERVER_IP, SERVER_PORT)
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
|
|
|
@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -47,18 +48,18 @@ class TCPEchoServerTest():
|
||||||
try:
|
try:
|
||||||
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
self.s.connect((self.ECHO_SERVER_ADDRESS, self.ECHO_PORT))
|
self.s.connect((self.ECHO_SERVER_ADDRESS, self.ECHO_PORT))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.s = None
|
self.s = None
|
||||||
selftest.notify("HOST: Socket error: %s"% e)
|
selftest.notify("HOST: Socket error: %s"% e)
|
||||||
return selftest.RESULT_ERROR
|
return selftest.RESULT_ERROR
|
||||||
|
|
||||||
print 'HOST: Sending %d echo strings...'% self.ECHO_LOOPs,
|
print('HOST: Sending %d echo strings...'% self.ECHO_LOOPs,)
|
||||||
for i in range(0, self.ECHO_LOOPs):
|
for i in range(0, self.ECHO_LOOPs):
|
||||||
TEST_STRING = str(uuid.uuid4())
|
TEST_STRING = str(uuid.uuid4())
|
||||||
try:
|
try:
|
||||||
self.s.sendall(TEST_STRING)
|
self.s.sendall(TEST_STRING)
|
||||||
data = self.s.recv(128)
|
data = self.s.recv(128)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.s = None
|
self.s = None
|
||||||
selftest.notify("HOST: Socket error: %s"% e)
|
selftest.notify("HOST: Socket error: %s"% e)
|
||||||
return selftest.RESULT_ERROR
|
return selftest.RESULT_ERROR
|
||||||
|
@ -69,10 +70,10 @@ class TCPEchoServerTest():
|
||||||
stdout.flush()
|
stdout.flush()
|
||||||
result = True
|
result = True
|
||||||
else:
|
else:
|
||||||
print "Expected: "
|
print("Expected: ")
|
||||||
print "'%s'"% TEST_STRING
|
print("'%s'"% TEST_STRING)
|
||||||
print "received: "
|
print("received: ")
|
||||||
print "'%s'"% received_str
|
print("'%s'"% received_str)
|
||||||
result = False
|
result = False
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,15 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import socket
|
import socket
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
from SocketServer import BaseRequestHandler, UDPServer
|
try:
|
||||||
|
from SocketServer import BaseRequestHandler, UDPServer
|
||||||
|
except ImportError:
|
||||||
|
from socketserver import BaseRequestHandler, UDPServer
|
||||||
|
|
||||||
class UDPEchoClient_Handler(BaseRequestHandler):
|
class UDPEchoClient_Handler(BaseRequestHandler):
|
||||||
def handle(self):
|
def handle(self):
|
||||||
|
@ -27,8 +31,7 @@ class UDPEchoClient_Handler(BaseRequestHandler):
|
||||||
data, socket = self.request
|
data, socket = self.request
|
||||||
socket.sendto(data, self.client_address)
|
socket.sendto(data, self.client_address)
|
||||||
if '{{end}}' in data:
|
if '{{end}}' in data:
|
||||||
print
|
print("\n%s" % data)
|
||||||
print data
|
|
||||||
else:
|
else:
|
||||||
sys.stdout.write('.')
|
sys.stdout.write('.')
|
||||||
stdout.flush()
|
stdout.flush()
|
||||||
|
@ -72,6 +75,6 @@ class UDPEchoClientTest():
|
||||||
|
|
||||||
# Returning none will suppress host test from printing success code
|
# Returning none will suppress host test from printing success code
|
||||||
server = UDPServer((SERVER_IP, SERVER_PORT), UDPEchoClient_Handler)
|
server = UDPServer((SERVER_IP, SERVER_PORT), UDPEchoClient_Handler)
|
||||||
print "HOST: Listening for UDP connections..."
|
print("HOST: Listening for UDP connections...")
|
||||||
self.send_server_ip_port(selftest, SERVER_IP, SERVER_PORT)
|
self.send_server_ip_port(selftest, SERVER_IP, SERVER_PORT)
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
|
|
|
@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -45,7 +46,7 @@ class UDPEchoServerTest():
|
||||||
# We assume this test fails so can't send 'error' message to server
|
# We assume this test fails so can't send 'error' message to server
|
||||||
try:
|
try:
|
||||||
self.s = socket(AF_INET, SOCK_DGRAM)
|
self.s = socket(AF_INET, SOCK_DGRAM)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.s = None
|
self.s = None
|
||||||
selftest.notify("HOST: Socket error: %s"% e)
|
selftest.notify("HOST: Socket error: %s"% e)
|
||||||
return selftest.RESULT_ERROR
|
return selftest.RESULT_ERROR
|
||||||
|
|
|
@ -18,6 +18,7 @@ limitations under the License.
|
||||||
|
|
||||||
TEST BUILD & RUN
|
TEST BUILD & RUN
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
@ -186,20 +187,20 @@ if __name__ == '__main__':
|
||||||
# Only prints matrix of supported toolchains
|
# Only prints matrix of supported toolchains
|
||||||
if options.supported_toolchains:
|
if options.supported_toolchains:
|
||||||
if options.supported_toolchains == "matrix":
|
if options.supported_toolchains == "matrix":
|
||||||
print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
|
print(mcu_toolchain_matrix(platform_filter=options.general_filter_regex))
|
||||||
elif options.supported_toolchains == "toolchains":
|
elif options.supported_toolchains == "toolchains":
|
||||||
toolchain_list = mcu_toolchain_list()
|
toolchain_list = mcu_toolchain_list()
|
||||||
# Only print the lines that matter
|
# Only print the lines that matter
|
||||||
for line in toolchain_list.split("\n"):
|
for line in toolchain_list.split("\n"):
|
||||||
if not "mbed" in line:
|
if not "mbed" in line:
|
||||||
print line
|
print(line)
|
||||||
elif options.supported_toolchains == "targets":
|
elif options.supported_toolchains == "targets":
|
||||||
print mcu_target_list()
|
print(mcu_target_list())
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# Print available tests in order and exit
|
# Print available tests in order and exit
|
||||||
if options.list_tests is True:
|
if options.list_tests is True:
|
||||||
print '\n'.join(map(str, sorted(TEST_MAP.values())))
|
print('\n'.join(map(str, sorted(TEST_MAP.values()))))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
# force program to "0" if a source dir is specified
|
# force program to "0" if a source dir is specified
|
||||||
|
@ -245,7 +246,7 @@ if __name__ == '__main__':
|
||||||
search_path = TOOLCHAIN_PATHS[toolchain] or "No path set"
|
search_path = TOOLCHAIN_PATHS[toolchain] or "No path set"
|
||||||
args_error(parser, "Could not find executable for %s.\n"
|
args_error(parser, "Could not find executable for %s.\n"
|
||||||
"Currently set search path: %s"
|
"Currently set search path: %s"
|
||||||
%(toolchain,search_path))
|
%(toolchain, search_path))
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
build_data_blob = {} if options.build_data else None
|
build_data_blob = {} if options.build_data else None
|
||||||
|
@ -259,7 +260,7 @@ if __name__ == '__main__':
|
||||||
if options.extra is not None: test.extra_files = options.extra
|
if options.extra is not None: test.extra_files = options.extra
|
||||||
|
|
||||||
if not test.is_supported(mcu, toolchain):
|
if not test.is_supported(mcu, toolchain):
|
||||||
print 'The selected test is not supported on target %s with toolchain %s' % (mcu, toolchain)
|
print('The selected test is not supported on target %s with toolchain %s' % (mcu, toolchain))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
# Linking with extra libraries
|
# Linking with extra libraries
|
||||||
|
@ -294,7 +295,7 @@ if __name__ == '__main__':
|
||||||
options,
|
options,
|
||||||
toolchain),
|
toolchain),
|
||||||
stats_depth=options.stats_depth)
|
stats_depth=options.stats_depth)
|
||||||
print 'Image: %s'% bin_file
|
print('Image: %s'% bin_file)
|
||||||
|
|
||||||
if options.disk:
|
if options.disk:
|
||||||
# Simple copy to the mbed disk
|
# Simple copy to the mbed disk
|
||||||
|
@ -328,16 +329,16 @@ if __name__ == '__main__':
|
||||||
sys.stdout.write(c)
|
sys.stdout.write(c)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
except KeyboardInterrupt, e:
|
except KeyboardInterrupt as e:
|
||||||
print "\n[CTRL+c] exit"
|
print("\n[CTRL+c] exit")
|
||||||
except NotSupportedException as e:
|
except NotSupportedException as e:
|
||||||
print "\nCould not compile for %s: %s" % (mcu, str(e))
|
print("\nCould not compile for %s: %s" % (mcu, str(e)))
|
||||||
except Exception,e:
|
except Exception as e:
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
else:
|
else:
|
||||||
print "[ERROR] %s" % str(e)
|
print("[ERROR] %s" % str(e))
|
||||||
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if options.build_data:
|
if options.build_data:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
"""Memory Map File Analyser for ARM mbed"""
|
"""Memory Map File Analyser for ARM mbed"""
|
||||||
|
from __future__ import print_function, division, absolute_import
|
||||||
|
|
||||||
from abc import abstractmethod, ABCMeta
|
from abc import abstractmethod, ABCMeta
|
||||||
from sys import stdout, exit, argv
|
from sys import stdout, exit, argv
|
||||||
|
@ -15,8 +16,8 @@ from copy import deepcopy
|
||||||
from prettytable import PrettyTable
|
from prettytable import PrettyTable
|
||||||
from tools.arm_pack_manager import Cache
|
from tools.arm_pack_manager import Cache
|
||||||
|
|
||||||
from utils import argparse_filestring_type, \
|
from .utils import (argparse_filestring_type, argparse_lowercase_hyphen_type,
|
||||||
argparse_lowercase_hyphen_type, argparse_uppercase_type
|
argparse_uppercase_type)
|
||||||
|
|
||||||
|
|
||||||
class _Parser(object):
|
class _Parser(object):
|
||||||
|
@ -132,7 +133,7 @@ class _GccParser(_Parser):
|
||||||
return join('[lib]', test_re_obj_name.group(2),
|
return join('[lib]', test_re_obj_name.group(2),
|
||||||
test_re_obj_name.group(3))
|
test_re_obj_name.group(3))
|
||||||
else:
|
else:
|
||||||
print "Unknown object name found in GCC map file: %s" % line
|
print("Unknown object name found in GCC map file: %s" % line)
|
||||||
return '[misc]'
|
return '[misc]'
|
||||||
|
|
||||||
def parse_section(self, line):
|
def parse_section(self, line):
|
||||||
|
@ -217,7 +218,7 @@ class _ArmccParser(_Parser):
|
||||||
if is_obj:
|
if is_obj:
|
||||||
return join('[lib]', basename(is_obj.group(1)), is_obj.group(3))
|
return join('[lib]', basename(is_obj.group(1)), is_obj.group(3))
|
||||||
else:
|
else:
|
||||||
print "Malformed input found when parsing ARMCC map: %s" % line
|
print("Malformed input found when parsing ARMCC map: %s" % line)
|
||||||
return '[misc]'
|
return '[misc]'
|
||||||
|
|
||||||
def parse_section(self, line):
|
def parse_section(self, line):
|
||||||
|
@ -246,8 +247,8 @@ class _ArmccParser(_Parser):
|
||||||
elif test_re.group(3) == 'Code':
|
elif test_re.group(3) == 'Code':
|
||||||
section = '.text'
|
section = '.text'
|
||||||
else:
|
else:
|
||||||
print "Malformed input found when parsing armcc map: %s, %r" %\
|
print("Malformed input found when parsing armcc map: %s, %r"
|
||||||
(line, test_re.groups())
|
% (line, test_re.groups()))
|
||||||
|
|
||||||
return ["", 0, ""]
|
return ["", 0, ""]
|
||||||
|
|
||||||
|
@ -352,7 +353,7 @@ class _IarParser(_Parser):
|
||||||
elif test_re.group(2) == 'inited':
|
elif test_re.group(2) == 'inited':
|
||||||
section = '.data'
|
section = '.data'
|
||||||
else:
|
else:
|
||||||
print "Malformed input found when parsing IAR map: %s" % line
|
print("Malformed input found when parsing IAR map: %s" % line)
|
||||||
return ["", 0, ""]
|
return ["", 0, ""]
|
||||||
|
|
||||||
# lookup object in dictionary and return module name
|
# lookup object in dictionary and return module name
|
||||||
|
@ -407,7 +408,7 @@ class _IarParser(_Parser):
|
||||||
if (not arg.startswith("-")) and arg.endswith(".o"):
|
if (not arg.startswith("-")) and arg.endswith(".o"):
|
||||||
self.cmd_modules[basename(arg)] = arg
|
self.cmd_modules[basename(arg)] = arg
|
||||||
|
|
||||||
common_prefix = dirname(commonprefix(self.cmd_modules.values()))
|
common_prefix = dirname(commonprefix(list(self.cmd_modules.values())))
|
||||||
self.cmd_modules = {s: relpath(f, common_prefix)
|
self.cmd_modules = {s: relpath(f, common_prefix)
|
||||||
for s, f in self.cmd_modules.items()}
|
for s, f in self.cmd_modules.items()}
|
||||||
|
|
||||||
|
@ -524,11 +525,11 @@ class MemapParser(object):
|
||||||
self.compute_report()
|
self.compute_report()
|
||||||
try:
|
try:
|
||||||
if file_output:
|
if file_output:
|
||||||
file_desc = open(file_output, 'wb')
|
file_desc = open(file_output, 'w')
|
||||||
else:
|
else:
|
||||||
file_desc = stdout
|
file_desc = stdout
|
||||||
except IOError as error:
|
except IOError as error:
|
||||||
print "I/O error({0}): {1}".format(error.errno, error.strerror)
|
print("I/O error({0}): {1}".format(error.errno, error.strerror))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
to_call = {'json': self.generate_json,
|
to_call = {'json': self.generate_json,
|
||||||
|
@ -558,24 +559,24 @@ class MemapParser(object):
|
||||||
Positional arguments:
|
Positional arguments:
|
||||||
file_desc - the file to write out the final report to
|
file_desc - the file to write out the final report to
|
||||||
"""
|
"""
|
||||||
csv_writer = csv.writer(file_desc, delimiter=',',
|
writer = csv.writer(file_desc, delimiter=',',
|
||||||
quoting=csv.QUOTE_MINIMAL)
|
quoting=csv.QUOTE_MINIMAL)
|
||||||
|
|
||||||
csv_module_section = []
|
module_section = []
|
||||||
csv_sizes = []
|
sizes = []
|
||||||
for i in sorted(self.short_modules):
|
for i in sorted(self.short_modules):
|
||||||
for k in self.print_sections:
|
for k in self.print_sections:
|
||||||
csv_module_section += [i+k]
|
module_section.append((i + k))
|
||||||
csv_sizes += [self.short_modules[i][k]]
|
sizes += [self.short_modules[i][k]]
|
||||||
|
|
||||||
csv_module_section += ['static_ram']
|
module_section.append('static_ram')
|
||||||
csv_sizes += [self.mem_summary['static_ram']]
|
sizes.append(self.mem_summary['static_ram'])
|
||||||
|
|
||||||
csv_module_section += ['total_flash']
|
module_section.append('total_flash')
|
||||||
csv_sizes += [self.mem_summary['total_flash']]
|
sizes.append(self.mem_summary['total_flash'])
|
||||||
|
|
||||||
csv_writer.writerow(csv_module_section)
|
writer.writerow(module_section)
|
||||||
csv_writer.writerow(csv_sizes)
|
writer.writerow(sizes)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def generate_table(self, file_desc):
|
def generate_table(self, file_desc):
|
||||||
|
@ -736,7 +737,7 @@ class MemapParser(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except IOError as error:
|
except IOError as error:
|
||||||
print "I/O error({0}): {1}".format(error.errno, error.strerror)
|
print("I/O error({0}): {1}".format(error.errno, error.strerror))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -803,7 +804,7 @@ def main():
|
||||||
returned_string = memap.generate_output(args.export, depth)
|
returned_string = memap.generate_output(args.export, depth)
|
||||||
|
|
||||||
if args.export == 'table' and returned_string:
|
if args.export == 'table' and returned_string:
|
||||||
print returned_string
|
print(returned_string)
|
||||||
|
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
|
|
@ -43,13 +43,13 @@ class MyJSONEncoder(json.JSONEncoder):
|
||||||
break
|
break
|
||||||
output = []
|
output = []
|
||||||
if primitives_only and len(o) < 3:
|
if primitives_only and len(o) < 3:
|
||||||
for key, value in o.iteritems():
|
for key, value in o.items():
|
||||||
output.append(json.dumps(key) + ": " + self.encode(value))
|
output.append(json.dumps(key) + ": " + self.encode(value))
|
||||||
return "{" + ", ".join(output) + "}"
|
return "{" + ", ".join(output) + "}"
|
||||||
else:
|
else:
|
||||||
self.current_indent += self.indent
|
self.current_indent += self.indent
|
||||||
self.current_indent_str = " " * self.current_indent
|
self.current_indent_str = " " * self.current_indent
|
||||||
for key, value in o.iteritems():
|
for key, value in o.items():
|
||||||
output.append(self.current_indent_str + json.dumps(key) + ": " + self.encode(value))
|
output.append(self.current_indent_str + json.dumps(key) + ": " + self.encode(value))
|
||||||
self.current_indent -= self.indent
|
self.current_indent -= self.indent
|
||||||
self.current_indent_str = " " * self.current_indent
|
self.current_indent_str = " " * self.current_indent
|
||||||
|
@ -141,7 +141,7 @@ def add_to_targets(targets, device_file, verbose=False, remove=False) :
|
||||||
print("[WARNING] device {} did not have an associated device.h".format(device))
|
print("[WARNING] device {} did not have an associated device.h".format(device))
|
||||||
else :
|
else :
|
||||||
possible_matches = set([key for key in targets.keys() if stem_match(device, key)])
|
possible_matches = set([key for key in targets.keys() if stem_match(device, key)])
|
||||||
for key, value in targets.iteritems() :
|
for key, value in targets.items() :
|
||||||
for alt in value['extra_labels'] if 'extra_labels' in value else [] :
|
for alt in value['extra_labels'] if 'extra_labels' in value else [] :
|
||||||
if stem_match(device, alt) : possible_matches.add(key)
|
if stem_match(device, alt) : possible_matches.add(key)
|
||||||
for alt in value['extra_labels_add'] if 'extra_labels_add' in value else [] :
|
for alt in value['extra_labels_add'] if 'extra_labels_add' in value else [] :
|
||||||
|
|
|
@ -14,16 +14,19 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function, division, absolute_import
|
||||||
|
|
||||||
from json import load
|
from json import load
|
||||||
from os.path import join, dirname
|
from os.path import join, dirname
|
||||||
from os import listdir
|
from os import listdir
|
||||||
from argparse import ArgumentParser, ArgumentTypeError
|
from argparse import ArgumentParser, ArgumentTypeError
|
||||||
from tools.toolchains import TOOLCHAINS
|
|
||||||
from tools.targets import TARGET_NAMES, Target, update_target_data
|
from .toolchains import TOOLCHAINS
|
||||||
from tools.utils import argparse_force_uppercase_type, \
|
from .targets import TARGET_NAMES, Target, update_target_data
|
||||||
argparse_lowercase_hyphen_type, argparse_many, \
|
from .utils import (argparse_force_uppercase_type, argparse_deprecate,
|
||||||
argparse_filestring_type, args_error, argparse_profile_filestring_type,\
|
argparse_lowercase_hyphen_type, argparse_many,
|
||||||
argparse_deprecate
|
argparse_filestring_type, args_error,
|
||||||
|
argparse_profile_filestring_type)
|
||||||
|
|
||||||
FLAGS_DEPRECATION_MESSAGE = "Please use the --profile argument instead.\n"\
|
FLAGS_DEPRECATION_MESSAGE = "Please use the --profile argument instead.\n"\
|
||||||
"Documentation may be found in "\
|
"Documentation may be found in "\
|
||||||
|
|
|
@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
from os import getenv
|
from os import getenv
|
||||||
from os.path import join, abspath, dirname, exists
|
from os.path import join, abspath, dirname, exists
|
||||||
import logging
|
import logging
|
||||||
|
@ -81,7 +81,8 @@ for _n in _ENV_PATHS:
|
||||||
if exists(getenv('MBED_'+_n)):
|
if exists(getenv('MBED_'+_n)):
|
||||||
globals()[_n] = getenv('MBED_'+_n)
|
globals()[_n] = getenv('MBED_'+_n)
|
||||||
else:
|
else:
|
||||||
print "WARNING: MBED_%s set as environment variable but doesn't exist" % _n
|
print("WARNING: MBED_%s set as environment variable but doesn't"
|
||||||
|
" exist" % _n)
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
|
@ -101,7 +101,7 @@ def compare(t1, t2, target):
|
||||||
benchmarks_data[name][t] = map(int, (code, data, bss, flash))
|
benchmarks_data[name][t] = map(int, (code, data, bss, flash))
|
||||||
|
|
||||||
print "%s vs %s for %s" % (t1, t2, target)
|
print "%s vs %s for %s" % (t1, t2, target)
|
||||||
for name, data in benchmarks_data.iteritems():
|
for name, data in benchmarks_data.items():
|
||||||
try:
|
try:
|
||||||
# Check Size
|
# Check Size
|
||||||
code_a, data_a, bss_a, flash_a = data[t1]
|
code_a, data_a, bss_a, flash_a = data[t1]
|
||||||
|
|
|
@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import binascii
|
import binascii
|
||||||
|
@ -65,7 +66,7 @@ def cached(func):
|
||||||
"""
|
"""
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
"""The wrapped function itself"""
|
"""The wrapped function itself"""
|
||||||
if not CACHES.has_key((func.__name__, args)):
|
if (func.__name__, args) not in CACHES:
|
||||||
CACHES[(func.__name__, args)] = func(*args, **kwargs)
|
CACHES[(func.__name__, args)] = func(*args, **kwargs)
|
||||||
return CACHES[(func.__name__, args)]
|
return CACHES[(func.__name__, args)]
|
||||||
return wrapper
|
return wrapper
|
||||||
|
@ -141,9 +142,10 @@ class Target(namedtuple("Target", "name json_data resolution_order resolution_or
|
||||||
Target.__targets_json_location_default)
|
Target.__targets_json_location_default)
|
||||||
|
|
||||||
for extra_target in Target.__extra_target_json_files:
|
for extra_target in Target.__extra_target_json_files:
|
||||||
for k, v in json_file_to_dict(extra_target).iteritems():
|
for k, v in json_file_to_dict(extra_target).items():
|
||||||
if k in targets:
|
if k in targets:
|
||||||
print 'WARNING: Custom target "%s" cannot replace existing target.' % k
|
print('WARNING: Custom target "%s" cannot replace existing '
|
||||||
|
'target.' % k)
|
||||||
else:
|
else:
|
||||||
targets[k] = v
|
targets[k] = v
|
||||||
|
|
||||||
|
@ -212,16 +214,16 @@ class Target(namedtuple("Target", "name json_data resolution_order resolution_or
|
||||||
# inheritance level, left to right order to figure out all the
|
# inheritance level, left to right order to figure out all the
|
||||||
# other classes that change the definition by adding or removing
|
# other classes that change the definition by adding or removing
|
||||||
# elements
|
# elements
|
||||||
for idx in xrange(self.resolution_order[def_idx][1] - 1, -1, -1):
|
for idx in range(self.resolution_order[def_idx][1] - 1, -1, -1):
|
||||||
same_level_targets = [tar[0] for tar in self.resolution_order
|
same_level_targets = [tar[0] for tar in self.resolution_order
|
||||||
if tar[1] == idx]
|
if tar[1] == idx]
|
||||||
for tar in same_level_targets:
|
for tar in same_level_targets:
|
||||||
data = tdata[tar]
|
data = tdata[tar]
|
||||||
# Do we have anything to add ?
|
# Do we have anything to add ?
|
||||||
if data.has_key(attrname + "_add"):
|
if (attrname + "_add") in data:
|
||||||
starting_value.extend(data[attrname + "_add"])
|
starting_value.extend(data[attrname + "_add"])
|
||||||
# Do we have anything to remove ?
|
# Do we have anything to remove ?
|
||||||
if data.has_key(attrname + "_remove"):
|
if (attrname + "_remove") in data:
|
||||||
# Macros can be defined either without a value (MACRO)
|
# Macros can be defined either without a value (MACRO)
|
||||||
# or with a value (MACRO=10). When removing, we specify
|
# or with a value (MACRO=10). When removing, we specify
|
||||||
# only the name of the macro, without the value. So we
|
# only the name of the macro, without the value. So we
|
||||||
|
@ -258,19 +260,14 @@ class Target(namedtuple("Target", "name json_data resolution_order resolution_or
|
||||||
starting_value = None
|
starting_value = None
|
||||||
for tgt in self.resolution_order:
|
for tgt in self.resolution_order:
|
||||||
data = tdata[tgt[0]]
|
data = tdata[tgt[0]]
|
||||||
if data.has_key(attrname):
|
try:
|
||||||
starting_value = data[attrname]
|
return data[attrname]
|
||||||
break
|
except KeyError:
|
||||||
|
pass
|
||||||
else: # Attribute not found
|
else: # Attribute not found
|
||||||
raise AttributeError(
|
raise AttributeError(
|
||||||
"Attribute '%s' not found in target '%s'"
|
"Attribute '%s' not found in target '%s'"
|
||||||
% (attrname, self.name))
|
% (attrname, self.name))
|
||||||
# 'progen' needs the full path to the template (the path in JSON is
|
|
||||||
# relative to tools/export)
|
|
||||||
if attrname == "progen":
|
|
||||||
return self.__add_paths_to_progen(starting_value)
|
|
||||||
else:
|
|
||||||
return starting_value
|
|
||||||
|
|
||||||
def __getattr__(self, attrname):
|
def __getattr__(self, attrname):
|
||||||
""" Return the value of an attribute. This function only computes the
|
""" Return the value of an attribute. This function only computes the
|
||||||
|
@ -338,7 +335,7 @@ class Target(namedtuple("Target", "name json_data resolution_order resolution_or
|
||||||
# "class_name" must refer to a class in this file, so check if the
|
# "class_name" must refer to a class in this file, so check if the
|
||||||
# class exists
|
# class exists
|
||||||
mdata = self.get_module_data()
|
mdata = self.get_module_data()
|
||||||
if not mdata.has_key(class_name) or \
|
if class_name not in mdata or \
|
||||||
not inspect.isclass(mdata[class_name]):
|
not inspect.isclass(mdata[class_name]):
|
||||||
raise HookError(
|
raise HookError(
|
||||||
("Class '%s' required by '%s' in target '%s'"
|
("Class '%s' required by '%s' in target '%s'"
|
||||||
|
@ -427,7 +424,7 @@ class MTSCode(object):
|
||||||
loader = os.path.join(TOOLS_BOOTLOADERS, target_name, "bootloader.bin")
|
loader = os.path.join(TOOLS_BOOTLOADERS, target_name, "bootloader.bin")
|
||||||
target = binf + ".tmp"
|
target = binf + ".tmp"
|
||||||
if not os.path.exists(loader):
|
if not os.path.exists(loader):
|
||||||
print "Can't find bootloader binary: " + loader
|
print("Can't find bootloader binary: " + loader)
|
||||||
return
|
return
|
||||||
outbin = open(target, 'w+b')
|
outbin = open(target, 'w+b')
|
||||||
part = open(loader, 'rb')
|
part = open(loader, 'rb')
|
||||||
|
|
|
@ -18,6 +18,7 @@ limitations under the License.
|
||||||
|
|
||||||
TEST BUILD & RUN
|
TEST BUILD & RUN
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function, division, absolute_import
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
@ -36,8 +37,8 @@ from tools.build_api import merge_build_data
|
||||||
from tools.targets import TARGET_MAP
|
from tools.targets import TARGET_MAP
|
||||||
from tools.utils import mkdir, ToolException, NotSupportedException, args_error
|
from tools.utils import mkdir, ToolException, NotSupportedException, args_error
|
||||||
from tools.test_exporters import ReportExporter, ResultExporterType
|
from tools.test_exporters import ReportExporter, ResultExporterType
|
||||||
from utils import argparse_filestring_type, argparse_lowercase_type, argparse_many
|
from tools.utils import argparse_filestring_type, argparse_lowercase_type, argparse_many
|
||||||
from utils import argparse_dir_not_parent
|
from tools.utils import argparse_dir_not_parent
|
||||||
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS, TOOLCHAIN_CLASSES
|
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS, TOOLCHAIN_CLASSES
|
||||||
from tools.settings import CLI_COLOR_MAP
|
from tools.settings import CLI_COLOR_MAP
|
||||||
|
|
||||||
|
@ -164,7 +165,8 @@ if __name__ == '__main__':
|
||||||
if fnmatch.fnmatch(testname, name):
|
if fnmatch.fnmatch(testname, name):
|
||||||
tests[testname] = test
|
tests[testname] = test
|
||||||
else:
|
else:
|
||||||
print "[Warning] Test with name '%s' was not found in the available tests" % (name)
|
print("[Warning] Test with name '%s' was not found in the "
|
||||||
|
"available tests" % (name))
|
||||||
else:
|
else:
|
||||||
tests = all_tests
|
tests = all_tests
|
||||||
|
|
||||||
|
@ -211,18 +213,18 @@ if __name__ == '__main__':
|
||||||
build_profile=profile)
|
build_profile=profile)
|
||||||
|
|
||||||
library_build_success = True
|
library_build_success = True
|
||||||
except ToolException, e:
|
except ToolException as e:
|
||||||
# ToolException output is handled by the build log
|
# ToolException output is handled by the build log
|
||||||
pass
|
pass
|
||||||
except NotSupportedException, e:
|
except NotSupportedException as e:
|
||||||
# NotSupportedException is handled by the build log
|
# NotSupportedException is handled by the build log
|
||||||
pass
|
pass
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# Some other exception occurred, print the error message
|
# Some other exception occurred, print the error message
|
||||||
print e
|
print(e)
|
||||||
|
|
||||||
if not library_build_success:
|
if not library_build_success:
|
||||||
print "Failed to build library"
|
print("Failed to build library")
|
||||||
else:
|
else:
|
||||||
# Build all the tests
|
# Build all the tests
|
||||||
|
|
||||||
|
@ -252,9 +254,9 @@ if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
with open(options.test_spec, 'w') as f:
|
with open(options.test_spec, 'w') as f:
|
||||||
f.write(json.dumps(test_spec_data, indent=2))
|
f.write(json.dumps(test_spec_data, indent=2))
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
print "[ERROR] Error writing test spec to file"
|
print("[ERROR] Error writing test spec to file")
|
||||||
print e
|
print(e)
|
||||||
|
|
||||||
# If a path to a JUnit build report spec is provided, write it to a file
|
# If a path to a JUnit build report spec is provided, write it to a file
|
||||||
if options.build_report_junit:
|
if options.build_report_junit:
|
||||||
|
@ -264,7 +266,7 @@ if __name__ == '__main__':
|
||||||
# Print memory map summary on screen
|
# Print memory map summary on screen
|
||||||
if build_report:
|
if build_report:
|
||||||
print
|
print
|
||||||
print print_build_memory_usage(build_report)
|
print(print_build_memory_usage(build_report))
|
||||||
|
|
||||||
print_report_exporter = ReportExporter(ResultExporterType.PRINT, package="build")
|
print_report_exporter = ReportExporter(ResultExporterType.PRINT, package="build")
|
||||||
status = print_report_exporter.report(build_report)
|
status = print_report_exporter.report(build_report)
|
||||||
|
@ -276,13 +278,13 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
except KeyboardInterrupt, e:
|
except KeyboardInterrupt as e:
|
||||||
print "\n[CTRL+c] exit"
|
print("\n[CTRL+c] exit")
|
||||||
except ConfigException, e:
|
except ConfigException as e:
|
||||||
# Catching ConfigException here to prevent a traceback
|
# Catching ConfigException here to prevent a traceback
|
||||||
print "[ERROR] %s" % str(e)
|
print("[ERROR] %s" % str(e))
|
||||||
except Exception,e:
|
except Exception as e:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
print "[ERROR] %s" % str(e)
|
print("[ERROR] %s" % str(e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -59,7 +59,7 @@ class BuildApiTests(unittest.TestCase):
|
||||||
@patch('os.mkdir')
|
@patch('os.mkdir')
|
||||||
@patch('tools.toolchains.exists', return_value=True)
|
@patch('tools.toolchains.exists', return_value=True)
|
||||||
@patch('tools.toolchains.mbedToolchain.dump_build_profile')
|
@patch('tools.toolchains.mbedToolchain.dump_build_profile')
|
||||||
@patch('tools.utils.run_cmd', return_value=("", "", 0))
|
@patch('tools.utils.run_cmd', return_value=(b'', b'', 0))
|
||||||
def test_always_complete_build(self, *_):
|
def test_always_complete_build(self, *_):
|
||||||
with MagicMock() as notify:
|
with MagicMock() as notify:
|
||||||
toolchain = prepare_toolchain(self.src_paths, self.build_path, self.target,
|
toolchain = prepare_toolchain(self.src_paths, self.build_path, self.target,
|
||||||
|
|
|
@ -40,7 +40,7 @@ def compare_config(cfg, expected):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return "Unexpected key '%s' in configuration data" % k
|
return "Unexpected key '%s' in configuration data" % k
|
||||||
for k in expected:
|
for k in expected:
|
||||||
if k not in ["expected_macros", "expected_features"] + cfg.keys():
|
if k not in ["expected_macros", "expected_features"] + list(cfg.keys()):
|
||||||
return "Expected key '%s' was not found in configuration data" % k
|
return "Expected key '%s' was not found in configuration data" % k
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ def test_config(name):
|
||||||
if expected_features is not None:
|
if expected_features is not None:
|
||||||
assert sorted(expected_features) == sorted(features)
|
assert sorted(expected_features) == sorted(features)
|
||||||
except ConfigException as e:
|
except ConfigException as e:
|
||||||
err_msg = e.message
|
err_msg = str(e)
|
||||||
if "exception_msg" not in expected:
|
if "exception_msg" not in expected:
|
||||||
assert not(err_msg), "Unexpected Error: %s" % e
|
assert not(err_msg), "Unexpected Error: %s" % e
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -18,8 +18,9 @@ sys.path.insert(0, ROOT)
|
||||||
from tools.build_api import get_mbed_official_release
|
from tools.build_api import get_mbed_official_release
|
||||||
from tools.targets import TARGET_MAP
|
from tools.targets import TARGET_MAP
|
||||||
from tools.export import EXPORTERS
|
from tools.export import EXPORTERS
|
||||||
|
from tools.toolchains import TOOLCHAINS
|
||||||
|
|
||||||
SUPPORTED_TOOLCHAINS = ["ARM", "IAR", "GCC_ARM", "ARMC6"]
|
SUPPORTED_TOOLCHAINS = list(TOOLCHAINS - set(u'uARM'))
|
||||||
SUPPORTED_IDES = [exp for exp in EXPORTERS.keys() if exp != "cmsis" and exp != "zip"]
|
SUPPORTED_IDES = [exp for exp in EXPORTERS.keys() if exp != "cmsis" and exp != "zip"]
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ def print_list(lst):
|
||||||
|
|
||||||
|
|
||||||
def print_category(results, index, message):
|
def print_category(results, index, message):
|
||||||
summary = [example for key, summ in results.iteritems()
|
summary = [example for key, summ in results.items()
|
||||||
for example in summ[index]]
|
for example in summ[index]]
|
||||||
if all(len(s) == 0 for s in summary):
|
if all(len(s) == 0 for s in summary):
|
||||||
return
|
return
|
||||||
|
@ -221,7 +222,7 @@ def get_num_failures(results, export=False):
|
||||||
"""
|
"""
|
||||||
num_failures = 0
|
num_failures = 0
|
||||||
|
|
||||||
for key, val in results.iteritems():
|
for key, val in results.items():
|
||||||
num_failures = num_failures + len(val[3])
|
num_failures = num_failures + len(val[3])
|
||||||
if export:
|
if export:
|
||||||
num_failures += len(val[4])
|
num_failures += len(val[4])
|
||||||
|
|
|
@ -16,6 +16,7 @@ limitations under the License.
|
||||||
|
|
||||||
Author: Przemyslaw Wirkus <Przemyslaw.wirkus@arm.com>
|
Author: Przemyslaw Wirkus <Przemyslaw.wirkus@arm.com>
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -29,13 +30,15 @@ import datetime
|
||||||
import threading
|
import threading
|
||||||
import ctypes
|
import ctypes
|
||||||
import functools
|
import functools
|
||||||
from types import ListType
|
|
||||||
from colorama import Fore, Back, Style
|
from colorama import Fore, Back, Style
|
||||||
from prettytable import PrettyTable
|
from prettytable import PrettyTable
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
from Queue import Queue, Empty
|
try:
|
||||||
|
from Queue import Queue, Empty
|
||||||
|
except ImportError:
|
||||||
|
from queue import Queue, Empty
|
||||||
from os.path import join, exists, basename, relpath
|
from os.path import join, exists, basename, relpath
|
||||||
from threading import Thread, Lock
|
from threading import Thread, Lock
|
||||||
from multiprocessing import Pool, cpu_count
|
from multiprocessing import Pool, cpu_count
|
||||||
|
@ -50,7 +53,7 @@ from tools.utils import ToolException
|
||||||
from tools.utils import NotSupportedException
|
from tools.utils import NotSupportedException
|
||||||
from tools.utils import construct_enum
|
from tools.utils import construct_enum
|
||||||
from tools.memap import MemapParser
|
from tools.memap import MemapParser
|
||||||
from tools.targets import TARGET_MAP
|
from tools.targets import TARGET_MAP, Target
|
||||||
import tools.test_configs as TestConfig
|
import tools.test_configs as TestConfig
|
||||||
from tools.test_db import BaseDBAccess
|
from tools.test_db import BaseDBAccess
|
||||||
from tools.build_api import build_project, build_mbed_libs, build_lib
|
from tools.build_api import build_project, build_mbed_libs, build_lib
|
||||||
|
@ -100,7 +103,7 @@ class ProcessObserver(Thread):
|
||||||
self.active = False
|
self.active = False
|
||||||
try:
|
try:
|
||||||
self.proc.terminate()
|
self.proc.terminate()
|
||||||
except Exception, _:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,12 +123,14 @@ class SingleTestExecutor(threading.Thread):
|
||||||
# Human readable summary
|
# Human readable summary
|
||||||
if not self.single_test.opts_suppress_summary:
|
if not self.single_test.opts_suppress_summary:
|
||||||
# prints well-formed summary with results (SQL table like)
|
# prints well-formed summary with results (SQL table like)
|
||||||
print self.single_test.generate_test_summary(test_summary, shuffle_seed)
|
print(self.single_test.generate_test_summary(test_summary,
|
||||||
|
shuffle_seed))
|
||||||
if self.single_test.opts_test_x_toolchain_summary:
|
if self.single_test.opts_test_x_toolchain_summary:
|
||||||
# prints well-formed summary with results (SQL table like)
|
# prints well-formed summary with results (SQL table like)
|
||||||
# table shows text x toolchain test result matrix
|
# table shows text x toolchain test result matrix
|
||||||
print self.single_test.generate_test_summary_by_target(test_summary, shuffle_seed)
|
print(self.single_test.generate_test_summary_by_target(
|
||||||
print "Completed in %.2f sec"% (elapsed_time)
|
test_summary, shuffle_seed))
|
||||||
|
print("Completed in %.2f sec"% (elapsed_time))
|
||||||
|
|
||||||
|
|
||||||
class SingleTestRunner(object):
|
class SingleTestRunner(object):
|
||||||
|
@ -360,31 +365,40 @@ class SingleTestRunner(object):
|
||||||
# print '=== %s::%s ===' % (target, toolchain)
|
# print '=== %s::%s ===' % (target, toolchain)
|
||||||
# Let's build our test
|
# Let's build our test
|
||||||
if target not in TARGET_MAP:
|
if target not in TARGET_MAP:
|
||||||
print self.logger.log_line(self.logger.LogType.NOTIF, 'Skipped tests for %s target. Target platform not found'% (target))
|
print(self.logger.log_line(
|
||||||
|
self.logger.LogType.NOTIF,
|
||||||
|
'Skipped tests for %s target. Target platform not found' %
|
||||||
|
(target)))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
clean_mbed_libs_options = True if self.opts_goanna_for_mbed_sdk or clean or self.opts_clean else None
|
clean_mbed_libs_options = (self.opts_goanna_for_mbed_sdk or
|
||||||
|
self.opts_clean or clean)
|
||||||
|
|
||||||
profile = extract_profile(self.opts_parser, self.opts, toolchain)
|
profile = extract_profile(self.opts_parser, self.opts, toolchain)
|
||||||
stats_depth = self.opts.stats_depth or 2
|
stats_depth = self.opts.stats_depth or 2
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
build_mbed_libs_result = build_mbed_libs(T,
|
build_mbed_libs_result = build_mbed_libs(
|
||||||
toolchain,
|
T, toolchain,
|
||||||
clean=clean_mbed_libs_options,
|
clean=clean_mbed_libs_options,
|
||||||
verbose=self.opts_verbose,
|
verbose=self.opts_verbose,
|
||||||
jobs=self.opts_jobs,
|
jobs=self.opts_jobs,
|
||||||
report=build_report,
|
report=build_report,
|
||||||
properties=build_properties,
|
properties=build_properties,
|
||||||
build_profile=profile)
|
build_profile=profile)
|
||||||
|
|
||||||
if not build_mbed_libs_result:
|
if not build_mbed_libs_result:
|
||||||
print self.logger.log_line(self.logger.LogType.NOTIF, 'Skipped tests for %s target. Toolchain %s is not yet supported for this target'% (T.name, toolchain))
|
print(self.logger.log_line(
|
||||||
|
self.logger.LogType.NOTIF,
|
||||||
|
'Skipped tests for %s target. Toolchain %s is not '
|
||||||
|
'supported for this target'% (T.name, toolchain)))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
except ToolException:
|
except ToolException:
|
||||||
print self.logger.log_line(self.logger.LogType.ERROR, 'There were errors while building MBED libs for %s using %s'% (target, toolchain))
|
print(self.logger.log_line(
|
||||||
|
self.logger.LogType.ERROR,
|
||||||
|
'There were errors while building MBED libs for %s using %s'
|
||||||
|
% (target, toolchain)))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
build_dir = join(BUILD_DIR, "test", target, toolchain)
|
build_dir = join(BUILD_DIR, "test", target, toolchain)
|
||||||
|
@ -402,16 +416,22 @@ class SingleTestRunner(object):
|
||||||
if self.db_logger:
|
if self.db_logger:
|
||||||
self.db_logger.reconnect();
|
self.db_logger.reconnect();
|
||||||
if self.db_logger.is_connected():
|
if self.db_logger.is_connected():
|
||||||
self.db_logger.update_build_id_info(self.db_logger_build_id, _shuffle_seed=self.shuffle_random_func())
|
self.db_logger.update_build_id_info(
|
||||||
|
self.db_logger_build_id,
|
||||||
|
_shuffle_seed=self.shuffle_random_func())
|
||||||
self.db_logger.disconnect();
|
self.db_logger.disconnect();
|
||||||
|
|
||||||
if self.db_logger:
|
if self.db_logger:
|
||||||
self.db_logger.reconnect();
|
self.db_logger.reconnect();
|
||||||
if self.db_logger.is_connected():
|
if self.db_logger.is_connected():
|
||||||
# Update MUTs and Test Specification in database
|
# Update MUTs and Test Specification in database
|
||||||
self.db_logger.update_build_id_info(self.db_logger_build_id, _muts=self.muts, _test_spec=self.test_spec)
|
self.db_logger.update_build_id_info(
|
||||||
|
self.db_logger_build_id,
|
||||||
|
_muts=self.muts, _test_spec=self.test_spec)
|
||||||
# Update Extra information in database (some options passed to test suite)
|
# Update Extra information in database (some options passed to test suite)
|
||||||
self.db_logger.update_build_id_info(self.db_logger_build_id, _extra=json.dumps(self.dump_options()))
|
self.db_logger.update_build_id_info(
|
||||||
|
self.db_logger_build_id,
|
||||||
|
_extra=json.dumps(self.dump_options()))
|
||||||
self.db_logger.disconnect();
|
self.db_logger.disconnect();
|
||||||
|
|
||||||
valid_test_map_keys = self.get_valid_tests(test_map_keys, target, toolchain, test_ids, self.opts_include_non_automated)
|
valid_test_map_keys = self.get_valid_tests(test_map_keys, target, toolchain, test_ids, self.opts_include_non_automated)
|
||||||
|
@ -449,7 +469,9 @@ class SingleTestRunner(object):
|
||||||
build_profile=profile)
|
build_profile=profile)
|
||||||
|
|
||||||
except ToolException:
|
except ToolException:
|
||||||
print self.logger.log_line(self.logger.LogType.ERROR, 'There were errors while building library %s'% (lib_id))
|
print(self.logger.log_line(
|
||||||
|
self.logger.LogType.ERROR,
|
||||||
|
'There were errors while building library %s' % lib_id))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
@ -491,23 +513,29 @@ class SingleTestRunner(object):
|
||||||
project_description=test.get_description(),
|
project_description=test.get_description(),
|
||||||
build_profile=profile, stats_depth=stats_depth)
|
build_profile=profile, stats_depth=stats_depth)
|
||||||
|
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
project_name_str = project_name if project_name is not None else test_id
|
project_name_str = project_name if project_name is not None else test_id
|
||||||
|
|
||||||
|
|
||||||
test_result = self.TEST_RESULT_FAIL
|
test_result = self.TEST_RESULT_FAIL
|
||||||
|
|
||||||
if isinstance(e, ToolException):
|
if isinstance(e, ToolException):
|
||||||
print self.logger.log_line(self.logger.LogType.ERROR, 'There were errors while building project %s'% (project_name_str))
|
print(self.logger.log_line(
|
||||||
|
self.logger.LogType.ERROR,
|
||||||
|
'There were errors while building project %s' %
|
||||||
|
project_name_str))
|
||||||
test_result = self.TEST_RESULT_BUILD_FAILED
|
test_result = self.TEST_RESULT_BUILD_FAILED
|
||||||
elif isinstance(e, NotSupportedException):
|
elif isinstance(e, NotSupportedException):
|
||||||
print self.logger.log_line(self.logger.LogType.INFO, 'The project %s is not supported'% (project_name_str))
|
print(elf.logger.log_line(
|
||||||
|
self.logger.LogType.INFO,
|
||||||
|
'Project %s is not supported' % project_name_str))
|
||||||
test_result = self.TEST_RESULT_NOT_SUPPORTED
|
test_result = self.TEST_RESULT_NOT_SUPPORTED
|
||||||
|
|
||||||
|
|
||||||
# Append test results to global test summary
|
# Append test results to global test summary
|
||||||
self.test_summary.append(
|
self.test_summary.append(
|
||||||
(test_result, target, toolchain, test_id, test.get_description(), 0, 0, '-')
|
(test_result, target, toolchain, test_id,
|
||||||
|
test.get_description(), 0, 0, '-')
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add detailed test result to test summary structure
|
# Add detailed test result to test summary structure
|
||||||
|
@ -603,7 +631,7 @@ class SingleTestRunner(object):
|
||||||
# in separate threads do not collide.
|
# in separate threads do not collide.
|
||||||
# Inside execute_thread_slice() function function handle() will be called to
|
# Inside execute_thread_slice() function function handle() will be called to
|
||||||
# get information about available MUTs (per target).
|
# get information about available MUTs (per target).
|
||||||
for target, toolchains in self.test_spec['targets'].iteritems():
|
for target, toolchains in self.test_spec['targets'].items():
|
||||||
self.test_suite_properties_ext[target] = {}
|
self.test_suite_properties_ext[target] = {}
|
||||||
t = threading.Thread(target=self.execute_thread_slice, args = (q, target, toolchains, clean, test_ids, self.build_report, self.build_properties))
|
t = threading.Thread(target=self.execute_thread_slice, args = (q, target, toolchains, clean, test_ids, self.build_report, self.build_properties))
|
||||||
t.daemon = True
|
t.daemon = True
|
||||||
|
@ -614,7 +642,7 @@ class SingleTestRunner(object):
|
||||||
q.get() # t.join() would block some threads because we should not wait in any order for thread end
|
q.get() # t.join() would block some threads because we should not wait in any order for thread end
|
||||||
else:
|
else:
|
||||||
# Serialized (not parallel) test execution
|
# Serialized (not parallel) test execution
|
||||||
for target, toolchains in self.test_spec['targets'].iteritems():
|
for target, toolchains in self.test_spec['targets'].items():
|
||||||
if target not in self.test_suite_properties_ext:
|
if target not in self.test_suite_properties_ext:
|
||||||
self.test_suite_properties_ext[target] = {}
|
self.test_suite_properties_ext[target] = {}
|
||||||
|
|
||||||
|
@ -642,23 +670,33 @@ class SingleTestRunner(object):
|
||||||
|
|
||||||
if self.opts_test_only_peripheral and not test.peripherals:
|
if self.opts_test_only_peripheral and not test.peripherals:
|
||||||
if self.opts_verbose_skipped_tests:
|
if self.opts_verbose_skipped_tests:
|
||||||
print self.logger.log_line(self.logger.LogType.INFO, 'Common test skipped for target %s'% (target))
|
print(self.logger.log_line(
|
||||||
|
self.logger.LogType.INFO,
|
||||||
|
'Common test skipped for target %s' % target))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if self.opts_peripheral_by_names and test.peripherals and not len([i for i in test.peripherals if i in self.opts_peripheral_by_names]):
|
if (self.opts_peripheral_by_names and test.peripherals and
|
||||||
|
not any((i in self.opts_peripheral_by_names)
|
||||||
|
for i in test.peripherals)):
|
||||||
# We will skip tests not forced with -p option
|
# We will skip tests not forced with -p option
|
||||||
if self.opts_verbose_skipped_tests:
|
if self.opts_verbose_skipped_tests:
|
||||||
print self.logger.log_line(self.logger.LogType.INFO, 'Common test skipped for target %s'% (target))
|
print(self.logger.log_line(
|
||||||
|
self.logger.LogType.INFO,
|
||||||
|
'Common test skipped for target %s' % target))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if self.opts_test_only_common and test.peripherals:
|
if self.opts_test_only_common and test.peripherals:
|
||||||
if self.opts_verbose_skipped_tests:
|
if self.opts_verbose_skipped_tests:
|
||||||
print self.logger.log_line(self.logger.LogType.INFO, 'Peripheral test skipped for target %s'% (target))
|
print(self.logger.log_line(
|
||||||
|
self.logger.LogType.INFO,
|
||||||
|
'Peripheral test skipped for target %s' % target))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not include_non_automated and not test.automated:
|
if not include_non_automated and not test.automated:
|
||||||
if self.opts_verbose_skipped_tests:
|
if self.opts_verbose_skipped_tests:
|
||||||
print self.logger.log_line(self.logger.LogType.INFO, 'Non automated test skipped for target %s'% (target))
|
print(self.logger.log_line(
|
||||||
|
self.logger.LogType.INFO,
|
||||||
|
'Non automated test skipped for target %s' % target))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if test.is_supported(target, toolchain):
|
if test.is_supported(target, toolchain):
|
||||||
|
@ -673,9 +711,15 @@ class SingleTestRunner(object):
|
||||||
elif not self.is_peripherals_available(target, test.peripherals):
|
elif not self.is_peripherals_available(target, test.peripherals):
|
||||||
if self.opts_verbose_skipped_tests:
|
if self.opts_verbose_skipped_tests:
|
||||||
if test.peripherals:
|
if test.peripherals:
|
||||||
print self.logger.log_line(self.logger.LogType.INFO, 'Peripheral %s test skipped for target %s'% (",".join(test.peripherals), target))
|
print(self.logger.log_line(
|
||||||
|
self.logger.LogType.INFO,
|
||||||
|
'Peripheral %s test skipped for target %s' %
|
||||||
|
(",".join(test.peripherals), target)))
|
||||||
else:
|
else:
|
||||||
print self.logger.log_line(self.logger.LogType.INFO, 'Test %s skipped for target %s'% (test_id, target))
|
print(self.logger.log_line(
|
||||||
|
self.logger.LogType.INFO,
|
||||||
|
'Test %s skipped for target %s' %
|
||||||
|
(test_id, target)))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# The test has made it through all the filters, so add it to the valid tests list
|
# The test has made it through all the filters, so add it to the valid tests list
|
||||||
|
@ -773,7 +817,7 @@ class SingleTestRunner(object):
|
||||||
result += "\n"
|
result += "\n"
|
||||||
|
|
||||||
# Print result count
|
# Print result count
|
||||||
result += "Result: " + ' / '.join(['%s %s' % (value, key) for (key, value) in {k: v for k, v in result_dict.items() if v != 0}.iteritems()])
|
result += "Result: " + ' / '.join(['%s %s' % (value, key) for (key, value) in {k: v for k, v in result_dict.items() if v != 0}.items()])
|
||||||
shuffle_seed_text = "Shuffle Seed: %.*f\n"% (self.SHUFFLE_SEED_ROUND,
|
shuffle_seed_text = "Shuffle Seed: %.*f\n"% (self.SHUFFLE_SEED_ROUND,
|
||||||
shuffle_seed if shuffle_seed else self.shuffle_random_seed)
|
shuffle_seed if shuffle_seed else self.shuffle_random_seed)
|
||||||
result += "\n%s"% (shuffle_seed_text if self.opts_shuffle_test_order else '')
|
result += "\n%s"% (shuffle_seed_text if self.opts_shuffle_test_order else '')
|
||||||
|
@ -812,7 +856,7 @@ class SingleTestRunner(object):
|
||||||
resutl_msg = ""
|
resutl_msg = ""
|
||||||
try:
|
try:
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
resutl_msg = e
|
resutl_msg = e
|
||||||
result = False
|
result = False
|
||||||
return result, resutl_msg
|
return result, resutl_msg
|
||||||
|
@ -828,7 +872,7 @@ class SingleTestRunner(object):
|
||||||
duration = data.get("duration", 10)
|
duration = data.get("duration", 10)
|
||||||
|
|
||||||
if mut is None:
|
if mut is None:
|
||||||
print "Error: No Mbed available: MUT[%s]" % data['mcu']
|
print("Error: No Mbed available: MUT[%s]" % data['mcu'])
|
||||||
return None
|
return None
|
||||||
|
|
||||||
mcu = mut['mcu']
|
mcu = mut['mcu']
|
||||||
|
@ -864,7 +908,7 @@ class SingleTestRunner(object):
|
||||||
break
|
break
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
print "Error: mbed not found with MBEDLS: %s" % data['mcu']
|
print("Error: mbed not found with MBEDLS: %s" % data['mcu'])
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
mut = muts_list[1]
|
mut = muts_list[1]
|
||||||
|
@ -895,7 +939,7 @@ class SingleTestRunner(object):
|
||||||
single_test_result = self.TEST_RESULT_NO_IMAGE
|
single_test_result = self.TEST_RESULT_NO_IMAGE
|
||||||
elapsed_time = 0
|
elapsed_time = 0
|
||||||
single_test_output = self.logger.log_line(self.logger.LogType.ERROR, 'Image file does not exist: %s'% image_path)
|
single_test_output = self.logger.log_line(self.logger.LogType.ERROR, 'Image file does not exist: %s'% image_path)
|
||||||
print single_test_output
|
print(single_test_output)
|
||||||
else:
|
else:
|
||||||
# Host test execution
|
# Host test execution
|
||||||
start_host_exec_time = time()
|
start_host_exec_time = time()
|
||||||
|
@ -930,8 +974,9 @@ class SingleTestRunner(object):
|
||||||
'copy_method' : _copy_method,
|
'copy_method' : _copy_method,
|
||||||
}
|
}
|
||||||
|
|
||||||
print self.print_test_result(single_test_result, target_name_unique, toolchain_name,
|
print(self.print_test_result(
|
||||||
test_id, test_description, elapsed_time, single_timeout)
|
single_test_result, target_name_unique, toolchain_name, test_id,
|
||||||
|
test_description, elapsed_time, single_timeout))
|
||||||
|
|
||||||
# Update database entries for ongoing test
|
# Update database entries for ongoing test
|
||||||
if self.db_logger and self.db_logger.is_connected():
|
if self.db_logger and self.db_logger.is_connected():
|
||||||
|
@ -972,7 +1017,7 @@ class SingleTestRunner(object):
|
||||||
|
|
||||||
# Find a suitable MUT:
|
# Find a suitable MUT:
|
||||||
mut = None
|
mut = None
|
||||||
for id, m in self.muts.iteritems():
|
for id, m in self.muts.items():
|
||||||
if m['mcu'] == data['mcu']:
|
if m['mcu'] == data['mcu']:
|
||||||
mut = m
|
mut = m
|
||||||
handle_result = self.handle_mut(mut, data, target_name, toolchain_name, test_loops=test_loops)
|
handle_result = self.handle_mut(mut, data, target_name, toolchain_name, test_loops=test_loops)
|
||||||
|
@ -1027,7 +1072,7 @@ class SingleTestRunner(object):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
c = obs.queue.get(block=True, timeout=0.5)
|
c = obs.queue.get(block=True, timeout=0.5)
|
||||||
except Empty, _:
|
except Empty:
|
||||||
c = None
|
c = None
|
||||||
return c
|
return c
|
||||||
|
|
||||||
|
@ -1060,7 +1105,6 @@ class SingleTestRunner(object):
|
||||||
result = property.groups()[0]
|
result = property.groups()[0]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# print "{%s} port:%s disk:%s" % (name, port, disk),
|
|
||||||
cmd = ["python",
|
cmd = ["python",
|
||||||
'%s.py'% name,
|
'%s.py'% name,
|
||||||
'-d', disk,
|
'-d', disk,
|
||||||
|
@ -1083,8 +1127,8 @@ class SingleTestRunner(object):
|
||||||
cmd += ["-R", str(reset_tout)]
|
cmd += ["-R", str(reset_tout)]
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print Fore.MAGENTA + "Executing '" + " ".join(cmd) + "'" + Fore.RESET
|
print(Fore.MAGENTA + "Executing '" + " ".join(cmd) + "'" + Fore.RESET)
|
||||||
print "Test::Output::Start"
|
print("Test::Output::Start")
|
||||||
|
|
||||||
proc = Popen(cmd, stdout=PIPE, cwd=HOST_TESTS)
|
proc = Popen(cmd, stdout=PIPE, cwd=HOST_TESTS)
|
||||||
obs = ProcessObserver(proc)
|
obs = ProcessObserver(proc)
|
||||||
|
@ -1138,7 +1182,7 @@ class SingleTestRunner(object):
|
||||||
output.append(c)
|
output.append(c)
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print "Test::Output::Finish"
|
print("Test::Output::Finish")
|
||||||
# Stop test process
|
# Stop test process
|
||||||
obs.stop()
|
obs.stop()
|
||||||
|
|
||||||
|
@ -1150,7 +1194,7 @@ class SingleTestRunner(object):
|
||||||
"""
|
"""
|
||||||
if peripherals is not None:
|
if peripherals is not None:
|
||||||
peripherals = set(peripherals)
|
peripherals = set(peripherals)
|
||||||
for id, mut in self.muts.iteritems():
|
for id, mut in self.muts.items():
|
||||||
# Target MCU name check
|
# Target MCU name check
|
||||||
if mut["mcu"] != target_mcu_name:
|
if mut["mcu"] != target_mcu_name:
|
||||||
continue
|
continue
|
||||||
|
@ -1205,9 +1249,10 @@ def show_json_file_format_error(json_spec_filename, line, column):
|
||||||
line_no = 1
|
line_no = 1
|
||||||
for json_line in data_file:
|
for json_line in data_file:
|
||||||
if line_no + 5 >= line: # Print last few lines before error
|
if line_no + 5 >= line: # Print last few lines before error
|
||||||
print 'Line %d:\t'%line_no + json_line, # Prints line
|
print('Line %d:\t'%line_no + json_line)
|
||||||
if line_no == line:
|
if line_no == line:
|
||||||
print ' ' * len('Line %d:'%line_no) + '\t', '-' * (column-1) + '^'
|
print('%s\t%s^' (' ' * len('Line %d:' % line_no),
|
||||||
|
'-' * (column - 1)))
|
||||||
break
|
break
|
||||||
line_no += 1
|
line_no += 1
|
||||||
|
|
||||||
|
@ -1244,18 +1289,19 @@ def get_json_data_from_file(json_spec_filename, verbose=False):
|
||||||
result = json.load(data_file)
|
result = json.load(data_file)
|
||||||
except ValueError as json_error_msg:
|
except ValueError as json_error_msg:
|
||||||
result = None
|
result = None
|
||||||
print 'JSON file %s parsing failed. Reason: %s' % (json_spec_filename, json_error_msg)
|
print('JSON file %s parsing failed. Reason: %s' %
|
||||||
|
(json_spec_filename, json_error_msg))
|
||||||
# We can print where error occurred inside JSON file if we can parse exception msg
|
# We can print where error occurred inside JSON file if we can parse exception msg
|
||||||
json_format_defect_pos = json_format_error_defect_pos(str(json_error_msg))
|
json_format_defect_pos = json_format_error_defect_pos(str(json_error_msg))
|
||||||
if json_format_defect_pos is not None:
|
if json_format_defect_pos is not None:
|
||||||
line = json_format_defect_pos[0]
|
line = json_format_defect_pos[0]
|
||||||
column = json_format_defect_pos[1]
|
column = json_format_defect_pos[1]
|
||||||
print
|
print()
|
||||||
show_json_file_format_error(json_spec_filename, line, column)
|
show_json_file_format_error(json_spec_filename, line, column)
|
||||||
|
|
||||||
except IOError as fileopen_error_msg:
|
except IOError as fileopen_error_msg:
|
||||||
print 'JSON file %s not opened. Reason: %s'% (json_spec_filename, fileopen_error_msg)
|
print('JSON file %s not opened. Reason: %s\n'%
|
||||||
print
|
(json_spec_filename, fileopen_error_msg))
|
||||||
if verbose and result:
|
if verbose and result:
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
pp.pprint(result)
|
pp.pprint(result)
|
||||||
|
@ -1290,7 +1336,7 @@ def print_muts_configuration_from_json(json_data, join_delim=", ", platform_filt
|
||||||
if add_row:
|
if add_row:
|
||||||
for col in muts_info_cols:
|
for col in muts_info_cols:
|
||||||
cell_val = mut_info[col] if col in mut_info else None
|
cell_val = mut_info[col] if col in mut_info else None
|
||||||
if type(cell_val) == ListType:
|
if isinstance(cell_val, list):
|
||||||
cell_val = join_delim.join(cell_val)
|
cell_val = join_delim.join(cell_val)
|
||||||
row.append(cell_val)
|
row.append(cell_val)
|
||||||
pt.add_row(row)
|
pt.add_row(row)
|
||||||
|
@ -1423,7 +1469,7 @@ def get_avail_tests_summary_table(cols=None, result_summary=True, join_delim=','
|
||||||
|
|
||||||
for col in test_properties:
|
for col in test_properties:
|
||||||
col_value = test[col]
|
col_value = test[col]
|
||||||
if type(test[col]) == ListType:
|
if isinstance(test[col], list):
|
||||||
col_value = join_delim.join(test[col])
|
col_value = join_delim.join(test[col])
|
||||||
elif test[col] == None:
|
elif test[col] == None:
|
||||||
col_value = "-"
|
col_value = "-"
|
||||||
|
@ -1502,13 +1548,14 @@ def singletest_in_cli_mode(single_test):
|
||||||
# Human readable summary
|
# Human readable summary
|
||||||
if not single_test.opts_suppress_summary:
|
if not single_test.opts_suppress_summary:
|
||||||
# prints well-formed summary with results (SQL table like)
|
# prints well-formed summary with results (SQL table like)
|
||||||
print single_test.generate_test_summary(test_summary, shuffle_seed)
|
print(single_test.generate_test_summary(test_summary, shuffle_seed))
|
||||||
if single_test.opts_test_x_toolchain_summary:
|
if single_test.opts_test_x_toolchain_summary:
|
||||||
# prints well-formed summary with results (SQL table like)
|
# prints well-formed summary with results (SQL table like)
|
||||||
# table shows text x toolchain test result matrix
|
# table shows text x toolchain test result matrix
|
||||||
print single_test.generate_test_summary_by_target(test_summary, shuffle_seed)
|
print(single_test.generate_test_summary_by_target(test_summary,
|
||||||
|
shuffle_seed))
|
||||||
|
|
||||||
print "Completed in %.2f sec"% (elapsed_time)
|
print("Completed in %.2f sec" % elapsed_time)
|
||||||
print
|
print
|
||||||
# Write summary of the builds
|
# Write summary of the builds
|
||||||
|
|
||||||
|
@ -1628,19 +1675,19 @@ def detect_database_verbose(db_url):
|
||||||
# Let's try to connect
|
# Let's try to connect
|
||||||
db_ = factory_db_logger(db_url)
|
db_ = factory_db_logger(db_url)
|
||||||
if db_ is not None:
|
if db_ is not None:
|
||||||
print "Connecting to database '%s'..."% db_url,
|
print("Connecting to database '%s'..." % db_url)
|
||||||
db_.connect(host, username, password, db_name)
|
db_.connect(host, username, password, db_name)
|
||||||
if db_.is_connected():
|
if db_.is_connected():
|
||||||
print "ok"
|
print("ok")
|
||||||
print "Detecting database..."
|
print("Detecting database...")
|
||||||
print db_.detect_database(verbose=True)
|
print(db_.detect_database(verbose=True))
|
||||||
print "Disconnecting...",
|
print("Disconnecting...")
|
||||||
db_.disconnect()
|
db_.disconnect()
|
||||||
print "done"
|
print("done")
|
||||||
else:
|
else:
|
||||||
print "Database type '%s' unknown"% db_type
|
print("Database type '%s' unknown" % db_type)
|
||||||
else:
|
else:
|
||||||
print "Parse error: '%s' - DB Url error"% (db_url)
|
print("Parse error: '%s' - DB Url error" % db_url)
|
||||||
|
|
||||||
|
|
||||||
def get_module_avail(module_name):
|
def get_module_avail(module_name):
|
||||||
|
@ -2089,13 +2136,14 @@ def print_tests(tests, format="list", sort=True):
|
||||||
if format == "list":
|
if format == "list":
|
||||||
for test_name in sorted(tests.keys()):
|
for test_name in sorted(tests.keys()):
|
||||||
test_path = tests[test_name][0]
|
test_path = tests[test_name][0]
|
||||||
print "Test Case:"
|
print("Test Case:")
|
||||||
print " Name: %s" % test_name
|
print(" Name: %s" % test_name)
|
||||||
print " Path: %s" % test_path
|
print(" Path: %s" % test_path)
|
||||||
elif format == "json":
|
elif format == "json":
|
||||||
print json.dumps({test_name: test_path[0] for test_name, test_paths in tests}, indent=2)
|
print(json.dumps({test_name: test_path[0] for test_name, test_paths
|
||||||
|
in tests}, indent=2))
|
||||||
else:
|
else:
|
||||||
print "Unknown format '%s'" % format
|
print("Unknown format '%s'" % format)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def norm_relative_path(path, start):
|
def norm_relative_path(path, start):
|
||||||
|
@ -2130,7 +2178,7 @@ def build_test_worker(*args, **kwargs):
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use parent TOOLCHAIN_PATHS variable
|
# Use parent TOOLCHAIN_PATHS variable
|
||||||
for key, value in kwargs['toolchain_paths'].iteritems():
|
for key, value in kwargs['toolchain_paths'].items():
|
||||||
TOOLCHAIN_PATHS[key] = value
|
TOOLCHAIN_PATHS[key] = value
|
||||||
|
|
||||||
del kwargs['toolchain_paths']
|
del kwargs['toolchain_paths']
|
||||||
|
@ -2141,11 +2189,11 @@ def build_test_worker(*args, **kwargs):
|
||||||
ret['bin_file'] = bin_file
|
ret['bin_file'] = bin_file
|
||||||
ret['kwargs'] = kwargs
|
ret['kwargs'] = kwargs
|
||||||
|
|
||||||
except NotSupportedException, e:
|
except NotSupportedException as e:
|
||||||
ret['reason'] = e
|
ret['reason'] = e
|
||||||
except ToolException, e:
|
except ToolException as e:
|
||||||
ret['reason'] = e
|
ret['reason'] = e
|
||||||
except KeyboardInterrupt, e:
|
except KeyboardInterrupt as e:
|
||||||
ret['reason'] = e
|
ret['reason'] = e
|
||||||
except:
|
except:
|
||||||
# Print unhandled exceptions here
|
# Print unhandled exceptions here
|
||||||
|
@ -2169,7 +2217,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
|
||||||
execution_directory = "."
|
execution_directory = "."
|
||||||
base_path = norm_relative_path(build_path, execution_directory)
|
base_path = norm_relative_path(build_path, execution_directory)
|
||||||
|
|
||||||
target_name = target if isinstance(target, str) else target.name
|
target_name = target.name if isinstance(target, Target) else target
|
||||||
cfg, _, _ = get_config(base_source_paths, target_name, toolchain_name)
|
cfg, _, _ = get_config(base_source_paths, target_name, toolchain_name)
|
||||||
|
|
||||||
baud_rate = 9600
|
baud_rate = 9600
|
||||||
|
@ -2190,8 +2238,8 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
|
||||||
jobs_count = int(jobs if jobs else cpu_count())
|
jobs_count = int(jobs if jobs else cpu_count())
|
||||||
p = Pool(processes=jobs_count)
|
p = Pool(processes=jobs_count)
|
||||||
results = []
|
results = []
|
||||||
for test_name, test_paths in tests.iteritems():
|
for test_name, test_paths in tests.items():
|
||||||
if type(test_paths) != ListType:
|
if not isinstance(test_paths, list):
|
||||||
test_paths = [test_paths]
|
test_paths = [test_paths]
|
||||||
|
|
||||||
test_build_path = os.path.join(build_path, test_paths[0])
|
test_build_path = os.path.join(build_path, test_paths[0])
|
||||||
|
@ -2265,8 +2313,8 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
|
||||||
|
|
||||||
test_key = worker_result['kwargs']['project_id'].upper()
|
test_key = worker_result['kwargs']['project_id'].upper()
|
||||||
if report:
|
if report:
|
||||||
print report[target_name][toolchain_name][test_key][0][0]['output'].rstrip()
|
print(report[target_name][toolchain_name][test_key][0][0]['output'].rstrip())
|
||||||
print 'Image: %s\n' % bin_file
|
print('Image: %s\n' % bin_file)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
if p._taskqueue.queue:
|
if p._taskqueue.queue:
|
||||||
|
|
|
@ -304,11 +304,13 @@ class ReportExporter():
|
||||||
|
|
||||||
def exporter_print_helper(self, array, print_log=False):
|
def exporter_print_helper(self, array, print_log=False):
|
||||||
for item in array:
|
for item in array:
|
||||||
print " * %s::%s::%s" % (item["target_name"], item["toolchain_name"], item["id"])
|
print(" * %s::%s::%s" % (item["target_name"],
|
||||||
|
item["toolchain_name"],
|
||||||
|
item["id"]))
|
||||||
if print_log:
|
if print_log:
|
||||||
log_lines = item["output"].split("\n")
|
log_lines = item["output"].split("\n")
|
||||||
for log_line in log_lines:
|
for log_line in log_lines:
|
||||||
print " %s" % log_line
|
print(" %s" % log_line)
|
||||||
|
|
||||||
def exporter_print(self, test_result_ext, print_log_for_failures=False):
|
def exporter_print(self, test_result_ext, print_log_for_failures=False):
|
||||||
""" Export test results in print format.
|
""" Export test results in print format.
|
||||||
|
@ -343,15 +345,15 @@ class ReportExporter():
|
||||||
raise Exception("'test_run' did not have a 'result' value")
|
raise Exception("'test_run' did not have a 'result' value")
|
||||||
|
|
||||||
if successes:
|
if successes:
|
||||||
print "\n\nBuild successes:"
|
print("\n\nBuild successes:")
|
||||||
self.exporter_print_helper(successes)
|
self.exporter_print_helper(successes)
|
||||||
|
|
||||||
if skips:
|
if skips:
|
||||||
print "\n\nBuild skips:"
|
print("\n\nBuild skips:")
|
||||||
self.exporter_print_helper(skips)
|
self.exporter_print_helper(skips)
|
||||||
|
|
||||||
if failures:
|
if failures:
|
||||||
print "\n\nBuild failures:"
|
print("\n\nBuild failures:")
|
||||||
self.exporter_print_helper(failures, print_log=print_log_for_failures)
|
self.exporter_print_helper(failures, print_log=print_log_for_failures)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
@ -410,5 +412,5 @@ class ReportExporter():
|
||||||
result += "\n"
|
result += "\n"
|
||||||
|
|
||||||
# Print result count
|
# Print result count
|
||||||
result += "Result: " + ' / '.join(['%s %s' % (value, key) for (key, value) in {k: v for k, v in result_dict.items() if v != 0}.iteritems()])
|
result += "Result: " + ' / '.join(['%s %s' % (value, key) for (key, value) in {k: v for k, v in result_dict.items() if v != 0}.items()])
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -15,14 +15,9 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
from tools.paths import *
|
from tools.paths import *
|
||||||
from tools.data.support import *
|
from tools.data.support import DEFAULT_SUPPORT, CORTEX_ARM_SUPPORT
|
||||||
from argparse import ArgumentTypeError
|
from argparse import ArgumentTypeError
|
||||||
from utils import columnate
|
from tools.utils import columnate
|
||||||
|
|
||||||
try:
|
|
||||||
import tools.private_settings as ps
|
|
||||||
except:
|
|
||||||
ps = object()
|
|
||||||
|
|
||||||
TEST_CMSIS_LIB = join(TEST_DIR, "cmsis", "lib")
|
TEST_CMSIS_LIB = join(TEST_DIR, "cmsis", "lib")
|
||||||
TEST_MBED_LIB = join(TEST_DIR, "mbed", "env")
|
TEST_MBED_LIB = join(TEST_DIR, "mbed", "env")
|
||||||
|
@ -916,9 +911,7 @@ def test_known(string):
|
||||||
raise ArgumentTypeError("{0} does not index a test. The accepted range is 0 to {1}\nThe test mapping is:\n{2}".format(i, len(TEST_MAP) - 1, columnate([str(i) + ":" + t['id'] for i,t in zip(range(len(TESTS)), TESTS)])))
|
raise ArgumentTypeError("{0} does not index a test. The accepted range is 0 to {1}\nThe test mapping is:\n{2}".format(i, len(TEST_MAP) - 1, columnate([str(i) + ":" + t['id'] for i,t in zip(range(len(TESTS)), TESTS)])))
|
||||||
|
|
||||||
def test_name_known(string):
|
def test_name_known(string):
|
||||||
if string not in TEST_MAP.keys() and \
|
if string not in TEST_MAP.keys():
|
||||||
(getattr(ps, "test_alias", None) is None or \
|
|
||||||
ps.test_alias.get(string, "") not in TEST_MAP.keys()):
|
|
||||||
raise ArgumentTypeError("Program with name '{0}' not found. Supported tests are: \n{1}".format(string, columnate([t['id'] for t in TESTS])))
|
raise ArgumentTypeError("Program with name '{0}' not found. Supported tests are: \n{1}".format(string, columnate([t['id'] for t in TESTS])))
|
||||||
|
|
||||||
return TEST_MAP[string].n
|
return TEST_MAP[string].n
|
||||||
|
|
|
@ -14,29 +14,31 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function, division, absolute_import
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from os import stat, walk, getcwd, sep, remove
|
from os import stat, walk, getcwd, sep, remove
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from time import time, sleep
|
from time import time, sleep
|
||||||
from types import ListType
|
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from os.path import join, splitext, exists, relpath, dirname, basename, split, abspath, isfile, isdir, normcase
|
from os.path import (join, splitext, exists, relpath, dirname, basename, split,
|
||||||
|
abspath, isfile, isdir, normcase)
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from inspect import getmro
|
from inspect import getmro
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
from distutils.spawn import find_executable
|
from distutils.spawn import find_executable
|
||||||
|
|
||||||
from multiprocessing import Pool, cpu_count
|
from multiprocessing import Pool, cpu_count
|
||||||
from tools.utils import run_cmd, mkdir, rel_path, ToolException, NotSupportedException, split_path, compile_worker
|
|
||||||
from tools.settings import MBED_ORG_USER
|
|
||||||
import tools.hooks as hooks
|
|
||||||
from tools.memap import MemapParser
|
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
import fnmatch
|
import fnmatch
|
||||||
|
|
||||||
|
from ..utils import (run_cmd, mkdir, rel_path, ToolException,
|
||||||
|
NotSupportedException, split_path, compile_worker)
|
||||||
|
from ..settings import MBED_ORG_USER
|
||||||
|
from .. import hooks
|
||||||
|
from ..memap import MemapParser
|
||||||
|
|
||||||
|
|
||||||
#Disables multiprocessing if set to higher number than the host machine CPUs
|
#Disables multiprocessing if set to higher number than the host machine CPUs
|
||||||
CPU_COUNT_MIN = 1
|
CPU_COUNT_MIN = 1
|
||||||
|
@ -80,7 +82,7 @@ class LazyDict(dict):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Lazy{%s}" % (
|
return "Lazy{%s}" % (
|
||||||
", ".join("%r: %r" % (k, v) for k, v in
|
", ".join("%r: %r" % (k, v) for k, v in
|
||||||
chain(self.eager.iteritems(), ((k, "not evaluated")
|
chain(self.eager.items(), ((k, "not evaluated")
|
||||||
for k in self.lazy))))
|
for k in self.lazy))))
|
||||||
|
|
||||||
def update(self, other):
|
def update(self, other):
|
||||||
|
@ -90,10 +92,10 @@ class LazyDict(dict):
|
||||||
else:
|
else:
|
||||||
self.eager.update(other)
|
self.eager.update(other)
|
||||||
|
|
||||||
def iteritems(self):
|
def items(self):
|
||||||
"""Warning: This forces the evaluation all of the items in this LazyDict
|
"""Warning: This forces the evaluation all of the items in this LazyDict
|
||||||
that are iterated over."""
|
that are iterated over."""
|
||||||
for k, v in self.eager.iteritems():
|
for k, v in self.eager.items():
|
||||||
yield k, v
|
yield k, v
|
||||||
for k in self.lazy.keys():
|
for k in self.lazy.keys():
|
||||||
yield k, self[k]
|
yield k, self[k]
|
||||||
|
@ -103,11 +105,11 @@ class LazyDict(dict):
|
||||||
Does no computation now. Instead the comuptation is performed when a
|
Does no computation now. Instead the comuptation is performed when a
|
||||||
consumer attempts to access a value in this LazyDict"""
|
consumer attempts to access a value in this LazyDict"""
|
||||||
new_lazy = {}
|
new_lazy = {}
|
||||||
for k, f in self.lazy.iteritems():
|
for k, f in self.lazy.items():
|
||||||
def closure(f=f):
|
def closure(f=f):
|
||||||
return fn(f())
|
return fn(f())
|
||||||
new_lazy[k] = closure
|
new_lazy[k] = closure
|
||||||
for k, v in self.eager.iteritems():
|
for k, v in self.eager.items():
|
||||||
def closure(v=v):
|
def closure(v=v):
|
||||||
return fn(v)
|
return fn(v)
|
||||||
new_lazy[k] = closure
|
new_lazy[k] = closure
|
||||||
|
@ -221,13 +223,13 @@ class Resources:
|
||||||
"""
|
"""
|
||||||
count = 0
|
count = 0
|
||||||
dupe_dict, dupe_headers = self._collect_duplicates(dict(), dict())
|
dupe_dict, dupe_headers = self._collect_duplicates(dict(), dict())
|
||||||
for objname, filenames in dupe_dict.iteritems():
|
for objname, filenames in dupe_dict.items():
|
||||||
if len(filenames) > 1:
|
if len(filenames) > 1:
|
||||||
count+=1
|
count+=1
|
||||||
toolchain.tool_error(
|
toolchain.tool_error(
|
||||||
"Object file %s.o is not unique! It could be made from: %s"\
|
"Object file %s.o is not unique! It could be made from: %s"\
|
||||||
% (objname, " ".join(filenames)))
|
% (objname, " ".join(filenames)))
|
||||||
for headername, locations in dupe_headers.iteritems():
|
for headername, locations in dupe_headers.items():
|
||||||
if len(locations) > 1:
|
if len(locations) > 1:
|
||||||
count+=1
|
count+=1
|
||||||
toolchain.tool_error(
|
toolchain.tool_error(
|
||||||
|
@ -472,7 +474,7 @@ class mbedToolchain:
|
||||||
|
|
||||||
if msg:
|
if msg:
|
||||||
if not silent:
|
if not silent:
|
||||||
print msg
|
print(msg)
|
||||||
self.output += msg + "\n"
|
self.output += msg + "\n"
|
||||||
|
|
||||||
def print_notify_verbose(self, event, silent=False):
|
def print_notify_verbose(self, event, silent=False):
|
||||||
|
@ -489,7 +491,7 @@ class mbedToolchain:
|
||||||
event['toolchain_name'] = event['toolchain_name'].upper() if event['toolchain_name'] else "Unknown"
|
event['toolchain_name'] = event['toolchain_name'].upper() if event['toolchain_name'] else "Unknown"
|
||||||
msg = '[%(severity)s] %(target_name)s::%(toolchain_name)s::%(file)s@%(line)s: %(message)s' % event
|
msg = '[%(severity)s] %(target_name)s::%(toolchain_name)s::%(file)s@%(line)s: %(message)s' % event
|
||||||
if not silent:
|
if not silent:
|
||||||
print msg
|
print(msg)
|
||||||
self.output += msg + "\n"
|
self.output += msg + "\n"
|
||||||
|
|
||||||
elif event['type'] == 'progress':
|
elif event['type'] == 'progress':
|
||||||
|
@ -590,7 +592,7 @@ class mbedToolchain:
|
||||||
if not d or not exists(d):
|
if not d or not exists(d):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not self.stat_cache.has_key(d):
|
if d not in self.stat_cache:
|
||||||
self.stat_cache[d] = stat(d).st_mtime
|
self.stat_cache[d] = stat(d).st_mtime
|
||||||
|
|
||||||
if self.stat_cache[d] >= target_mod_time:
|
if self.stat_cache[d] >= target_mod_time:
|
||||||
|
@ -793,14 +795,15 @@ class mbedToolchain:
|
||||||
|
|
||||||
def copy_files(self, files_paths, trg_path, resources=None, rel_path=None):
|
def copy_files(self, files_paths, trg_path, resources=None, rel_path=None):
|
||||||
# Handle a single file
|
# Handle a single file
|
||||||
if type(files_paths) != ListType: files_paths = [files_paths]
|
if not isinstance(files_paths, list):
|
||||||
|
files_paths = [files_paths]
|
||||||
|
|
||||||
for source in files_paths:
|
for source in files_paths:
|
||||||
if source is None:
|
if source is None:
|
||||||
files_paths.remove(source)
|
files_paths.remove(source)
|
||||||
|
|
||||||
for source in files_paths:
|
for source in files_paths:
|
||||||
if resources is not None and resources.file_basepath.has_key(source):
|
if resources is not None and source in resources.file_basepath:
|
||||||
relative_path = relpath(source, resources.file_basepath[source])
|
relative_path = relpath(source, resources.file_basepath[source])
|
||||||
elif rel_path is not None:
|
elif rel_path is not None:
|
||||||
relative_path = relpath(source, rel_path)
|
relative_path = relpath(source, rel_path)
|
||||||
|
@ -830,7 +833,7 @@ class mbedToolchain:
|
||||||
def get_inc_file(self, includes):
|
def get_inc_file(self, includes):
|
||||||
include_file = join(self.build_dir, ".includes_%s.txt" % self.inc_md5)
|
include_file = join(self.build_dir, ".includes_%s.txt" % self.inc_md5)
|
||||||
if not exists(include_file):
|
if not exists(include_file):
|
||||||
with open(include_file, "wb") as f:
|
with open(include_file, "w") as f:
|
||||||
cmd_list = []
|
cmd_list = []
|
||||||
for c in includes:
|
for c in includes:
|
||||||
if c:
|
if c:
|
||||||
|
@ -846,7 +849,7 @@ class mbedToolchain:
|
||||||
# ARM, GCC, IAR cross compatible
|
# ARM, GCC, IAR cross compatible
|
||||||
def get_link_file(self, cmd):
|
def get_link_file(self, cmd):
|
||||||
link_file = join(self.build_dir, ".link_files.txt")
|
link_file = join(self.build_dir, ".link_files.txt")
|
||||||
with open(link_file, "wb") as f:
|
with open(link_file, "w") as f:
|
||||||
cmd_list = []
|
cmd_list = []
|
||||||
for c in cmd:
|
for c in cmd:
|
||||||
if c:
|
if c:
|
||||||
|
@ -862,7 +865,7 @@ class mbedToolchain:
|
||||||
# ARM, GCC, IAR cross compatible
|
# ARM, GCC, IAR cross compatible
|
||||||
def get_arch_file(self, objects):
|
def get_arch_file(self, objects):
|
||||||
archive_file = join(self.build_dir, ".archive_files.txt")
|
archive_file = join(self.build_dir, ".archive_files.txt")
|
||||||
with open(archive_file, "wb") as f:
|
with open(archive_file, "w") as f:
|
||||||
o_list = []
|
o_list = []
|
||||||
for o in objects:
|
for o in objects:
|
||||||
o_list.append('"%s"' % o)
|
o_list.append('"%s"' % o)
|
||||||
|
@ -891,7 +894,7 @@ class mbedToolchain:
|
||||||
# Sort include paths for consistency
|
# Sort include paths for consistency
|
||||||
inc_paths = sorted(set(inc_paths))
|
inc_paths = sorted(set(inc_paths))
|
||||||
# Unique id of all include paths
|
# Unique id of all include paths
|
||||||
self.inc_md5 = md5(' '.join(inc_paths)).hexdigest()
|
self.inc_md5 = md5(' '.join(inc_paths).encode('utf-8')).hexdigest()
|
||||||
|
|
||||||
objects = []
|
objects = []
|
||||||
queue = []
|
queue = []
|
||||||
|
@ -967,7 +970,7 @@ class mbedToolchain:
|
||||||
sleep(0.01)
|
sleep(0.01)
|
||||||
pending = 0
|
pending = 0
|
||||||
for r in results:
|
for r in results:
|
||||||
if r._ready is True:
|
if r.ready():
|
||||||
try:
|
try:
|
||||||
result = r.get()
|
result = r.get()
|
||||||
results.remove(r)
|
results.remove(r)
|
||||||
|
@ -982,7 +985,7 @@ class mbedToolchain:
|
||||||
res['command']
|
res['command']
|
||||||
])
|
])
|
||||||
objects.append(result['object'])
|
objects.append(result['object'])
|
||||||
except ToolException, err:
|
except ToolException as err:
|
||||||
if p._taskqueue.queue:
|
if p._taskqueue.queue:
|
||||||
p._taskqueue.queue.clear()
|
p._taskqueue.queue.clear()
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
|
@ -1010,7 +1013,7 @@ class mbedToolchain:
|
||||||
dep_path = base + '.d'
|
dep_path = base + '.d'
|
||||||
try:
|
try:
|
||||||
deps = self.parse_dependencies(dep_path) if (exists(dep_path)) else []
|
deps = self.parse_dependencies(dep_path) if (exists(dep_path)) else []
|
||||||
except IOError, IndexError:
|
except (IOError, IndexError):
|
||||||
deps = []
|
deps = []
|
||||||
config_file = ([self.config.app_config_location]
|
config_file = ([self.config.app_config_location]
|
||||||
if self.config.app_config_location else [])
|
if self.config.app_config_location else [])
|
||||||
|
@ -1054,7 +1057,7 @@ class mbedToolchain:
|
||||||
buff[0] = re.sub('^(.*?)\: ', '', buff[0])
|
buff[0] = re.sub('^(.*?)\: ', '', buff[0])
|
||||||
for line in buff:
|
for line in buff:
|
||||||
filename = line.replace('\\\n', '').strip()
|
filename = line.replace('\\\n', '').strip()
|
||||||
if file:
|
if filename:
|
||||||
filename = filename.replace('\\ ', '\a')
|
filename = filename.replace('\\ ', '\a')
|
||||||
dependencies.extend(((self.CHROOT if self.CHROOT else '') +
|
dependencies.extend(((self.CHROOT if self.CHROOT else '') +
|
||||||
f.replace('\a', ' '))
|
f.replace('\a', ' '))
|
||||||
|
@ -1177,7 +1180,7 @@ class mbedToolchain:
|
||||||
# ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY
|
# ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY
|
||||||
def debug(self, message):
|
def debug(self, message):
|
||||||
if self.VERBOSE:
|
if self.VERBOSE:
|
||||||
if type(message) is ListType:
|
if isinstance(message, list):
|
||||||
message = ' '.join(message)
|
message = ' '.join(message)
|
||||||
message = "[DEBUG] " + message
|
message = "[DEBUG] " + message
|
||||||
self.notify({'type': 'debug', 'message': message})
|
self.notify({'type': 'debug', 'message': message})
|
||||||
|
@ -1274,7 +1277,7 @@ class mbedToolchain:
|
||||||
self.config_file = join(self.build_dir, self.MBED_CONFIG_FILE_NAME)
|
self.config_file = join(self.build_dir, self.MBED_CONFIG_FILE_NAME)
|
||||||
# If the file exists, read its current content in prev_data
|
# If the file exists, read its current content in prev_data
|
||||||
if exists(self.config_file):
|
if exists(self.config_file):
|
||||||
with open(self.config_file, "rt") as f:
|
with open(self.config_file, "r") as f:
|
||||||
prev_data = f.read()
|
prev_data = f.read()
|
||||||
else:
|
else:
|
||||||
prev_data = None
|
prev_data = None
|
||||||
|
@ -1288,12 +1291,12 @@ class mbedToolchain:
|
||||||
self.config_file = None # this means "config file not present"
|
self.config_file = None # this means "config file not present"
|
||||||
changed = True
|
changed = True
|
||||||
elif crt_data != prev_data: # different content of config file
|
elif crt_data != prev_data: # different content of config file
|
||||||
with open(self.config_file, "wt") as f:
|
with open(self.config_file, "w") as f:
|
||||||
f.write(crt_data)
|
f.write(crt_data)
|
||||||
changed = True
|
changed = True
|
||||||
else: # a previous mbed_config.h does not exist
|
else: # a previous mbed_config.h does not exist
|
||||||
if crt_data is not None: # there's configuration data available
|
if crt_data is not None: # there's configuration data available
|
||||||
with open(self.config_file, "wt") as f:
|
with open(self.config_file, "w") as f:
|
||||||
f.write(crt_data)
|
f.write(crt_data)
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
|
@ -1318,7 +1321,7 @@ class mbedToolchain:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _overwrite_when_not_equal(filename, content):
|
def _overwrite_when_not_equal(filename, content):
|
||||||
if not exists(filename) or content != open(filename).read():
|
if not exists(filename) or content != open(filename).read():
|
||||||
with open(filename, "wb") as out:
|
with open(filename, "w") as out:
|
||||||
out.write(content)
|
out.write(content)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -1605,11 +1608,11 @@ from tools.toolchains.gcc import GCC_ARM
|
||||||
from tools.toolchains.iar import IAR
|
from tools.toolchains.iar import IAR
|
||||||
|
|
||||||
TOOLCHAIN_CLASSES = {
|
TOOLCHAIN_CLASSES = {
|
||||||
'ARM': ARM_STD,
|
u'ARM': ARM_STD,
|
||||||
'uARM': ARM_MICRO,
|
u'uARM': ARM_MICRO,
|
||||||
'ARMC6': ARMC6,
|
u'ARMC6': ARMC6,
|
||||||
'GCC_ARM': GCC_ARM,
|
u'GCC_ARM': GCC_ARM,
|
||||||
'IAR': IAR
|
u'IAR': IAR
|
||||||
}
|
}
|
||||||
|
|
||||||
TOOLCHAINS = set(TOOLCHAIN_CLASSES.keys())
|
TOOLCHAINS = set(TOOLCHAIN_CLASSES.keys())
|
||||||
|
|
|
@ -181,10 +181,10 @@ def format_project_run_data(project_run_data, limit):
|
||||||
ts_data = prep_ts_data()
|
ts_data = prep_ts_data()
|
||||||
ts_data['projectRuns'] = []
|
ts_data['projectRuns'] = []
|
||||||
|
|
||||||
for hostOs_name, hostOs in project_run_data['projectRuns'].iteritems():
|
for hostOs_name, hostOs in project_run_data['projectRuns'].items():
|
||||||
for platform_name, platform in hostOs.iteritems():
|
for platform_name, platform in hostOs.items():
|
||||||
for toolchain_name, toolchain in platform.iteritems():
|
for toolchain_name, toolchain in platform.items():
|
||||||
for project_name, project in toolchain.iteritems():
|
for project_name, project in toolchain.items():
|
||||||
if current_limit_count >= limit:
|
if current_limit_count >= limit:
|
||||||
finish_ts_data(ts_data, project_run_data)
|
finish_ts_data(ts_data, project_run_data)
|
||||||
all_ts_data.append(ts_data)
|
all_ts_data.append(ts_data)
|
||||||
|
|
|
@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function, division, absolute_import
|
||||||
import sys
|
import sys
|
||||||
import inspect
|
import inspect
|
||||||
import os
|
import os
|
||||||
|
@ -30,6 +31,11 @@ from collections import OrderedDict
|
||||||
import logging
|
import logging
|
||||||
from intelhex import IntelHex
|
from intelhex import IntelHex
|
||||||
|
|
||||||
|
try:
|
||||||
|
unicode
|
||||||
|
except NameError:
|
||||||
|
unicode = str
|
||||||
|
|
||||||
def remove_if_in(lst, thing):
|
def remove_if_in(lst, thing):
|
||||||
if thing in lst:
|
if thing in lst:
|
||||||
lst.remove(thing)
|
lst.remove(thing)
|
||||||
|
@ -66,14 +72,14 @@ def cmd(command, check=True, verbose=False, shell=False, cwd=None):
|
||||||
"""A wrapper to run a command as a blocking job"""
|
"""A wrapper to run a command as a blocking job"""
|
||||||
text = command if shell else ' '.join(command)
|
text = command if shell else ' '.join(command)
|
||||||
if verbose:
|
if verbose:
|
||||||
print text
|
print(text)
|
||||||
return_code = call(command, shell=shell, cwd=cwd)
|
return_code = call(command, shell=shell, cwd=cwd)
|
||||||
if check and return_code != 0:
|
if check and return_code != 0:
|
||||||
raise Exception('ERROR %d: "%s"' % (return_code, text))
|
raise Exception('ERROR %d: "%s"' % (return_code, text))
|
||||||
|
|
||||||
|
|
||||||
def run_cmd(command, work_dir=None, chroot=None, redirect=False):
|
def run_cmd(command, work_dir=None, chroot=None, redirect=False):
|
||||||
"""Run a command in the forground
|
"""Run a command in the foreground
|
||||||
|
|
||||||
Positional arguments:
|
Positional arguments:
|
||||||
command - the command to run
|
command - the command to run
|
||||||
|
@ -100,7 +106,7 @@ def run_cmd(command, work_dir=None, chroot=None, redirect=False):
|
||||||
stderr=STDOUT if redirect else PIPE, cwd=work_dir)
|
stderr=STDOUT if redirect else PIPE, cwd=work_dir)
|
||||||
_stdout, _stderr = process.communicate()
|
_stdout, _stderr = process.communicate()
|
||||||
except OSError:
|
except OSError:
|
||||||
print "[OS ERROR] Command: "+(' '.join(command))
|
print("[OS ERROR] Command: "+(' '.join(command)))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return _stdout, _stderr, process.returncode
|
return _stdout, _stderr, process.returncode
|
||||||
|
@ -318,13 +324,13 @@ def check_required_modules(required_modules, verbose=True):
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
not_installed_modules.append(module_name)
|
not_installed_modules.append(module_name)
|
||||||
if verbose:
|
if verbose:
|
||||||
print "Error: %s" % exc
|
print("Error: %s" % exc)
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
if not_installed_modules:
|
if not_installed_modules:
|
||||||
print ("Warning: Module(s) %s not installed. Please install " + \
|
print("Warning: Module(s) %s not installed. Please install "
|
||||||
"required module(s) before using this script.")\
|
"required module(s) before using this script."
|
||||||
% (', '.join(not_installed_modules))
|
% (', '.join(not_installed_modules)))
|
||||||
|
|
||||||
if not_installed_modules:
|
if not_installed_modules:
|
||||||
return False
|
return False
|
||||||
|
@ -342,11 +348,11 @@ def dict_to_ascii(dictionary):
|
||||||
"""
|
"""
|
||||||
if isinstance(dictionary, dict):
|
if isinstance(dictionary, dict):
|
||||||
return OrderedDict([(dict_to_ascii(key), dict_to_ascii(value))
|
return OrderedDict([(dict_to_ascii(key), dict_to_ascii(value))
|
||||||
for key, value in dictionary.iteritems()])
|
for key, value in dictionary.items()])
|
||||||
elif isinstance(dictionary, list):
|
elif isinstance(dictionary, list):
|
||||||
return [dict_to_ascii(element) for element in dictionary]
|
return [dict_to_ascii(element) for element in dictionary]
|
||||||
elif isinstance(dictionary, unicode):
|
elif isinstance(dictionary, unicode):
|
||||||
return dictionary.encode('ascii')
|
return dictionary.encode('ascii').decode()
|
||||||
else:
|
else:
|
||||||
return dictionary
|
return dictionary
|
||||||
|
|
||||||
|
@ -375,6 +381,8 @@ def argparse_type(casedness, prefer_hyphen=False):
|
||||||
the string, or the hyphens/underscores do not match the expected
|
the string, or the hyphens/underscores do not match the expected
|
||||||
style of the argument.
|
style of the argument.
|
||||||
"""
|
"""
|
||||||
|
if not isinstance(string, unicode):
|
||||||
|
string = string.decode()
|
||||||
if prefer_hyphen:
|
if prefer_hyphen:
|
||||||
newstring = casedness(string).replace("_", "-")
|
newstring = casedness(string).replace("_", "-")
|
||||||
else:
|
else:
|
||||||
|
@ -393,10 +401,10 @@ def argparse_type(casedness, prefer_hyphen=False):
|
||||||
return middle
|
return middle
|
||||||
|
|
||||||
# short cuts for the argparse_type versions
|
# short cuts for the argparse_type versions
|
||||||
argparse_uppercase_type = argparse_type(str.upper, False)
|
argparse_uppercase_type = argparse_type(unicode.upper, False)
|
||||||
argparse_lowercase_type = argparse_type(str.lower, False)
|
argparse_lowercase_type = argparse_type(unicode.lower, False)
|
||||||
argparse_uppercase_hyphen_type = argparse_type(str.upper, True)
|
argparse_uppercase_hyphen_type = argparse_type(unicode.upper, True)
|
||||||
argparse_lowercase_hyphen_type = argparse_type(str.lower, True)
|
argparse_lowercase_hyphen_type = argparse_type(unicode.lower, True)
|
||||||
|
|
||||||
def argparse_force_type(case):
|
def argparse_force_type(case):
|
||||||
""" validate that an argument passed in (as string) is a member of the list
|
""" validate that an argument passed in (as string) is a member of the list
|
||||||
|
@ -406,6 +414,8 @@ def argparse_force_type(case):
|
||||||
""" The parser type generator"""
|
""" The parser type generator"""
|
||||||
def parse_type(string):
|
def parse_type(string):
|
||||||
""" The parser type"""
|
""" The parser type"""
|
||||||
|
if not isinstance(string, unicode):
|
||||||
|
string = string.decode()
|
||||||
for option in lst:
|
for option in lst:
|
||||||
if case(string) == case(option):
|
if case(string) == case(option):
|
||||||
return option
|
return option
|
||||||
|
@ -416,8 +426,8 @@ def argparse_force_type(case):
|
||||||
return middle
|
return middle
|
||||||
|
|
||||||
# these two types convert the case of their arguments _before_ validation
|
# these two types convert the case of their arguments _before_ validation
|
||||||
argparse_force_uppercase_type = argparse_force_type(str.upper)
|
argparse_force_uppercase_type = argparse_force_type(unicode.upper)
|
||||||
argparse_force_lowercase_type = argparse_force_type(str.lower)
|
argparse_force_lowercase_type = argparse_force_type(unicode.lower)
|
||||||
|
|
||||||
def argparse_many(func):
|
def argparse_many(func):
|
||||||
""" An argument parser combinator that takes in an argument parser and
|
""" An argument parser combinator that takes in an argument parser and
|
||||||
|
|
Loading…
Reference in New Issue