Skip to content

Commit 95c8393

Browse files
authored
Merge pull request #1908 from mbedmicro/tools-update
Aligned make.py and build.py options
2 parents 4dba251 + 8f4cb59 commit 95c8393

File tree

5 files changed

+189
-19
lines changed

5 files changed

+189
-19
lines changed

tools/build.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,17 @@
116116
default=False,
117117
help="Displays supported matrix of MCUs and toolchains")
118118

119+
parser.add_option('-f', '--filter',
120+
dest='general_filter_regex',
121+
default=None,
122+
help='For some commands you can use filter to filter out results')
123+
119124
parser.add_option("", "--cppcheck",
120125
action="store_true",
121126
dest="cppcheck_validation",
122127
default=False,
123128
help="Forces 'cppcheck' static code analysis")
124129

125-
parser.add_option('-f', '--filter',
126-
dest='general_filter_regex',
127-
default=None,
128-
help='For some commands you can use filter to filter out results')
129-
130130
parser.add_option("-j", "--jobs", type="int", dest="jobs",
131131
default=0, help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)")
132132

tools/build_api.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -668,12 +668,12 @@ def mcu_toolchain_matrix(verbose_html=False, platform_filter=None):
668668
from prettytable import PrettyTable # Only use it in this function so building works without extra modules
669669

670670
# All tests status table print
671-
columns = ["Platform"] + unique_supported_toolchains
672-
pt = PrettyTable(["Platform"] + unique_supported_toolchains)
671+
columns = ["Target"] + unique_supported_toolchains
672+
pt = PrettyTable(["Target"] + unique_supported_toolchains)
673673
# Align table
674674
for col in columns:
675675
pt.align[col] = "c"
676-
pt.align["Platform"] = "l"
676+
pt.align["Target"] = "l"
677677

678678
perm_counter = 0
679679
target_counter = 0
@@ -685,25 +685,21 @@ def mcu_toolchain_matrix(verbose_html=False, platform_filter=None):
685685
target_counter += 1
686686

687687
row = [target] # First column is platform name
688-
default_toolchain = TARGET_MAP[target].default_toolchain
689688
for unique_toolchain in unique_supported_toolchains:
690-
text = "-"
691-
if default_toolchain == unique_toolchain:
692-
text = "Default"
693-
perm_counter += 1
694-
elif unique_toolchain in TARGET_MAP[target].supported_toolchains:
689+
if unique_toolchain in TARGET_MAP[target].supported_toolchains:
695690
text = "Supported"
696691
perm_counter += 1
692+
else:
693+
text = "-"
694+
697695
row.append(text)
698696
pt.add_row(row)
699697

700698
result = pt.get_html_string() if verbose_html else pt.get_string()
701699
result += "\n"
702-
result += "*Default - default on-line compiler\n"
703-
result += "*Supported - supported off-line compiler\n"
704-
result += "\n"
705-
result += "Total platforms: %d\n"% (target_counter)
706-
result += "Total permutations: %d"% (perm_counter)
700+
result += "Supported targets: %d\n"% (target_counter)
701+
if target_counter == 1:
702+
result += "Supported toolchains: %d"% (perm_counter)
707703
return result
708704

709705

tools/default_settings.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"""
2+
mbed SDK
3+
Copyright (c) 2011-2013 ARM Limited
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
"""
14+
15+
from os.path import join, abspath, dirname
16+
import logging
17+
18+
ROOT = abspath(join(dirname(__file__), ".."))
19+
20+
# These default settings have two purposes:
21+
# 1) Give a template for writing local "private_settings.py"
22+
# 2) Give default initialization fields for the "toolchains.py" constructors
23+
24+
##############################################################################
25+
# Build System Settings
26+
##############################################################################
27+
BUILD_DIR = abspath(join(ROOT, "build"))
28+
29+
# ARM
30+
ARM_PATH = "C:/Program Files/ARM"
31+
ARM_BIN = join(ARM_PATH, "bin")
32+
ARM_INC = join(ARM_PATH, "include")
33+
ARM_LIB = join(ARM_PATH, "lib")
34+
35+
ARM_CPPLIB = join(ARM_LIB, "cpplib")
36+
MY_ARM_CLIB = join(ARM_PATH, "lib", "microlib")
37+
38+
# GCC ARM
39+
GCC_ARM_PATH = ""
40+
41+
# GCC CodeRed
42+
GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin"
43+
44+
# IAR
45+
IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm"
46+
47+
# Goanna static analyser. Please overload it in private_settings.py
48+
GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin"
49+
50+
# cppcheck path (command) and output message format
51+
CPPCHECK_CMD = ["cppcheck", "--enable=all"]
52+
CPPCHECK_MSG_FORMAT = ["--template=[{severity}] {file}@{line}: {id}:{message}"]
53+
54+
BUILD_OPTIONS = []
55+
56+
# mbed.org username
57+
MBED_ORG_USER = ""
58+
59+
##############################################################################
60+
# Private Settings
61+
##############################################################################
62+
try:
63+
# Allow to overwrite the default settings without the need to edit the
64+
# settings file stored in the repository
65+
from mbed_settings import *
66+
except ImportError:
67+
print '[WARNING] Using default settings. Define your settings in the file "./mbed_settings.py"'

