Skip to content

Commit 55884de

Browse files
Merge pull request #4115 from cvtsi2sd/master
Support for Qt Creator Generic project export and associated Makefile
2 parents 0b11177 + 2baa215 commit 55884de

File tree

6 files changed

+83
-0
lines changed

6 files changed

+83
-0
lines changed

tools/export/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from tools.export import embitz, coide, kds, simplicity, atmelstudio
3333
from tools.export import sw4stm32, e2studio, zip, cmsis, uvision, cdt
3434
from tools.export import gnuarmeclipse
35+
from tools.export import qtcreator
3536
from tools.targets import TARGET_NAMES
3637

3738
EXPORTERS = {
@@ -55,6 +56,7 @@
5556
'eclipse_iar' : cdt.EclipseIAR,
5657
'eclipse_armc5' : cdt.EclipseArmc5,
5758
'gnuarmeclipse': gnuarmeclipse.GNUARMEclipse,
59+
'qtcreator': qtcreator.QtCreator,
5860
'zip' : zip.ZIP,
5961
'cmsis' : cmsis.CMSIS
6062
}

tools/export/qtcreator/__init__.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
"""
2+
mbed SDK
3+
Copyright (c) 2014-2017 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+
from tools.export.makefile import GccArm
21+
22+
class QtCreator(GccArm):
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+
defines = [] # list of tuples ('D'/'U', [key, value]) (value is optional)
34+
forced_includes = [] # list of strings
35+
sources = [] # list of strings
36+
include_paths = [] # list of strings
37+
38+
next_is_include = False
39+
for f in self.flags['c_flags'] + self.flags['cxx_flags']:
40+
f=f.strip()
41+
if next_is_include:
42+
forced_includes.append(f)
43+
next_is_include = False
44+
continue
45+
if f.startswith('-D'):
46+
defines.append(('D', f[2:].split('=', 1)))
47+
elif f.startswith('-U'):
48+
defines.append(('U', [f[2:]]))
49+
elif f == "-include":
50+
next_is_include = True
51+
52+
for r_type in ['headers', 'c_sources', 's_sources', 'cpp_sources']:
53+
sources.extend(getattr(self.resources, r_type))
54+
55+
include_paths = self.resources.inc_dirs
56+
57+
ctx = {
58+
'defines': defines,
59+
'forced_includes': forced_includes,
60+
'sources': sources,
61+
'include_paths': self.resources.inc_dirs
62+
}
63+
64+
for ext in ['creator', 'files', 'includes', 'config']:
65+
self.gen_file('qtcreator/%s.tmpl' % ext, ctx, "%s.%s" % (self.project_name, ext))
66+
67+
# finally, generate the Makefile
68+
super(QtCreator, self).generate()

tools/export/qtcreator/config.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% for d in defines -%}
2+
{% if d[0] == 'D' %}#define {% else %}#undef{% endif %} {{ d[1]|join(' ')}}
3+
{% endfor %}
4+
{% for i in forced_includes -%}
5+
#include "{{i}}"
6+
{% endfor %}

tools/export/qtcreator/creator.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[General]

tools/export/qtcreator/files.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% for s in sources -%}
2+
{{s}}
3+
{% endfor %}

tools/export/qtcreator/includes.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% for i in include_paths -%}
2+
{{i}}
3+
{% endfor %}

0 commit comments

Comments
 (0)