Skip to content

Commit 1712506

Browse files
committed
Fix pylint warnings in gcc.py except for the long regex
1 parent 5dd149c commit 1712506

File tree

1 file changed

+42
-17
lines changed

1 file changed

+42
-17
lines changed

tools/toolchains/gcc.py

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
from tools.targets import CORE_ARCH
2424
from tools.toolchains.mbed_toolchain import mbedToolchain, TOOLCHAIN_PATHS
25-
from tools.utils import run_cmd, NotSupportedException
25+
from tools.utils import run_cmd
26+
2627

2728
class GCC(mbedToolchain):
2829
OFFICIALLY_SUPPORTED = True
@@ -37,15 +38,21 @@ class GCC(mbedToolchain):
3738

3839
def __init__(self, target, notify=None, macros=None, build_profile=None,
3940
build_dir=None):
40-
mbedToolchain.__init__(self, target, notify, macros,
41-
build_profile=build_profile, build_dir=build_dir)
42-
43-
tool_path=TOOLCHAIN_PATHS['GCC_ARM']
41+
mbedToolchain.__init__(
42+
self,
43+
target,
44+
notify,
45+
macros,
46+
build_profile=build_profile,
47+
build_dir=build_dir
48+
)
49+
50+
tool_path = TOOLCHAIN_PATHS['GCC_ARM']
4451
# Add flags for current size setting
4552
default_lib = "std"
4653
if hasattr(target, "default_lib"):
4754
default_lib = target.default_lib
48-
elif hasattr(target, "default_build"): # Legacy
55+
elif hasattr(target, "default_build"):
4956
default_lib = target.default_build
5057

5158
if default_lib == "small":
@@ -109,8 +116,8 @@ def __init__(self, target, notify=None, macros=None, build_profile=None,
109116
main_cc = join(tool_path, "arm-none-eabi-gcc")
110117
main_cppc = join(tool_path, "arm-none-eabi-g++")
111118
self.asm = [main_cc] + self.flags['asm'] + self.flags["common"]
112-
self.cc = [main_cc]
113-
self.cppc =[main_cppc]
119+
self.cc = [main_cc]
120+
self.cppc = [main_cppc]
114121
self.cc += self.flags['c'] + self.flags['common']
115122
self.cppc += self.flags['cxx'] + self.flags['common']
116123

@@ -129,9 +136,13 @@ def version_check(self):
129136
stdout, _, retcode = run_cmd([self.cc[0], "--version"], redirect=True)
130137
msg = None
131138
match = self.GCC_VERSION_RE.search(stdout.encode("utf-8"))
132-
found_version = LooseVersion(match.group(0).decode('utf-8')) if match else None
139+
if match:
140+
found_version = LooseVersion(match.group(0).decode('utf-8'))
141+
else:
142+
found_version = None
133143
min_ver, max_ver = self.GCC_RANGE
134-
if found_version and (found_version < min_ver or found_version >= max_ver):
144+
if found_version and (found_version < min_ver
145+
or found_version >= max_ver):
135146
msg = ("Compiler version mismatch: Have {}; "
136147
"expected version >= {} and < {}"
137148
.format(found_version, min_ver, max_ver))
@@ -196,7 +207,9 @@ def get_compile_options(self, defines, includes, for_asm=False):
196207

197208
def assemble(self, source, object, includes):
198209
# Build assemble command
199-
cmd = self.asm + self.get_compile_options(self.get_symbols(True), includes) + ["-o", object, source]
210+
cmd = self.asm + self.get_compile_options(
211+
self.get_symbols(True), includes
212+
) + ["-o", object, source]
200213

201214
# Return command array, don't execute
202215
return [cmd]
@@ -230,15 +243,23 @@ def link(self, output, objects, libraries, lib_dirs, mem_map):
230243
# Preprocess
231244
if mem_map:
232245
preproc_output = join(dirname(output), ".link_script.ld")
233-
cmd = (self.preproc + [mem_map] + self.ld[1:] +
234-
[ "-o", preproc_output])
246+
cmd = (
247+
self.preproc + [mem_map] + self.ld[1:] + ["-o", preproc_output]
248+
)
235249
self.notify.cc_verbose("Preproc: %s" % ' '.join(cmd))
236250
self.default_cmd(cmd)
237251
mem_map = preproc_output
238252

239253
# Build linker command
240254
map_file = splitext(output)[0] + ".map"
241-
cmd = self.ld + ["-o", output, "-Wl,-Map=%s" % map_file] + objects + ["-Wl,--start-group"] + libs + ["-Wl,--end-group"]
255+
cmd = (
256+
self.ld +
257+
["-o", output, "-Wl,-Map=%s" % map_file] +
258+
objects +
259+
["-Wl,--start-group"] +
260+
libs +
261+
["-Wl,--end-group"]
262+
)
242263

243264
if mem_map:
244265
cmd.extend(['-T', mem_map])
@@ -291,9 +312,12 @@ def redirect_symbol(source, sync, build_dir):
291312
@staticmethod
292313
def check_executable():
293314
"""Returns True if the executable (arm-none-eabi-gcc) location
294-
specified by the user exists OR the executable can be found on the PATH.
295-
Returns False otherwise."""
296-
if not TOOLCHAIN_PATHS['GCC_ARM'] or not exists(TOOLCHAIN_PATHS['GCC_ARM']):
315+
specified by the user exists OR the executable can be found on the
316+
PATH. Returns False otherwise."""
317+
if (
318+
not TOOLCHAIN_PATHS['GCC_ARM'] or
319+
not exists(TOOLCHAIN_PATHS['GCC_ARM'])
320+
):
297321
if find_executable('arm-none-eabi-gcc'):
298322
TOOLCHAIN_PATHS['GCC_ARM'] = ''
299323
return True
@@ -303,5 +327,6 @@ def check_executable():
303327
exec_name = join(TOOLCHAIN_PATHS['GCC_ARM'], 'arm-none-eabi-gcc')
304328
return exists(exec_name) or exists(exec_name + '.exe')
305329

330+
306331
class GCC_ARM(GCC):
307332
pass

0 commit comments

Comments
 (0)