diff --git a/tools/export/__init__.py b/tools/export/__init__.py
index 16e5d48563..46c4488f1d 100644
--- a/tools/export/__init__.py
+++ b/tools/export/__init__.py
@@ -19,18 +19,14 @@ from os.path import join, exists, basename
from shutil import copytree, rmtree, copy
import yaml
-from tools.export import uvision4, uvision5, codered, makefile, ds5_5, iar
+from tools.export import codered, ds5_5, iar, makefile
from tools.export import emblocks, coide, kds, simplicityv3, atmelstudio
-from tools.export import sw4stm32, e2studio, zip, cdt
+from tools.export import sw4stm32, e2studio, zip, cmsis, uvision, cdt
from tools.export.exporters import OldLibrariesException, FailedBuildException
-from tools.targets import TARGET_NAMES, EXPORT_MAP, TARGET_MAP
-
-from project_generator_definitions.definitions import ProGenDef
+from tools.targets import TARGET_NAMES
EXPORTERS = {
- 'uvision': uvision5.Uvision5,
- 'uvision4': uvision4.Uvision4, # deprecated - to be removed in future version
- 'uvision5': uvision5.Uvision5,
+ 'uvision5': uvision.Uvision,
'lpcxpresso': codered.CodeRed,
'gcc_arm': makefile.GccArm,
'make_gcc_arm': makefile.GccArm,
@@ -48,7 +44,8 @@ EXPORTERS = {
'eclipse_gcc_arm' : cdt.EclipseGcc,
'eclipse_iar' : cdt.EclipseIAR,
'eclipse_armc5' : cdt.EclipseArmc5,
- 'zip' : zip.ZIP
+ 'zip' : zip.ZIP,
+ 'cmsis' : cmsis.CMSIS
}
ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN = """
diff --git a/tools/export/cmsis/__init__.py b/tools/export/cmsis/__init__.py
new file mode 100644
index 0000000000..f237643ff7
--- /dev/null
+++ b/tools/export/cmsis/__init__.py
@@ -0,0 +1,138 @@
+import os
+from os.path import sep
+from itertools import groupby
+from xml.etree.ElementTree import Element, tostring
+from xml.dom.minidom import parseString
+import ntpath
+import re
+
+from ArmPackManager import Cache
+
+from tools.targets import TARGET_MAP
+from tools.export.exporters import Exporter, TargetNotSupportedException
+
+cache_d = False
+
+
+class fileCMSIS():
+ """CMSIS file class.
+
+ Encapsulates information necessary for files in cpdsc project file"""
+ file_types = {'.cpp': 'sourceCpp', '.c': 'sourceC', '.s': 'sourceAsm',
+ '.obj': 'object', '.o': 'object', '.lib': 'library',
+ '.ar': 'linkerScript', '.h': 'header', '.sct': 'linkerScript'}
+
+ def __init__(self, loc, name):
+ #print loc
+ _, ext = os.path.splitext(loc)
+ self.type = self.file_types[ext.lower()]
+ self.loc = loc
+ self.name = name
+
+
+class DeviceCMSIS():
+ """CMSIS Device class
+
+ Encapsulates target information retrieved by arm-pack-manager"""
+ def __init__(self, target, use_generic_cpu=False):
+ cache = Cache(True, False)
+ if cache_d:
+ cache.cache_descriptors()
+
+ t = TARGET_MAP[target]
+ self.core = t.core
+ try:
+ cpu_name = t.device_name
+ target_info = cache.index[cpu_name]
+ # Target does not have device name or pdsc file
+ except:
+ try:
+ # Try to find the core as a generic CMSIS target
+ cpu_name = self.cpu_cmsis()
+ target_info = cache.index[cpu_name]
+ except:
+ raise TargetNotSupportedException("Target not in CMSIS packs")
+
+ self.url = target_info['pdsc_file']
+ self.pack_url, self.pack_id = ntpath.split(self.url)
+ self.dname = cpu_name
+ self.dfpu = target_info['processor']['fpu']
+ self.dvendor = target_info['vendor']
+ self.dendian = target_info['processor'].get('endianness','Little-endian')
+ self.debug_interface = self.find_debug()
+ self.debug_svd = target_info.get('debug', '')
+ self.compile_header = target_info['compile']['header']
+
+ def find_debug(self):
+ debug_map ={
+ 'STMicroelectronics':'ST-Link',
+ 'Silicon Labs':'J-LINK',
+ 'Nuvoton':'NULink'
+ }
+ reg = "([\w\s]+):?\d*?"
+ m = re.search(reg, self.dvendor)
+ vendor_match = m.group(1) if m else None
+ return debug_map.get(vendor_match, "CMSIS-DAP")
+
+ def cpu_cmsis(self):
+ #Cortex-M4F => ARMCM4_FP, Cortex-M0+ => ARMCM0P
+ cpu = self.core
+ cpu = cpu.replace("Cortex-","ARMC")
+ cpu = cpu.replace("+","P")
+ cpu = cpu.replace("F","_FP")
+ return cpu
+
+class CMSIS(Exporter):
+ NAME = 'cmsis'
+ TOOLCHAIN = 'ARM'
+ TARGETS = [target for target, obj in TARGET_MAP.iteritems()
+ if "ARM" in obj.supported_toolchains]
+
+ def make_key(self, src):
+ """turn a source file into its group name"""
+ key = src.name.split(sep)[0]
+ if key == ".":
+ key = os.path.basename(os.path.realpath(self.export_dir))
+ return key
+
+ def group_project_files(self, sources, root_element):
+ """Recursively group the source files by their encompassing directory"""
+
+ data = sorted(sources, key=self.make_key)
+ for group, files in groupby(data, self.make_key):
+ new_srcs = []
+ for f in list(files):
+ spl = f.name.split(sep)
+ if len(spl)==2:
+ file_element = Element('file',
+ attrib={
+ 'category':f.type,
+ 'name': f.loc})
+ root_element.append(file_element)
+ else:
+ f.name = os.path.join(*spl[1:])
+ new_srcs.append(f)
+ if new_srcs:
+ group_element = Element('group',attrib={'name':group})
+ root_element.append(self.group_project_files(new_srcs,
+ group_element))
+ return root_element
+
+ def generate(self):
+
+ srcs = self.resources.headers + self.resources.s_sources + \
+ self.resources.c_sources + self.resources.cpp_sources + \
+ self.resources.objects + self.resources.libraries + \
+ [self.resources.linker_script]
+ srcs = [fileCMSIS(src, src) for src in srcs if src]
+ ctx = {
+ 'name': self.project_name,
+ 'project_files': tostring(self.group_project_files(srcs, Element('files'))),
+ 'device': DeviceCMSIS(self.target),
+ 'date': ''
+ }
+ # TODO: find how to keep prettyxml from adding xml version to this blob
+ #dom = parseString(ctx['project_files'])
+ #ctx['project_files'] = dom.toprettyxml(indent="\t")
+
+ self.gen_file('cmsis/cpdsc.tmpl', ctx, 'project.cpdsc')
diff --git a/tools/export/cmsis/cpdsc.tmpl b/tools/export/cmsis/cpdsc.tmpl
new file mode 100644
index 0000000000..347bf91e79
--- /dev/null
+++ b/tools/export/cmsis/cpdsc.tmpl
@@ -0,0 +1,20 @@
+
+
+ Keil
+ {{name}}
+ Exported mbed project.
+ {{device.url}}
+
+
+ Generated
+
+
+
+
+
+
+
+ {{project_files}}
+
+
+
\ No newline at end of file
diff --git a/tools/export/exporters.py b/tools/export/exporters.py
index 085e04ae13..41a3d31c4a 100644
--- a/tools/export/exporters.py
+++ b/tools/export/exporters.py
@@ -2,10 +2,11 @@
import os
import sys
import logging
-from os.path import join, dirname, relpath
+from os.path import join, dirname, relpath, basename, realpath
from itertools import groupby
from jinja2 import FileSystemLoader
from jinja2.environment import Environment
+import copy
from tools.targets import TARGET_MAP
from project_generator.tools import tool
@@ -73,11 +74,20 @@ class Exporter(object):
self.resources = resources
self.generated_files = [join(self.TEMPLATE_DIR,"GettingStarted.html")]
self.builder_files_dict = {}
+ self.add_config()
def get_toolchain(self):
"""A helper getter function that we should probably eliminate"""
return self.TOOLCHAIN
+ def add_config(self):
+ """Add the containgin directory of mbed_config.h to include dirs"""
+ config = self.toolchain.get_config_header()
+ if config:
+ self.resources.inc_dirs.append(
+ dirname(relpath(config,
+ self.resources.file_basepath[config])))
+
@property
def flags(self):
"""Returns a dictionary of toolchain flags.
@@ -89,7 +99,7 @@ class Exporter(object):
common_flags - common options
"""
config_header = self.toolchain.get_config_header()
- flags = {key + "_flags": value for key, value
+ flags = {key + "_flags": copy.deepcopy(value) for key, value
in self.toolchain.flags.iteritems()}
asm_defines = ["-D" + symbol for symbol in self.toolchain.get_symbols(True)]
c_defines = ["-D" + symbol for symbol in self.toolchain.get_symbols()]
@@ -217,3 +227,23 @@ class Exporter(object):
logging.debug("Generating: %s", target_path)
open(target_path, "w").write(target_text)
self.generated_files += [target_path]
+
+ def make_key(self, src):
+ """From a source file, extract group name
+ Positional Arguments:
+ src - the src's location
+ """
+ key = basename(dirname(src))
+ if key == ".":
+ key = basename(realpath(self.export_dir))
+ return key
+
+ def group_project_files(self, sources):
+ """Group the source files by their encompassing directory
+ Positional Arguments:
+ sources - array of sourc locations
+
+ Returns a dictionary of {group name: list of source locations}
+ """
+ data = sorted(sources, key=self.make_key)
+ return {k: list(g) for k,g in groupby(data, self.make_key)}
diff --git a/tools/export/uvision.uvproj.tmpl b/tools/export/uvision.uvproj.tmpl
deleted file mode 100644
index 87f90acc50..0000000000
--- a/tools/export/uvision.uvproj.tmpl
+++ /dev/null
@@ -1,403 +0,0 @@
-
-
-
- 1.1
-
- ###This file was automagically generated by mbed.org. For more information, see http://mbed.org/handbook/Exporting-To-Uvision
-
-
-
- mbed FRDM-KL25Z
- 0x4
- ARM-ADS
-
-
- MKL25Z128xxx4
- Freescale Semiconductor
- IRAM(0x1FFFF000-0x1FFFFFFF) IRAM2(0x20000000-0x20002FFF) IROM(0x0-0x1FFFF) CLOCK(8000000) CPUTYPE("Cortex-M0+") ELITTLE
-
- "STARTUP\Freescale\Kinetis\startup_MKL25Z4.s" ("Freescale MKL25Zxxxxxx4 Startup Code")
- ULP2CM3(-O2510 -S0 -C0 -FO15 -FD20000000 -FC800 -FN1 -FF0MK_P128_48MHZ -FS00 -FL020000)
- 6533
- MKL25Z4.H
-
-
-
-
-
-
-
-
-
- SFD\Freescale\Kinetis\MKL25Z4.sfr
- 0
-
-
-
- Freescale\Kinetis\
- Freescale\Kinetis\
-
- 0
- 0
- 0
- 0
- 1
-
- .\build\
- MBED_11
- 1
- 0
- 0
- 1
- 1
- .\build\
- 1
- 0
- 0
-
- 0
- 0
-
-
- 0
- 0
- 0
- 0
-
-
- 0
- 0
-
-
- 0
- 0
-
-
- 1
- 0
- fromelf --bin --output=@L.bin !L
-
- 0
- 0
-
- 0
-
-
-
- 0
- 0
- 0
- 0
- 0
- 1
- 0
- 0
- 0
- 0
- 3
-
-
-
-
- SARMCM3.DLL
-
- DARMCM1.DLL
- -pCM0+
- SARMCM3.DLL
-
- TARMCM1.DLL
- -pCM0+
-
-
-
- 1
- 0
- 0
- 0
- 16
-
-
- 0
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 0
-
-
- 1
- 1
- 1
- 1
- 1
- 1
- 0
- 1
-
- 0
- 14
-
-
-
-
-
-
-
-
-
-
-
-
-
- BIN\CMSIS_AGDI.dll
-
-
-
-
- 1
- 0
- 0
- 1
- 1
- 4105
-
- BIN\CMSIS_AGDI.dll
- "" ()
-
-
-
-
- 0
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 0
- 1
- 1
- 0
- 1
- 1
- 0
- 0
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 0
- 0
- "Cortex-M0+"
-
- 0
- 0
- 0
- 1
- 1
- 0
- 0
- 0
- 1
- 0
- 8
- 0
- 0
- 0
- 3
- 3
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 1
- 0
- 0
- 0
- 0
- 1
- 0
-
-
- 0
- 0x0
- 0x0
-
-
- 0
- 0x0
- 0x0
-
-
- 0
- 0x0
- 0x0
-
-
- 0
- 0x0
- 0x0
-
-
- 0
- 0x0
- 0x0
-
-
- 0
- 0x0
- 0x0
-
-
- 0
- 0x1ffff000
- 0x1000
-
-
- 1
- 0x0
- 0x20000
-
-
- 0
- 0x0
- 0x0
-
-
- 1
- 0x0
- 0x0
-
-
- 1
- 0x0
- 0x0
-
-
- 1
- 0x0
- 0x0
-
-
- 1
- 0x0
- 0x20000
-
-
- 1
- 0x0
- 0x0
-
-
- 0
- 0x0
- 0x0
-
-
- 0
- 0x0
- 0x0
-
-
- 0
- 0x0
- 0x0
-
-
- 0
- 0x20000000
- 0x3000
-
-
- 0
- 0x0
- 0x0
-
-
-
-
-
- 1
- 1
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 1
-
-
-
-
-
-
-
-
- 1
- 0
- 0
- 0
- 0
- 0
- 0
- 0
-
-
-
-
-
-
-
-
- 0
- 0
- 0
- 0
- 1
- 0
- 0x00000000
- 0x10000000
- mbed\TARGET_KL25Z\TOOLCHAIN_ARM_STD\MKL25Z4.sct
-
-
-
-
-
-
-
-
-
-
-
-
- src
-
-
-
-
-
-
-
-
-
diff --git a/tools/export/uvision/__init__.py b/tools/export/uvision/__init__.py
new file mode 100644
index 0000000000..b64a76adab
--- /dev/null
+++ b/tools/export/uvision/__init__.py
@@ -0,0 +1,165 @@
+import os
+from os.path import sep, normpath, join, exists
+import ntpath
+import copy
+from collections import namedtuple
+from distutils.spawn import find_executable
+import subprocess
+
+from ArmPackManager import Cache
+
+from tools.targets import TARGET_MAP
+from tools.export.exporters import Exporter, FailedBuildException
+from tools.export.cmsis import DeviceCMSIS
+
+cache_d = False
+
+
+class DeviceUvision(DeviceCMSIS):
+ """Uvision Device class, inherits CMSIS Device class
+
+ Encapsulates information necessary for uvision project targets"""
+ def __init__(self, target, use_generic_cpu=False):
+ DeviceCMSIS.__init__(self, target, use_generic_cpu)
+ dev_format = "$$Device:{0}${1}"
+ self.svd = ''
+ if self.debug_svd:
+ self.svd = dev_format.format(self.dname, self.debug_svd)
+ self.reg_file = dev_format.format(self.dname, self.compile_header)
+ self.debug_interface = self.uv_debug()
+
+ def uv_debug(self):
+ """Return a namedtuple of information about uvision debug settings"""
+ UVDebug = namedtuple('UVDebug',['bin_loc','core_flag'])
+
+ # CortexMXn => pCMX
+ cpu = self.core.replace("Cortex-", "C")
+ cpu = cpu.replace("+", "")
+ cpu = cpu.replace("F", "")
+ cpu_flag = "p"+cpu
+
+ # Locations found in Keil_v5/TOOLS.INI
+ debuggers = {"st-link":'STLink\\ST-LINKIII-KEIL_SWO.dll',
+ "j-link":'Segger\\JL2CM3.dll',
+ "cmsis-dap":'BIN\\CMSIS_AGDI.dll',
+ "nulink":'NULink\\Nu_Link.dll'}
+ binary = debuggers[self.debug_interface.lower()]
+ return UVDebug(binary, cpu_flag)
+
+
+class Uvision(Exporter):
+ """Keil Uvision class
+
+ This class encapsulates information to be contained in a Uvision
+ project file (.uvprojx).
+ The needed information can be viewed in uvision.tmpl
+ """
+ NAME = 'cmsis'
+ TOOLCHAIN = 'ARM'
+ TARGETS = [target for target, obj in TARGET_MAP.iteritems()
+ if "ARM" in obj.supported_toolchains]
+ #File associations within .uvprojx file
+ file_types = {'.cpp': 8, '.c': 1, '.s': 2,
+ '.obj': 3, '.o': 3, '.lib': 4,
+ '.ar': 4, '.h': 5, '.sct': 4}
+
+ def uv_file(self, loc):
+ """Return a namedtuple of information about project file
+ Positional Arguments:
+ loc - the file's location
+
+ .uvprojx XML for project file:
+
+ {{file.type}}
+ {{file.name}}
+ {{file.loc}}
+
+ """
+ UVFile = namedtuple('UVFile', ['type','loc','name'])
+ _, ext = os.path.splitext(loc)
+ type = self.file_types[ext.lower()]
+ name = ntpath.basename(normpath(loc))
+ return UVFile(type, loc, name)
+
+ def format_flags(self):
+ """Format toolchain flags for Uvision"""
+ flags = copy.deepcopy(self.flags)
+ asm_flag_string = '--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' + \
+ ",".join(flags['asm_flags'])
+ # asm flags only, common are not valid within uvision project,
+ # they are armcc specific
+ flags['asm_flags'] = asm_flag_string
+ # cxx flags included, as uvision have them all in one tab
+ flags['c_flags'] = list(set(['-D__ASSERT_MSG']
+ + flags['common_flags']
+ + flags['c_flags']
+ + flags['cxx_flags']))
+ # not compatible with c99 flag set in the template
+ try: flags['c_flags'].remove("--c99")
+ except ValueError: pass
+ # cpp is not required as it's implicit for cpp files
+ try: flags['c_flags'].remove("--cpp")
+ except ValueError: pass
+ # we want no-vla for only cxx, but it's also applied for C in IDE,
+ # thus we remove it
+ try: flags['c_flags'].remove("--no_vla")
+ except ValueError: pass
+ flags['c_flags'] =" ".join(flags['c_flags'])
+ return flags
+
+ def format_src(self, srcs):
+ """Make sources into the named tuple for use in the template"""
+ grouped = self.group_project_files(srcs)
+ for group, files in grouped.items():
+ grouped[group] = [self.uv_file(src) for src in files]
+ return grouped
+
+ def generate(self):
+ """Generate the .uvproj file"""
+ cache = Cache(True, False)
+ if cache_d:
+ cache.cache_descriptors()
+
+ srcs = self.resources.headers + self.resources.s_sources + \
+ self.resources.c_sources + self.resources.cpp_sources + \
+ self.resources.objects + self.resources.libraries
+
+ ctx = {
+ 'name': self.project_name,
+ 'project_files': self.format_src(srcs),
+ 'linker_script':self.resources.linker_script,
+ 'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'),
+ 'device': DeviceUvision(self.target)
+ }
+ ctx.update(self.format_flags())
+ self.gen_file('uvision/uvision.tmpl', ctx, self.project_name+".uvprojx")
+
+ def build(self):
+ ERRORLEVEL = {
+ 0: 'success (0 warnings, 0 errors)',
+ 1: 'warnings',
+ 2: 'errors',
+ 3: 'fatal errors',
+ 11: 'cant write to project file',
+ 12: 'device error',
+ 13: 'error writing',
+ 15: 'error reading xml file',
+ }
+ success = 0
+ warn = 1
+ if find_executable("UV4"):
+ uv_exe = "UV4.exe"
+ else:
+ uv_exe = join('C:', sep,
+ 'Keil_v5', 'UV4', 'UV4.exe')
+ if not exists(uv_exe):
+ raise Exception("UV4.exe not found. Add to path.")
+ cmd = [uv_exe, '-r', '-j0', '-o', join(self.export_dir,'build_log.txt'), join(self.export_dir,self.project_name+".uvprojx")]
+ ret_code = subprocess.call(cmd)
+ if ret_code != success and ret_code != warn:
+ # Seems like something went wrong.
+ raise FailedBuildException("Project: %s build failed with the status: %s" % (
+ self.project_name, ERRORLEVEL.get(ret_code, "Unknown")))
+ else:
+ return "Project: %s build succeeded with the status: %s" % (
+ self.project_name, ERRORLEVEL.get(ret_code, "Unknown"))
diff --git a/tools/export/uvision5_arm_beetle_soc.uvproj.tmpl b/tools/export/uvision/uvision.tmpl
similarity index 79%
rename from tools/export/uvision5_arm_beetle_soc.uvproj.tmpl
rename to tools/export/uvision/uvision.tmpl
index d20e6399fb..9cd11fd052 100644
--- a/tools/export/uvision5_arm_beetle_soc.uvproj.tmpl
+++ b/tools/export/uvision/uvision.tmpl
@@ -1,25 +1,27 @@
-
+
- 1.1
+ 2.1
- ###This file was automagically generated by mbed.org. For more information, see http://mbed.org/handbook/Exporting-To-Uvision
+ ### uVision Project, (C) Keil Software
- ARM BEETLE SoC
+ {{name}}
0x4
ARM-ADS
- ARMCM3
- ARM
- IROM(0x00000000,0x40000) IRAM(0x20000200,0x1FE00) CPUTYPE("Cortex-M3") CLOCK(24000000) ESEL ELITTLE
+ {{device.dname}}
+ {{device.dvendor}}
+ {{device.pack_id}}
+ {{device.pack_url}}
+
- UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000)
+ {{device.flash_dll}}
0
- $$Device:ARMCM3$Device\ARM\ARMCM3\Include\ARMCM3.h
+ {{device.reg_file}}
@@ -29,7 +31,8 @@
-
+ {{device.svd}}
+ 0
0
@@ -43,14 +46,14 @@
0
1
- .\build\
-
+ .\.build\uvision5\
+ {{name}}
1
0
0
1
1
- .\build\
+ .\build
1
0
0
@@ -71,11 +74,13 @@
0
0
+ 0
+ 0
- 1
+ 0
0
- $K\ARM\ARMCC\bin\fromelf.exe --bin --output=.\build\@L.bin !L
+
0
0
@@ -102,14 +107,14 @@
1
- SARMCM3.DLL
- -MPU
+
+
DCM.DLL
- -pCM3
+
SARMCM3.DLL
- -MPU
+
TCM.DLL
- -pCM3
+ -{{device.debug_interface.core_flag}}
@@ -144,7 +149,7 @@
1
0
- 1
+ 0
@@ -158,7 +163,7 @@
- BIN\UL2CM3.DLL
+ {{device.debug_interface.bin_loc}}
@@ -167,8 +172,8 @@
0
0
1
- 1
- 4096
+ 0
+ -1
1
BIN\UL2CM3.DLL
@@ -208,7 +213,7 @@
1
0
0
- "Cortex-M3"
+ "Cortex-M4"
0
0
@@ -217,12 +222,12 @@
1
0
0
- 0
- 0
+ 2
+ 1
0
8
0
- 1
+ 0
0
0
3
@@ -260,11 +265,11 @@
0x0
0x0
-
+
0
0x0
0x0
-
+
0
0x0
@@ -275,15 +280,16 @@
0x0
0x0
+ {
0
- 0x20000000
- 0x20000
+ 0
+ 0
1
- 0x0
- 0x40000
+ 0
+ 0
0
@@ -291,27 +297,27 @@
0x0
- 1
+ 0
0x0
0x0
- 1
+ 0
0x0
0x0
- 1
+ 0
0x0
0x0
1
0x0
- 0x40000
+ 0x20000
- 1
+ 0
0x0
0x0
@@ -333,19 +339,19 @@
0
0x20000000
- 0x20000
+ 0x2000
0
- 0x0
- 0x0
+ 0x1fffe000
+ 0x2000
- 1
- 4
+ 0
+ 2
0
0
0
@@ -354,20 +360,27 @@
0
0
0
- 2
+ 0
0
0
1
0
+ 1
+ 1
+ 1
+ 1
+ 0
+ 0
+ 0
- --gnu --no_rtti
+ {{c_flags}}
-
+ {{include_paths}}
- 1
+ 0
0
0
0
@@ -376,8 +389,9 @@
0
0
0
+ 0
-
+ {{asm_flags}}
@@ -388,41 +402,35 @@
0
0
0
- 1
+ 0
0
- 0x00000000
- 0x20000000
-
+ 0
+ 0
+
+ {{linker_script}}
-
- --entry=Reset_Handler
-
+
+ {% for group, files in project_files.iteritems() %}
-
-
-
-
-
-
-
-
-
-
- --c99
-
-
-
-
-
-
-
+ {{group}}
+
+ {% for file in files %}
+
+ {{file.type}}
+ {{file.name}}
+ {{file.loc}}
+
+ {% endfor %}
+
+
+ {% endfor %}
diff --git a/tools/export/uvision4.py b/tools/export/uvision4.py
deleted file mode 100644
index 02c630f26d..0000000000
--- a/tools/export/uvision4.py
+++ /dev/null
@@ -1,99 +0,0 @@
-"""
-mbed SDK
-Copyright (c) 2011-2016 ARM Limited
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-"""
-from os.path import basename, join, dirname
-from project_generator_definitions.definitions import ProGenDef
-
-from tools.export.exporters import Exporter, ExporterTargetsProperty
-from tools.targets import TARGET_MAP, TARGET_NAMES
-from tools.utils import remove_if_in
-
-# If you wish to add a new target, add it to project_generator_definitions, and then
-# define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
-# There are 2 default mbed templates (predefined settings) uvision.uvproj and uvproj_microlib.uvproj.tmpl
-class Uvision4(Exporter):
- """
- Exporter class for uvision. This class uses project generator.
- """
- # These 2 are currently for exporters backward compatiblity
- NAME = 'uvision'
- TOOLCHAIN = 'ARM'
- # PROGEN_ACTIVE contains information for exporter scripts that this is using progen
- PROGEN_ACTIVE = True
-
- MBED_CONFIG_HEADER_SUPPORTED = True
-
- @ExporterTargetsProperty
- def TARGETS(cls):
- if not hasattr(cls, "_targets_supported"):
- cls._targets_supported = []
- progendef = ProGenDef('uvision')
- for target in TARGET_NAMES:
- try:
- if (progendef.is_supported(str(TARGET_MAP[target])) or
- progendef.is_supported(TARGET_MAP[target].progen['target'])):
- cls._targets_supported.append(target)
- except AttributeError:
- # target is not supported yet
- continue
- return cls._targets_supported
-
- def get_toolchain(self):
- return TARGET_MAP[self.target].default_toolchain
-
- def generate(self):
- """ Generates the project files """
-
- print "WARNING: exporting to uVision4 is deprecated and will be removed in a future version"
-
- project_data = self.progen_get_project_data()
- tool_specific = {}
- # Expand tool specific settings by uvision specific settings which are required
- try:
- if TARGET_MAP[self.target].progen['uvision']['template']:
- tool_specific['uvision'] = TARGET_MAP[self.target].progen['uvision']
- except KeyError:
- # use default template
- # by the mbed projects
- tool_specific['uvision'] = {
- 'template': [join(dirname(__file__), 'uvision.uvproj.tmpl')],
- }
-
- project_data['tool_specific'] = {}
- project_data['tool_specific'].update(tool_specific)
-
- # get flags from toolchain and apply
- project_data['misc'] = {}
- # need to make this a string for progen. Only adds preprocessor when "macros" set
- asm_flag_string = '--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' + ",".join(
- list(set(self.flags['asm_flags'])))
- # asm flags only, common are not valid within uvision project, they are armcc specific
- project_data['misc']['asm_flags'] = [asm_flag_string]
- # cxx flags included, as uvision have them all in one tab
- project_data['misc']['c_flags'] = list(set(['-D__ASSERT_MSG']
- + self.flags['common_flags']
- + self.flags['c_flags']
- + self.flags['cxx_flags']))
- # not compatible with c99 flag set in the template
- remove_if_in(project_data['misc']['c_flags'], "--c99")
- # cpp is not required as it's implicit for cpp files
- remove_if_in(project_data['misc']['c_flags'], "--cpp")
- # we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it
- remove_if_in(project_data['misc']['c_flags'], "--no_vla")
- project_data['misc']['ld_flags'] = self.flags['ld_flags']
-
- project_data['build_dir'] = project_data['build_dir'] + '\\' + 'uvision4'
- self.progen_gen_file(project_data)
diff --git a/tools/export/uvision5.py b/tools/export/uvision5.py
deleted file mode 100644
index 5b4a6756e0..0000000000
--- a/tools/export/uvision5.py
+++ /dev/null
@@ -1,97 +0,0 @@
-"""
-mbed SDK
-Copyright (c) 2016 ARM Limited
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-"""
-from os.path import basename, join, dirname
-from project_generator_definitions.definitions import ProGenDef
-
-from tools.export.exporters import Exporter, ExporterTargetsProperty
-from tools.targets import TARGET_MAP, TARGET_NAMES
-from tools.utils import remove_if_in
-
-# If you wish to add a new target, add it to project_generator_definitions, and then
-# define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
-# There are 2 default mbed templates (predefined settings) uvision.uvproj and uvproj_microlib.uvproj.tmpl
-class Uvision5(Exporter):
- """
- Exporter class for uvision5. This class uses project generator.
- """
- # These 2 are currently for exporters backward compatiblity
- NAME = 'uvision5'
- TOOLCHAIN = 'ARM'
- # PROGEN_ACTIVE contains information for exporter scripts that this is using progen
- PROGEN_ACTIVE = True
-
- MBED_CONFIG_HEADER_SUPPORTED = True
-
- @ExporterTargetsProperty
- def TARGETS(cls):
- if not hasattr(cls, "_targets_supported"):
- cls._targets_supported = []
- progendef = ProGenDef('uvision5')
- for target in TARGET_NAMES:
- try:
- if (progendef.is_supported(str(TARGET_MAP[target])) or
- progendef.is_supported(TARGET_MAP[target].progen['target'])):
- cls._targets_supported.append(target)
- except AttributeError:
- # target is not supported yet
- continue
- return cls._targets_supported
-
- def get_toolchain(self):
- return TARGET_MAP[self.target].default_toolchain
-
- def generate(self):
- """ Generates the project files """
- project_data = self.progen_get_project_data()
- tool_specific = {}
- # Expand tool specific settings by uvision specific settings which are required
- try:
- if TARGET_MAP[self.target].progen['uvision5']['template']:
- tool_specific['uvision5'] = TARGET_MAP[self.target].progen['uvision5']
- except KeyError:
- # use default template
- # by the mbed projects
- tool_specific['uvision5'] = {
- 'template': [join(dirname(__file__), 'uvision.uvproj.tmpl')],
- }
-
- #project_data['template'] = [tool_specific['uvision5']['template']]
- project_data['tool_specific'] = {}
- project_data['tool_specific'].update(tool_specific)
-
- # get flags from toolchain and apply
- project_data['misc'] = {}
- asm_flag_string = '--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' + ",".join(list(set(self.flags['asm_flags'])))
- # asm flags only, common are not valid within uvision project, they are armcc specific
- project_data['misc']['asm_flags'] = [asm_flag_string]
- # cxx flags included, as uvision have them all in one tab
- project_data['misc']['c_flags'] = list(set(['-D__ASSERT_MSG']
- + self.flags['common_flags']
- + self.flags['c_flags']
- + self.flags['cxx_flags']))
- # not compatible with c99 flag set in the template
- remove_if_in(project_data['misc']['c_flags'], "--c99")
- # cpp is not required as it's implicit for cpp files
- remove_if_in(project_data['misc']['c_flags'], "--cpp")
- # we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it
- remove_if_in(project_data['misc']['c_flags'], "--no_vla")
- # not compatible with c99 flag set in the template
- project_data['misc']['ld_flags'] = self.flags['ld_flags']
-
- i = 0
- project_data['build_dir'] = project_data['build_dir'] + '\\' + 'uvision5'
- self.progen_gen_file(project_data)