|
1 | 1 | """
|
2 | 2 | mbed SDK
|
3 |
| -Copyright (c) 2011-2013 ARM Limited |
| 3 | +Copyright (c) 2011-2015 ARM Limited |
4 | 4 |
|
5 | 5 | Licensed under the Apache License, Version 2.0 (the "License");
|
6 | 6 | you may not use this file except in compliance with the License.
|
|
14 | 14 | See the License for the specific language governing permissions and
|
15 | 15 | limitations under the License.
|
16 | 16 | """
|
17 |
| -from workspace_tools.export.exporters import Exporter |
18 | 17 | import re
|
19 | 18 | import os
|
| 19 | +from project_generator_definitions.definitions import ProGenDef |
| 20 | + |
| 21 | +from workspace_tools.export.exporters import Exporter |
| 22 | +from workspace_tools.targets import TARGET_MAP, TARGET_NAMES |
| 23 | + |
| 24 | +# If you wish to add a new target, add it to project_generator_definitions, and then |
| 25 | +# define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``) |
20 | 26 | class IAREmbeddedWorkbench(Exporter):
|
21 | 27 | """
|
22 |
| - Exporter class for IAR Systems. |
| 28 | + Exporter class for IAR Systems. This class uses project generator. |
23 | 29 | """
|
| 30 | + # These 2 are currently for exporters backward compatiblity |
24 | 31 | NAME = 'IAR'
|
25 | 32 | TOOLCHAIN = 'IAR'
|
| 33 | + # PROGEN_ACTIVE contains information for exporter scripts that this is using progen |
| 34 | + PROGEN_ACTIVE = True |
26 | 35 |
|
27 |
| - TARGETS = [ |
28 |
| - 'LPC1768', |
29 |
| - 'LPC1347', |
30 |
| - 'LPC11U24', |
31 |
| - 'LPC11U35_401', |
32 |
| - 'LPC11U35_501', |
33 |
| - #Removed LPCCAPPUCCINO linker file and startup file missing |
34 |
| - #'LPCCAPPUCCINO', |
35 |
| - 'LPC1114', |
36 |
| - 'LPC1549', |
37 |
| - 'LPC812', |
38 |
| - 'LPC4088', |
39 |
| - 'LPC4088_DM', |
40 |
| - 'LPC824', |
41 |
| - 'UBLOX_C027', |
42 |
| - 'ARCH_PRO', |
43 |
| - 'K20D50M', |
44 |
| - 'KL05Z', |
45 |
| - 'KL25Z', |
46 |
| - 'KL46Z', |
47 |
| - 'K22F', |
48 |
| - 'K64F', |
49 |
| - 'NUCLEO_F030R8', |
50 |
| - 'NUCLEO_F031K6', |
51 |
| - 'NUCLEO_F042K6', |
52 |
| - 'NUCLEO_F070RB', |
53 |
| - 'NUCLEO_F072RB', |
54 |
| - 'NUCLEO_F091RC', |
55 |
| - 'NUCLEO_F103RB', |
56 |
| - 'NUCLEO_F302R8', |
57 |
| - 'NUCLEO_F303K8', |
58 |
| - 'NUCLEO_F303RE', |
59 |
| - 'NUCLEO_F334R8', |
60 |
| - 'NUCLEO_F401RE', |
61 |
| - 'NUCLEO_F410RB', |
62 |
| - 'NUCLEO_F411RE', |
63 |
| - 'NUCLEO_F446RE', |
64 |
| - 'NUCLEO_L053R8', |
65 |
| - 'NUCLEO_L073RZ', |
66 |
| - 'NUCLEO_L152RE', |
67 |
| - 'NUCLEO_L476RG', |
68 |
| - 'DISCO_F429ZI', |
69 |
| - 'DISCO_L053C8', |
70 |
| - 'DISCO_F334C8', |
71 |
| - 'DISCO_F469NI', |
72 |
| - 'DISCO_F746NG', |
73 |
| - 'DISCO_L476VG', |
74 |
| - 'B96B_F446VE', |
75 |
| - #'STM32F407', Fails to build same for GCC |
76 |
| - 'MAXWSNENV', |
77 |
| - 'MAX32600MBED', |
78 |
| - 'MTS_MDOT_F405RG', |
79 |
| - 'MTS_MDOT_F411RE', |
80 |
| - 'MTS_DRAGONFLY_F411RE', |
81 |
| - 'NRF51822', |
82 |
| - 'NRF51_DK', |
83 |
| - 'NRF51_DONGLE', |
84 |
| - 'DELTA_DFCM_NNN40', |
85 |
| - 'SEEED_TINY_BLE', |
86 |
| - 'HRM1017', |
87 |
| - 'ARCH_BLE', |
88 |
| - 'MOTE_L152RC', |
89 |
| - 'EFM32PG_STK3401', |
90 |
| - 'RZ_A1H', |
91 |
| - ] |
| 36 | + # backward compatibility with our scripts |
| 37 | + TARGETS = [] |
| 38 | + for target in TARGET_NAMES: |
| 39 | + try: |
| 40 | + if (ProGenDef('iar').is_supported(TARGET_MAP[target]) or |
| 41 | + ProGenDef('iar').is_supported(TARGET_MAP[target].progen_target)): |
| 42 | + TARGETS.append(target) |
| 43 | + except AttributeError: |
| 44 | + # target is not supported yet |
| 45 | + continue |
92 | 46 |
|
93 | 47 | def generate(self):
|
94 |
| - """ |
95 |
| - Generates the project files |
96 |
| - """ |
97 |
| - sources = [] |
98 |
| - sources += self.resources.c_sources |
99 |
| - sources += self.resources.cpp_sources |
100 |
| - sources += self.resources.s_sources |
101 |
| - |
102 |
| - iar_files = IarFolder("", "", []) |
103 |
| - for source in sources: |
104 |
| - iar_files.insert_file(source) |
105 |
| - |
106 |
| - ctx = { |
107 |
| - 'name': self.program_name, |
108 |
| - 'include_paths': self.resources.inc_dirs, |
109 |
| - 'linker_script': self.resources.linker_script, |
110 |
| - 'object_files': self.resources.objects, |
111 |
| - 'libraries': self.resources.libraries, |
112 |
| - 'symbols': self.get_symbols(), |
113 |
| - 'source_files': iar_files.__str__(), |
114 |
| - 'binary_files': self.resources.bin_files, |
| 48 | + """ Generates the project files """ |
| 49 | + project_data = self.progen_get_project_data() |
| 50 | + # Expand tool specific settings by IAR specific settings which are required |
| 51 | + # by the mbed projects |
| 52 | + tool_specific = { |
| 53 | + 'iar': { |
| 54 | + # We currently don't use misc, template sets those for us |
| 55 | + # 'misc': { |
| 56 | + # 'cxx_flags': ['--no_rtti', '--no_exceptions'], |
| 57 | + # 'c_flags': ['--diag_suppress=Pa050,Pa084,Pa093,Pa082'], |
| 58 | + # 'ld_flags': ['--skip_dynamic_initialization'], |
| 59 | + # }, |
| 60 | + 'template': [os.path.join(os.path.dirname(__file__), 'iar_template.ewp.tmpl')], |
| 61 | + } |
115 | 62 | }
|
116 |
| - self.gen_file('iar_%s.ewp.tmpl' % self.target.lower(), ctx, '%s.ewp' % self.program_name) |
117 |
| - self.gen_file('iar.eww.tmpl', ctx, '%s.eww' % self.program_name) |
118 |
| - self.gen_file('iar_%s.ewd.tmpl' % self.target.lower(), ctx, '%s.ewd' % self.program_name) |
| 63 | + project_data['tool_specific'] = {} |
| 64 | + project_data['tool_specific'].update(tool_specific) |
| 65 | + self.progen_gen_file('iar_arm', project_data) |
119 | 66 |
|
| 67 | +# Currently not used, we should reuse folder_name to create virtual folders |
120 | 68 | class IarFolder():
|
121 | 69 | """
|
122 | 70 | This is a recursive folder object.
|
|
0 commit comments