Clone of official tools

Committer:
theotherjimmy
Date:
Tue Oct 10 16:56:30 2017 -0500
Revision:
40:7d3fa6b99b2b
Parent:
38:399953da035d
Child:
41:2a77626a4c21
Update to tools release 5.6.1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
The Other Jimmy 35:da9c89f8be7d 1 """
The Other Jimmy 35:da9c89f8be7d 2 mbed SDK
theotherjimmy 40:7d3fa6b99b2b 3 Copyright (c) 2011-2017 ARM Limited
The Other Jimmy 35:da9c89f8be7d 4
The Other Jimmy 35:da9c89f8be7d 5 Licensed under the Apache License, Version 2.0 (the "License");
The Other Jimmy 35:da9c89f8be7d 6 you may not use this file except in compliance with the License.
The Other Jimmy 35:da9c89f8be7d 7 You may obtain a copy of the License at
The Other Jimmy 35:da9c89f8be7d 8
The Other Jimmy 35:da9c89f8be7d 9 http://www.apache.org/licenses/LICENSE-2.0
The Other Jimmy 35:da9c89f8be7d 10
The Other Jimmy 35:da9c89f8be7d 11 Unless required by applicable law or agreed to in writing, software
The Other Jimmy 35:da9c89f8be7d 12 distributed under the License is distributed on an "AS IS" BASIS,
The Other Jimmy 35:da9c89f8be7d 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
The Other Jimmy 35:da9c89f8be7d 14 See the License for the specific language governing permissions and
The Other Jimmy 35:da9c89f8be7d 15 limitations under the License.
The Other Jimmy 35:da9c89f8be7d 16 """
theotherjimmy 40:7d3fa6b99b2b 17
The Other Jimmy 35:da9c89f8be7d 18 from os.path import splitext, basename, join
The Other Jimmy 35:da9c89f8be7d 19 from tools.utils import mkdir
theotherjimmy 40:7d3fa6b99b2b 20 from tools.export.gnuarmeclipse import GNUARMEclipse
theotherjimmy 40:7d3fa6b99b2b 21 from tools.export.gnuarmeclipse import UID
theotherjimmy 40:7d3fa6b99b2b 22 from tools.build_api import prepare_toolchain
theotherjimmy 40:7d3fa6b99b2b 23 from sys import flags, platform
theotherjimmy 40:7d3fa6b99b2b 24
theotherjimmy 40:7d3fa6b99b2b 25 # Global random number generator instance.
theotherjimmy 40:7d3fa6b99b2b 26 u = UID()
The Other Jimmy 35:da9c89f8be7d 27
The Other Jimmy 35:da9c89f8be7d 28
theotherjimmy 40:7d3fa6b99b2b 29 class Sw4STM32(GNUARMEclipse):
theotherjimmy 40:7d3fa6b99b2b 30 """
theotherjimmy 40:7d3fa6b99b2b 31 Sw4STM32 class
theotherjimmy 40:7d3fa6b99b2b 32 """
The Other Jimmy 35:da9c89f8be7d 33 NAME = 'Sw4STM32'
The Other Jimmy 35:da9c89f8be7d 34 TOOLCHAIN = 'GCC_ARM'
The Other Jimmy 35:da9c89f8be7d 35
The Other Jimmy 35:da9c89f8be7d 36 BOARDS = {
theotherjimmy 40:7d3fa6b99b2b 37 'B96B_F446VE':
theotherjimmy 40:7d3fa6b99b2b 38 {
theotherjimmy 40:7d3fa6b99b2b 39 'name': 'B96B-F446VE',
theotherjimmy 40:7d3fa6b99b2b 40 'mcuId': 'STM32F446VETx'
theotherjimmy 40:7d3fa6b99b2b 41 },
theotherjimmy 40:7d3fa6b99b2b 42 'DISCO_F051R8':
theotherjimmy 40:7d3fa6b99b2b 43 {
theotherjimmy 40:7d3fa6b99b2b 44 'name': 'STM32F0DISCOVERY',
theotherjimmy 40:7d3fa6b99b2b 45 'mcuId': 'STM32F051R8Tx'
theotherjimmy 40:7d3fa6b99b2b 46 },
theotherjimmy 40:7d3fa6b99b2b 47 'DISCO_F303VC':
theotherjimmy 40:7d3fa6b99b2b 48 {
theotherjimmy 40:7d3fa6b99b2b 49 'name': 'STM32F3DISCOVERY',
theotherjimmy 40:7d3fa6b99b2b 50 'mcuId': 'STM32F303VCTx'
theotherjimmy 40:7d3fa6b99b2b 51 },
theotherjimmy 40:7d3fa6b99b2b 52 'DISCO_F334C8':
theotherjimmy 40:7d3fa6b99b2b 53 {
theotherjimmy 40:7d3fa6b99b2b 54 'name': 'STM32F3348DISCOVERY',
theotherjimmy 40:7d3fa6b99b2b 55 'mcuId': 'STM32F334C8Tx'
theotherjimmy 40:7d3fa6b99b2b 56 },
theotherjimmy 40:7d3fa6b99b2b 57 'DISCO_F401VC':
theotherjimmy 40:7d3fa6b99b2b 58 {
theotherjimmy 40:7d3fa6b99b2b 59 'name': 'STM32F401C-DISCO',
theotherjimmy 40:7d3fa6b99b2b 60 'mcuId': 'STM32F401VCTx'
theotherjimmy 40:7d3fa6b99b2b 61 },
theotherjimmy 40:7d3fa6b99b2b 62 'DISCO_F407VG':
theotherjimmy 40:7d3fa6b99b2b 63 {
theotherjimmy 40:7d3fa6b99b2b 64 'name': 'STM32F4DISCOVERY',
theotherjimmy 40:7d3fa6b99b2b 65 'mcuId': 'STM32F407VGTx'
theotherjimmy 40:7d3fa6b99b2b 66 },
theotherjimmy 40:7d3fa6b99b2b 67 'DISCO_F413ZH':
theotherjimmy 40:7d3fa6b99b2b 68 {
theotherjimmy 40:7d3fa6b99b2b 69 'name': 'DISCO_F413',
theotherjimmy 40:7d3fa6b99b2b 70 'mcuId': 'STM32F413ZHTx'
theotherjimmy 40:7d3fa6b99b2b 71 },
theotherjimmy 40:7d3fa6b99b2b 72 'DISCO_F429ZI':
theotherjimmy 40:7d3fa6b99b2b 73 {
theotherjimmy 40:7d3fa6b99b2b 74 'name': 'STM32F429I-DISCO',
theotherjimmy 40:7d3fa6b99b2b 75 'mcuId': 'STM32F429ZITx'
theotherjimmy 40:7d3fa6b99b2b 76 },
theotherjimmy 40:7d3fa6b99b2b 77 'DISCO_F469NI':
theotherjimmy 40:7d3fa6b99b2b 78 {
theotherjimmy 40:7d3fa6b99b2b 79 'name': 'DISCO-F469NI',
theotherjimmy 40:7d3fa6b99b2b 80 'mcuId': 'STM32F469NIHx'
theotherjimmy 40:7d3fa6b99b2b 81 },
theotherjimmy 40:7d3fa6b99b2b 82 'DISCO_F746NG':
theotherjimmy 40:7d3fa6b99b2b 83 {
theotherjimmy 40:7d3fa6b99b2b 84 'name': 'STM32F746G-DISCO',
theotherjimmy 40:7d3fa6b99b2b 85 'mcuId': 'STM32F746NGHx'
theotherjimmy 40:7d3fa6b99b2b 86 },
theotherjimmy 40:7d3fa6b99b2b 87 'DISCO_F769NI':
theotherjimmy 40:7d3fa6b99b2b 88 {
theotherjimmy 40:7d3fa6b99b2b 89 'name': 'DISCO-F769NI',
theotherjimmy 40:7d3fa6b99b2b 90 'mcuId': 'STM32F769NIHx'
theotherjimmy 40:7d3fa6b99b2b 91 },
theotherjimmy 40:7d3fa6b99b2b 92 'DISCO_L053C8':
theotherjimmy 40:7d3fa6b99b2b 93 {
theotherjimmy 40:7d3fa6b99b2b 94 'name': 'STM32L0538DISCOVERY',
theotherjimmy 40:7d3fa6b99b2b 95 'mcuId': 'STM32L053C8Tx'
theotherjimmy 40:7d3fa6b99b2b 96 },
theotherjimmy 40:7d3fa6b99b2b 97 'DISCO_L072CZ_LRWAN1':
theotherjimmy 40:7d3fa6b99b2b 98 {
theotherjimmy 40:7d3fa6b99b2b 99 'name': 'DISCO-L072CZ-LRWAN1',
theotherjimmy 40:7d3fa6b99b2b 100 'mcuId': 'STM32L072CZTx'
theotherjimmy 40:7d3fa6b99b2b 101 },
theotherjimmy 40:7d3fa6b99b2b 102 'DISCO_L475VG_IOT01A':
theotherjimmy 40:7d3fa6b99b2b 103 {
theotherjimmy 40:7d3fa6b99b2b 104 'name': 'STM32L475G-DISCO',
theotherjimmy 40:7d3fa6b99b2b 105 'mcuId': 'STM32L475VGTx'
theotherjimmy 40:7d3fa6b99b2b 106 },
theotherjimmy 40:7d3fa6b99b2b 107 'DISCO_L476VG':
theotherjimmy 40:7d3fa6b99b2b 108 {
theotherjimmy 40:7d3fa6b99b2b 109 'name': 'STM32L476G-DISCO',
theotherjimmy 40:7d3fa6b99b2b 110 'mcuId': 'STM32L476VGTx'
theotherjimmy 40:7d3fa6b99b2b 111 },
theotherjimmy 40:7d3fa6b99b2b 112 'NUCLEO_F030R8':
theotherjimmy 40:7d3fa6b99b2b 113 {
theotherjimmy 40:7d3fa6b99b2b 114 'name': 'NUCLEO-F030R8',
theotherjimmy 40:7d3fa6b99b2b 115 'mcuId': 'STM32F030R8Tx'
theotherjimmy 40:7d3fa6b99b2b 116 },
theotherjimmy 40:7d3fa6b99b2b 117 'NUCLEO_F031K6':
theotherjimmy 40:7d3fa6b99b2b 118 {
theotherjimmy 40:7d3fa6b99b2b 119 'name': 'NUCLEO-F031K6',
theotherjimmy 40:7d3fa6b99b2b 120 'mcuId': 'STM32F031K6Tx'
theotherjimmy 40:7d3fa6b99b2b 121 },
theotherjimmy 40:7d3fa6b99b2b 122 'NUCLEO_F042K6':
theotherjimmy 40:7d3fa6b99b2b 123 {
theotherjimmy 40:7d3fa6b99b2b 124 'name': 'NUCLEO-F042K6',
theotherjimmy 40:7d3fa6b99b2b 125 'mcuId': 'STM32F042K6Tx'
theotherjimmy 40:7d3fa6b99b2b 126 },
theotherjimmy 40:7d3fa6b99b2b 127 'NUCLEO_F070RB':
theotherjimmy 40:7d3fa6b99b2b 128 {
theotherjimmy 40:7d3fa6b99b2b 129 'name': 'NUCLEO-F070RB',
theotherjimmy 40:7d3fa6b99b2b 130 'mcuId': 'STM32F070RBTx'
theotherjimmy 40:7d3fa6b99b2b 131 },
theotherjimmy 40:7d3fa6b99b2b 132 'NUCLEO_F072RB':
theotherjimmy 40:7d3fa6b99b2b 133 {
theotherjimmy 40:7d3fa6b99b2b 134 'name': 'NUCLEO-F072RB',
theotherjimmy 40:7d3fa6b99b2b 135 'mcuId': 'STM32F072RBTx'
theotherjimmy 40:7d3fa6b99b2b 136 },
theotherjimmy 40:7d3fa6b99b2b 137 'NUCLEO_F091RC':
theotherjimmy 40:7d3fa6b99b2b 138 {
theotherjimmy 40:7d3fa6b99b2b 139 'name': 'NUCLEO-F091RC',
theotherjimmy 40:7d3fa6b99b2b 140 'mcuId': 'STM32F091RCTx'
theotherjimmy 40:7d3fa6b99b2b 141 },
theotherjimmy 40:7d3fa6b99b2b 142 'NUCLEO_F103RB':
theotherjimmy 40:7d3fa6b99b2b 143 {
theotherjimmy 40:7d3fa6b99b2b 144 'name': 'NUCLEO-F103RB',
theotherjimmy 40:7d3fa6b99b2b 145 'mcuId': 'STM32F103RBTx'
theotherjimmy 40:7d3fa6b99b2b 146 },
theotherjimmy 40:7d3fa6b99b2b 147 'NUCLEO_F207ZG':
theotherjimmy 40:7d3fa6b99b2b 148 {
theotherjimmy 40:7d3fa6b99b2b 149 'name': 'NUCLEO-F207ZG',
theotherjimmy 40:7d3fa6b99b2b 150 'mcuId': 'STM32F207ZGTx'
theotherjimmy 40:7d3fa6b99b2b 151 },
theotherjimmy 40:7d3fa6b99b2b 152 'NUCLEO_F302R8':
theotherjimmy 40:7d3fa6b99b2b 153 {
theotherjimmy 40:7d3fa6b99b2b 154 'name': 'NUCLEO-F302R8',
theotherjimmy 40:7d3fa6b99b2b 155 'mcuId': 'STM32F302R8Tx'
theotherjimmy 40:7d3fa6b99b2b 156 },
theotherjimmy 40:7d3fa6b99b2b 157 'NUCLEO_F303K8':
theotherjimmy 40:7d3fa6b99b2b 158 {
theotherjimmy 40:7d3fa6b99b2b 159 'name': 'NUCLEO-F303K8',
theotherjimmy 40:7d3fa6b99b2b 160 'mcuId': 'STM32F303K8Tx'
theotherjimmy 40:7d3fa6b99b2b 161 },
theotherjimmy 40:7d3fa6b99b2b 162 'NUCLEO_F303RE':
theotherjimmy 40:7d3fa6b99b2b 163 {
theotherjimmy 40:7d3fa6b99b2b 164 'name': 'NUCLEO-F303RE',
theotherjimmy 40:7d3fa6b99b2b 165 'mcuId': 'STM32F303RETx'
theotherjimmy 40:7d3fa6b99b2b 166 },
theotherjimmy 40:7d3fa6b99b2b 167 'NUCLEO_F303ZE':
theotherjimmy 40:7d3fa6b99b2b 168 {
theotherjimmy 40:7d3fa6b99b2b 169 'name': 'NUCLEO-F303ZE',
theotherjimmy 40:7d3fa6b99b2b 170 'mcuId': 'STM32F303ZETx'
theotherjimmy 40:7d3fa6b99b2b 171 },
theotherjimmy 40:7d3fa6b99b2b 172 'NUCLEO_F334R8':
theotherjimmy 40:7d3fa6b99b2b 173 {
theotherjimmy 40:7d3fa6b99b2b 174 'name': 'NUCLEO-F334R8',
theotherjimmy 40:7d3fa6b99b2b 175 'mcuId': 'STM32F334R8Tx'
theotherjimmy 40:7d3fa6b99b2b 176 },
theotherjimmy 40:7d3fa6b99b2b 177 'NUCLEO_F401RE':
theotherjimmy 40:7d3fa6b99b2b 178 {
theotherjimmy 40:7d3fa6b99b2b 179 'name': 'NUCLEO-F401RE',
theotherjimmy 40:7d3fa6b99b2b 180 'mcuId': 'STM32F401RETx'
theotherjimmy 40:7d3fa6b99b2b 181 },
theotherjimmy 40:7d3fa6b99b2b 182 'NUCLEO_F410RB':
theotherjimmy 40:7d3fa6b99b2b 183 {
theotherjimmy 40:7d3fa6b99b2b 184 'name': 'NUCLEO-F410RB',
theotherjimmy 40:7d3fa6b99b2b 185 'mcuId': 'STM32F410RBTx'
theotherjimmy 40:7d3fa6b99b2b 186 },
theotherjimmy 40:7d3fa6b99b2b 187 'NUCLEO_F411RE':
theotherjimmy 40:7d3fa6b99b2b 188 {
theotherjimmy 40:7d3fa6b99b2b 189 'name': 'NUCLEO-F411RE',
theotherjimmy 40:7d3fa6b99b2b 190 'mcuId': 'STM32F411RETx'
theotherjimmy 40:7d3fa6b99b2b 191 },
theotherjimmy 40:7d3fa6b99b2b 192 'NUCLEO_F429ZI':
theotherjimmy 40:7d3fa6b99b2b 193 {
theotherjimmy 40:7d3fa6b99b2b 194 'name': 'NUCLEO-F429ZI',
theotherjimmy 40:7d3fa6b99b2b 195 'mcuId': 'STM32F429ZITx'
theotherjimmy 40:7d3fa6b99b2b 196 },
theotherjimmy 40:7d3fa6b99b2b 197 'NUCLEO_F446RE':
theotherjimmy 40:7d3fa6b99b2b 198 {
theotherjimmy 40:7d3fa6b99b2b 199 'name': 'NUCLEO-F446RE',
theotherjimmy 40:7d3fa6b99b2b 200 'mcuId': 'STM32F446RETx'
theotherjimmy 40:7d3fa6b99b2b 201 },
theotherjimmy 40:7d3fa6b99b2b 202 'NUCLEO_F446ZE':
theotherjimmy 40:7d3fa6b99b2b 203 {
theotherjimmy 40:7d3fa6b99b2b 204 'name': 'NUCLEO-F446ZE',
theotherjimmy 40:7d3fa6b99b2b 205 'mcuId': 'STM32F446ZETx'
theotherjimmy 40:7d3fa6b99b2b 206 },
theotherjimmy 40:7d3fa6b99b2b 207 'NUCLEO_F746ZG':
theotherjimmy 40:7d3fa6b99b2b 208 {
theotherjimmy 40:7d3fa6b99b2b 209 'name': 'NUCLEO-F746ZG',
theotherjimmy 40:7d3fa6b99b2b 210 'mcuId': 'STM32F746ZGTx'
theotherjimmy 40:7d3fa6b99b2b 211 },
theotherjimmy 40:7d3fa6b99b2b 212 'NUCLEO_F767ZI':
theotherjimmy 40:7d3fa6b99b2b 213 {
theotherjimmy 40:7d3fa6b99b2b 214 'name': 'NUCLEO-F767ZI',
theotherjimmy 40:7d3fa6b99b2b 215 'mcuId': 'STM32F767ZITx'
theotherjimmy 40:7d3fa6b99b2b 216 },
theotherjimmy 40:7d3fa6b99b2b 217 'NUCLEO_L011K4':
theotherjimmy 40:7d3fa6b99b2b 218 {
theotherjimmy 40:7d3fa6b99b2b 219 'name': 'NUCLEO-L011K4',
theotherjimmy 40:7d3fa6b99b2b 220 'mcuId': 'STM32L011K4Tx'
theotherjimmy 40:7d3fa6b99b2b 221 },
theotherjimmy 40:7d3fa6b99b2b 222 'NUCLEO_L031K6':
theotherjimmy 40:7d3fa6b99b2b 223 {
theotherjimmy 40:7d3fa6b99b2b 224 'name': 'NUCLEO-L031K6',
theotherjimmy 40:7d3fa6b99b2b 225 'mcuId': 'STM32L031K6Tx'
theotherjimmy 40:7d3fa6b99b2b 226 },
theotherjimmy 40:7d3fa6b99b2b 227 'NUCLEO_L053R8':
theotherjimmy 40:7d3fa6b99b2b 228 {
theotherjimmy 40:7d3fa6b99b2b 229 'name': 'NUCLEO-L053R8',
theotherjimmy 40:7d3fa6b99b2b 230 'mcuId': 'STM32L053R8Tx'
theotherjimmy 40:7d3fa6b99b2b 231 },
theotherjimmy 40:7d3fa6b99b2b 232 'NUCLEO_L073RZ':
theotherjimmy 40:7d3fa6b99b2b 233 {
theotherjimmy 40:7d3fa6b99b2b 234 'name': 'NUCLEO-L073RZ',
theotherjimmy 40:7d3fa6b99b2b 235 'mcuId': 'STM32L073RZTx'
theotherjimmy 40:7d3fa6b99b2b 236 },
theotherjimmy 40:7d3fa6b99b2b 237 'NUCLEO_L152RE':
theotherjimmy 40:7d3fa6b99b2b 238 {
theotherjimmy 40:7d3fa6b99b2b 239 'name': 'NUCLEO-L152RE',
theotherjimmy 40:7d3fa6b99b2b 240 'mcuId': 'STM32L152RETx'
theotherjimmy 40:7d3fa6b99b2b 241 },
theotherjimmy 40:7d3fa6b99b2b 242 'NUCLEO_L432KC':
theotherjimmy 40:7d3fa6b99b2b 243 {
theotherjimmy 40:7d3fa6b99b2b 244 'name': 'NUCLEO-L432KC',
theotherjimmy 40:7d3fa6b99b2b 245 'mcuId': 'STM32L432KCUx'
theotherjimmy 40:7d3fa6b99b2b 246 },
theotherjimmy 40:7d3fa6b99b2b 247 'NUCLEO_L476RG':
theotherjimmy 40:7d3fa6b99b2b 248 {
theotherjimmy 40:7d3fa6b99b2b 249 'name': 'NUCLEO-L476RG',
theotherjimmy 40:7d3fa6b99b2b 250 'mcuId': 'STM32L476RGTx'
theotherjimmy 40:7d3fa6b99b2b 251 },
The Other Jimmy 35:da9c89f8be7d 252 }
The Other Jimmy 35:da9c89f8be7d 253
The Other Jimmy 35:da9c89f8be7d 254 TARGETS = BOARDS.keys()
The Other Jimmy 35:da9c89f8be7d 255
theotherjimmy 40:7d3fa6b99b2b 256 def __gen_dir(self, dir_name):
theotherjimmy 40:7d3fa6b99b2b 257 """
theotherjimmy 40:7d3fa6b99b2b 258 Method that creates directory
theotherjimmy 40:7d3fa6b99b2b 259 """
theotherjimmy 40:7d3fa6b99b2b 260 settings = join(self.export_dir, dir_name)
The Other Jimmy 35:da9c89f8be7d 261 mkdir(settings)
The Other Jimmy 35:da9c89f8be7d 262
theotherjimmy 40:7d3fa6b99b2b 263 def get_fpu_hardware(self, fpu_unit):
theotherjimmy 40:7d3fa6b99b2b 264 """
theotherjimmy 40:7d3fa6b99b2b 265 Convert fpu unit name into hardware name.
theotherjimmy 40:7d3fa6b99b2b 266 """
theotherjimmy 40:7d3fa6b99b2b 267 hw = ''
theotherjimmy 40:7d3fa6b99b2b 268 fpus = {
theotherjimmy 40:7d3fa6b99b2b 269 'fpv4spd16': 'fpv4-sp-d16',
theotherjimmy 40:7d3fa6b99b2b 270 'fpv5d16': 'fpv5-d16',
theotherjimmy 40:7d3fa6b99b2b 271 'fpv5spd16': 'fpv5-sp-d16'
theotherjimmy 40:7d3fa6b99b2b 272 }
theotherjimmy 40:7d3fa6b99b2b 273 if fpu_unit in fpus:
theotherjimmy 40:7d3fa6b99b2b 274 hw = fpus[fpu_unit]
theotherjimmy 40:7d3fa6b99b2b 275 return hw
theotherjimmy 40:7d3fa6b99b2b 276
theotherjimmy 40:7d3fa6b99b2b 277 def process_sw_options(self, opts, flags_in):
theotherjimmy 40:7d3fa6b99b2b 278 """
theotherjimmy 40:7d3fa6b99b2b 279 Process System Workbench specific options.
theotherjimmy 40:7d3fa6b99b2b 280
theotherjimmy 40:7d3fa6b99b2b 281 System Workbench for STM32 has some compile options, which are not recognized by the GNUARMEclipse exporter.
theotherjimmy 40:7d3fa6b99b2b 282 Those are handled in this method.
theotherjimmy 40:7d3fa6b99b2b 283 """
theotherjimmy 40:7d3fa6b99b2b 284 opts['c']['preprocess'] = False
theotherjimmy 40:7d3fa6b99b2b 285 if '-E' in flags_in['c_flags']:
theotherjimmy 40:7d3fa6b99b2b 286 opts['c']['preprocess'] = True
theotherjimmy 40:7d3fa6b99b2b 287 opts['cpp']['preprocess'] = False
theotherjimmy 40:7d3fa6b99b2b 288 if '-E' in flags_in['cxx_flags']:
theotherjimmy 40:7d3fa6b99b2b 289 opts['cpp']['preprocess'] = True
theotherjimmy 40:7d3fa6b99b2b 290 opts['c']['slowflashdata'] = False
theotherjimmy 40:7d3fa6b99b2b 291 if '-mslow-flash-data' in flags_in['c_flags']:
theotherjimmy 40:7d3fa6b99b2b 292 opts['c']['slowflashdata'] = True
theotherjimmy 40:7d3fa6b99b2b 293 opts['cpp']['slowflashdata'] = False
theotherjimmy 40:7d3fa6b99b2b 294 if '-mslow-flash-data' in flags_in['cxx_flags']:
theotherjimmy 40:7d3fa6b99b2b 295 opts['cpp']['slowflashdata'] = True
theotherjimmy 40:7d3fa6b99b2b 296 if opts['common']['optimization.messagelength']:
theotherjimmy 40:7d3fa6b99b2b 297 opts['common']['optimization.other'] += ' -fmessage-length=0'
theotherjimmy 40:7d3fa6b99b2b 298 if opts['common']['optimization.signedchar']:
theotherjimmy 40:7d3fa6b99b2b 299 opts['common']['optimization.other'] += ' -fsigned-char'
theotherjimmy 40:7d3fa6b99b2b 300 if opts['common']['optimization.nocommon']:
theotherjimmy 40:7d3fa6b99b2b 301 opts['common']['optimization.other'] += ' -fno-common'
theotherjimmy 40:7d3fa6b99b2b 302 if opts['common']['optimization.noinlinefunctions']:
theotherjimmy 40:7d3fa6b99b2b 303 opts['common']['optimization.other'] += ' -fno-inline-functions'
theotherjimmy 40:7d3fa6b99b2b 304 if opts['common']['optimization.freestanding']:
theotherjimmy 40:7d3fa6b99b2b 305 opts['common']['optimization.other'] += ' -ffreestanding'
theotherjimmy 40:7d3fa6b99b2b 306 if opts['common']['optimization.nobuiltin']:
theotherjimmy 40:7d3fa6b99b2b 307 opts['common']['optimization.other'] += ' -fno-builtin'
theotherjimmy 40:7d3fa6b99b2b 308 if opts['common']['optimization.spconstant']:
theotherjimmy 40:7d3fa6b99b2b 309 opts['common']['optimization.other'] += ' -fsingle-precision-constant'
theotherjimmy 40:7d3fa6b99b2b 310 if opts['common']['optimization.nomoveloopinvariants']:
theotherjimmy 40:7d3fa6b99b2b 311 opts['common']['optimization.other'] += ' -fno-move-loop-invariants'
theotherjimmy 40:7d3fa6b99b2b 312 if opts['common']['warnings.unused']:
theotherjimmy 40:7d3fa6b99b2b 313 opts['common']['warnings.other'] += ' -Wunused'
theotherjimmy 40:7d3fa6b99b2b 314 if opts['common']['warnings.uninitialized']:
theotherjimmy 40:7d3fa6b99b2b 315 opts['common']['warnings.other'] += ' -Wuninitialized'
theotherjimmy 40:7d3fa6b99b2b 316 if opts['common']['warnings.missingdeclaration']:
theotherjimmy 40:7d3fa6b99b2b 317 opts['common']['warnings.other'] += ' -Wmissing-declarations'
theotherjimmy 40:7d3fa6b99b2b 318 if opts['common']['warnings.pointerarith']:
theotherjimmy 40:7d3fa6b99b2b 319 opts['common']['warnings.other'] += ' -Wpointer-arith'
theotherjimmy 40:7d3fa6b99b2b 320 if opts['common']['warnings.padded']:
theotherjimmy 40:7d3fa6b99b2b 321 opts['common']['warnings.other'] += ' -Wpadded'
theotherjimmy 40:7d3fa6b99b2b 322 if opts['common']['warnings.shadow']:
theotherjimmy 40:7d3fa6b99b2b 323 opts['common']['warnings.other'] += ' -Wshadow'
theotherjimmy 40:7d3fa6b99b2b 324 if opts['common']['warnings.logicalop']:
theotherjimmy 40:7d3fa6b99b2b 325 opts['common']['warnings.other'] += ' -Wlogical-op'
theotherjimmy 40:7d3fa6b99b2b 326 if opts['common']['warnings.agreggatereturn']:
theotherjimmy 40:7d3fa6b99b2b 327 opts['common']['warnings.other'] += ' -Waggregate-return'
theotherjimmy 40:7d3fa6b99b2b 328 if opts['common']['warnings.floatequal']:
theotherjimmy 40:7d3fa6b99b2b 329 opts['common']['warnings.other'] += ' -Wfloat-equal'
theotherjimmy 40:7d3fa6b99b2b 330 opts['ld']['strip'] = False
theotherjimmy 40:7d3fa6b99b2b 331 if '-s' in flags_in['ld_flags']:
theotherjimmy 40:7d3fa6b99b2b 332 opts['ld']['strip'] = True
theotherjimmy 40:7d3fa6b99b2b 333 opts['ld']['shared'] = False
theotherjimmy 40:7d3fa6b99b2b 334 if '-shared' in flags_in['ld_flags']:
theotherjimmy 40:7d3fa6b99b2b 335 opts['ld']['shared'] = True
theotherjimmy 40:7d3fa6b99b2b 336 opts['ld']['soname'] = ''
theotherjimmy 40:7d3fa6b99b2b 337 opts['ld']['implname'] = ''
theotherjimmy 40:7d3fa6b99b2b 338 opts['ld']['defname'] = ''
theotherjimmy 40:7d3fa6b99b2b 339 for item in flags_in['ld_flags']:
theotherjimmy 40:7d3fa6b99b2b 340 if item.startswith('-Wl,-soname='):
theotherjimmy 40:7d3fa6b99b2b 341 opts['ld']['soname'] = item[len('-Wl,-soname='):]
theotherjimmy 40:7d3fa6b99b2b 342 if item.startswith('-Wl,--out-implib='):
theotherjimmy 40:7d3fa6b99b2b 343 opts['ld']['implname'] = item[len('-Wl,--out-implib='):]
theotherjimmy 40:7d3fa6b99b2b 344 if item.startswith('-Wl,--output-def='):
theotherjimmy 40:7d3fa6b99b2b 345 opts['ld']['defname'] = item[len('-Wl,--output-def='):]
theotherjimmy 40:7d3fa6b99b2b 346 opts['common']['arm.target.fpu.hardware'] = self.get_fpu_hardware(
theotherjimmy 40:7d3fa6b99b2b 347 opts['common']['arm.target.fpu.unit'])
theotherjimmy 40:7d3fa6b99b2b 348 opts['common']['debugging.codecov'] = False
theotherjimmy 40:7d3fa6b99b2b 349 if '-fprofile-arcs' in flags_in['common_flags'] and '-ftest-coverage' in flags_in['common_flags']:
theotherjimmy 40:7d3fa6b99b2b 350 opts['common']['debugging.codecov'] = True
theotherjimmy 40:7d3fa6b99b2b 351 # Passing linker options to linker with '-Wl,'-prefix.
theotherjimmy 40:7d3fa6b99b2b 352 for index in range(len(opts['ld']['flags'])):
theotherjimmy 40:7d3fa6b99b2b 353 item = opts['ld']['flags'][index]
theotherjimmy 40:7d3fa6b99b2b 354 if not item.startswith('-Wl,'):
theotherjimmy 40:7d3fa6b99b2b 355 opts['ld']['flags'][index] = '-Wl,' + item
theotherjimmy 40:7d3fa6b99b2b 356 # Strange System Workbench feature: If first parameter in Other flags is a
theotherjimmy 40:7d3fa6b99b2b 357 # define (-D...), Other flags will be replaced by defines and other flags
theotherjimmy 40:7d3fa6b99b2b 358 # are completely ignored. Moving -D parameters to defines.
theotherjimmy 40:7d3fa6b99b2b 359 for compiler in ['c', 'cpp', 'as']:
theotherjimmy 40:7d3fa6b99b2b 360 tmpList = opts[compiler]['other'].split(' ')
theotherjimmy 40:7d3fa6b99b2b 361 otherList = []
theotherjimmy 40:7d3fa6b99b2b 362 for item in tmpList:
theotherjimmy 40:7d3fa6b99b2b 363 if item.startswith('-D'):
theotherjimmy 40:7d3fa6b99b2b 364 opts[compiler]['defines'].append(str(item[2:]))
theotherjimmy 40:7d3fa6b99b2b 365 else:
theotherjimmy 40:7d3fa6b99b2b 366 otherList.append(item)
theotherjimmy 40:7d3fa6b99b2b 367 opts[compiler]['other'] = ' '.join(otherList)
theotherjimmy 40:7d3fa6b99b2b 368 # Assembler options
theotherjimmy 40:7d3fa6b99b2b 369 for as_def in opts['as']['defines']:
theotherjimmy 40:7d3fa6b99b2b 370 if '=' in as_def:
theotherjimmy 40:7d3fa6b99b2b 371 opts['as']['other'] += ' --defsym ' + as_def
theotherjimmy 40:7d3fa6b99b2b 372 else:
theotherjimmy 40:7d3fa6b99b2b 373 opts['as']['other'] += ' --defsym ' + as_def + '=1'
The Other Jimmy 35:da9c89f8be7d 374
The Other Jimmy 35:da9c89f8be7d 375 def generate(self):
theotherjimmy 40:7d3fa6b99b2b 376 """
theotherjimmy 40:7d3fa6b99b2b 377 Generate the .project and .cproject files.
theotherjimmy 40:7d3fa6b99b2b 378 """
theotherjimmy 40:7d3fa6b99b2b 379 options = {}
theotherjimmy 40:7d3fa6b99b2b 380
theotherjimmy 40:7d3fa6b99b2b 381 if not self.resources.linker_script:
theotherjimmy 40:7d3fa6b99b2b 382 raise NotSupportedException("No linker script found.")
theotherjimmy 40:7d3fa6b99b2b 383
theotherjimmy 40:7d3fa6b99b2b 384 print ('\nCreate a System Workbench for STM32 managed project')
theotherjimmy 40:7d3fa6b99b2b 385 print ('Project name: {0}'.format(self.project_name))
theotherjimmy 40:7d3fa6b99b2b 386 print ('Target: {0}'.format(self.toolchain.target.name))
theotherjimmy 40:7d3fa6b99b2b 387 print ('Toolchain: {0}'.format(self.TOOLCHAIN) + '\n')
theotherjimmy 40:7d3fa6b99b2b 388
theotherjimmy 40:7d3fa6b99b2b 389 self.resources.win_to_unix()
theotherjimmy 40:7d3fa6b99b2b 390
theotherjimmy 40:7d3fa6b99b2b 391 config_header = self.filter_dot(self.toolchain.get_config_header())
theotherjimmy 40:7d3fa6b99b2b 392
The Other Jimmy 35:da9c89f8be7d 393 libraries = []
The Other Jimmy 35:da9c89f8be7d 394 for lib in self.resources.libraries:
theotherjimmy 40:7d3fa6b99b2b 395 library, _ = splitext(basename(lib))
theotherjimmy 40:7d3fa6b99b2b 396 libraries.append(library[3:])
theotherjimmy 40:7d3fa6b99b2b 397
theotherjimmy 40:7d3fa6b99b2b 398 self.system_libraries = [
theotherjimmy 40:7d3fa6b99b2b 399 'stdc++', 'supc++', 'm', 'c', 'gcc', 'nosys'
theotherjimmy 40:7d3fa6b99b2b 400 ]
theotherjimmy 40:7d3fa6b99b2b 401
theotherjimmy 40:7d3fa6b99b2b 402 profiles = self.get_all_profiles()
theotherjimmy 40:7d3fa6b99b2b 403 self.as_defines = [s.replace('"', '"')
theotherjimmy 40:7d3fa6b99b2b 404 for s in self.toolchain.get_symbols(True)]
theotherjimmy 40:7d3fa6b99b2b 405 self.c_defines = [s.replace('"', '"')
theotherjimmy 40:7d3fa6b99b2b 406 for s in self.toolchain.get_symbols()]
theotherjimmy 40:7d3fa6b99b2b 407 self.cpp_defines = self.c_defines
theotherjimmy 40:7d3fa6b99b2b 408 print 'Symbols: {0}'.format(len(self.c_defines))
theotherjimmy 40:7d3fa6b99b2b 409
theotherjimmy 40:7d3fa6b99b2b 410 self.include_path = []
theotherjimmy 40:7d3fa6b99b2b 411 for s in self.resources.inc_dirs:
theotherjimmy 40:7d3fa6b99b2b 412 self.include_path.append("../" + self.filter_dot(s))
theotherjimmy 40:7d3fa6b99b2b 413 print ('Include folders: {0}'.format(len(self.include_path)))
theotherjimmy 40:7d3fa6b99b2b 414
theotherjimmy 40:7d3fa6b99b2b 415 self.compute_exclusions()
theotherjimmy 40:7d3fa6b99b2b 416
theotherjimmy 40:7d3fa6b99b2b 417 print ('Exclude folders: {0}'.format(len(self.excluded_folders)))
theotherjimmy 40:7d3fa6b99b2b 418
theotherjimmy 40:7d3fa6b99b2b 419 ld_script = self.filter_dot(self.resources.linker_script)
theotherjimmy 40:7d3fa6b99b2b 420 print ('Linker script: {0}'.format(ld_script))
theotherjimmy 40:7d3fa6b99b2b 421
theotherjimmy 40:7d3fa6b99b2b 422 lib_dirs = [self.filter_dot(s) for s in self.resources.lib_dirs]
theotherjimmy 40:7d3fa6b99b2b 423
theotherjimmy 40:7d3fa6b99b2b 424 preproc_cmd = basename(self.toolchain.preproc[0]) + " " + " ".join(self.toolchain.preproc[1:])
theotherjimmy 40:7d3fa6b99b2b 425
theotherjimmy 40:7d3fa6b99b2b 426 for id in ['debug', 'release']:
theotherjimmy 40:7d3fa6b99b2b 427 opts = {}
theotherjimmy 40:7d3fa6b99b2b 428 opts['common'] = {}
theotherjimmy 40:7d3fa6b99b2b 429 opts['as'] = {}
theotherjimmy 40:7d3fa6b99b2b 430 opts['c'] = {}
theotherjimmy 40:7d3fa6b99b2b 431 opts['cpp'] = {}
theotherjimmy 40:7d3fa6b99b2b 432 opts['ld'] = {}
theotherjimmy 40:7d3fa6b99b2b 433
theotherjimmy 40:7d3fa6b99b2b 434 opts['id'] = id
theotherjimmy 40:7d3fa6b99b2b 435 opts['name'] = opts['id'].capitalize()
theotherjimmy 40:7d3fa6b99b2b 436
theotherjimmy 40:7d3fa6b99b2b 437 # TODO: Add prints to log or console in verbose mode.
theotherjimmy 40:7d3fa6b99b2b 438 #print ('\nBuild configuration: {0}'.format(opts['name']))
theotherjimmy 40:7d3fa6b99b2b 439
theotherjimmy 40:7d3fa6b99b2b 440 profile = profiles[id]
theotherjimmy 40:7d3fa6b99b2b 441
theotherjimmy 40:7d3fa6b99b2b 442 # A small hack, do not bother with src_path again,
theotherjimmy 40:7d3fa6b99b2b 443 # pass an empty string to avoid crashing.
theotherjimmy 40:7d3fa6b99b2b 444 src_paths = ['']
theotherjimmy 40:7d3fa6b99b2b 445 toolchain = prepare_toolchain(
theotherjimmy 40:7d3fa6b99b2b 446 src_paths, "", self.toolchain.target.name, self.TOOLCHAIN, build_profile=[profile])
theotherjimmy 40:7d3fa6b99b2b 447
theotherjimmy 40:7d3fa6b99b2b 448 # Hack to fill in build_dir
theotherjimmy 40:7d3fa6b99b2b 449 toolchain.build_dir = self.toolchain.build_dir
theotherjimmy 40:7d3fa6b99b2b 450
theotherjimmy 40:7d3fa6b99b2b 451 flags = self.toolchain_flags(toolchain)
theotherjimmy 40:7d3fa6b99b2b 452
theotherjimmy 40:7d3fa6b99b2b 453 # TODO: Add prints to log or console in verbose mode.
theotherjimmy 40:7d3fa6b99b2b 454 # print 'Common flags:', ' '.join(flags['common_flags'])
theotherjimmy 40:7d3fa6b99b2b 455 # print 'C++ flags:', ' '.join(flags['cxx_flags'])
theotherjimmy 40:7d3fa6b99b2b 456 # print 'C flags:', ' '.join(flags['c_flags'])
theotherjimmy 40:7d3fa6b99b2b 457 # print 'ASM flags:', ' '.join(flags['asm_flags'])
theotherjimmy 40:7d3fa6b99b2b 458 # print 'Linker flags:', ' '.join(flags['ld_flags'])
theotherjimmy 40:7d3fa6b99b2b 459
theotherjimmy 40:7d3fa6b99b2b 460 # Most GNU ARM Eclipse options have a parent,
theotherjimmy 40:7d3fa6b99b2b 461 # either debug or release.
theotherjimmy 40:7d3fa6b99b2b 462 if '-O0' in flags['common_flags'] or '-Og' in flags['common_flags']:
theotherjimmy 40:7d3fa6b99b2b 463 opts['parent_id'] = 'debug'
theotherjimmy 40:7d3fa6b99b2b 464 else:
theotherjimmy 40:7d3fa6b99b2b 465 opts['parent_id'] = 'release'
theotherjimmy 40:7d3fa6b99b2b 466
theotherjimmy 40:7d3fa6b99b2b 467 self.process_options(opts, flags)
theotherjimmy 40:7d3fa6b99b2b 468
theotherjimmy 40:7d3fa6b99b2b 469 opts['c']['defines'] = self.c_defines
theotherjimmy 40:7d3fa6b99b2b 470 opts['cpp']['defines'] = self.cpp_defines
theotherjimmy 40:7d3fa6b99b2b 471 opts['as']['defines'] = self.as_defines
theotherjimmy 40:7d3fa6b99b2b 472
theotherjimmy 40:7d3fa6b99b2b 473 self.process_sw_options(opts, flags)
theotherjimmy 40:7d3fa6b99b2b 474
theotherjimmy 40:7d3fa6b99b2b 475 opts['ld']['library_paths'] = [
theotherjimmy 40:7d3fa6b99b2b 476 self.filter_dot(s) for s in self.resources.lib_dirs]
theotherjimmy 40:7d3fa6b99b2b 477
theotherjimmy 40:7d3fa6b99b2b 478 opts['ld']['user_libraries'] = libraries
theotherjimmy 40:7d3fa6b99b2b 479 opts['ld']['system_libraries'] = self.system_libraries
theotherjimmy 40:7d3fa6b99b2b 480 opts['ld']['script'] = "linker-script-" + id + ".ld"
theotherjimmy 40:7d3fa6b99b2b 481
theotherjimmy 40:7d3fa6b99b2b 482 # Unique IDs used in multiple places.
theotherjimmy 40:7d3fa6b99b2b 483 uid = {}
theotherjimmy 40:7d3fa6b99b2b 484 uid['config'] = u.id
theotherjimmy 40:7d3fa6b99b2b 485 uid['tool_c_compiler'] = u.id
theotherjimmy 40:7d3fa6b99b2b 486 uid['tool_c_compiler_input'] = u.id
theotherjimmy 40:7d3fa6b99b2b 487 uid['tool_cpp_compiler'] = u.id
theotherjimmy 40:7d3fa6b99b2b 488 uid['tool_cpp_compiler_input'] = u.id
theotherjimmy 40:7d3fa6b99b2b 489
theotherjimmy 40:7d3fa6b99b2b 490 opts['uid'] = uid
theotherjimmy 40:7d3fa6b99b2b 491
theotherjimmy 40:7d3fa6b99b2b 492 options[id] = opts
The Other Jimmy 35:da9c89f8be7d 493
The Other Jimmy 35:da9c89f8be7d 494 ctx = {
The Other Jimmy 35:da9c89f8be7d 495 'name': self.project_name,
theotherjimmy 40:7d3fa6b99b2b 496 'platform': platform,
theotherjimmy 40:7d3fa6b99b2b 497 'include_paths': self.include_path,
theotherjimmy 40:7d3fa6b99b2b 498 'config_header': config_header,
theotherjimmy 40:7d3fa6b99b2b 499 'exclude_paths': '|'.join(self.excluded_folders),
theotherjimmy 40:7d3fa6b99b2b 500 'ld_script': ld_script,
theotherjimmy 40:7d3fa6b99b2b 501 'library_paths': lib_dirs,
The Other Jimmy 35:da9c89f8be7d 502 'object_files': self.resources.objects,
The Other Jimmy 35:da9c89f8be7d 503 'libraries': libraries,
The Other Jimmy 35:da9c89f8be7d 504 'board_name': self.BOARDS[self.target.upper()]['name'],
The Other Jimmy 35:da9c89f8be7d 505 'mcu_name': self.BOARDS[self.target.upper()]['mcuId'],
theotherjimmy 40:7d3fa6b99b2b 506 'cpp_cmd': preproc_cmd,
theotherjimmy 40:7d3fa6b99b2b 507 'options': options,
theotherjimmy 40:7d3fa6b99b2b 508 # id property of 'u' will generate new random identifier every time
theotherjimmy 40:7d3fa6b99b2b 509 # when called.
theotherjimmy 40:7d3fa6b99b2b 510 'u': u
The Other Jimmy 35:da9c89f8be7d 511 }
The Other Jimmy 35:da9c89f8be7d 512
The Other Jimmy 35:da9c89f8be7d 513 self.__gen_dir('.settings')
theotherjimmy 40:7d3fa6b99b2b 514 self.gen_file('sw4stm32/language_settings_commom.tmpl',
theotherjimmy 40:7d3fa6b99b2b 515 ctx, '.settings/language.settings.xml')
The Other Jimmy 35:da9c89f8be7d 516 self.gen_file('sw4stm32/project_common.tmpl', ctx, '.project')
The Other Jimmy 35:da9c89f8be7d 517 self.gen_file('sw4stm32/cproject_common.tmpl', ctx, '.cproject')
theotherjimmy 40:7d3fa6b99b2b 518 self.gen_file('sw4stm32/makefile.targets.tmpl', ctx,
theotherjimmy 40:7d3fa6b99b2b 519 'makefile.targets', trim_blocks=True, lstrip_blocks=True)
theotherjimmy 40:7d3fa6b99b2b 520 self.gen_file('sw4stm32/launch.tmpl', ctx, self.project_name +
theotherjimmy 40:7d3fa6b99b2b 521 ' ' + options['debug']['name'] + '.launch')