Skip to content

Commit

Permalink
Merge pull request #1691 from 0xc0170/dev_flags_uvision
Browse files Browse the repository at this point in the history
Flags unification for uvision
  • Loading branch information
0xc0170 committed Apr 29, 2016
2 parents d1dc989 + 690b8f0 commit 6f14439
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
10 changes: 10 additions & 0 deletions workspace_tools/export/uvision4.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ def generate(self):

project_data['tool_specific'] = {}
project_data['tool_specific'].update(tool_specific)

# get flags from toolchain and apply
project_data['tool_specific']['uvision']['misc'] = {}
project_data['tool_specific']['uvision']['misc']['asm_flags'] = self.toolchain.flags['common'] + self.toolchain.flags['asm']
project_data['tool_specific']['uvision']['misc']['c_flags'] = self.toolchain.flags['common'] + self.toolchain.flags['c']
# not compatible with c99 flag set in the template
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--c99")
project_data['tool_specific']['uvision']['misc']['cxx_flags'] = self.toolchain.flags['common'] + self.toolchain.flags['ld']
project_data['tool_specific']['uvision']['misc']['ld_flags'] = self.toolchain.flags['ld']

i = 0
for macro in project_data['common']['macros']:
# armasm does not like floating numbers in macros, timestamp to int
Expand Down
52 changes: 26 additions & 26 deletions workspace_tools/toolchains/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ class ARM(mbedToolchain):
DIAGNOSTIC_PATTERN = re.compile('"(?P<file>[^"]+)", line (?P<line>\d+)( \(column (?P<column>\d+)\)|): (?P<severity>Warning|Error): (?P<message>.+)')
DEP_PATTERN = re.compile('\S+:\s(?P<file>.+)\n')

DEFAULT_FLAGS = {
'common': ["-c", "--gnu", "-Otime", "--split_sections", "--apcs=interwork",
"--brief_diagnostics", "--restrict", "--multibyte_chars"],
'asm': ['-I%s' % ARM_INC],
'c': ["--md", "--no_depend_system_headers", '-I%s' % ARM_INC,
"--c99", "-D__ASSERT_MSG" ],
'cxx': ["--cpp", "--no_rtti", "-D__ASSERT_MSG"],
'ld': [],
}

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)

Expand All @@ -43,33 +53,25 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
cpu = target.core

main_cc = join(ARM_BIN, "armcc")
common = ["-c",
"--cpu=%s" % cpu, "--gnu",
"-Otime", "--split_sections", "--apcs=interwork",
"--brief_diagnostics", "--restrict", "--multibyte_chars"
]

self.flags = self.DEFAULT_FLAGS
self.flags['common'] += ["--cpu=%s" % cpu]
if "save-asm" in self.options:
common.extend(["--asm", "--interleave"])
self.flags['common'].extend(["--asm", "--interleave"])

if "debug-info" in self.options:
common.append("-g")
common.append("-O0")
self.flags['common'].append("-g")
self.flags['common'].append("-O0")
else:
common.append("-O3")

common_c = [
"--md", "--no_depend_system_headers",
'-I%s' % ARM_INC
]
self.flags['common'].append("-O3")

self.asm = [main_cc] + common + ['-I%s' % ARM_INC]
self.asm = [main_cc] + self.flags['common'] + self.flags['asm']
if not "analyze" in self.options:
self.cc = [main_cc] + common + common_c + ["--c99"]
self.cppc = [main_cc] + common + common_c + ["--cpp", "--no_rtti"]
self.cc = [main_cc] + self.flags['common'] + self.flags['c']
self.cppc = [main_cc] + self.flags['common'] + self.flags['c'] + self.flags['cxx']
else:
self.cc = [join(GOANNA_PATH, "goannacc"), "--with-cc=" + main_cc.replace('\\', '/'), "--dialect=armcc", '--output-format="%s"' % self.GOANNA_FORMAT] + common + common_c + ["--c99"]
self.cppc= [join(GOANNA_PATH, "goannac++"), "--with-cxx=" + main_cc.replace('\\', '/'), "--dialect=armcc", '--output-format="%s"' % self.GOANNA_FORMAT] + common + common_c + ["--cpp", "--no_rtti"]
self.cc = [join(GOANNA_PATH, "goannacc"), "--with-cc=" + main_cc.replace('\\', '/'), "--dialect=armcc", '--output-format="%s"' % self.GOANNA_FORMAT] + self.flags['common'] + self.flags['c']
self.cppc= [join(GOANNA_PATH, "goannac++"), "--with-cxx=" + main_cc.replace('\\', '/'), "--dialect=armcc", '--output-format="%s"' % self.GOANNA_FORMAT] + self.flags['common'] + self.flags['c'] + self.flags['cxx']

self.ld = [join(ARM_BIN, "armlink")]
self.sys_libs = []
Expand Down Expand Up @@ -151,8 +153,6 @@ def binary(self, resources, elf, bin):
class ARM_STD(ARM):
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
self.cc += ["-D__ASSERT_MSG"]
self.cppc += ["-D__ASSERT_MSG"]
self.ld.append("--libpath=%s" % ARM_LIB)


Expand All @@ -163,17 +163,17 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)

# Compiler
self.asm += ["-D__MICROLIB"]
self.cc += ["--library_type=microlib", "-D__MICROLIB", "-D__ASSERT_MSG"]
self.cppc += ["--library_type=microlib", "-D__MICROLIB", "-D__ASSERT_MSG"]
self.flags['asm'] += ["-D__MICROLIB"]
self.flags['c'] += ["--library_type=microlib", "-D__MICROLIB"]
self.flags['cxx'] += ["--library_type=microlib", "-D__MICROLIB"]

# Linker
self.ld.append("--library_type=microlib")
self.flags['ld'].append("--library_type=microlib")

# We had to patch microlib to add C++ support
# In later releases this patch should have entered mainline
if ARM_MICRO.PATCHED_LIBRARY:
self.ld.append("--noscanlib")
self.flags['ld'].append("--noscanlib")

# System Libraries
self.sys_libs.extend([join(MY_ARM_CLIB, lib+".l") for lib in ["mc_p", "mf_p", "m_ps"]])
Expand Down

0 comments on commit 6f14439

Please sign in to comment.