mirror of https://github.com/ARMmbed/mbed-os.git
Revise checking toolchain path
parent
e9d0fbd178
commit
61dee45dca
|
@ -27,7 +27,7 @@ ROOT = abspath(join(dirname(__file__), ".."))
|
|||
sys.path.insert(0, ROOT)
|
||||
|
||||
|
||||
from tools.toolchains import TOOLCHAINS
|
||||
from tools.toolchains import TOOLCHAINS, TOOLCHAIN_CLASSES, TOOLCHAIN_PATHS
|
||||
from tools.toolchains import mbedToolchain
|
||||
from tools.targets import TARGET_NAMES, TARGET_MAP
|
||||
from tools.options import get_default_options_parser
|
||||
|
@ -161,6 +161,7 @@ if __name__ == '__main__':
|
|||
print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
|
||||
exit(0)
|
||||
|
||||
|
||||
# Get target list
|
||||
targets = options.mcu if options.mcu else TARGET_NAMES
|
||||
|
||||
|
@ -212,6 +213,12 @@ if __name__ == '__main__':
|
|||
# CPPCHECK code validation
|
||||
if options.cppcheck_validation:
|
||||
for toolchain in toolchains:
|
||||
if not TOOLCHAIN_CLASSES[toolchain].check_executable():
|
||||
if TOOLCHAIN_PATHS[toolchain] == '':
|
||||
TOOLCHAIN_PATHS[toolchain] = "No path set"
|
||||
args_error(parser, "Could not find executable for %s.\n"
|
||||
"Currently set search path: %s"
|
||||
% (toolchain, TOOLCHAIN_PATHS[toolchain]))
|
||||
for target in targets:
|
||||
try:
|
||||
mcu = TARGET_MAP[target]
|
||||
|
|
|
@ -21,7 +21,8 @@ TEST BUILD & RUN
|
|||
import sys
|
||||
from time import sleep
|
||||
from shutil import copy
|
||||
from os.path import join, abspath, dirname, isfile, isdir
|
||||
from os.path import join, abspath, dirname, exists
|
||||
from distutils.spawn import find_executable
|
||||
|
||||
# Be sure that the tools directory is in the search path
|
||||
ROOT = abspath(join(dirname(__file__), ".."))
|
||||
|
@ -46,8 +47,7 @@ from tools.build_api import mcu_toolchain_matrix
|
|||
from utils import argparse_filestring_type
|
||||
from utils import argparse_many
|
||||
from utils import argparse_dir_not_parent
|
||||
from argparse import ArgumentTypeError
|
||||
from tools.toolchains import mbedToolchain
|
||||
from tools.toolchains import mbedToolchain, TOOLCHAIN_CLASSES, TOOLCHAIN_PATHS
|
||||
from tools.settings import CLI_COLOR_MAP
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -232,6 +232,13 @@ if __name__ == '__main__':
|
|||
else:
|
||||
notify = None
|
||||
|
||||
if not TOOLCHAIN_CLASSES[toolchain].check_executable():
|
||||
if TOOLCHAIN_PATHS[toolchain] == '':
|
||||
TOOLCHAIN_PATHS[toolchain] = "No path set"
|
||||
args_error(parser, "Could not find executable for %s.\n"
|
||||
"Currently set search path: %s"
|
||||
%(toolchain,TOOLCHAIN_PATHS[toolchain]))
|
||||
|
||||
# Test
|
||||
for test_no in p:
|
||||
test = Test(test_no)
|
||||
|
|
|
@ -35,7 +35,7 @@ from tools.utils import mkdir, ToolException, NotSupportedException, args_error
|
|||
from tools.test_exporters import ReportExporter, ResultExporterType
|
||||
from utils import argparse_filestring_type, argparse_lowercase_type, argparse_many
|
||||
from utils import argparse_dir_not_parent
|
||||
from tools.toolchains import mbedToolchain
|
||||
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS, TOOLCHAIN_CLASSES
|
||||
from tools.settings import CLI_COLOR_MAP
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -115,6 +115,13 @@ if __name__ == '__main__':
|
|||
args_error(parser, "argument -t/--tool is required")
|
||||
toolchain = options.tool[0]
|
||||
|
||||
if not TOOLCHAIN_CLASSES[toolchain].check_executable():
|
||||
if TOOLCHAIN_PATHS[toolchain] == '':
|
||||
TOOLCHAIN_PATHS[toolchain] = "No path set"
|
||||
args_error(parser, "Could not find executable for %s.\n"
|
||||
"Currently set search path: %s"
|
||||
% (toolchain, TOOLCHAIN_PATHS[toolchain]))
|
||||
|
||||
# Find all tests in the relevant paths
|
||||
for path in all_paths:
|
||||
all_tests.update(find_tests(path, mcu, toolchain, options.options,
|
||||
|
@ -196,6 +203,7 @@ if __name__ == '__main__':
|
|||
print "Failed to build library"
|
||||
else:
|
||||
# Build all the tests
|
||||
|
||||
test_build_success, test_build = build_tests(tests, [options.build_dir], options.build_dir, mcu, toolchain,
|
||||
options=options.options,
|
||||
clean=options.clean,
|
||||
|
|
|
@ -188,23 +188,6 @@ LEGACY_TOOLCHAIN_NAMES = {
|
|||
}
|
||||
|
||||
|
||||
def check_toolchain_path(function):
|
||||
"""Check if the path to toolchain is valid. Exit if not.
|
||||
Use this function as a decorator. Causes a system exit if the path does
|
||||
not exist. Execute the function as normal if the path does exist.
|
||||
|
||||
Positional arguments:
|
||||
function -- the function to decorate
|
||||
"""
|
||||
def perform_check(self, *args, **kwargs):
|
||||
if not exists(self.toolchain_path) and not exists(self.toolchain_path+'.exe'):
|
||||
error_string = 'Could not find executable for %s.\n Currently ' \
|
||||
'set search path: %s'% (self.name, self.toolchain_path)
|
||||
raise Exception(error_string)
|
||||
return function(self, *args, **kwargs)
|
||||
return perform_check
|
||||
|
||||
|
||||
class mbedToolchain:
|
||||
# Verbose logging
|
||||
VERBOSE = True
|
||||
|
@ -720,7 +703,6 @@ class mbedToolchain:
|
|||
|
||||
# THIS METHOD IS BEING CALLED BY THE MBED ONLINE BUILD SYSTEM
|
||||
# ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY
|
||||
@check_toolchain_path
|
||||
def compile_sources(self, resources, build_path, inc_dirs=None):
|
||||
# Web IDE progress bar for project build
|
||||
files_to_compile = resources.s_sources + resources.c_sources + resources.cpp_sources
|
||||
|
@ -919,7 +901,6 @@ class mbedToolchain:
|
|||
else:
|
||||
raise ToolException(_stderr)
|
||||
|
||||
@check_toolchain_path
|
||||
def build_library(self, objects, dir, name):
|
||||
needed_update = False
|
||||
lib = self.STD_LIB_NAME % name
|
||||
|
@ -931,7 +912,6 @@ class mbedToolchain:
|
|||
|
||||
return needed_update
|
||||
|
||||
@check_toolchain_path
|
||||
def link_program(self, r, tmp_path, name):
|
||||
needed_update = False
|
||||
ext = 'bin'
|
||||
|
|
|
@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
"""
|
||||
import re
|
||||
from os.path import join, dirname, splitext, basename
|
||||
from os.path import join, dirname, splitext, basename, exists
|
||||
from distutils.spawn import find_executable
|
||||
|
||||
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
|
||||
|
@ -42,6 +42,15 @@ class ARM(mbedToolchain):
|
|||
'ld': [],
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def check_executable():
|
||||
if not TOOLCHAIN_PATHS["ARM"] or not exists(TOOLCHAIN_PATHS['ARM']):
|
||||
exe = find_executable('armcc')
|
||||
if not exe:
|
||||
return False
|
||||
TOOLCHAIN_PATHS['ARM'] = dirname(dirname(exe))
|
||||
return True
|
||||
|
||||
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
|
||||
mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
|
||||
|
||||
|
@ -56,11 +65,6 @@ class ARM(mbedToolchain):
|
|||
else:
|
||||
cpu = target.core
|
||||
|
||||
if not TOOLCHAIN_PATHS['ARM']:
|
||||
exe = find_executable('armcc')
|
||||
if exe:
|
||||
TOOLCHAIN_PATHS['ARM'] = dirname(dirname(exe))
|
||||
|
||||
ARM_BIN = join(TOOLCHAIN_PATHS['ARM'], "bin")
|
||||
ARM_INC = join(TOOLCHAIN_PATHS['ARM'], "include")
|
||||
|
||||
|
@ -86,8 +90,6 @@ class ARM(mbedToolchain):
|
|||
self.ar = join(ARM_BIN, "armar")
|
||||
self.elf2bin = join(ARM_BIN, "fromelf")
|
||||
|
||||
self.toolchain_path = TOOLCHAIN_PATHS['ARM']
|
||||
|
||||
def parse_dependencies(self, dep_path):
|
||||
dependencies = []
|
||||
for line in open(dep_path).readlines():
|
||||
|
|
|
@ -111,11 +111,6 @@ class GCC(mbedToolchain):
|
|||
self.ar = join(tool_path, "arm-none-eabi-ar")
|
||||
self.elf2bin = join(tool_path, "arm-none-eabi-objcopy")
|
||||
|
||||
if tool_path:
|
||||
self.toolchain_path = main_cc
|
||||
else:
|
||||
self.toolchain_path = find_executable("arm-none-eabi-gcc") or ''
|
||||
|
||||
def parse_dependencies(self, dep_path):
|
||||
dependencies = []
|
||||
buff = open(dep_path).readlines()
|
||||
|
@ -275,6 +270,15 @@ class GCC(mbedToolchain):
|
|||
|
||||
|
||||
class GCC_ARM(GCC):
|
||||
@staticmethod
|
||||
def check_executable():
|
||||
if not TOOLCHAIN_PATHS["GCC_ARM"] or not exists(TOOLCHAIN_PATHS['GCC_ARM']):
|
||||
exe = find_executable('arm-none-eabi-gcc')
|
||||
if not exe:
|
||||
return False
|
||||
TOOLCHAIN_PATHS['GCC_ARM'] = dirname(exe)
|
||||
return True
|
||||
|
||||
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
|
||||
GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_ARM'], extra_verbose=extra_verbose)
|
||||
|
||||
|
@ -300,6 +304,15 @@ class GCC_ARM(GCC):
|
|||
|
||||
|
||||
class GCC_CR(GCC):
|
||||
@staticmethod
|
||||
def check_executable():
|
||||
if not TOOLCHAIN_PATHS["GCC_CR"] or not exists(TOOLCHAIN_PATHS['GCC_CR']):
|
||||
exe = find_executable('arm-none-eabi-gcc')
|
||||
if not exe:
|
||||
return False
|
||||
TOOLCHAIN_PATHS['GCC_CR'] = dirname(exe)
|
||||
return True
|
||||
|
||||
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
|
||||
GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_CR'], extra_verbose=extra_verbose)
|
||||
|
||||
|
|
|
@ -45,6 +45,15 @@ class IAR(mbedToolchain):
|
|||
'ld': ["--skip_dynamic_initialization", "--threaded_lib"],
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def check_executable():
|
||||
if not TOOLCHAIN_PATHS["IAR"] or not exists(TOOLCHAIN_PATHS['IAR']):
|
||||
exe = find_executable('iccarm')
|
||||
if not exe:
|
||||
return False
|
||||
TOOLCHAIN_PATHS['IAR'] = dirname(dirname(exe))
|
||||
return True
|
||||
|
||||
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
|
||||
mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
|
||||
if target.core == "Cortex-M7F" or target.core == "Cortex-M7FD":
|
||||
|
@ -52,11 +61,6 @@ class IAR(mbedToolchain):
|
|||
else:
|
||||
cpuchoice = target.core
|
||||
|
||||
if not TOOLCHAIN_PATHS['IAR']:
|
||||
exe = find_executable('iccarm')
|
||||
if exe:
|
||||
TOOLCHAIN_PATHS['IAR'] = dirname(dirname(exe))
|
||||
|
||||
# flags_cmd are used only by our scripts, the project files have them already defined,
|
||||
# using this flags results in the errors (duplication)
|
||||
# asm accepts --cpu Core or --fpu FPU, not like c/c++ --cpu=Core
|
||||
|
@ -108,8 +112,6 @@ class IAR(mbedToolchain):
|
|||
self.ar = join(IAR_BIN, "iarchive")
|
||||
self.elf2bin = join(IAR_BIN, "ielftool")
|
||||
|
||||
self.toolchain_path = TOOLCHAIN_PATHS['IAR']
|
||||
|
||||
def parse_dependencies(self, dep_path):
|
||||
return [(self.CHROOT if self.CHROOT else '')+path.strip() for path in open(dep_path).readlines()
|
||||
if (path and not path.isspace())]
|
||||
|
|
Loading…
Reference in New Issue