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