Clone of official tools

Committer:
screamer
Date:
Mon Aug 29 11:18:36 2016 +0100
Revision:
29:1210849dba19
Parent:
24:25bff2709c20
Port the latest tools patches from https://github.com/ARMmbed/mbed-os

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 13:ab47a20b66f0 1 """
screamer 13:ab47a20b66f0 2 mbed SDK
screamer 13:ab47a20b66f0 3 Copyright (c) 2016 ARM Limited
screamer 13:ab47a20b66f0 4
screamer 13:ab47a20b66f0 5 Licensed under the Apache License, Version 2.0 (the "License");
screamer 13:ab47a20b66f0 6 you may not use this file except in compliance with the License.
screamer 13:ab47a20b66f0 7 You may obtain a copy of the License at
screamer 13:ab47a20b66f0 8
screamer 13:ab47a20b66f0 9 http://www.apache.org/licenses/LICENSE-2.0
screamer 13:ab47a20b66f0 10
screamer 13:ab47a20b66f0 11 Unless required by applicable law or agreed to in writing, software
screamer 13:ab47a20b66f0 12 distributed under the License is distributed on an "AS IS" BASIS,
screamer 13:ab47a20b66f0 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
screamer 13:ab47a20b66f0 14 See the License for the specific language governing permissions and
screamer 13:ab47a20b66f0 15 limitations under the License.
screamer 13:ab47a20b66f0 16 """
screamer 13:ab47a20b66f0 17 from os.path import basename, join, dirname
screamer 13:ab47a20b66f0 18 from project_generator_definitions.definitions import ProGenDef
screamer 13:ab47a20b66f0 19
screamer 24:25bff2709c20 20 from tools.export.exporters import Exporter, ExporterTargetsProperty
screamer 13:ab47a20b66f0 21 from tools.targets import TARGET_MAP, TARGET_NAMES
screamer 13:ab47a20b66f0 22
screamer 13:ab47a20b66f0 23 # If you wish to add a new target, add it to project_generator_definitions, and then
screamer 13:ab47a20b66f0 24 # define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
screamer 13:ab47a20b66f0 25 # There are 2 default mbed templates (predefined settings) uvision.uvproj and uvproj_microlib.uvproj.tmpl
screamer 13:ab47a20b66f0 26 class Uvision5(Exporter):
screamer 13:ab47a20b66f0 27 """
screamer 13:ab47a20b66f0 28 Exporter class for uvision5. This class uses project generator.
screamer 13:ab47a20b66f0 29 """
screamer 13:ab47a20b66f0 30 # These 2 are currently for exporters backward compatiblity
screamer 13:ab47a20b66f0 31 NAME = 'uVision5'
screamer 13:ab47a20b66f0 32 TOOLCHAIN = 'ARM'
screamer 13:ab47a20b66f0 33 # PROGEN_ACTIVE contains information for exporter scripts that this is using progen
screamer 13:ab47a20b66f0 34 PROGEN_ACTIVE = True
screamer 13:ab47a20b66f0 35
screamer 13:ab47a20b66f0 36 MBED_CONFIG_HEADER_SUPPORTED = True
screamer 13:ab47a20b66f0 37
screamer 24:25bff2709c20 38 @ExporterTargetsProperty
screamer 24:25bff2709c20 39 def TARGETS(cls):
screamer 24:25bff2709c20 40 if not hasattr(cls, "_targets_supported"):
screamer 24:25bff2709c20 41 cls._targets_supported = []
screamer 24:25bff2709c20 42 progendef = ProGenDef('uvision5')
screamer 23:fbae331171fa 43 for target in TARGET_NAMES:
screamer 23:fbae331171fa 44 try:
screamer 24:25bff2709c20 45 if (progendef.is_supported(str(TARGET_MAP[target])) or
screamer 24:25bff2709c20 46 progendef.is_supported(TARGET_MAP[target].progen['target'])):
screamer 24:25bff2709c20 47 cls._targets_supported.append(target)
screamer 23:fbae331171fa 48 except AttributeError:
screamer 23:fbae331171fa 49 # target is not supported yet
screamer 23:fbae331171fa 50 continue
screamer 24:25bff2709c20 51 return cls._targets_supported
screamer 13:ab47a20b66f0 52
screamer 13:ab47a20b66f0 53 def get_toolchain(self):
screamer 13:ab47a20b66f0 54 return TARGET_MAP[self.target].default_toolchain
screamer 13:ab47a20b66f0 55
screamer 23:fbae331171fa 56 def generate(self, progen_build=False):
screamer 13:ab47a20b66f0 57 """ Generates the project files """
screamer 13:ab47a20b66f0 58 project_data = self.progen_get_project_data()
screamer 13:ab47a20b66f0 59 tool_specific = {}
screamer 13:ab47a20b66f0 60 # Expand tool specific settings by uvision specific settings which are required
screamer 13:ab47a20b66f0 61 try:
screamer 13:ab47a20b66f0 62 if TARGET_MAP[self.target].progen['uvision5']['template']:
screamer 13:ab47a20b66f0 63 tool_specific['uvision5'] = TARGET_MAP[self.target].progen['uvision5']
screamer 13:ab47a20b66f0 64 except KeyError:
screamer 13:ab47a20b66f0 65 # use default template
screamer 13:ab47a20b66f0 66 # by the mbed projects
screamer 13:ab47a20b66f0 67 tool_specific['uvision5'] = {
screamer 13:ab47a20b66f0 68 'template': [join(dirname(__file__), 'uvision.uvproj.tmpl')],
screamer 13:ab47a20b66f0 69 }
screamer 13:ab47a20b66f0 70
screamer 13:ab47a20b66f0 71 project_data['tool_specific'] = {}
screamer 13:ab47a20b66f0 72 project_data['tool_specific'].update(tool_specific)
screamer 13:ab47a20b66f0 73
screamer 13:ab47a20b66f0 74 # get flags from toolchain and apply
screamer 13:ab47a20b66f0 75 project_data['tool_specific']['uvision5']['misc'] = {}
screamer 29:1210849dba19 76
screamer 29:1210849dba19 77 # need to make this a string got progen. Only adds preprocessor when "macros" set
screamer 29:1210849dba19 78 asm_flag_string = '--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' + ",".join(list(set(self.progen_flags['asm_flags'])))
screamer 29:1210849dba19 79 project_data['tool_specific']['uvision5']['misc']['asm_flags'] = [asm_flag_string]
screamer 13:ab47a20b66f0 80 # cxx flags included, as uvision have them all in one tab
screamer 29:1210849dba19 81 project_data['tool_specific']['uvision5']['misc']['c_flags'] = list(set(['-D__ASSERT_MSG']+self.progen_flags['common_flags'] + self.progen_flags['c_flags'] + self.progen_flags['cxx_flags']))
screamer 13:ab47a20b66f0 82 # not compatible with c99 flag set in the template
screamer 13:ab47a20b66f0 83 project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--c99")
screamer 13:ab47a20b66f0 84 # cpp is not required as it's implicit for cpp files
screamer 13:ab47a20b66f0 85 project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--cpp")
screamer 13:ab47a20b66f0 86 # we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it
screamer 13:ab47a20b66f0 87 project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--no_vla")
screamer 13:ab47a20b66f0 88 project_data['tool_specific']['uvision5']['misc']['ld_flags'] = self.progen_flags['ld_flags']
screamer 13:ab47a20b66f0 89
screamer 13:ab47a20b66f0 90 project_data['common']['build_dir'] = project_data['common']['build_dir'] + '\\' + 'uvision5'
screamer 23:fbae331171fa 91 if progen_build:
screamer 23:fbae331171fa 92 self.progen_gen_file('uvision5', project_data, True)
screamer 23:fbae331171fa 93 else:
screamer 23:fbae331171fa 94 self.progen_gen_file('uvision5', project_data)