Skip to content

Commit cd229ba

Browse files
committed
Allow users to set armcc and iccarm in path.
Raise exceptin instead of exit. Corrected error for arm-none-eabi-gcc/g++ set in path.
1 parent 51245ce commit cd229ba

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

tools/toolchains/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ def check_toolchain_path(function):
198198
"""
199199
def perform_check(self, *args, **kwargs):
200200
if not exists(self.toolchain_path):
201-
print('[ERROR] Toolchain path for %s does not exist.\n'
202-
'Current value: %s' % (self.name, self.toolchain_path))
203-
sys.exit(-1)
201+
error_string = 'Could not find executable for %s.\n Currently ' \
202+
'set search path: %s'% (self.name, self.toolchain_path)
203+
raise Exception(error_string)
204204
return function(self, *args, **kwargs)
205205
return perform_check
206206

tools/toolchains/arm.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
limitations under the License.
1616
"""
1717
import re
18-
from os.path import join, dirname, splitext, basename, exists
18+
from os.path import join, dirname, splitext, basename
19+
from distutils.spawn import find_executable
1920

2021
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
2122
from tools.hooks import hook_tool
2223
from tools.utils import mkdir
23-
import copy
2424

2525
class ARM(mbedToolchain):
2626
LINKER_EXT = '.sct'
@@ -56,6 +56,11 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
5656
else:
5757
cpu = target.core
5858

59+
if not TOOLCHAIN_PATHS['ARM']:
60+
exe = find_executable('armcc')
61+
if exe:
62+
TOOLCHAIN_PATHS['ARM'] = dirname(dirname(exe))
63+
5964
ARM_BIN = join(TOOLCHAIN_PATHS['ARM'], "bin")
6065
ARM_INC = join(TOOLCHAIN_PATHS['ARM'], "include")
6166

tools/toolchains/gcc.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"""
1717
import re
1818
from os.path import join, basename, splitext, dirname, exists
19+
from distutils.spawn import find_executable
1920

2021
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
2122
from tools.hooks import hook_tool
@@ -110,7 +111,10 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
110111
self.ar = join(tool_path, "arm-none-eabi-ar")
111112
self.elf2bin = join(tool_path, "arm-none-eabi-objcopy")
112113

113-
self.toolchain_path = tool_path
114+
if tool_path:
115+
self.toolchain_path = main_cc
116+
else:
117+
self.toolchain_path = find_executable("arm-none-eabi-gcc") or ''
114118

115119
def parse_dependencies(self, dep_path):
116120
dependencies = []

tools/toolchains/iar.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import re
1818
from os import remove
1919
from os.path import join, exists, dirname, splitext, exists
20+
from distutils.spawn import find_executable
2021

2122
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
2223
from tools.hooks import hook_tool
@@ -50,6 +51,12 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
5051
cpuchoice = "Cortex-M7"
5152
else:
5253
cpuchoice = target.core
54+
55+
if not TOOLCHAIN_PATHS['IAR']:
56+
exe = find_executable('iccarm')
57+
if exe:
58+
TOOLCHAIN_PATHS['IAR'] = dirname(dirname(exe))
59+
5360
# flags_cmd are used only by our scripts, the project files have them already defined,
5461
# using this flags results in the errors (duplication)
5562
# asm accepts --cpu Core or --fpu FPU, not like c/c++ --cpu=Core

0 commit comments

Comments
 (0)