BA / Mbed OS BaBoRo1
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers __init__.py Source File

__init__.py

00001 """
00002 mbed SDK
00003 Copyright (c) 2014-2017 ARM Limited
00004 
00005 Licensed under the Apache License, Version 2.0 (the "License");
00006 you may not use this file except in compliance with the License.
00007 You may obtain a copy of the License at
00008 
00009     http://www.apache.org/licenses/LICENSE-2.0
00010 
00011 Unless required by applicable law or agreed to in writing, software
00012 distributed under the License is distributed on an "AS IS" BASIS,
00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 See the License for the specific language governing permissions and
00015 limitations under the License.
00016 """
00017 from os.path import splitext, basename
00018 from os import remove
00019 from tools.targets import TARGET_MAP
00020 from tools.export.exporters import Exporter
00021 from tools.export.makefile import GccArm
00022 
00023 class QtCreator(GccArm ):
00024     NAME = 'QtCreator'
00025 
00026     MBED_CONFIG_HEADER_SUPPORTED = True
00027 
00028     def generate(self):
00029         self.resources.win_to_unix()
00030 
00031         defines         = [] # list of tuples ('D'/'U', [key, value]) (value is optional)
00032         forced_includes = [] # list of strings
00033         sources         = [] # list of strings
00034         include_paths   = [] # list of strings
00035 
00036         next_is_include = False
00037         for f in self.flags['c_flags'] + self.flags['cxx_flags']:
00038             f=f.strip()
00039             if next_is_include:
00040                 forced_includes.append(f)
00041                 next_is_include = False
00042                 continue
00043             if f.startswith('-D'):
00044                 defines.append(('D', f[2:].split('=', 1)))
00045             elif f.startswith('-U'):
00046                 defines.append(('U', [f[2:]]))
00047             elif f == "-include":
00048                 next_is_include = True
00049 
00050         for r_type in ['headers', 'c_sources', 's_sources', 'cpp_sources']:
00051             sources.extend(getattr(self.resources, r_type))
00052 
00053         include_paths = self.resources.inc_dirs
00054 
00055         ctx = {
00056             'defines': defines,
00057             'forced_includes': forced_includes,
00058             'sources': sources,
00059             'include_paths': self.resources.inc_dirs
00060             }
00061 
00062         for ext in ['creator', 'files', 'includes', 'config']:
00063             self.gen_file('qtcreator/%s.tmpl' % ext, ctx, "%s.%s" % (self.project_name, ext))
00064 
00065         # finally, generate the Makefile
00066         super(QtCreator, self).generate()
00067 
00068     @staticmethod
00069     def clean(project_name):
00070         for ext in ['creator', 'files', 'includes', 'config']:
00071             remove("%s.%s" % (project_name, ext))