Clone of official tools
export/gnuarmeclipse/__init__.py@36:96847d42f010, 2017-06-22 (annotated)
- Committer:
- The Other Jimmy
- Date:
- Thu Jun 22 11:12:28 2017 -0500
- Revision:
- 36:96847d42f010
- Child:
- 40:7d3fa6b99b2b
Tools release 5.5.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
The Other Jimmy |
36:96847d42f010 | 1 | """ |
The Other Jimmy |
36:96847d42f010 | 2 | mbed SDK |
The Other Jimmy |
36:96847d42f010 | 3 | Copyright (c) 2011-2017 ARM Limited |
The Other Jimmy |
36:96847d42f010 | 4 | |
The Other Jimmy |
36:96847d42f010 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
The Other Jimmy |
36:96847d42f010 | 6 | you may not use this file except in compliance with the License. |
The Other Jimmy |
36:96847d42f010 | 7 | You may obtain a copy of the License at |
The Other Jimmy |
36:96847d42f010 | 8 | |
The Other Jimmy |
36:96847d42f010 | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
The Other Jimmy |
36:96847d42f010 | 10 | |
The Other Jimmy |
36:96847d42f010 | 11 | Unless required by applicable law or agreed to in writing, software |
The Other Jimmy |
36:96847d42f010 | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
The Other Jimmy |
36:96847d42f010 | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
The Other Jimmy |
36:96847d42f010 | 14 | See the License for the specific language governing permissions and |
The Other Jimmy |
36:96847d42f010 | 15 | limitations under the License. |
The Other Jimmy |
36:96847d42f010 | 16 | |
The Other Jimmy |
36:96847d42f010 | 17 | Title: GNU ARM Eclipse (http://gnuarmeclipse.github.io) exporter. |
The Other Jimmy |
36:96847d42f010 | 18 | |
The Other Jimmy |
36:96847d42f010 | 19 | Description: Creates a managed build project that can be imported by |
The Other Jimmy |
36:96847d42f010 | 20 | the GNU ARM Eclipse plug-ins. |
The Other Jimmy |
36:96847d42f010 | 21 | |
The Other Jimmy |
36:96847d42f010 | 22 | Author: Liviu Ionescu <ilg@livius.net> |
The Other Jimmy |
36:96847d42f010 | 23 | """ |
The Other Jimmy |
36:96847d42f010 | 24 | |
The Other Jimmy |
36:96847d42f010 | 25 | import os |
The Other Jimmy |
36:96847d42f010 | 26 | import copy |
The Other Jimmy |
36:96847d42f010 | 27 | import tempfile |
The Other Jimmy |
36:96847d42f010 | 28 | import shutil |
The Other Jimmy |
36:96847d42f010 | 29 | import copy |
The Other Jimmy |
36:96847d42f010 | 30 | |
The Other Jimmy |
36:96847d42f010 | 31 | from subprocess import call, Popen, PIPE |
The Other Jimmy |
36:96847d42f010 | 32 | from os.path import splitext, basename, relpath, dirname, exists, join, dirname |
The Other Jimmy |
36:96847d42f010 | 33 | from random import randint |
The Other Jimmy |
36:96847d42f010 | 34 | from json import load |
The Other Jimmy |
36:96847d42f010 | 35 | |
The Other Jimmy |
36:96847d42f010 | 36 | from tools.export.exporters import Exporter, filter_supported |
The Other Jimmy |
36:96847d42f010 | 37 | from tools.options import list_profiles |
The Other Jimmy |
36:96847d42f010 | 38 | from tools.targets import TARGET_MAP |
The Other Jimmy |
36:96847d42f010 | 39 | from tools.utils import NotSupportedException |
The Other Jimmy |
36:96847d42f010 | 40 | from tools.build_api import prepare_toolchain |
The Other Jimmy |
36:96847d42f010 | 41 | |
The Other Jimmy |
36:96847d42f010 | 42 | # ============================================================================= |
The Other Jimmy |
36:96847d42f010 | 43 | |
The Other Jimmy |
36:96847d42f010 | 44 | |
The Other Jimmy |
36:96847d42f010 | 45 | class UID: |
The Other Jimmy |
36:96847d42f010 | 46 | """ |
The Other Jimmy |
36:96847d42f010 | 47 | Helper class, used to generate unique ids required by .cproject symbols. |
The Other Jimmy |
36:96847d42f010 | 48 | """ |
The Other Jimmy |
36:96847d42f010 | 49 | @property |
The Other Jimmy |
36:96847d42f010 | 50 | def id(self): |
The Other Jimmy |
36:96847d42f010 | 51 | return "%0.9u" % randint(0, 999999999) |
The Other Jimmy |
36:96847d42f010 | 52 | |
The Other Jimmy |
36:96847d42f010 | 53 | # Global UID generator instance. |
The Other Jimmy |
36:96847d42f010 | 54 | # Passed to the template engine, and referred as {{u.id}}. |
The Other Jimmy |
36:96847d42f010 | 55 | # Each invocation generates a new number. |
The Other Jimmy |
36:96847d42f010 | 56 | u = UID() |
The Other Jimmy |
36:96847d42f010 | 57 | |
The Other Jimmy |
36:96847d42f010 | 58 | # ============================================================================= |
The Other Jimmy |
36:96847d42f010 | 59 | |
The Other Jimmy |
36:96847d42f010 | 60 | |
The Other Jimmy |
36:96847d42f010 | 61 | POST_BINARY_WHITELIST = set([ |
The Other Jimmy |
36:96847d42f010 | 62 | "TEENSY3_1Code.binary_hook", |
The Other Jimmy |
36:96847d42f010 | 63 | "MCU_NRF51Code.binary_hook", |
The Other Jimmy |
36:96847d42f010 | 64 | "LPCTargetCode.lpc_patch", |
The Other Jimmy |
36:96847d42f010 | 65 | "LPC4088Code.binary_hook" |
The Other Jimmy |
36:96847d42f010 | 66 | ]) |
The Other Jimmy |
36:96847d42f010 | 67 | |
The Other Jimmy |
36:96847d42f010 | 68 | class GNUARMEclipse(Exporter): |
The Other Jimmy |
36:96847d42f010 | 69 | NAME = 'GNU ARM Eclipse' |
The Other Jimmy |
36:96847d42f010 | 70 | TOOLCHAIN = 'GCC_ARM' |
The Other Jimmy |
36:96847d42f010 | 71 | |
The Other Jimmy |
36:96847d42f010 | 72 | TARGETS = filter_supported("GCC_ARM", POST_BINARY_WHITELIST) |
The Other Jimmy |
36:96847d42f010 | 73 | |
The Other Jimmy |
36:96847d42f010 | 74 | # override |
The Other Jimmy |
36:96847d42f010 | 75 | @property |
The Other Jimmy |
36:96847d42f010 | 76 | def flags(self): |
The Other Jimmy |
36:96847d42f010 | 77 | """Returns a dictionary of toolchain flags. |
The Other Jimmy |
36:96847d42f010 | 78 | Keys of the dictionary are: |
The Other Jimmy |
36:96847d42f010 | 79 | cxx_flags - c++ flags |
The Other Jimmy |
36:96847d42f010 | 80 | c_flags - c flags |
The Other Jimmy |
36:96847d42f010 | 81 | ld_flags - linker flags |
The Other Jimmy |
36:96847d42f010 | 82 | asm_flags - assembler flags |
The Other Jimmy |
36:96847d42f010 | 83 | common_flags - common options |
The Other Jimmy |
36:96847d42f010 | 84 | |
The Other Jimmy |
36:96847d42f010 | 85 | The difference from the parent function is that it does not |
The Other Jimmy |
36:96847d42f010 | 86 | add macro definitions, since they are passed separately. |
The Other Jimmy |
36:96847d42f010 | 87 | """ |
The Other Jimmy |
36:96847d42f010 | 88 | |
The Other Jimmy |
36:96847d42f010 | 89 | config_header = self.toolchain.get_config_header() |
The Other Jimmy |
36:96847d42f010 | 90 | flags = {key + "_flags": copy.deepcopy(value) for key, value |
The Other Jimmy |
36:96847d42f010 | 91 | in self.toolchain.flags.iteritems()} |
The Other Jimmy |
36:96847d42f010 | 92 | if config_header: |
The Other Jimmy |
36:96847d42f010 | 93 | config_header = relpath(config_header, |
The Other Jimmy |
36:96847d42f010 | 94 | self.resources.file_basepath[config_header]) |
The Other Jimmy |
36:96847d42f010 | 95 | flags['c_flags'] += self.toolchain.get_config_option(config_header) |
The Other Jimmy |
36:96847d42f010 | 96 | flags['cxx_flags'] += self.toolchain.get_config_option( |
The Other Jimmy |
36:96847d42f010 | 97 | config_header) |
The Other Jimmy |
36:96847d42f010 | 98 | return flags |
The Other Jimmy |
36:96847d42f010 | 99 | |
The Other Jimmy |
36:96847d42f010 | 100 | def toolchain_flags(self, toolchain): |
The Other Jimmy |
36:96847d42f010 | 101 | """Returns a dictionary of toolchain flags. |
The Other Jimmy |
36:96847d42f010 | 102 | Keys of the dictionary are: |
The Other Jimmy |
36:96847d42f010 | 103 | cxx_flags - c++ flags |
The Other Jimmy |
36:96847d42f010 | 104 | c_flags - c flags |
The Other Jimmy |
36:96847d42f010 | 105 | ld_flags - linker flags |
The Other Jimmy |
36:96847d42f010 | 106 | asm_flags - assembler flags |
The Other Jimmy |
36:96847d42f010 | 107 | common_flags - common options |
The Other Jimmy |
36:96847d42f010 | 108 | |
The Other Jimmy |
36:96847d42f010 | 109 | The difference from the above is that it takes a parameter. |
The Other Jimmy |
36:96847d42f010 | 110 | """ |
The Other Jimmy |
36:96847d42f010 | 111 | |
The Other Jimmy |
36:96847d42f010 | 112 | # Note: use the config options from the currently selected toolchain. |
The Other Jimmy |
36:96847d42f010 | 113 | config_header = self.toolchain.get_config_header() |
The Other Jimmy |
36:96847d42f010 | 114 | |
The Other Jimmy |
36:96847d42f010 | 115 | flags = {key + "_flags": copy.deepcopy(value) for key, value |
The Other Jimmy |
36:96847d42f010 | 116 | in toolchain.flags.iteritems()} |
The Other Jimmy |
36:96847d42f010 | 117 | if config_header: |
The Other Jimmy |
36:96847d42f010 | 118 | config_header = relpath(config_header, |
The Other Jimmy |
36:96847d42f010 | 119 | self.resources.file_basepath[config_header]) |
The Other Jimmy |
36:96847d42f010 | 120 | header_options = self.toolchain.get_config_option(config_header) |
The Other Jimmy |
36:96847d42f010 | 121 | flags['c_flags'] += header_options |
The Other Jimmy |
36:96847d42f010 | 122 | flags['cxx_flags'] += header_options |
The Other Jimmy |
36:96847d42f010 | 123 | return flags |
The Other Jimmy |
36:96847d42f010 | 124 | |
The Other Jimmy |
36:96847d42f010 | 125 | # override |
The Other Jimmy |
36:96847d42f010 | 126 | def generate(self): |
The Other Jimmy |
36:96847d42f010 | 127 | """ |
The Other Jimmy |
36:96847d42f010 | 128 | Generate the .project and .cproject files. |
The Other Jimmy |
36:96847d42f010 | 129 | """ |
The Other Jimmy |
36:96847d42f010 | 130 | if not self.resources.linker_script: |
The Other Jimmy |
36:96847d42f010 | 131 | raise NotSupportedException("No linker script found.") |
The Other Jimmy |
36:96847d42f010 | 132 | |
The Other Jimmy |
36:96847d42f010 | 133 | |
The Other Jimmy |
36:96847d42f010 | 134 | print 'Create a GNU ARM Eclipse C++ managed project' |
The Other Jimmy |
36:96847d42f010 | 135 | print 'Project name: {0}'.format(self.project_name) |
The Other Jimmy |
36:96847d42f010 | 136 | print 'Target: {0}'.format(self.toolchain.target.name) |
The Other Jimmy |
36:96847d42f010 | 137 | print 'Toolchain: {0}'.format(self.TOOLCHAIN) |
The Other Jimmy |
36:96847d42f010 | 138 | |
The Other Jimmy |
36:96847d42f010 | 139 | self.resources.win_to_unix() |
The Other Jimmy |
36:96847d42f010 | 140 | |
The Other Jimmy |
36:96847d42f010 | 141 | # TODO: use some logger to display additional info if verbose |
The Other Jimmy |
36:96847d42f010 | 142 | |
The Other Jimmy |
36:96847d42f010 | 143 | libraries = [] |
The Other Jimmy |
36:96847d42f010 | 144 | # print 'libraries' |
The Other Jimmy |
36:96847d42f010 | 145 | # print self.resources.libraries |
The Other Jimmy |
36:96847d42f010 | 146 | for lib in self.resources.libraries: |
The Other Jimmy |
36:96847d42f010 | 147 | l, _ = splitext(basename(lib)) |
The Other Jimmy |
36:96847d42f010 | 148 | libraries.append(l[3:]) |
The Other Jimmy |
36:96847d42f010 | 149 | |
The Other Jimmy |
36:96847d42f010 | 150 | self.system_libraries = [ |
The Other Jimmy |
36:96847d42f010 | 151 | 'stdc++', 'supc++', 'm', 'c', 'gcc', 'nosys' |
The Other Jimmy |
36:96847d42f010 | 152 | ] |
The Other Jimmy |
36:96847d42f010 | 153 | |
The Other Jimmy |
36:96847d42f010 | 154 | # Read in all profiles, we'll extract compiler options. |
The Other Jimmy |
36:96847d42f010 | 155 | profiles = self.get_all_profiles() |
The Other Jimmy |
36:96847d42f010 | 156 | |
The Other Jimmy |
36:96847d42f010 | 157 | profile_ids = [s.lower() for s in profiles] |
The Other Jimmy |
36:96847d42f010 | 158 | profile_ids.sort() |
The Other Jimmy |
36:96847d42f010 | 159 | |
The Other Jimmy |
36:96847d42f010 | 160 | # TODO: get the list from existing .cproject |
The Other Jimmy |
36:96847d42f010 | 161 | build_folders = [s.capitalize() for s in profile_ids] |
The Other Jimmy |
36:96847d42f010 | 162 | build_folders.append('BUILD') |
The Other Jimmy |
36:96847d42f010 | 163 | # print build_folders |
The Other Jimmy |
36:96847d42f010 | 164 | |
The Other Jimmy |
36:96847d42f010 | 165 | objects = [self.filter_dot(s) for s in self.resources.objects] |
The Other Jimmy |
36:96847d42f010 | 166 | for bf in build_folders: |
The Other Jimmy |
36:96847d42f010 | 167 | objects = [o for o in objects if not o.startswith(bf + '/')] |
The Other Jimmy |
36:96847d42f010 | 168 | # print 'objects' |
The Other Jimmy |
36:96847d42f010 | 169 | # print objects |
The Other Jimmy |
36:96847d42f010 | 170 | |
The Other Jimmy |
36:96847d42f010 | 171 | self.compute_exclusions() |
The Other Jimmy |
36:96847d42f010 | 172 | |
The Other Jimmy |
36:96847d42f010 | 173 | self.include_path = [ |
The Other Jimmy |
36:96847d42f010 | 174 | self.filter_dot(s) for s in self.resources.inc_dirs] |
The Other Jimmy |
36:96847d42f010 | 175 | print 'Include folders: {0}'.format(len(self.include_path)) |
The Other Jimmy |
36:96847d42f010 | 176 | |
The Other Jimmy |
36:96847d42f010 | 177 | self.as_defines = self.toolchain.get_symbols(True) |
The Other Jimmy |
36:96847d42f010 | 178 | self.c_defines = self.toolchain.get_symbols() |
The Other Jimmy |
36:96847d42f010 | 179 | self.cpp_defines = self.c_defines |
The Other Jimmy |
36:96847d42f010 | 180 | print 'Symbols: {0}'.format(len(self.c_defines)) |
The Other Jimmy |
36:96847d42f010 | 181 | |
The Other Jimmy |
36:96847d42f010 | 182 | self.ld_script = self.filter_dot( |
The Other Jimmy |
36:96847d42f010 | 183 | self.resources.linker_script) |
The Other Jimmy |
36:96847d42f010 | 184 | print 'Linker script: {0}'.format(self.ld_script) |
The Other Jimmy |
36:96847d42f010 | 185 | |
The Other Jimmy |
36:96847d42f010 | 186 | self.options = {} |
The Other Jimmy |
36:96847d42f010 | 187 | for id in profile_ids: |
The Other Jimmy |
36:96847d42f010 | 188 | |
The Other Jimmy |
36:96847d42f010 | 189 | # There are 4 categories of options, a category common too |
The Other Jimmy |
36:96847d42f010 | 190 | # all tools and a specific category for each of the tools. |
The Other Jimmy |
36:96847d42f010 | 191 | opts = {} |
The Other Jimmy |
36:96847d42f010 | 192 | opts['common'] = {} |
The Other Jimmy |
36:96847d42f010 | 193 | opts['as'] = {} |
The Other Jimmy |
36:96847d42f010 | 194 | opts['c'] = {} |
The Other Jimmy |
36:96847d42f010 | 195 | opts['cpp'] = {} |
The Other Jimmy |
36:96847d42f010 | 196 | opts['ld'] = {} |
The Other Jimmy |
36:96847d42f010 | 197 | |
The Other Jimmy |
36:96847d42f010 | 198 | opts['id'] = id |
The Other Jimmy |
36:96847d42f010 | 199 | opts['name'] = opts['id'].capitalize() |
The Other Jimmy |
36:96847d42f010 | 200 | |
The Other Jimmy |
36:96847d42f010 | 201 | |
The Other Jimmy |
36:96847d42f010 | 202 | print 'Build configuration: {0}'.format(opts['name']) |
The Other Jimmy |
36:96847d42f010 | 203 | |
The Other Jimmy |
36:96847d42f010 | 204 | profile = profiles[id] |
The Other Jimmy |
36:96847d42f010 | 205 | |
The Other Jimmy |
36:96847d42f010 | 206 | # A small hack, do not bother with src_path again, |
The Other Jimmy |
36:96847d42f010 | 207 | # pass an empty string to avoid crashing. |
The Other Jimmy |
36:96847d42f010 | 208 | src_paths = [''] |
The Other Jimmy |
36:96847d42f010 | 209 | target_name = self.toolchain.target.name |
The Other Jimmy |
36:96847d42f010 | 210 | toolchain = prepare_toolchain( |
The Other Jimmy |
36:96847d42f010 | 211 | src_paths, "", target_name, self.TOOLCHAIN, build_profile=[profile]) |
The Other Jimmy |
36:96847d42f010 | 212 | |
The Other Jimmy |
36:96847d42f010 | 213 | # Hack to fill in build_dir |
The Other Jimmy |
36:96847d42f010 | 214 | toolchain.build_dir = self.toolchain.build_dir |
The Other Jimmy |
36:96847d42f010 | 215 | |
The Other Jimmy |
36:96847d42f010 | 216 | flags = self.toolchain_flags(toolchain) |
The Other Jimmy |
36:96847d42f010 | 217 | |
The Other Jimmy |
36:96847d42f010 | 218 | print 'Common flags:', ' '.join(flags['common_flags']) |
The Other Jimmy |
36:96847d42f010 | 219 | print 'C++ flags:', ' '.join(flags['cxx_flags']) |
The Other Jimmy |
36:96847d42f010 | 220 | print 'C flags:', ' '.join(flags['c_flags']) |
The Other Jimmy |
36:96847d42f010 | 221 | print 'ASM flags:', ' '.join(flags['asm_flags']) |
The Other Jimmy |
36:96847d42f010 | 222 | print 'Linker flags:', ' '.join(flags['ld_flags']) |
The Other Jimmy |
36:96847d42f010 | 223 | |
The Other Jimmy |
36:96847d42f010 | 224 | # Most GNU ARM Eclipse options have a parent, |
The Other Jimmy |
36:96847d42f010 | 225 | # either debug or release. |
The Other Jimmy |
36:96847d42f010 | 226 | if '-O0' in flags['common_flags'] or '-Og' in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 227 | opts['parent_id'] = 'debug' |
The Other Jimmy |
36:96847d42f010 | 228 | else: |
The Other Jimmy |
36:96847d42f010 | 229 | opts['parent_id'] = 'release' |
The Other Jimmy |
36:96847d42f010 | 230 | |
The Other Jimmy |
36:96847d42f010 | 231 | self.process_options(opts, flags) |
The Other Jimmy |
36:96847d42f010 | 232 | |
The Other Jimmy |
36:96847d42f010 | 233 | opts['as']['defines'] = self.as_defines |
The Other Jimmy |
36:96847d42f010 | 234 | opts['c']['defines'] = self.c_defines |
The Other Jimmy |
36:96847d42f010 | 235 | opts['cpp']['defines'] = self.cpp_defines |
The Other Jimmy |
36:96847d42f010 | 236 | |
The Other Jimmy |
36:96847d42f010 | 237 | opts['common']['include_paths'] = self.include_path |
The Other Jimmy |
36:96847d42f010 | 238 | opts['common']['excluded_folders'] = '|'.join( |
The Other Jimmy |
36:96847d42f010 | 239 | self.excluded_folders) |
The Other Jimmy |
36:96847d42f010 | 240 | |
The Other Jimmy |
36:96847d42f010 | 241 | opts['ld']['library_paths'] = [ |
The Other Jimmy |
36:96847d42f010 | 242 | self.filter_dot(s) for s in self.resources.lib_dirs] |
The Other Jimmy |
36:96847d42f010 | 243 | |
The Other Jimmy |
36:96847d42f010 | 244 | opts['ld']['object_files'] = objects |
The Other Jimmy |
36:96847d42f010 | 245 | opts['ld']['user_libraries'] = libraries |
The Other Jimmy |
36:96847d42f010 | 246 | opts['ld']['system_libraries'] = self.system_libraries |
The Other Jimmy |
36:96847d42f010 | 247 | opts['ld']['script'] = join(id.capitalize(), |
The Other Jimmy |
36:96847d42f010 | 248 | "linker-script-%s.ld" % id) |
The Other Jimmy |
36:96847d42f010 | 249 | opts['cpp_cmd'] = " ".join(toolchain.preproc) |
The Other Jimmy |
36:96847d42f010 | 250 | |
The Other Jimmy |
36:96847d42f010 | 251 | # Unique IDs used in multiple places. |
The Other Jimmy |
36:96847d42f010 | 252 | # Those used only once are implemented with {{u.id}}. |
The Other Jimmy |
36:96847d42f010 | 253 | uid = {} |
The Other Jimmy |
36:96847d42f010 | 254 | uid['config'] = u.id |
The Other Jimmy |
36:96847d42f010 | 255 | uid['tool_c_compiler'] = u.id |
The Other Jimmy |
36:96847d42f010 | 256 | uid['tool_c_compiler_input'] = u.id |
The Other Jimmy |
36:96847d42f010 | 257 | uid['tool_cpp_compiler'] = u.id |
The Other Jimmy |
36:96847d42f010 | 258 | uid['tool_cpp_compiler_input'] = u.id |
The Other Jimmy |
36:96847d42f010 | 259 | |
The Other Jimmy |
36:96847d42f010 | 260 | opts['uid'] = uid |
The Other Jimmy |
36:96847d42f010 | 261 | |
The Other Jimmy |
36:96847d42f010 | 262 | self.options[id] = opts |
The Other Jimmy |
36:96847d42f010 | 263 | |
The Other Jimmy |
36:96847d42f010 | 264 | jinja_ctx = { |
The Other Jimmy |
36:96847d42f010 | 265 | 'name': self.project_name, |
The Other Jimmy |
36:96847d42f010 | 266 | 'ld_script': self.ld_script, |
The Other Jimmy |
36:96847d42f010 | 267 | |
The Other Jimmy |
36:96847d42f010 | 268 | # Compiler & linker command line options |
The Other Jimmy |
36:96847d42f010 | 269 | 'options': self.options, |
The Other Jimmy |
36:96847d42f010 | 270 | |
The Other Jimmy |
36:96847d42f010 | 271 | # Must be an object with an `id` property, which |
The Other Jimmy |
36:96847d42f010 | 272 | # will be called repeatedly, to generate multiple UIDs. |
The Other Jimmy |
36:96847d42f010 | 273 | 'u': u, |
The Other Jimmy |
36:96847d42f010 | 274 | } |
The Other Jimmy |
36:96847d42f010 | 275 | |
The Other Jimmy |
36:96847d42f010 | 276 | self.gen_file('gnuarmeclipse/.project.tmpl', jinja_ctx, |
The Other Jimmy |
36:96847d42f010 | 277 | '.project', trim_blocks=True, lstrip_blocks=True) |
The Other Jimmy |
36:96847d42f010 | 278 | self.gen_file('gnuarmeclipse/.cproject.tmpl', jinja_ctx, |
The Other Jimmy |
36:96847d42f010 | 279 | '.cproject', trim_blocks=True, lstrip_blocks=True) |
The Other Jimmy |
36:96847d42f010 | 280 | self.gen_file('gnuarmeclipse/makefile.targets.tmpl', jinja_ctx, |
The Other Jimmy |
36:96847d42f010 | 281 | 'makefile.targets', trim_blocks=True, lstrip_blocks=True) |
The Other Jimmy |
36:96847d42f010 | 282 | self.gen_file('gnuarmeclipse/mbedignore.tmpl', jinja_ctx, '.mbedignore') |
The Other Jimmy |
36:96847d42f010 | 283 | |
The Other Jimmy |
36:96847d42f010 | 284 | |
The Other Jimmy |
36:96847d42f010 | 285 | print 'Done. Import the \'{0}\' project in Eclipse.'.format(self.project_name) |
The Other Jimmy |
36:96847d42f010 | 286 | |
The Other Jimmy |
36:96847d42f010 | 287 | # override |
The Other Jimmy |
36:96847d42f010 | 288 | @staticmethod |
The Other Jimmy |
36:96847d42f010 | 289 | def build(project_name, log_name="build_log.txt", cleanup=True): |
The Other Jimmy |
36:96847d42f010 | 290 | """ |
The Other Jimmy |
36:96847d42f010 | 291 | Headless build an Eclipse project. |
The Other Jimmy |
36:96847d42f010 | 292 | |
The Other Jimmy |
36:96847d42f010 | 293 | The following steps are performed: |
The Other Jimmy |
36:96847d42f010 | 294 | - a temporary workspace is created, |
The Other Jimmy |
36:96847d42f010 | 295 | - the project is imported, |
The Other Jimmy |
36:96847d42f010 | 296 | - a clean build of all configurations is performed and |
The Other Jimmy |
36:96847d42f010 | 297 | - the temporary workspace is removed. |
The Other Jimmy |
36:96847d42f010 | 298 | |
The Other Jimmy |
36:96847d42f010 | 299 | The build results are in the Debug & Release folders. |
The Other Jimmy |
36:96847d42f010 | 300 | |
The Other Jimmy |
36:96847d42f010 | 301 | All executables (eclipse & toolchain) must be in the PATH. |
The Other Jimmy |
36:96847d42f010 | 302 | |
The Other Jimmy |
36:96847d42f010 | 303 | The general method to start a headless Eclipse build is: |
The Other Jimmy |
36:96847d42f010 | 304 | |
The Other Jimmy |
36:96847d42f010 | 305 | $ eclipse \ |
The Other Jimmy |
36:96847d42f010 | 306 | --launcher.suppressErrors \ |
The Other Jimmy |
36:96847d42f010 | 307 | -nosplash \ |
The Other Jimmy |
36:96847d42f010 | 308 | -application org.eclipse.cdt.managedbuilder.core.headlessbuild \ |
The Other Jimmy |
36:96847d42f010 | 309 | -data /path/to/workspace \ |
The Other Jimmy |
36:96847d42f010 | 310 | -import /path/to/project \ |
The Other Jimmy |
36:96847d42f010 | 311 | -cleanBuild "project[/configuration] | all" |
The Other Jimmy |
36:96847d42f010 | 312 | """ |
The Other Jimmy |
36:96847d42f010 | 313 | |
The Other Jimmy |
36:96847d42f010 | 314 | # TODO: possibly use the log file. |
The Other Jimmy |
36:96847d42f010 | 315 | |
The Other Jimmy |
36:96847d42f010 | 316 | # Create a temporary folder for the workspace. |
The Other Jimmy |
36:96847d42f010 | 317 | tmp_folder = tempfile.mkdtemp() |
The Other Jimmy |
36:96847d42f010 | 318 | |
The Other Jimmy |
36:96847d42f010 | 319 | cmd = [ |
The Other Jimmy |
36:96847d42f010 | 320 | 'eclipse', |
The Other Jimmy |
36:96847d42f010 | 321 | '--launcher.suppressErrors', |
The Other Jimmy |
36:96847d42f010 | 322 | '-nosplash', |
The Other Jimmy |
36:96847d42f010 | 323 | '-application org.eclipse.cdt.managedbuilder.core.headlessbuild', |
The Other Jimmy |
36:96847d42f010 | 324 | '-data', tmp_folder, |
The Other Jimmy |
36:96847d42f010 | 325 | '-import', os.getcwd(), |
The Other Jimmy |
36:96847d42f010 | 326 | '-cleanBuild', project_name |
The Other Jimmy |
36:96847d42f010 | 327 | ] |
The Other Jimmy |
36:96847d42f010 | 328 | |
The Other Jimmy |
36:96847d42f010 | 329 | p = Popen(' '.join(cmd), shell=True, stdout=PIPE, stderr=PIPE) |
The Other Jimmy |
36:96847d42f010 | 330 | out, err = p.communicate() |
The Other Jimmy |
36:96847d42f010 | 331 | ret_code = p.returncode |
The Other Jimmy |
36:96847d42f010 | 332 | stdout_string = "=" * 10 + "STDOUT" + "=" * 10 + "\n" |
The Other Jimmy |
36:96847d42f010 | 333 | err_string = "=" * 10 + "STDERR" + "=" * 10 + "\n" |
The Other Jimmy |
36:96847d42f010 | 334 | err_string += err |
The Other Jimmy |
36:96847d42f010 | 335 | |
The Other Jimmy |
36:96847d42f010 | 336 | ret_string = "SUCCESS\n" |
The Other Jimmy |
36:96847d42f010 | 337 | if ret_code != 0: |
The Other Jimmy |
36:96847d42f010 | 338 | ret_string += "FAILURE\n" |
The Other Jimmy |
36:96847d42f010 | 339 | |
The Other Jimmy |
36:96847d42f010 | 340 | print "%s\n%s\n%s\n%s" % (stdout_string, out, err_string, ret_string) |
The Other Jimmy |
36:96847d42f010 | 341 | |
The Other Jimmy |
36:96847d42f010 | 342 | if log_name: |
The Other Jimmy |
36:96847d42f010 | 343 | # Write the output to the log file |
The Other Jimmy |
36:96847d42f010 | 344 | with open(log_name, 'w+') as f: |
The Other Jimmy |
36:96847d42f010 | 345 | f.write(stdout_string) |
The Other Jimmy |
36:96847d42f010 | 346 | f.write(out) |
The Other Jimmy |
36:96847d42f010 | 347 | f.write(err_string) |
The Other Jimmy |
36:96847d42f010 | 348 | f.write(ret_string) |
The Other Jimmy |
36:96847d42f010 | 349 | |
The Other Jimmy |
36:96847d42f010 | 350 | # Cleanup the exported and built files |
The Other Jimmy |
36:96847d42f010 | 351 | if cleanup: |
The Other Jimmy |
36:96847d42f010 | 352 | if exists(log_name): |
The Other Jimmy |
36:96847d42f010 | 353 | os.remove(log_name) |
The Other Jimmy |
36:96847d42f010 | 354 | os.remove('.project') |
The Other Jimmy |
36:96847d42f010 | 355 | os.remove('.cproject') |
The Other Jimmy |
36:96847d42f010 | 356 | if exists('Debug'): |
The Other Jimmy |
36:96847d42f010 | 357 | shutil.rmtree('Debug') |
The Other Jimmy |
36:96847d42f010 | 358 | if exists('Release'): |
The Other Jimmy |
36:96847d42f010 | 359 | shutil.rmtree('Release') |
The Other Jimmy |
36:96847d42f010 | 360 | if exists('makefile.targets'): |
The Other Jimmy |
36:96847d42f010 | 361 | os.remove('makefile.targets') |
The Other Jimmy |
36:96847d42f010 | 362 | |
The Other Jimmy |
36:96847d42f010 | 363 | # Always remove the temporary folder. |
The Other Jimmy |
36:96847d42f010 | 364 | if exists(tmp_folder): |
The Other Jimmy |
36:96847d42f010 | 365 | shutil.rmtree(tmp_folder) |
The Other Jimmy |
36:96847d42f010 | 366 | |
The Other Jimmy |
36:96847d42f010 | 367 | if ret_code == 0: |
The Other Jimmy |
36:96847d42f010 | 368 | # Return Success |
The Other Jimmy |
36:96847d42f010 | 369 | return 0 |
The Other Jimmy |
36:96847d42f010 | 370 | |
The Other Jimmy |
36:96847d42f010 | 371 | # Seems like something went wrong. |
The Other Jimmy |
36:96847d42f010 | 372 | return -1 |
The Other Jimmy |
36:96847d42f010 | 373 | |
The Other Jimmy |
36:96847d42f010 | 374 | # ------------------------------------------------------------------------- |
The Other Jimmy |
36:96847d42f010 | 375 | |
The Other Jimmy |
36:96847d42f010 | 376 | @staticmethod |
The Other Jimmy |
36:96847d42f010 | 377 | def get_all_profiles(): |
The Other Jimmy |
36:96847d42f010 | 378 | tools_path = dirname(dirname(dirname(__file__))) |
The Other Jimmy |
36:96847d42f010 | 379 | file_names = [join(tools_path, "profiles", fn) for fn in os.listdir( |
The Other Jimmy |
36:96847d42f010 | 380 | join(tools_path, "profiles")) if fn.endswith(".json")] |
The Other Jimmy |
36:96847d42f010 | 381 | |
The Other Jimmy |
36:96847d42f010 | 382 | # print file_names |
The Other Jimmy |
36:96847d42f010 | 383 | |
The Other Jimmy |
36:96847d42f010 | 384 | profile_names = [basename(fn).replace(".json", "") |
The Other Jimmy |
36:96847d42f010 | 385 | for fn in file_names] |
The Other Jimmy |
36:96847d42f010 | 386 | # print profile_names |
The Other Jimmy |
36:96847d42f010 | 387 | |
The Other Jimmy |
36:96847d42f010 | 388 | profiles = {} |
The Other Jimmy |
36:96847d42f010 | 389 | |
The Other Jimmy |
36:96847d42f010 | 390 | for fn in file_names: |
The Other Jimmy |
36:96847d42f010 | 391 | content = load(open(fn)) |
The Other Jimmy |
36:96847d42f010 | 392 | profile_name = basename(fn).replace(".json", "") |
The Other Jimmy |
36:96847d42f010 | 393 | profiles[profile_name] = content |
The Other Jimmy |
36:96847d42f010 | 394 | |
The Other Jimmy |
36:96847d42f010 | 395 | return profiles |
The Other Jimmy |
36:96847d42f010 | 396 | |
The Other Jimmy |
36:96847d42f010 | 397 | # ------------------------------------------------------------------------- |
The Other Jimmy |
36:96847d42f010 | 398 | # Process source files/folders exclusions. |
The Other Jimmy |
36:96847d42f010 | 399 | |
The Other Jimmy |
36:96847d42f010 | 400 | def compute_exclusions(self): |
The Other Jimmy |
36:96847d42f010 | 401 | """ |
The Other Jimmy |
36:96847d42f010 | 402 | With the project root as the only source folder known to CDT, |
The Other Jimmy |
36:96847d42f010 | 403 | based on the list of source files, compute the folders to not |
The Other Jimmy |
36:96847d42f010 | 404 | be included in the build. |
The Other Jimmy |
36:96847d42f010 | 405 | |
The Other Jimmy |
36:96847d42f010 | 406 | The steps are: |
The Other Jimmy |
36:96847d42f010 | 407 | - get the list of source folders, as dirname(source_file) |
The Other Jimmy |
36:96847d42f010 | 408 | - compute the top folders (subfolders of the project folder) |
The Other Jimmy |
36:96847d42f010 | 409 | - iterate all subfolders and add them to a tree, with all |
The Other Jimmy |
36:96847d42f010 | 410 | nodes markes as 'not used' |
The Other Jimmy |
36:96847d42f010 | 411 | - iterate the source folders and mark them as 'used' in the |
The Other Jimmy |
36:96847d42f010 | 412 | tree, including all intermediate nodes |
The Other Jimmy |
36:96847d42f010 | 413 | - recurse the tree and collect all unused folders; descend |
The Other Jimmy |
36:96847d42f010 | 414 | the hierarchy only for used nodes |
The Other Jimmy |
36:96847d42f010 | 415 | """ |
The Other Jimmy |
36:96847d42f010 | 416 | source_folders = [self.filter_dot(s) for s in set(dirname( |
The Other Jimmy |
36:96847d42f010 | 417 | src) for src in self.resources.c_sources + self.resources.cpp_sources + self.resources.s_sources)] |
The Other Jimmy |
36:96847d42f010 | 418 | if '.' in source_folders: |
The Other Jimmy |
36:96847d42f010 | 419 | source_folders.remove('.') |
The Other Jimmy |
36:96847d42f010 | 420 | |
The Other Jimmy |
36:96847d42f010 | 421 | # print 'source folders' |
The Other Jimmy |
36:96847d42f010 | 422 | # print source_folders |
The Other Jimmy |
36:96847d42f010 | 423 | |
The Other Jimmy |
36:96847d42f010 | 424 | # Source folders were converted before and are guaranteed to |
The Other Jimmy |
36:96847d42f010 | 425 | # use the POSIX separator. |
The Other Jimmy |
36:96847d42f010 | 426 | top_folders = [f for f in set(s.split('/')[0] |
The Other Jimmy |
36:96847d42f010 | 427 | for s in source_folders)] |
The Other Jimmy |
36:96847d42f010 | 428 | # print 'top folders' |
The Other Jimmy |
36:96847d42f010 | 429 | # print top_folders |
The Other Jimmy |
36:96847d42f010 | 430 | |
The Other Jimmy |
36:96847d42f010 | 431 | self.source_tree = {} |
The Other Jimmy |
36:96847d42f010 | 432 | for top_folder in top_folders: |
The Other Jimmy |
36:96847d42f010 | 433 | for root, dirs, files in os.walk(top_folder, topdown=True): |
The Other Jimmy |
36:96847d42f010 | 434 | # print root, dirs, files |
The Other Jimmy |
36:96847d42f010 | 435 | |
The Other Jimmy |
36:96847d42f010 | 436 | # Paths returned by os.walk() must be split with os.dep |
The Other Jimmy |
36:96847d42f010 | 437 | # to accomodate Windows weirdness. |
The Other Jimmy |
36:96847d42f010 | 438 | parts = root.split(os.sep) |
The Other Jimmy |
36:96847d42f010 | 439 | |
The Other Jimmy |
36:96847d42f010 | 440 | # Ignore paths that include parts starting with dot. |
The Other Jimmy |
36:96847d42f010 | 441 | skip = False |
The Other Jimmy |
36:96847d42f010 | 442 | for part in parts: |
The Other Jimmy |
36:96847d42f010 | 443 | if part.startswith('.'): |
The Other Jimmy |
36:96847d42f010 | 444 | skip = True |
The Other Jimmy |
36:96847d42f010 | 445 | break |
The Other Jimmy |
36:96847d42f010 | 446 | if skip: |
The Other Jimmy |
36:96847d42f010 | 447 | continue |
The Other Jimmy |
36:96847d42f010 | 448 | |
The Other Jimmy |
36:96847d42f010 | 449 | # Further process only leaf paths, (that do not have |
The Other Jimmy |
36:96847d42f010 | 450 | # sub-folders). |
The Other Jimmy |
36:96847d42f010 | 451 | if len(dirs) == 0: |
The Other Jimmy |
36:96847d42f010 | 452 | # The path is reconstructed using POSIX separators. |
The Other Jimmy |
36:96847d42f010 | 453 | self.add_source_folder_to_tree('/'.join(parts)) |
The Other Jimmy |
36:96847d42f010 | 454 | |
The Other Jimmy |
36:96847d42f010 | 455 | for folder in source_folders: |
The Other Jimmy |
36:96847d42f010 | 456 | self.add_source_folder_to_tree(folder, True) |
The Other Jimmy |
36:96847d42f010 | 457 | |
The Other Jimmy |
36:96847d42f010 | 458 | |
The Other Jimmy |
36:96847d42f010 | 459 | # print self.source_tree |
The Other Jimmy |
36:96847d42f010 | 460 | # self.dump_paths(self.source_tree) |
The Other Jimmy |
36:96847d42f010 | 461 | # self.dump_tree(self.source_tree) |
The Other Jimmy |
36:96847d42f010 | 462 | |
The Other Jimmy |
36:96847d42f010 | 463 | # print 'excludings' |
The Other Jimmy |
36:96847d42f010 | 464 | self.excluded_folders = ['BUILD'] |
The Other Jimmy |
36:96847d42f010 | 465 | self.recurse_excludings(self.source_tree) |
The Other Jimmy |
36:96847d42f010 | 466 | |
The Other Jimmy |
36:96847d42f010 | 467 | print 'Source folders: {0}, with {1} exclusions'.format(len(source_folders), len(self.excluded_folders)) |
The Other Jimmy |
36:96847d42f010 | 468 | |
The Other Jimmy |
36:96847d42f010 | 469 | def add_source_folder_to_tree(self, path, is_used=False): |
The Other Jimmy |
36:96847d42f010 | 470 | """ |
The Other Jimmy |
36:96847d42f010 | 471 | Decompose a path in an array of folder names and create the tree. |
The Other Jimmy |
36:96847d42f010 | 472 | On the second pass the nodes should be already there; mark them |
The Other Jimmy |
36:96847d42f010 | 473 | as used. |
The Other Jimmy |
36:96847d42f010 | 474 | """ |
The Other Jimmy |
36:96847d42f010 | 475 | # print path, is_used |
The Other Jimmy |
36:96847d42f010 | 476 | |
The Other Jimmy |
36:96847d42f010 | 477 | # All paths arriving here are guaranteed to use the POSIX |
The Other Jimmy |
36:96847d42f010 | 478 | # separators, os.walk() paths were also explicitly converted. |
The Other Jimmy |
36:96847d42f010 | 479 | parts = path.split('/') |
The Other Jimmy |
36:96847d42f010 | 480 | # print parts |
The Other Jimmy |
36:96847d42f010 | 481 | node = self.source_tree |
The Other Jimmy |
36:96847d42f010 | 482 | prev = None |
The Other Jimmy |
36:96847d42f010 | 483 | for part in parts: |
The Other Jimmy |
36:96847d42f010 | 484 | if part not in node.keys(): |
The Other Jimmy |
36:96847d42f010 | 485 | new_node = {} |
The Other Jimmy |
36:96847d42f010 | 486 | new_node['name'] = part |
The Other Jimmy |
36:96847d42f010 | 487 | new_node['children'] = {} |
The Other Jimmy |
36:96847d42f010 | 488 | if prev != None: |
The Other Jimmy |
36:96847d42f010 | 489 | new_node['parent'] = prev |
The Other Jimmy |
36:96847d42f010 | 490 | node[part] = new_node |
The Other Jimmy |
36:96847d42f010 | 491 | node[part]['is_used'] = is_used |
The Other Jimmy |
36:96847d42f010 | 492 | prev = node[part] |
The Other Jimmy |
36:96847d42f010 | 493 | node = node[part]['children'] |
The Other Jimmy |
36:96847d42f010 | 494 | |
The Other Jimmy |
36:96847d42f010 | 495 | def recurse_excludings(self, nodes): |
The Other Jimmy |
36:96847d42f010 | 496 | """ |
The Other Jimmy |
36:96847d42f010 | 497 | Recurse the tree and collect all unused folders; descend |
The Other Jimmy |
36:96847d42f010 | 498 | the hierarchy only for used nodes. |
The Other Jimmy |
36:96847d42f010 | 499 | """ |
The Other Jimmy |
36:96847d42f010 | 500 | for k in nodes.keys(): |
The Other Jimmy |
36:96847d42f010 | 501 | node = nodes[k] |
The Other Jimmy |
36:96847d42f010 | 502 | if node['is_used'] == False: |
The Other Jimmy |
36:96847d42f010 | 503 | parts = [] |
The Other Jimmy |
36:96847d42f010 | 504 | cnode = node |
The Other Jimmy |
36:96847d42f010 | 505 | while True: |
The Other Jimmy |
36:96847d42f010 | 506 | parts.insert(0, cnode['name']) |
The Other Jimmy |
36:96847d42f010 | 507 | if 'parent' not in cnode: |
The Other Jimmy |
36:96847d42f010 | 508 | break |
The Other Jimmy |
36:96847d42f010 | 509 | cnode = cnode['parent'] |
The Other Jimmy |
36:96847d42f010 | 510 | |
The Other Jimmy |
36:96847d42f010 | 511 | # Compose a POSIX path. |
The Other Jimmy |
36:96847d42f010 | 512 | path = '/'.join(parts) |
The Other Jimmy |
36:96847d42f010 | 513 | # print path |
The Other Jimmy |
36:96847d42f010 | 514 | self.excluded_folders.append(path) |
The Other Jimmy |
36:96847d42f010 | 515 | else: |
The Other Jimmy |
36:96847d42f010 | 516 | self.recurse_excludings(node['children']) |
The Other Jimmy |
36:96847d42f010 | 517 | |
The Other Jimmy |
36:96847d42f010 | 518 | # ------------------------------------------------------------------------- |
The Other Jimmy |
36:96847d42f010 | 519 | |
The Other Jimmy |
36:96847d42f010 | 520 | @staticmethod |
The Other Jimmy |
36:96847d42f010 | 521 | def filter_dot(str): |
The Other Jimmy |
36:96847d42f010 | 522 | """ |
The Other Jimmy |
36:96847d42f010 | 523 | Remove the './' prefix, if present. |
The Other Jimmy |
36:96847d42f010 | 524 | This function assumes that resources.win_to_unix() |
The Other Jimmy |
36:96847d42f010 | 525 | replaced all windows backslashes with slashes. |
The Other Jimmy |
36:96847d42f010 | 526 | """ |
The Other Jimmy |
36:96847d42f010 | 527 | if str == None: |
The Other Jimmy |
36:96847d42f010 | 528 | return None |
The Other Jimmy |
36:96847d42f010 | 529 | if str[:2] == './': |
The Other Jimmy |
36:96847d42f010 | 530 | return str[2:] |
The Other Jimmy |
36:96847d42f010 | 531 | return str |
The Other Jimmy |
36:96847d42f010 | 532 | |
The Other Jimmy |
36:96847d42f010 | 533 | # ------------------------------------------------------------------------- |
The Other Jimmy |
36:96847d42f010 | 534 | |
The Other Jimmy |
36:96847d42f010 | 535 | def dump_tree(self, nodes, depth=0): |
The Other Jimmy |
36:96847d42f010 | 536 | for k in nodes.keys(): |
The Other Jimmy |
36:96847d42f010 | 537 | node = nodes[k] |
The Other Jimmy |
36:96847d42f010 | 538 | parent_name = node['parent'][ |
The Other Jimmy |
36:96847d42f010 | 539 | 'name'] if 'parent' in node.keys() else '' |
The Other Jimmy |
36:96847d42f010 | 540 | print ' ' * depth, node['name'], node['is_used'], parent_name |
The Other Jimmy |
36:96847d42f010 | 541 | if len(node['children'].keys()) != 0: |
The Other Jimmy |
36:96847d42f010 | 542 | self.dump_tree(node['children'], depth + 1) |
The Other Jimmy |
36:96847d42f010 | 543 | |
The Other Jimmy |
36:96847d42f010 | 544 | def dump_paths(self, nodes, depth=0): |
The Other Jimmy |
36:96847d42f010 | 545 | for k in nodes.keys(): |
The Other Jimmy |
36:96847d42f010 | 546 | node = nodes[k] |
The Other Jimmy |
36:96847d42f010 | 547 | parts = [] |
The Other Jimmy |
36:96847d42f010 | 548 | while True: |
The Other Jimmy |
36:96847d42f010 | 549 | parts.insert(0, node['name']) |
The Other Jimmy |
36:96847d42f010 | 550 | if 'parent' not in node: |
The Other Jimmy |
36:96847d42f010 | 551 | break |
The Other Jimmy |
36:96847d42f010 | 552 | node = node['parent'] |
The Other Jimmy |
36:96847d42f010 | 553 | path = '/'.join(parts) |
The Other Jimmy |
36:96847d42f010 | 554 | print path, nodes[k]['is_used'] |
The Other Jimmy |
36:96847d42f010 | 555 | self.dump_paths(nodes[k]['children'], depth + 1) |
The Other Jimmy |
36:96847d42f010 | 556 | |
The Other Jimmy |
36:96847d42f010 | 557 | # ------------------------------------------------------------------------- |
The Other Jimmy |
36:96847d42f010 | 558 | |
The Other Jimmy |
36:96847d42f010 | 559 | def process_options(self, opts, flags_in): |
The Other Jimmy |
36:96847d42f010 | 560 | """ |
The Other Jimmy |
36:96847d42f010 | 561 | CDT managed projects store lots of build options in separate |
The Other Jimmy |
36:96847d42f010 | 562 | variables, with separate IDs in the .cproject file. |
The Other Jimmy |
36:96847d42f010 | 563 | When the CDT build is started, all these options are brought |
The Other Jimmy |
36:96847d42f010 | 564 | together to compose the compiler and linker command lines. |
The Other Jimmy |
36:96847d42f010 | 565 | |
The Other Jimmy |
36:96847d42f010 | 566 | Here the process is reversed, from the compiler and linker |
The Other Jimmy |
36:96847d42f010 | 567 | command lines, the options are identified and various flags are |
The Other Jimmy |
36:96847d42f010 | 568 | set to control the template generation process. |
The Other Jimmy |
36:96847d42f010 | 569 | |
The Other Jimmy |
36:96847d42f010 | 570 | Once identified, the options are removed from the command lines. |
The Other Jimmy |
36:96847d42f010 | 571 | |
The Other Jimmy |
36:96847d42f010 | 572 | The options that were not identified are options that do not |
The Other Jimmy |
36:96847d42f010 | 573 | have CDT equivalents and will be passed in the 'Other options' |
The Other Jimmy |
36:96847d42f010 | 574 | categories. |
The Other Jimmy |
36:96847d42f010 | 575 | |
The Other Jimmy |
36:96847d42f010 | 576 | Although this process does not have a very complicated logic, |
The Other Jimmy |
36:96847d42f010 | 577 | given the large number of explicit configuration options |
The Other Jimmy |
36:96847d42f010 | 578 | used by the GNU ARM Eclipse managed build plug-in, it is tedious... |
The Other Jimmy |
36:96847d42f010 | 579 | """ |
The Other Jimmy |
36:96847d42f010 | 580 | |
The Other Jimmy |
36:96847d42f010 | 581 | # Make a copy of the flags, to be one by one removed after processing. |
The Other Jimmy |
36:96847d42f010 | 582 | flags = copy.deepcopy(flags_in) |
The Other Jimmy |
36:96847d42f010 | 583 | |
The Other Jimmy |
36:96847d42f010 | 584 | if False: |
The Other Jimmy |
36:96847d42f010 | 585 | |
The Other Jimmy |
36:96847d42f010 | 586 | print 'common_flags', flags['common_flags'] |
The Other Jimmy |
36:96847d42f010 | 587 | print 'asm_flags', flags['asm_flags'] |
The Other Jimmy |
36:96847d42f010 | 588 | print 'c_flags', flags['c_flags'] |
The Other Jimmy |
36:96847d42f010 | 589 | print 'cxx_flags', flags['cxx_flags'] |
The Other Jimmy |
36:96847d42f010 | 590 | print 'ld_flags', flags['ld_flags'] |
The Other Jimmy |
36:96847d42f010 | 591 | |
The Other Jimmy |
36:96847d42f010 | 592 | # Initialise the 'last resort' options where all unrecognised |
The Other Jimmy |
36:96847d42f010 | 593 | # options will be collected. |
The Other Jimmy |
36:96847d42f010 | 594 | opts['as']['other'] = '' |
The Other Jimmy |
36:96847d42f010 | 595 | opts['c']['other'] = '' |
The Other Jimmy |
36:96847d42f010 | 596 | opts['cpp']['other'] = '' |
The Other Jimmy |
36:96847d42f010 | 597 | opts['ld']['other'] = '' |
The Other Jimmy |
36:96847d42f010 | 598 | |
The Other Jimmy |
36:96847d42f010 | 599 | MCPUS = { |
The Other Jimmy |
36:96847d42f010 | 600 | 'Cortex-M0': {'mcpu': 'cortex-m0', 'fpu_unit': None}, |
The Other Jimmy |
36:96847d42f010 | 601 | 'Cortex-M0+': {'mcpu': 'cortex-m0plus', 'fpu_unit': None}, |
The Other Jimmy |
36:96847d42f010 | 602 | 'Cortex-M1': {'mcpu': 'cortex-m1', 'fpu_unit': None}, |
The Other Jimmy |
36:96847d42f010 | 603 | 'Cortex-M3': {'mcpu': 'cortex-m3', 'fpu_unit': None}, |
The Other Jimmy |
36:96847d42f010 | 604 | 'Cortex-M4': {'mcpu': 'cortex-m4', 'fpu_unit': None}, |
The Other Jimmy |
36:96847d42f010 | 605 | 'Cortex-M4F': {'mcpu': 'cortex-m4', 'fpu_unit': 'fpv4spd16'}, |
The Other Jimmy |
36:96847d42f010 | 606 | 'Cortex-M7': {'mcpu': 'cortex-m7', 'fpu_unit': None}, |
The Other Jimmy |
36:96847d42f010 | 607 | 'Cortex-M7F': {'mcpu': 'cortex-m7', 'fpu_unit': 'fpv4spd16'}, |
The Other Jimmy |
36:96847d42f010 | 608 | 'Cortex-M7FD': {'mcpu': 'cortex-m7', 'fpu_unit': 'fpv5d16'}, |
The Other Jimmy |
36:96847d42f010 | 609 | 'Cortex-A9': {'mcpu': 'cortex-a9', 'fpu_unit': 'vfpv3'} |
The Other Jimmy |
36:96847d42f010 | 610 | } |
The Other Jimmy |
36:96847d42f010 | 611 | |
The Other Jimmy |
36:96847d42f010 | 612 | # Remove options that are supplied by CDT |
The Other Jimmy |
36:96847d42f010 | 613 | self.remove_option(flags['common_flags'], '-c') |
The Other Jimmy |
36:96847d42f010 | 614 | self.remove_option(flags['common_flags'], '-MMD') |
The Other Jimmy |
36:96847d42f010 | 615 | |
The Other Jimmy |
36:96847d42f010 | 616 | # As 'plan B', get the CPU from the target definition. |
The Other Jimmy |
36:96847d42f010 | 617 | core = self.toolchain.target.core |
The Other Jimmy |
36:96847d42f010 | 618 | |
The Other Jimmy |
36:96847d42f010 | 619 | opts['common']['arm.target.family'] = None |
The Other Jimmy |
36:96847d42f010 | 620 | |
The Other Jimmy |
36:96847d42f010 | 621 | # cortex-m0, cortex-m0-small-multiply, cortex-m0plus, |
The Other Jimmy |
36:96847d42f010 | 622 | # cortex-m0plus-small-multiply, cortex-m1, cortex-m1-small-multiply, |
The Other Jimmy |
36:96847d42f010 | 623 | # cortex-m3, cortex-m4, cortex-m7. |
The Other Jimmy |
36:96847d42f010 | 624 | str = self.find_options(flags['common_flags'], '-mcpu=') |
The Other Jimmy |
36:96847d42f010 | 625 | if str != None: |
The Other Jimmy |
36:96847d42f010 | 626 | opts['common']['arm.target.family'] = str[len('-mcpu='):] |
The Other Jimmy |
36:96847d42f010 | 627 | self.remove_option(flags['common_flags'], str) |
The Other Jimmy |
36:96847d42f010 | 628 | self.remove_option(flags['ld_flags'], str) |
The Other Jimmy |
36:96847d42f010 | 629 | else: |
The Other Jimmy |
36:96847d42f010 | 630 | if core not in MCPUS: |
The Other Jimmy |
36:96847d42f010 | 631 | raise NotSupportedException( |
The Other Jimmy |
36:96847d42f010 | 632 | 'Target core {0} not supported.'.format(core)) |
The Other Jimmy |
36:96847d42f010 | 633 | opts['common']['arm.target.family'] = MCPUS[core]['mcpu'] |
The Other Jimmy |
36:96847d42f010 | 634 | |
The Other Jimmy |
36:96847d42f010 | 635 | opts['common']['arm.target.arch'] = 'none' |
The Other Jimmy |
36:96847d42f010 | 636 | str = self.find_options(flags['common_flags'], '-march=') |
The Other Jimmy |
36:96847d42f010 | 637 | arch = str[len('-march='):] |
The Other Jimmy |
36:96847d42f010 | 638 | archs = {'armv6-m': 'armv6-m', 'armv7-m': 'armv7-m', 'armv7-a': 'armv7-a'} |
The Other Jimmy |
36:96847d42f010 | 639 | if arch in archs: |
The Other Jimmy |
36:96847d42f010 | 640 | opts['common']['arm.target.arch'] = archs[arch] |
The Other Jimmy |
36:96847d42f010 | 641 | self.remove_option(flags['common_flags'], str) |
The Other Jimmy |
36:96847d42f010 | 642 | |
The Other Jimmy |
36:96847d42f010 | 643 | opts['common']['arm.target.instructionset'] = 'thumb' |
The Other Jimmy |
36:96847d42f010 | 644 | if '-mthumb' in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 645 | self.remove_option(flags['common_flags'], '-mthumb') |
The Other Jimmy |
36:96847d42f010 | 646 | self.remove_option(flags['ld_flags'], '-mthumb') |
The Other Jimmy |
36:96847d42f010 | 647 | elif '-marm' in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 648 | opts['common']['arm.target.instructionset'] = 'arm' |
The Other Jimmy |
36:96847d42f010 | 649 | self.remove_option(flags['common_flags'], '-marm') |
The Other Jimmy |
36:96847d42f010 | 650 | self.remove_option(flags['ld_flags'], '-marm') |
The Other Jimmy |
36:96847d42f010 | 651 | |
The Other Jimmy |
36:96847d42f010 | 652 | opts['common']['arm.target.thumbinterwork'] = False |
The Other Jimmy |
36:96847d42f010 | 653 | if '-mthumb-interwork' in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 654 | opts['common']['arm.target.thumbinterwork'] = True |
The Other Jimmy |
36:96847d42f010 | 655 | self.remove_option(flags['common_flags'], '-mthumb-interwork') |
The Other Jimmy |
36:96847d42f010 | 656 | |
The Other Jimmy |
36:96847d42f010 | 657 | opts['common']['arm.target.endianness'] = None |
The Other Jimmy |
36:96847d42f010 | 658 | if '-mlittle-endian' in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 659 | opts['common']['arm.target.endianness'] = 'little' |
The Other Jimmy |
36:96847d42f010 | 660 | self.remove_option(flags['common_flags'], '-mlittle-endian') |
The Other Jimmy |
36:96847d42f010 | 661 | elif '-mbig-endian' in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 662 | opts['common']['arm.target.endianness'] = 'big' |
The Other Jimmy |
36:96847d42f010 | 663 | self.remove_option(flags['common_flags'], '-mbig-endian') |
The Other Jimmy |
36:96847d42f010 | 664 | |
The Other Jimmy |
36:96847d42f010 | 665 | opts['common']['arm.target.fpu.unit'] = None |
The Other Jimmy |
36:96847d42f010 | 666 | # default, fpv4spd16, fpv5d16, fpv5spd16 |
The Other Jimmy |
36:96847d42f010 | 667 | str = self.find_options(flags['common_flags'], '-mfpu=') |
The Other Jimmy |
36:96847d42f010 | 668 | if str != None: |
The Other Jimmy |
36:96847d42f010 | 669 | fpu = str[len('-mfpu='):] |
The Other Jimmy |
36:96847d42f010 | 670 | fpus = { |
The Other Jimmy |
36:96847d42f010 | 671 | 'fpv4-sp-d16': 'fpv4spd16', |
The Other Jimmy |
36:96847d42f010 | 672 | 'fpv5-d16': 'fpv5d16', |
The Other Jimmy |
36:96847d42f010 | 673 | 'fpv5-sp-d16': 'fpv5spd16' |
The Other Jimmy |
36:96847d42f010 | 674 | } |
The Other Jimmy |
36:96847d42f010 | 675 | if fpu in fpus: |
The Other Jimmy |
36:96847d42f010 | 676 | opts['common']['arm.target.fpu.unit'] = fpus[fpu] |
The Other Jimmy |
36:96847d42f010 | 677 | |
The Other Jimmy |
36:96847d42f010 | 678 | self.remove_option(flags['common_flags'], str) |
The Other Jimmy |
36:96847d42f010 | 679 | self.remove_option(flags['ld_flags'], str) |
The Other Jimmy |
36:96847d42f010 | 680 | if opts['common']['arm.target.fpu.unit'] == None: |
The Other Jimmy |
36:96847d42f010 | 681 | if core not in MCPUS: |
The Other Jimmy |
36:96847d42f010 | 682 | raise NotSupportedException( |
The Other Jimmy |
36:96847d42f010 | 683 | 'Target core {0} not supported.'.format(core)) |
The Other Jimmy |
36:96847d42f010 | 684 | if MCPUS[core]['fpu_unit']: |
The Other Jimmy |
36:96847d42f010 | 685 | opts['common'][ |
The Other Jimmy |
36:96847d42f010 | 686 | 'arm.target.fpu.unit'] = MCPUS[core]['fpu_unit'] |
The Other Jimmy |
36:96847d42f010 | 687 | |
The Other Jimmy |
36:96847d42f010 | 688 | # soft, softfp, hard. |
The Other Jimmy |
36:96847d42f010 | 689 | str = self.find_options(flags['common_flags'], '-mfloat-abi=') |
The Other Jimmy |
36:96847d42f010 | 690 | if str != None: |
The Other Jimmy |
36:96847d42f010 | 691 | opts['common']['arm.target.fpu.abi'] = str[ |
The Other Jimmy |
36:96847d42f010 | 692 | len('-mfloat-abi='):] |
The Other Jimmy |
36:96847d42f010 | 693 | self.remove_option(flags['common_flags'], str) |
The Other Jimmy |
36:96847d42f010 | 694 | self.remove_option(flags['ld_flags'], str) |
The Other Jimmy |
36:96847d42f010 | 695 | |
The Other Jimmy |
36:96847d42f010 | 696 | opts['common']['arm.target.unalignedaccess'] = None |
The Other Jimmy |
36:96847d42f010 | 697 | if '-munaligned-access' in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 698 | opts['common']['arm.target.unalignedaccess'] = 'enabled' |
The Other Jimmy |
36:96847d42f010 | 699 | self.remove_option(flags['common_flags'], '-munaligned-access') |
The Other Jimmy |
36:96847d42f010 | 700 | elif '-mno-unaligned-access' in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 701 | opts['common']['arm.target.unalignedaccess'] = 'disabled' |
The Other Jimmy |
36:96847d42f010 | 702 | self.remove_option(flags['common_flags'], '-mno-unaligned-access') |
The Other Jimmy |
36:96847d42f010 | 703 | |
The Other Jimmy |
36:96847d42f010 | 704 | # Default optimisation level for Release. |
The Other Jimmy |
36:96847d42f010 | 705 | opts['common']['optimization.level'] = '-Os' |
The Other Jimmy |
36:96847d42f010 | 706 | |
The Other Jimmy |
36:96847d42f010 | 707 | # If the project defines an optimisation level, it is used |
The Other Jimmy |
36:96847d42f010 | 708 | # only for the Release configuration, the Debug one used '-Og'. |
The Other Jimmy |
36:96847d42f010 | 709 | str = self.find_options(flags['common_flags'], '-O') |
The Other Jimmy |
36:96847d42f010 | 710 | if str != None: |
The Other Jimmy |
36:96847d42f010 | 711 | levels = { |
The Other Jimmy |
36:96847d42f010 | 712 | '-O0': 'none', '-O1': 'optimize', '-O2': 'more', |
The Other Jimmy |
36:96847d42f010 | 713 | '-O3': 'most', '-Os': 'size', '-Og': 'debug' |
The Other Jimmy |
36:96847d42f010 | 714 | } |
The Other Jimmy |
36:96847d42f010 | 715 | if str in levels: |
The Other Jimmy |
36:96847d42f010 | 716 | opts['common']['optimization.level'] = levels[str] |
The Other Jimmy |
36:96847d42f010 | 717 | self.remove_option(flags['common_flags'], str) |
The Other Jimmy |
36:96847d42f010 | 718 | |
The Other Jimmy |
36:96847d42f010 | 719 | include_files = [] |
The Other Jimmy |
36:96847d42f010 | 720 | for all_flags in [flags['common_flags'], flags['c_flags'], flags['cxx_flags']]: |
The Other Jimmy |
36:96847d42f010 | 721 | while '-include' in all_flags: |
The Other Jimmy |
36:96847d42f010 | 722 | ix = all_flags.index('-include') |
The Other Jimmy |
36:96847d42f010 | 723 | str = all_flags[ix + 1] |
The Other Jimmy |
36:96847d42f010 | 724 | if str not in include_files: |
The Other Jimmy |
36:96847d42f010 | 725 | include_files.append(str) |
The Other Jimmy |
36:96847d42f010 | 726 | self.remove_option(all_flags, '-include') |
The Other Jimmy |
36:96847d42f010 | 727 | self.remove_option(all_flags, str) |
The Other Jimmy |
36:96847d42f010 | 728 | |
The Other Jimmy |
36:96847d42f010 | 729 | opts['common']['include_files'] = include_files |
The Other Jimmy |
36:96847d42f010 | 730 | |
The Other Jimmy |
36:96847d42f010 | 731 | if '-ansi' in flags['c_flags']: |
The Other Jimmy |
36:96847d42f010 | 732 | opts['c']['compiler.std'] = '-ansi' |
The Other Jimmy |
36:96847d42f010 | 733 | self.remove_option(flags['c_flags'], str) |
The Other Jimmy |
36:96847d42f010 | 734 | else: |
The Other Jimmy |
36:96847d42f010 | 735 | str = self.find_options(flags['c_flags'], '-std') |
The Other Jimmy |
36:96847d42f010 | 736 | std = str[len('-std='):] |
The Other Jimmy |
36:96847d42f010 | 737 | c_std = { |
The Other Jimmy |
36:96847d42f010 | 738 | 'c90': 'c90', 'c89': 'c90', 'gnu90': 'gnu90', 'gnu89': 'gnu90', |
The Other Jimmy |
36:96847d42f010 | 739 | 'c99': 'c99', 'c9x': 'c99', 'gnu99': 'gnu99', 'gnu9x': 'gnu98', |
The Other Jimmy |
36:96847d42f010 | 740 | 'c11': 'c11', 'c1x': 'c11', 'gnu11': 'gnu11', 'gnu1x': 'gnu11' |
The Other Jimmy |
36:96847d42f010 | 741 | } |
The Other Jimmy |
36:96847d42f010 | 742 | if std in c_std: |
The Other Jimmy |
36:96847d42f010 | 743 | opts['c']['compiler.std'] = c_std[std] |
The Other Jimmy |
36:96847d42f010 | 744 | self.remove_option(flags['c_flags'], str) |
The Other Jimmy |
36:96847d42f010 | 745 | |
The Other Jimmy |
36:96847d42f010 | 746 | if '-ansi' in flags['cxx_flags']: |
The Other Jimmy |
36:96847d42f010 | 747 | opts['cpp']['compiler.std'] = '-ansi' |
The Other Jimmy |
36:96847d42f010 | 748 | self.remove_option(flags['cxx_flags'], str) |
The Other Jimmy |
36:96847d42f010 | 749 | else: |
The Other Jimmy |
36:96847d42f010 | 750 | str = self.find_options(flags['cxx_flags'], '-std') |
The Other Jimmy |
36:96847d42f010 | 751 | std = str[len('-std='):] |
The Other Jimmy |
36:96847d42f010 | 752 | cpp_std = { |
The Other Jimmy |
36:96847d42f010 | 753 | 'c++98': 'cpp98', 'c++03': 'cpp98', |
The Other Jimmy |
36:96847d42f010 | 754 | 'gnu++98': 'gnucpp98', 'gnu++03': 'gnucpp98', |
The Other Jimmy |
36:96847d42f010 | 755 | 'c++0x': 'cpp0x', 'gnu++0x': 'gnucpp0x', |
The Other Jimmy |
36:96847d42f010 | 756 | 'c++11': 'cpp11', 'gnu++11': 'gnucpp11', |
The Other Jimmy |
36:96847d42f010 | 757 | 'c++1y': 'cpp1y', 'gnu++1y': 'gnucpp1y', |
The Other Jimmy |
36:96847d42f010 | 758 | 'c++14': 'cpp14', 'gnu++14': 'gnucpp14', |
The Other Jimmy |
36:96847d42f010 | 759 | 'c++1z': 'cpp1z', 'gnu++1z': 'gnucpp1z', |
The Other Jimmy |
36:96847d42f010 | 760 | } |
The Other Jimmy |
36:96847d42f010 | 761 | if std in cpp_std: |
The Other Jimmy |
36:96847d42f010 | 762 | opts['cpp']['compiler.std'] = cpp_std[std] |
The Other Jimmy |
36:96847d42f010 | 763 | self.remove_option(flags['cxx_flags'], str) |
The Other Jimmy |
36:96847d42f010 | 764 | |
The Other Jimmy |
36:96847d42f010 | 765 | # Common optimisation options. |
The Other Jimmy |
36:96847d42f010 | 766 | optimization_options = { |
The Other Jimmy |
36:96847d42f010 | 767 | '-fmessage-length=0': 'optimization.messagelength', |
The Other Jimmy |
36:96847d42f010 | 768 | '-fsigned-char': 'optimization.signedchar', |
The Other Jimmy |
36:96847d42f010 | 769 | '-ffunction-sections': 'optimization.functionsections', |
The Other Jimmy |
36:96847d42f010 | 770 | '-fdata-sections': 'optimization.datasections', |
The Other Jimmy |
36:96847d42f010 | 771 | '-fno-common': 'optimization.nocommon', |
The Other Jimmy |
36:96847d42f010 | 772 | '-fno-inline-functions': 'optimization.noinlinefunctions', |
The Other Jimmy |
36:96847d42f010 | 773 | '-ffreestanding': 'optimization.freestanding', |
The Other Jimmy |
36:96847d42f010 | 774 | '-fno-builtin': 'optimization.nobuiltin', |
The Other Jimmy |
36:96847d42f010 | 775 | '-fsingle-precision-constant': 'optimization.spconstant', |
The Other Jimmy |
36:96847d42f010 | 776 | '-fPIC': 'optimization.PIC', |
The Other Jimmy |
36:96847d42f010 | 777 | '-fno-move-loop-invariants': 'optimization.nomoveloopinvariants', |
The Other Jimmy |
36:96847d42f010 | 778 | } |
The Other Jimmy |
36:96847d42f010 | 779 | |
The Other Jimmy |
36:96847d42f010 | 780 | for option in optimization_options: |
The Other Jimmy |
36:96847d42f010 | 781 | opts['common'][optimization_options[option]] = False |
The Other Jimmy |
36:96847d42f010 | 782 | if option in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 783 | opts['common'][optimization_options[option]] = True |
The Other Jimmy |
36:96847d42f010 | 784 | self.remove_option(flags['common_flags'], option) |
The Other Jimmy |
36:96847d42f010 | 785 | |
The Other Jimmy |
36:96847d42f010 | 786 | # Common warning options. |
The Other Jimmy |
36:96847d42f010 | 787 | warning_options = { |
The Other Jimmy |
36:96847d42f010 | 788 | '-fsyntax-only': 'warnings.syntaxonly', |
The Other Jimmy |
36:96847d42f010 | 789 | '-pedantic': 'warnings.pedantic', |
The Other Jimmy |
36:96847d42f010 | 790 | '-pedantic-errors': 'warnings.pedanticerrors', |
The Other Jimmy |
36:96847d42f010 | 791 | '-w': 'warnings.nowarn', |
The Other Jimmy |
36:96847d42f010 | 792 | '-Wunused': 'warnings.unused', |
The Other Jimmy |
36:96847d42f010 | 793 | '-Wuninitialized': 'warnings.uninitialized', |
The Other Jimmy |
36:96847d42f010 | 794 | '-Wall': 'warnings.allwarn', |
The Other Jimmy |
36:96847d42f010 | 795 | '-Wextra': 'warnings.extrawarn', |
The Other Jimmy |
36:96847d42f010 | 796 | '-Wmissing-declarations': 'warnings.missingdeclaration', |
The Other Jimmy |
36:96847d42f010 | 797 | '-Wconversion': 'warnings.conversion', |
The Other Jimmy |
36:96847d42f010 | 798 | '-Wpointer-arith': 'warnings.pointerarith', |
The Other Jimmy |
36:96847d42f010 | 799 | '-Wpadded': 'warnings.padded', |
The Other Jimmy |
36:96847d42f010 | 800 | '-Wshadow': 'warnings.shadow', |
The Other Jimmy |
36:96847d42f010 | 801 | '-Wlogical-op': 'warnings.logicalop', |
The Other Jimmy |
36:96847d42f010 | 802 | '-Waggregate-return': 'warnings.agreggatereturn', |
The Other Jimmy |
36:96847d42f010 | 803 | '-Wfloat-equal': 'warnings.floatequal', |
The Other Jimmy |
36:96847d42f010 | 804 | '-Werror': 'warnings.toerrors', |
The Other Jimmy |
36:96847d42f010 | 805 | } |
The Other Jimmy |
36:96847d42f010 | 806 | |
The Other Jimmy |
36:96847d42f010 | 807 | for option in warning_options: |
The Other Jimmy |
36:96847d42f010 | 808 | opts['common'][warning_options[option]] = False |
The Other Jimmy |
36:96847d42f010 | 809 | if option in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 810 | opts['common'][warning_options[option]] = True |
The Other Jimmy |
36:96847d42f010 | 811 | self.remove_option(flags['common_flags'], option) |
The Other Jimmy |
36:96847d42f010 | 812 | |
The Other Jimmy |
36:96847d42f010 | 813 | # Common debug options. |
The Other Jimmy |
36:96847d42f010 | 814 | debug_levels = { |
The Other Jimmy |
36:96847d42f010 | 815 | '-g': 'default', |
The Other Jimmy |
36:96847d42f010 | 816 | '-g1': 'minimal', |
The Other Jimmy |
36:96847d42f010 | 817 | '-g3': 'max', |
The Other Jimmy |
36:96847d42f010 | 818 | } |
The Other Jimmy |
36:96847d42f010 | 819 | opts['common']['debugging.level'] = 'none' |
The Other Jimmy |
36:96847d42f010 | 820 | for option in debug_levels: |
The Other Jimmy |
36:96847d42f010 | 821 | if option in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 822 | opts['common'][ |
The Other Jimmy |
36:96847d42f010 | 823 | 'debugging.level'] = debug_levels[option] |
The Other Jimmy |
36:96847d42f010 | 824 | self.remove_option(flags['common_flags'], option) |
The Other Jimmy |
36:96847d42f010 | 825 | |
The Other Jimmy |
36:96847d42f010 | 826 | debug_formats = { |
The Other Jimmy |
36:96847d42f010 | 827 | '-ggdb': 'gdb', |
The Other Jimmy |
36:96847d42f010 | 828 | '-gstabs': 'stabs', |
The Other Jimmy |
36:96847d42f010 | 829 | '-gstabs+': 'stabsplus', |
The Other Jimmy |
36:96847d42f010 | 830 | '-gdwarf-2': 'dwarf2', |
The Other Jimmy |
36:96847d42f010 | 831 | '-gdwarf-3': 'dwarf3', |
The Other Jimmy |
36:96847d42f010 | 832 | '-gdwarf-4': 'dwarf4', |
The Other Jimmy |
36:96847d42f010 | 833 | '-gdwarf-5': 'dwarf5', |
The Other Jimmy |
36:96847d42f010 | 834 | } |
The Other Jimmy |
36:96847d42f010 | 835 | |
The Other Jimmy |
36:96847d42f010 | 836 | opts['common']['debugging.format'] = '' |
The Other Jimmy |
36:96847d42f010 | 837 | for option in debug_levels: |
The Other Jimmy |
36:96847d42f010 | 838 | if option in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 839 | opts['common'][ |
The Other Jimmy |
36:96847d42f010 | 840 | 'debugging.format'] = debug_formats[option] |
The Other Jimmy |
36:96847d42f010 | 841 | self.remove_option(flags['common_flags'], option) |
The Other Jimmy |
36:96847d42f010 | 842 | |
The Other Jimmy |
36:96847d42f010 | 843 | opts['common']['debugging.prof'] = False |
The Other Jimmy |
36:96847d42f010 | 844 | if '-p' in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 845 | opts['common']['debugging.prof'] = True |
The Other Jimmy |
36:96847d42f010 | 846 | self.remove_option(flags['common_flags'], '-p') |
The Other Jimmy |
36:96847d42f010 | 847 | |
The Other Jimmy |
36:96847d42f010 | 848 | opts['common']['debugging.gprof'] = False |
The Other Jimmy |
36:96847d42f010 | 849 | if '-pg' in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 850 | opts['common']['debugging.gprof'] = True |
The Other Jimmy |
36:96847d42f010 | 851 | self.remove_option(flags['common_flags'], '-gp') |
The Other Jimmy |
36:96847d42f010 | 852 | |
The Other Jimmy |
36:96847d42f010 | 853 | # Assembler options. |
The Other Jimmy |
36:96847d42f010 | 854 | opts['as']['usepreprocessor'] = False |
The Other Jimmy |
36:96847d42f010 | 855 | while '-x' in flags['asm_flags']: |
The Other Jimmy |
36:96847d42f010 | 856 | ix = flags['asm_flags'].index('-x') |
The Other Jimmy |
36:96847d42f010 | 857 | str = flags['asm_flags'][ix + 1] |
The Other Jimmy |
36:96847d42f010 | 858 | |
The Other Jimmy |
36:96847d42f010 | 859 | if str == 'assembler-with-cpp': |
The Other Jimmy |
36:96847d42f010 | 860 | opts['as']['usepreprocessor'] = True |
The Other Jimmy |
36:96847d42f010 | 861 | else: |
The Other Jimmy |
36:96847d42f010 | 862 | # Collect all other assembler options. |
The Other Jimmy |
36:96847d42f010 | 863 | opts['as']['other'] += ' -x ' + str |
The Other Jimmy |
36:96847d42f010 | 864 | |
The Other Jimmy |
36:96847d42f010 | 865 | self.remove_option(flags['asm_flags'], '-x') |
The Other Jimmy |
36:96847d42f010 | 866 | self.remove_option(flags['asm_flags'], 'assembler-with-cpp') |
The Other Jimmy |
36:96847d42f010 | 867 | |
The Other Jimmy |
36:96847d42f010 | 868 | opts['as']['nostdinc'] = False |
The Other Jimmy |
36:96847d42f010 | 869 | if '-nostdinc' in flags['asm_flags']: |
The Other Jimmy |
36:96847d42f010 | 870 | opts['as']['nostdinc'] = True |
The Other Jimmy |
36:96847d42f010 | 871 | self.remove_option(flags['asm_flags'], '-nostdinc') |
The Other Jimmy |
36:96847d42f010 | 872 | |
The Other Jimmy |
36:96847d42f010 | 873 | opts['as']['verbose'] = False |
The Other Jimmy |
36:96847d42f010 | 874 | if '-v' in flags['asm_flags']: |
The Other Jimmy |
36:96847d42f010 | 875 | opts['as']['verbose'] = True |
The Other Jimmy |
36:96847d42f010 | 876 | self.remove_option(flags['asm_flags'], '-v') |
The Other Jimmy |
36:96847d42f010 | 877 | |
The Other Jimmy |
36:96847d42f010 | 878 | # C options. |
The Other Jimmy |
36:96847d42f010 | 879 | opts['c']['nostdinc'] = False |
The Other Jimmy |
36:96847d42f010 | 880 | if '-nostdinc' in flags['c_flags']: |
The Other Jimmy |
36:96847d42f010 | 881 | opts['c']['nostdinc'] = True |
The Other Jimmy |
36:96847d42f010 | 882 | self.remove_option(flags['c_flags'], '-nostdinc') |
The Other Jimmy |
36:96847d42f010 | 883 | |
The Other Jimmy |
36:96847d42f010 | 884 | opts['c']['verbose'] = False |
The Other Jimmy |
36:96847d42f010 | 885 | if '-v' in flags['c_flags']: |
The Other Jimmy |
36:96847d42f010 | 886 | opts['c']['verbose'] = True |
The Other Jimmy |
36:96847d42f010 | 887 | self.remove_option(flags['c_flags'], '-v') |
The Other Jimmy |
36:96847d42f010 | 888 | |
The Other Jimmy |
36:96847d42f010 | 889 | warning_options = { |
The Other Jimmy |
36:96847d42f010 | 890 | '-Wmissing-prototypes': 'warnings.missingprototypes', |
The Other Jimmy |
36:96847d42f010 | 891 | '-Wstrict-prototypes': 'warnings.strictprototypes', |
The Other Jimmy |
36:96847d42f010 | 892 | '-Wbad-function-cast': 'warnings.badfunctioncast', |
The Other Jimmy |
36:96847d42f010 | 893 | } |
The Other Jimmy |
36:96847d42f010 | 894 | |
The Other Jimmy |
36:96847d42f010 | 895 | for option in warning_options: |
The Other Jimmy |
36:96847d42f010 | 896 | opts['c'][warning_options[option]] = False |
The Other Jimmy |
36:96847d42f010 | 897 | if option in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 898 | opts['c'][warning_options[option]] = True |
The Other Jimmy |
36:96847d42f010 | 899 | self.remove_option(flags['common_flags'], option) |
The Other Jimmy |
36:96847d42f010 | 900 | |
The Other Jimmy |
36:96847d42f010 | 901 | # C++ options. |
The Other Jimmy |
36:96847d42f010 | 902 | opts['cpp']['nostdinc'] = False |
The Other Jimmy |
36:96847d42f010 | 903 | if '-nostdinc' in flags['cxx_flags']: |
The Other Jimmy |
36:96847d42f010 | 904 | opts['cpp']['nostdinc'] = True |
The Other Jimmy |
36:96847d42f010 | 905 | self.remove_option(flags['cxx_flags'], '-nostdinc') |
The Other Jimmy |
36:96847d42f010 | 906 | |
The Other Jimmy |
36:96847d42f010 | 907 | opts['cpp']['nostdincpp'] = False |
The Other Jimmy |
36:96847d42f010 | 908 | if '-nostdinc++' in flags['cxx_flags']: |
The Other Jimmy |
36:96847d42f010 | 909 | opts['cpp']['nostdincpp'] = True |
The Other Jimmy |
36:96847d42f010 | 910 | self.remove_option(flags['cxx_flags'], '-nostdinc++') |
The Other Jimmy |
36:96847d42f010 | 911 | |
The Other Jimmy |
36:96847d42f010 | 912 | optimization_options = { |
The Other Jimmy |
36:96847d42f010 | 913 | '-fno-exceptions': 'optimization.noexceptions', |
The Other Jimmy |
36:96847d42f010 | 914 | '-fno-rtti': 'optimization.nortti', |
The Other Jimmy |
36:96847d42f010 | 915 | '-fno-use-cxa-atexit': 'optimization.nousecxaatexit', |
The Other Jimmy |
36:96847d42f010 | 916 | '-fno-threadsafe-statics': 'optimization.nothreadsafestatics', |
The Other Jimmy |
36:96847d42f010 | 917 | } |
The Other Jimmy |
36:96847d42f010 | 918 | |
The Other Jimmy |
36:96847d42f010 | 919 | for option in optimization_options: |
The Other Jimmy |
36:96847d42f010 | 920 | opts['cpp'][optimization_options[option]] = False |
The Other Jimmy |
36:96847d42f010 | 921 | if option in flags['cxx_flags']: |
The Other Jimmy |
36:96847d42f010 | 922 | opts['cpp'][optimization_options[option]] = True |
The Other Jimmy |
36:96847d42f010 | 923 | self.remove_option(flags['cxx_flags'], option) |
The Other Jimmy |
36:96847d42f010 | 924 | if option in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 925 | opts['cpp'][optimization_options[option]] = True |
The Other Jimmy |
36:96847d42f010 | 926 | self.remove_option(flags['common_flags'], option) |
The Other Jimmy |
36:96847d42f010 | 927 | |
The Other Jimmy |
36:96847d42f010 | 928 | warning_options = { |
The Other Jimmy |
36:96847d42f010 | 929 | '-Wabi': 'warnabi', |
The Other Jimmy |
36:96847d42f010 | 930 | '-Wctor-dtor-privacy': 'warnings.ctordtorprivacy', |
The Other Jimmy |
36:96847d42f010 | 931 | '-Wnoexcept': 'warnings.noexcept', |
The Other Jimmy |
36:96847d42f010 | 932 | '-Wnon-virtual-dtor': 'warnings.nonvirtualdtor', |
The Other Jimmy |
36:96847d42f010 | 933 | '-Wstrict-null-sentinel': 'warnings.strictnullsentinel', |
The Other Jimmy |
36:96847d42f010 | 934 | '-Wsign-promo': 'warnings.signpromo', |
The Other Jimmy |
36:96847d42f010 | 935 | '-Weffc++': 'warneffc', |
The Other Jimmy |
36:96847d42f010 | 936 | } |
The Other Jimmy |
36:96847d42f010 | 937 | |
The Other Jimmy |
36:96847d42f010 | 938 | for option in warning_options: |
The Other Jimmy |
36:96847d42f010 | 939 | opts['cpp'][warning_options[option]] = False |
The Other Jimmy |
36:96847d42f010 | 940 | if option in flags['cxx_flags']: |
The Other Jimmy |
36:96847d42f010 | 941 | opts['cpp'][warning_options[option]] = True |
The Other Jimmy |
36:96847d42f010 | 942 | self.remove_option(flags['cxx_flags'], option) |
The Other Jimmy |
36:96847d42f010 | 943 | if option in flags['common_flags']: |
The Other Jimmy |
36:96847d42f010 | 944 | opts['cpp'][warning_options[option]] = True |
The Other Jimmy |
36:96847d42f010 | 945 | self.remove_option(flags['common_flags'], option) |
The Other Jimmy |
36:96847d42f010 | 946 | |
The Other Jimmy |
36:96847d42f010 | 947 | opts['cpp']['verbose'] = False |
The Other Jimmy |
36:96847d42f010 | 948 | if '-v' in flags['cxx_flags']: |
The Other Jimmy |
36:96847d42f010 | 949 | opts['cpp']['verbose'] = True |
The Other Jimmy |
36:96847d42f010 | 950 | self.remove_option(flags['cxx_flags'], '-v') |
The Other Jimmy |
36:96847d42f010 | 951 | |
The Other Jimmy |
36:96847d42f010 | 952 | # Linker options. |
The Other Jimmy |
36:96847d42f010 | 953 | linker_options = { |
The Other Jimmy |
36:96847d42f010 | 954 | '-nostartfiles': 'nostart', |
The Other Jimmy |
36:96847d42f010 | 955 | '-nodefaultlibs': 'nodeflibs', |
The Other Jimmy |
36:96847d42f010 | 956 | '-nostdlib': 'nostdlibs', |
The Other Jimmy |
36:96847d42f010 | 957 | } |
The Other Jimmy |
36:96847d42f010 | 958 | |
The Other Jimmy |
36:96847d42f010 | 959 | for option in linker_options: |
The Other Jimmy |
36:96847d42f010 | 960 | opts['ld'][linker_options[option]] = False |
The Other Jimmy |
36:96847d42f010 | 961 | if option in flags['ld_flags']: |
The Other Jimmy |
36:96847d42f010 | 962 | opts['ld'][linker_options[option]] = True |
The Other Jimmy |
36:96847d42f010 | 963 | self.remove_option(flags['ld_flags'], option) |
The Other Jimmy |
36:96847d42f010 | 964 | |
The Other Jimmy |
36:96847d42f010 | 965 | opts['ld']['gcsections'] = False |
The Other Jimmy |
36:96847d42f010 | 966 | if '-Wl,--gc-sections' in flags['ld_flags']: |
The Other Jimmy |
36:96847d42f010 | 967 | opts['ld']['gcsections'] = True |
The Other Jimmy |
36:96847d42f010 | 968 | self.remove_option(flags['ld_flags'], '-Wl,--gc-sections') |
The Other Jimmy |
36:96847d42f010 | 969 | |
The Other Jimmy |
36:96847d42f010 | 970 | opts['ld']['flags'] = [] |
The Other Jimmy |
36:96847d42f010 | 971 | to_remove = [] |
The Other Jimmy |
36:96847d42f010 | 972 | for opt in flags['ld_flags']: |
The Other Jimmy |
36:96847d42f010 | 973 | if opt.startswith('-Wl,--wrap,'): |
The Other Jimmy |
36:96847d42f010 | 974 | opts['ld']['flags'].append( |
The Other Jimmy |
36:96847d42f010 | 975 | '--wrap=' + opt[len('-Wl,--wrap,'):]) |
The Other Jimmy |
36:96847d42f010 | 976 | to_remove.append(opt) |
The Other Jimmy |
36:96847d42f010 | 977 | for opt in to_remove: |
The Other Jimmy |
36:96847d42f010 | 978 | self.remove_option(flags['ld_flags'], opt) |
The Other Jimmy |
36:96847d42f010 | 979 | |
The Other Jimmy |
36:96847d42f010 | 980 | # Other tool remaining options are separated by category. |
The Other Jimmy |
36:96847d42f010 | 981 | opts['as']['otherwarnings'] = self.find_options( |
The Other Jimmy |
36:96847d42f010 | 982 | flags['asm_flags'], '-W') |
The Other Jimmy |
36:96847d42f010 | 983 | |
The Other Jimmy |
36:96847d42f010 | 984 | opts['c']['otherwarnings'] = self.find_options( |
The Other Jimmy |
36:96847d42f010 | 985 | flags['c_flags'], '-W') |
The Other Jimmy |
36:96847d42f010 | 986 | opts['c']['otheroptimizations'] = self.find_options(flags[ |
The Other Jimmy |
36:96847d42f010 | 987 | 'c_flags'], '-f') |
The Other Jimmy |
36:96847d42f010 | 988 | |
The Other Jimmy |
36:96847d42f010 | 989 | opts['cpp']['otherwarnings'] = self.find_options( |
The Other Jimmy |
36:96847d42f010 | 990 | flags['cxx_flags'], '-W') |
The Other Jimmy |
36:96847d42f010 | 991 | opts['cpp']['otheroptimizations'] = self.find_options( |
The Other Jimmy |
36:96847d42f010 | 992 | flags['cxx_flags'], '-f') |
The Other Jimmy |
36:96847d42f010 | 993 | |
The Other Jimmy |
36:96847d42f010 | 994 | # Other common remaining options are separated by category. |
The Other Jimmy |
36:96847d42f010 | 995 | opts['common']['optimization.other'] = self.find_options( |
The Other Jimmy |
36:96847d42f010 | 996 | flags['common_flags'], '-f') |
The Other Jimmy |
36:96847d42f010 | 997 | opts['common']['warnings.other'] = self.find_options( |
The Other Jimmy |
36:96847d42f010 | 998 | flags['common_flags'], '-W') |
The Other Jimmy |
36:96847d42f010 | 999 | |
The Other Jimmy |
36:96847d42f010 | 1000 | # Remaining common flags are added to each tool. |
The Other Jimmy |
36:96847d42f010 | 1001 | opts['as']['other'] += ' ' + \ |
The Other Jimmy |
36:96847d42f010 | 1002 | ' '.join(flags['common_flags']) + ' ' + \ |
The Other Jimmy |
36:96847d42f010 | 1003 | ' '.join(flags['asm_flags']) |
The Other Jimmy |
36:96847d42f010 | 1004 | opts['c']['other'] += ' ' + \ |
The Other Jimmy |
36:96847d42f010 | 1005 | ' '.join(flags['common_flags']) + ' ' + ' '.join(flags['c_flags']) |
The Other Jimmy |
36:96847d42f010 | 1006 | opts['cpp']['other'] += ' ' + \ |
The Other Jimmy |
36:96847d42f010 | 1007 | ' '.join(flags['common_flags']) + ' ' + \ |
The Other Jimmy |
36:96847d42f010 | 1008 | ' '.join(flags['cxx_flags']) |
The Other Jimmy |
36:96847d42f010 | 1009 | opts['ld']['other'] += ' ' + \ |
The Other Jimmy |
36:96847d42f010 | 1010 | ' '.join(flags['common_flags']) + ' ' + ' '.join(flags['ld_flags']) |
The Other Jimmy |
36:96847d42f010 | 1011 | |
The Other Jimmy |
36:96847d42f010 | 1012 | if len(self.system_libraries) > 0: |
The Other Jimmy |
36:96847d42f010 | 1013 | opts['ld']['other'] += ' -Wl,--start-group ' |
The Other Jimmy |
36:96847d42f010 | 1014 | opts['ld'][ |
The Other Jimmy |
36:96847d42f010 | 1015 | 'other'] += ' '.join('-l' + s for s in self.system_libraries) |
The Other Jimmy |
36:96847d42f010 | 1016 | opts['ld']['other'] += ' -Wl,--end-group ' |
The Other Jimmy |
36:96847d42f010 | 1017 | |
The Other Jimmy |
36:96847d42f010 | 1018 | # Strip all 'other' flags, since they might have leading spaces. |
The Other Jimmy |
36:96847d42f010 | 1019 | opts['as']['other'] = opts['as']['other'].strip() |
The Other Jimmy |
36:96847d42f010 | 1020 | opts['c']['other'] = opts['c']['other'].strip() |
The Other Jimmy |
36:96847d42f010 | 1021 | opts['cpp']['other'] = opts['cpp']['other'].strip() |
The Other Jimmy |
36:96847d42f010 | 1022 | opts['ld']['other'] = opts['ld']['other'].strip() |
The Other Jimmy |
36:96847d42f010 | 1023 | |
The Other Jimmy |
36:96847d42f010 | 1024 | if False: |
The Other Jimmy |
36:96847d42f010 | 1025 | |
The Other Jimmy |
36:96847d42f010 | 1026 | print opts |
The Other Jimmy |
36:96847d42f010 | 1027 | |
The Other Jimmy |
36:96847d42f010 | 1028 | |
The Other Jimmy |
36:96847d42f010 | 1029 | print 'common_flags', flags['common_flags'] |
The Other Jimmy |
36:96847d42f010 | 1030 | print 'asm_flags', flags['asm_flags'] |
The Other Jimmy |
36:96847d42f010 | 1031 | print 'c_flags', flags['c_flags'] |
The Other Jimmy |
36:96847d42f010 | 1032 | print 'cxx_flags', flags['cxx_flags'] |
The Other Jimmy |
36:96847d42f010 | 1033 | print 'ld_flags', flags['ld_flags'] |
The Other Jimmy |
36:96847d42f010 | 1034 | |
The Other Jimmy |
36:96847d42f010 | 1035 | @staticmethod |
The Other Jimmy |
36:96847d42f010 | 1036 | def find_options(lst, option): |
The Other Jimmy |
36:96847d42f010 | 1037 | tmp = [str for str in lst if str.startswith(option)] |
The Other Jimmy |
36:96847d42f010 | 1038 | if len(tmp) > 0: |
The Other Jimmy |
36:96847d42f010 | 1039 | return tmp[0] |
The Other Jimmy |
36:96847d42f010 | 1040 | else: |
The Other Jimmy |
36:96847d42f010 | 1041 | return None |
The Other Jimmy |
36:96847d42f010 | 1042 | |
The Other Jimmy |
36:96847d42f010 | 1043 | @staticmethod |
The Other Jimmy |
36:96847d42f010 | 1044 | def find_options(lst, prefix): |
The Other Jimmy |
36:96847d42f010 | 1045 | other = '' |
The Other Jimmy |
36:96847d42f010 | 1046 | opts = [str for str in lst if str.startswith(prefix)] |
The Other Jimmy |
36:96847d42f010 | 1047 | if len(opts) > 0: |
The Other Jimmy |
36:96847d42f010 | 1048 | for opt in opts: |
The Other Jimmy |
36:96847d42f010 | 1049 | other += ' ' + opt |
The Other Jimmy |
36:96847d42f010 | 1050 | GNUARMEclipse.remove_option(lst, opt) |
The Other Jimmy |
36:96847d42f010 | 1051 | return other.strip() |
The Other Jimmy |
36:96847d42f010 | 1052 | |
The Other Jimmy |
36:96847d42f010 | 1053 | @staticmethod |
The Other Jimmy |
36:96847d42f010 | 1054 | def remove_option(lst, option): |
The Other Jimmy |
36:96847d42f010 | 1055 | if option in lst: |
The Other Jimmy |
36:96847d42f010 | 1056 | lst.remove(option) |
The Other Jimmy |
36:96847d42f010 | 1057 | |
The Other Jimmy |
36:96847d42f010 | 1058 | # ============================================================================= |