tools/detect_targets.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#! /usr/bin/env python2
2+
"""
3+
mbed SDK
4+
Copyright (c) 2011-2013 ARM Limited
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
19+
TEST BUILD & RUN
20+
"""
21+
import sys
22+
import os
23+
import json
24+
25+
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
26+
sys.path.insert(0, ROOT)
27+
28+
29+
from tools.options import get_default_options_parser
30+
31+
# Check: Extra modules which are required by core test suite
32+
from tools.utils import check_required_modules
33+
check_required_modules(['prettytable'])
34+
35+
# Imports related to mbed build api
36+
from tools.build_api import mcu_toolchain_matrix
37+
from tools.test_api import get_autodetected_MUTS_list
38+
39+
40+
if __name__ == '__main__':
41+
try:
42+
# Parse Options
43+
parser = get_default_options_parser()
44+
45+
parser.add_option("-S", "--supported-toolchains",
46+
action="store_true",
47+
dest="supported_toolchains",
48+
default=False,
49+
help="Displays supported matrix of targets and toolchains")
50+
51+
parser.add_option('-f', '--filter',
52+
dest='general_filter_regex',
53+
default=None,
54+
help='Filter targets')
55+
56+
parser.add_option("-v", "--verbose",
57+
action="store_true",
58+
dest="verbose",
59+
default=False,
60+
help="Verbose diagnostic output")
61+
62+
(options, args) = parser.parse_args()
63+
64+
# Only prints matrix of supported toolchains
65+
if options.supported_toolchains:
66+
print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
67+
exit(0)
68+
69+
# If auto_detect attribute is present, we assume other auto-detection
70+
# parameters like 'toolchains_filter' are also set.
71+
MUTs = get_autodetected_MUTS_list()
72+
73+
count = 0
74+
for mut in MUTs.values():
75+
print ""
76+
print "[mbed] Detected %s, port %s, mounted %s" % (mut['mcu'], mut['port'], mut['disk'])
77+
print "[mbed] Supported toolchains for %s" % mut['mcu']
78+
print mcu_toolchain_matrix(platform_filter=r'^'+mut['mcu']+'$')
79+
count += 1
80+
81+
if count == 0:
82+
print "[mbed] No mbed targets where detected on your system."
83+
84+
except KeyboardInterrupt, e:
85+
print "\n[CTRL+c] exit"
86+
except Exception,e:
87+
import traceback
88+
traceback.print_exc(file=sys.stdout)
89+
print "[ERROR] %s" % str(e)
90+
sys.exit(1)

tools/make.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from tools.targets import TARGET_MAP
4242
from tools.options import get_default_options_parser
4343
from tools.build_api import build_project
44+
from tools.build_api import mcu_toolchain_matrix
4445
try:
4546
import tools.private_settings as ps
4647
except:
@@ -81,6 +82,17 @@
8182
dest="macros",
8283
help="Add a macro definition")
8384

85+
parser.add_option("-S", "--supported-toolchains",
86+
action="store_true",
87+
dest="supported_toolchains",
88+
default=False,
89+
help="Displays supported matrix of MCUs and toolchains")
90+
91+
parser.add_option('-f', '--filter',
92+
dest='general_filter_regex',
93+
default=None,
94+
help='For some commands you can use filter to filter out results')
95+
8496
# Local run
8597
parser.add_option("--automated", action="store_true", dest="automated",
8698
default=False, help="Automated test")
@@ -166,6 +178,11 @@
166178

167179
(options, args) = parser.parse_args()
168180

181+
# Only prints matrix of supported toolchains
182+
if options.supported_toolchains:
183+
print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
184+
exit(0)
185+
169186
if options.source_dir:
170187
for path in options.source_dir :
171188
if not isfile(path) and not isdir(path) :

0 commit comments

Comments
 (0)