Skip to content

Commit 8b74c5b

Browse files
committed
Docstrings. Empty executable search path handling.
1 parent 61dee45 commit 8b74c5b

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

tools/build.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,10 @@
214214
if options.cppcheck_validation:
215215
for toolchain in toolchains:
216216
if not TOOLCHAIN_CLASSES[toolchain].check_executable():
217-
if TOOLCHAIN_PATHS[toolchain] == '':
218-
TOOLCHAIN_PATHS[toolchain] = "No path set"
217+
search_path = TOOLCHAIN_PATHS[toolchain] or "No path set"
219218
args_error(parser, "Could not find executable for %s.\n"
220219
"Currently set search path: %s"
221-
% (toolchain, TOOLCHAIN_PATHS[toolchain]))
220+
% (toolchain, search_path))
222221
for target in targets:
223222
try:
224223
mcu = TARGET_MAP[target]

tools/make.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,10 @@
233233
notify = None
234234

235235
if not TOOLCHAIN_CLASSES[toolchain].check_executable():
236-
if TOOLCHAIN_PATHS[toolchain] == '':
237-
TOOLCHAIN_PATHS[toolchain] = "No path set"
236+
search_path = TOOLCHAIN_PATHS[toolchain] or "No path set"
238237
args_error(parser, "Could not find executable for %s.\n"
239238
"Currently set search path: %s"
240-
%(toolchain,TOOLCHAIN_PATHS[toolchain]))
239+
%(toolchain,search_path))
241240

242241
# Test
243242
for test_no in p:

tools/test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,10 @@
116116
toolchain = options.tool[0]
117117

118118
if not TOOLCHAIN_CLASSES[toolchain].check_executable():
119-
if TOOLCHAIN_PATHS[toolchain] == '':
120-
TOOLCHAIN_PATHS[toolchain] = "No path set"
119+
search_path = TOOLCHAIN_PATHS[toolchain] or "No path set"
121120
args_error(parser, "Could not find executable for %s.\n"
122121
"Currently set search path: %s"
123-
% (toolchain, TOOLCHAIN_PATHS[toolchain]))
122+
% (toolchain, search_path))
124123

125124
# Find all tests in the relevant paths
126125
for path in all_paths:

tools/toolchains/arm.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class ARM(mbedToolchain):
4444

4545
@staticmethod
4646
def check_executable():
47+
"""Returns True if the executable (armcc) location specified by the
48+
user exists OR the executable can be found on the PATH.
49+
Returns False otherwise."""
4750
if not TOOLCHAIN_PATHS["ARM"] or not exists(TOOLCHAIN_PATHS['ARM']):
4851
exe = find_executable('armcc')
4952
if not exe:

tools/toolchains/gcc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ def binary(self, resources, elf, bin):
272272
class GCC_ARM(GCC):
273273
@staticmethod
274274
def check_executable():
275+
"""Returns True if the executable (arm-none-eabi-gcc) location
276+
specified by the user exists OR the executable can be found on the PATH.
277+
Returns False otherwise."""
275278
if not TOOLCHAIN_PATHS["GCC_ARM"] or not exists(TOOLCHAIN_PATHS['GCC_ARM']):
276279
exe = find_executable('arm-none-eabi-gcc')
277280
if not exe:
@@ -306,6 +309,9 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
306309
class GCC_CR(GCC):
307310
@staticmethod
308311
def check_executable():
312+
"""Returns True if the executable (arm-none-eabi-gcc) location
313+
specified by the user exists OR the executable can be found on the PATH.
314+
Returns False otherwise."""
309315
if not TOOLCHAIN_PATHS["GCC_CR"] or not exists(TOOLCHAIN_PATHS['GCC_CR']):
310316
exe = find_executable('arm-none-eabi-gcc')
311317
if not exe:

tools/toolchains/iar.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class IAR(mbedToolchain):
4747

4848
@staticmethod
4949
def check_executable():
50+
"""Returns True if the executable (arm-none-eabi-gcc) location
51+
specified by the user exists OR the executable can be found on the PATH.
52+
Returns False otherwise."""
5053
if not TOOLCHAIN_PATHS["IAR"] or not exists(TOOLCHAIN_PATHS['IAR']):
5154
exe = find_executable('iccarm')
5255
if not exe:

0 commit comments

Comments
 (0)