mirror of https://github.com/ARMmbed/mbed-os.git
Clean code style of python code for generic make
parent
920bb47ffd
commit
6838aa9372
|
|
@ -32,10 +32,10 @@ EXPORTERS = {
|
|||
'uvision4': uvision4.Uvision4,
|
||||
'uvision5': uvision5.Uvision5,
|
||||
'lpcxpresso': codered.CodeRed,
|
||||
'gcc_arm': makefile.GccArm_Exporter,
|
||||
'make_gcc_arm': makefile.GccArm_Exporter,
|
||||
'make_armc5': makefile.Armc5_Exporter,
|
||||
'make_iar': makefile.IAR_Exporter,
|
||||
'gcc_arm': makefile.GccArm,
|
||||
'make_gcc_arm': makefile.GccArm,
|
||||
'make_armc5': makefile.Armc5,
|
||||
'make_iar': makefile.IAR,
|
||||
'ds5_5': ds5_5.DS5_5,
|
||||
'iar': iar.IAREmbeddedWorkbench,
|
||||
'emblocks' : emblocks.IntermediateFile,
|
||||
|
|
|
|||
|
|
@ -17,47 +17,48 @@ limitations under the License.
|
|||
from os.path import splitext, basename, relpath, join, abspath, dirname,\
|
||||
exists
|
||||
from os import curdir, getcwd
|
||||
from jinja2.exceptions import TemplateNotFound
|
||||
from tools.export.exporters import Exporter
|
||||
from tools.utils import NotSupportedException
|
||||
from tools.targets import TARGET_MAP
|
||||
from jinja2.exceptions import TemplateNotFound
|
||||
|
||||
|
||||
class Makefile(Exporter):
|
||||
"""Generic Makefile template that mimics the behavior of the python build
|
||||
system
|
||||
"""
|
||||
|
||||
DOT_IN_RELATIVE_PATH = True
|
||||
|
||||
MBED_CONFIG_HEADER_SUPPORTED = True
|
||||
|
||||
def generate(self):
|
||||
# "make" wants Unix paths
|
||||
"""Generate the makefile
|
||||
|
||||
Note: subclasses should not need to override this method
|
||||
"""
|
||||
self.resources.win_to_unix()
|
||||
|
||||
to_be_compiled = []
|
||||
for r_type in ['s_sources', 'c_sources', 'cpp_sources']:
|
||||
r = getattr(self.resources, r_type)
|
||||
if r:
|
||||
for source in r:
|
||||
base, ext = splitext(source)
|
||||
to_be_compiled.append(base + '.o')
|
||||
to_be_compiled = [splitext(src)[0] + ".o" for src in
|
||||
self.resources['s_sources'] +
|
||||
self.resources['c_sources'] +
|
||||
self.resources['cpp_sources']]
|
||||
|
||||
libraries = []
|
||||
for lib in self.resources.libraries:
|
||||
l, _ = splitext(basename(lib))
|
||||
libraries.append(l[3:])
|
||||
libraries = [splitext(lib)[0][3:] for lib in self.resources.libraries]
|
||||
|
||||
ctx = {
|
||||
'name': self.project_name,
|
||||
'to_be_compiled': to_be_compiled,
|
||||
'object_files': self.resources.objects,
|
||||
'include_paths': self.resources.inc_dirs,
|
||||
'include_paths': list(set(self.resources.inc_dirs)),
|
||||
'library_paths': self.resources.lib_dirs,
|
||||
'linker_script': self.resources.linker_script,
|
||||
'libraries': libraries,
|
||||
'symbols': self.toolchain.get_symbols(),
|
||||
'hex_files': self.resources.hex_files,
|
||||
'vpath': (["../../.."]
|
||||
if basename(dirname(dirname(self.export_dir))) == "projectfiles"
|
||||
if (basename(dirname(dirname(self.export_dir)))
|
||||
== "projectfiles")
|
||||
else [".."]),
|
||||
'cc_cmd': " ".join(self.toolchain.cc),
|
||||
'cppc_cmd': " ".join(self.toolchain.cppc),
|
||||
|
|
@ -68,15 +69,16 @@ class Makefile(Exporter):
|
|||
'link_script_option': self.LINK_SCRIPT_OPTION,
|
||||
}
|
||||
|
||||
for key in ['include_paths', 'library_paths', 'linker_script', 'hex_files']:
|
||||
for key in ['include_paths', 'library_paths', 'linker_script',
|
||||
'hex_files']:
|
||||
if isinstance(ctx[key], list):
|
||||
ctx[key] = [ctx['vpath'][0] + "/" + t for t in ctx[key]]
|
||||
else:
|
||||
ctx[key] = ctx['vpath'][0] + "/" + ctx[key]
|
||||
if "../." not in ctx["include_paths"]:
|
||||
ctx["include_paths"] += ['../.']
|
||||
ctx["include_paths"] = list(set(ctx["include_paths"]))
|
||||
for key in ['include_paths', 'library_paths', 'hex_files', 'to_be_compiled', 'symbols']:
|
||||
for key in ['include_paths', 'library_paths', 'hex_files',
|
||||
'to_be_compiled', 'symbols']:
|
||||
ctx[key] = sorted(ctx[key])
|
||||
ctx.update(self.flags)
|
||||
|
||||
|
|
@ -96,7 +98,8 @@ class Makefile(Exporter):
|
|||
raise NotSupportedException("This make tool is in development")
|
||||
|
||||
|
||||
class GccArm_Exporter(Makefile):
|
||||
class GccArm(Makefile):
|
||||
"""GCC ARM specific makefile target"""
|
||||
TARGETS = [target for target, obj in TARGET_MAP.iteritems()
|
||||
if "GCC_ARM" in obj.supported_toolchains]
|
||||
NAME = 'Make-GCC-ARM'
|
||||
|
|
@ -104,7 +107,8 @@ class GccArm_Exporter(Makefile):
|
|||
LINK_SCRIPT_OPTION = "-T"
|
||||
|
||||
|
||||
class Armc5_Exporter(Makefile):
|
||||
class Armc5(Makefile):
|
||||
"""ARM Compiler 5 specific makefile target"""
|
||||
TARGETS = [target for target, obj in TARGET_MAP.iteritems()
|
||||
if "ARM" in obj.supported_toolchains]
|
||||
NAME = 'Make-ARMc5'
|
||||
|
|
@ -112,7 +116,8 @@ class Armc5_Exporter(Makefile):
|
|||
LINK_SCRIPT_OPTION = "--scatter"
|
||||
|
||||
|
||||
class IAR_Exporter(Makefile):
|
||||
class IAR(Makefile):
|
||||
"""IAR specific makefile target"""
|
||||
TARGETS = [target for target, obj in TARGET_MAP.iteritems()
|
||||
if "IAR" in obj.supported_toolchains]
|
||||
NAME = 'Make-IAR'
|
||||
|
|
|
|||
Loading…
Reference in New Issue