mirror of https://github.com/ARMmbed/mbed-os.git
Fix pylint warnings in gcc.py except for the long regex
parent
5dd149cb13
commit
1712506de2
|
|
@ -22,7 +22,8 @@ from distutils.version import LooseVersion
|
||||||
|
|
||||||
from tools.targets import CORE_ARCH
|
from tools.targets import CORE_ARCH
|
||||||
from tools.toolchains.mbed_toolchain import mbedToolchain, TOOLCHAIN_PATHS
|
from tools.toolchains.mbed_toolchain import mbedToolchain, TOOLCHAIN_PATHS
|
||||||
from tools.utils import run_cmd, NotSupportedException
|
from tools.utils import run_cmd
|
||||||
|
|
||||||
|
|
||||||
class GCC(mbedToolchain):
|
class GCC(mbedToolchain):
|
||||||
OFFICIALLY_SUPPORTED = True
|
OFFICIALLY_SUPPORTED = True
|
||||||
|
|
@ -37,15 +38,21 @@ class GCC(mbedToolchain):
|
||||||
|
|
||||||
def __init__(self, target, notify=None, macros=None, build_profile=None,
|
def __init__(self, target, notify=None, macros=None, build_profile=None,
|
||||||
build_dir=None):
|
build_dir=None):
|
||||||
mbedToolchain.__init__(self, target, notify, macros,
|
mbedToolchain.__init__(
|
||||||
build_profile=build_profile, build_dir=build_dir)
|
self,
|
||||||
|
target,
|
||||||
|
notify,
|
||||||
|
macros,
|
||||||
|
build_profile=build_profile,
|
||||||
|
build_dir=build_dir
|
||||||
|
)
|
||||||
|
|
||||||
tool_path = TOOLCHAIN_PATHS['GCC_ARM']
|
tool_path = TOOLCHAIN_PATHS['GCC_ARM']
|
||||||
# Add flags for current size setting
|
# Add flags for current size setting
|
||||||
default_lib = "std"
|
default_lib = "std"
|
||||||
if hasattr(target, "default_lib"):
|
if hasattr(target, "default_lib"):
|
||||||
default_lib = target.default_lib
|
default_lib = target.default_lib
|
||||||
elif hasattr(target, "default_build"): # Legacy
|
elif hasattr(target, "default_build"):
|
||||||
default_lib = target.default_build
|
default_lib = target.default_build
|
||||||
|
|
||||||
if default_lib == "small":
|
if default_lib == "small":
|
||||||
|
|
@ -129,9 +136,13 @@ class GCC(mbedToolchain):
|
||||||
stdout, _, retcode = run_cmd([self.cc[0], "--version"], redirect=True)
|
stdout, _, retcode = run_cmd([self.cc[0], "--version"], redirect=True)
|
||||||
msg = None
|
msg = None
|
||||||
match = self.GCC_VERSION_RE.search(stdout.encode("utf-8"))
|
match = self.GCC_VERSION_RE.search(stdout.encode("utf-8"))
|
||||||
found_version = LooseVersion(match.group(0).decode('utf-8')) if match else None
|
if match:
|
||||||
|
found_version = LooseVersion(match.group(0).decode('utf-8'))
|
||||||
|
else:
|
||||||
|
found_version = None
|
||||||
min_ver, max_ver = self.GCC_RANGE
|
min_ver, max_ver = self.GCC_RANGE
|
||||||
if found_version and (found_version < min_ver or found_version >= max_ver):
|
if found_version and (found_version < min_ver
|
||||||
|
or found_version >= max_ver):
|
||||||
msg = ("Compiler version mismatch: Have {}; "
|
msg = ("Compiler version mismatch: Have {}; "
|
||||||
"expected version >= {} and < {}"
|
"expected version >= {} and < {}"
|
||||||
.format(found_version, min_ver, max_ver))
|
.format(found_version, min_ver, max_ver))
|
||||||
|
|
@ -196,7 +207,9 @@ class GCC(mbedToolchain):
|
||||||
|
|
||||||
def assemble(self, source, object, includes):
|
def assemble(self, source, object, includes):
|
||||||
# Build assemble command
|
# Build assemble command
|
||||||
cmd = self.asm + self.get_compile_options(self.get_symbols(True), includes) + ["-o", object, source]
|
cmd = self.asm + self.get_compile_options(
|
||||||
|
self.get_symbols(True), includes
|
||||||
|
) + ["-o", object, source]
|
||||||
|
|
||||||
# Return command array, don't execute
|
# Return command array, don't execute
|
||||||
return [cmd]
|
return [cmd]
|
||||||
|
|
@ -230,15 +243,23 @@ class GCC(mbedToolchain):
|
||||||
# Preprocess
|
# Preprocess
|
||||||
if mem_map:
|
if mem_map:
|
||||||
preproc_output = join(dirname(output), ".link_script.ld")
|
preproc_output = join(dirname(output), ".link_script.ld")
|
||||||
cmd = (self.preproc + [mem_map] + self.ld[1:] +
|
cmd = (
|
||||||
[ "-o", preproc_output])
|
self.preproc + [mem_map] + self.ld[1:] + ["-o", preproc_output]
|
||||||
|
)
|
||||||
self.notify.cc_verbose("Preproc: %s" % ' '.join(cmd))
|
self.notify.cc_verbose("Preproc: %s" % ' '.join(cmd))
|
||||||
self.default_cmd(cmd)
|
self.default_cmd(cmd)
|
||||||
mem_map = preproc_output
|
mem_map = preproc_output
|
||||||
|
|
||||||
# Build linker command
|
# Build linker command
|
||||||
map_file = splitext(output)[0] + ".map"
|
map_file = splitext(output)[0] + ".map"
|
||||||
cmd = self.ld + ["-o", output, "-Wl,-Map=%s" % map_file] + objects + ["-Wl,--start-group"] + libs + ["-Wl,--end-group"]
|
cmd = (
|
||||||
|
self.ld +
|
||||||
|
["-o", output, "-Wl,-Map=%s" % map_file] +
|
||||||
|
objects +
|
||||||
|
["-Wl,--start-group"] +
|
||||||
|
libs +
|
||||||
|
["-Wl,--end-group"]
|
||||||
|
)
|
||||||
|
|
||||||
if mem_map:
|
if mem_map:
|
||||||
cmd.extend(['-T', mem_map])
|
cmd.extend(['-T', mem_map])
|
||||||
|
|
@ -291,9 +312,12 @@ class GCC(mbedToolchain):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_executable():
|
def check_executable():
|
||||||
"""Returns True if the executable (arm-none-eabi-gcc) location
|
"""Returns True if the executable (arm-none-eabi-gcc) location
|
||||||
specified by the user exists OR the executable can be found on the PATH.
|
specified by the user exists OR the executable can be found on the
|
||||||
Returns False otherwise."""
|
PATH. Returns False otherwise."""
|
||||||
if not TOOLCHAIN_PATHS['GCC_ARM'] or not exists(TOOLCHAIN_PATHS['GCC_ARM']):
|
if (
|
||||||
|
not TOOLCHAIN_PATHS['GCC_ARM'] or
|
||||||
|
not exists(TOOLCHAIN_PATHS['GCC_ARM'])
|
||||||
|
):
|
||||||
if find_executable('arm-none-eabi-gcc'):
|
if find_executable('arm-none-eabi-gcc'):
|
||||||
TOOLCHAIN_PATHS['GCC_ARM'] = ''
|
TOOLCHAIN_PATHS['GCC_ARM'] = ''
|
||||||
return True
|
return True
|
||||||
|
|
@ -303,5 +327,6 @@ class GCC(mbedToolchain):
|
||||||
exec_name = join(TOOLCHAIN_PATHS['GCC_ARM'], 'arm-none-eabi-gcc')
|
exec_name = join(TOOLCHAIN_PATHS['GCC_ARM'], 'arm-none-eabi-gcc')
|
||||||
return exists(exec_name) or exists(exec_name + '.exe')
|
return exists(exec_name) or exists(exec_name + '.exe')
|
||||||
|
|
||||||
|
|
||||||
class GCC_ARM(GCC):
|
class GCC_ARM(GCC):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue