|
| 1 | +""" |
| 2 | +mbed SDK |
| 3 | +Copyright (c) 2014-2016 ARM Limited |
| 4 | +
|
| 5 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +you may not use this file except in compliance with the License. |
| 7 | +You may obtain a copy of the License at |
| 8 | +
|
| 9 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +
|
| 11 | +Unless required by applicable law or agreed to in writing, software |
| 12 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +See the License for the specific language governing permissions and |
| 15 | +limitations under the License. |
| 16 | +""" |
| 17 | +from os.path import splitext, basename |
| 18 | +from tools.targets import TARGET_MAP |
| 19 | +from tools.export.exporters import Exporter, filter_supported |
| 20 | + |
| 21 | + |
| 22 | +class QtCreator(Exporter): |
| 23 | + NAME = 'QtCreator' |
| 24 | + TOOLCHAIN = 'GCC_ARM' |
| 25 | + |
| 26 | + TARGETS = filter_supported("GCC_ARM", set()) |
| 27 | + |
| 28 | + MBED_CONFIG_HEADER_SUPPORTED = True |
| 29 | + |
| 30 | + def generate(self): |
| 31 | + self.resources.win_to_unix() |
| 32 | + |
| 33 | + with open("%s.creator" % self.project_name, "w") as fd: |
| 34 | + fd.write("[General]\n") |
| 35 | + |
| 36 | + next_is_include = False |
| 37 | + includes = [] |
| 38 | + with open("%s.config" % self.project_name, "w") as fd: |
| 39 | + for f in self.flags['c_flags'] + self.flags['cxx_flags']: |
| 40 | + f=f.strip() |
| 41 | + if next_is_include: |
| 42 | + includes.append(f) |
| 43 | + next_is_include = False |
| 44 | + continue |
| 45 | + if f.startswith('-D'): |
| 46 | + fd.write("#define %s\n" % (f[2:].replace('=', ' '))) |
| 47 | + elif f.startswith('-U'): |
| 48 | + fd.write("#undef %s\n" % f[2:]) |
| 49 | + elif f == "-include": |
| 50 | + next_is_include = True |
| 51 | + for i in includes: |
| 52 | + fd.write("#include \"%s\"\n" % i) |
| 53 | + |
| 54 | + with open("%s.files" % self.project_name, "w") as fd: |
| 55 | + for r_type in ['headers', 'c_sources', 's_sources', 'cpp_sources']: |
| 56 | + for f in getattr(self.resources, r_type): |
| 57 | + fd.write(f + "\n") |
| 58 | + |
| 59 | + with open("%s.includes" % self.project_name, "w") as fd: |
| 60 | + for i in self.resources.inc_dirs: |
| 61 | + fd.write(i + "\n") |
0 commit comments