Merge pull request #4115 from cvtsi2sd/master

Support for Qt Creator Generic project export and associated Makefile
pull/4153/head
Jimmy Brisson 2017-04-10 16:17:14 -05:00 committed by GitHub
commit 55884de07e
6 changed files with 83 additions and 0 deletions

View File

@ -32,6 +32,7 @@ from tools.export import lpcxpresso, ds5_5, iar, makefile
from tools.export import embitz, coide, kds, simplicity, atmelstudio
from tools.export import sw4stm32, e2studio, zip, cmsis, uvision, cdt
from tools.export import gnuarmeclipse
from tools.export import qtcreator
from tools.targets import TARGET_NAMES
EXPORTERS = {
@ -55,6 +56,7 @@ EXPORTERS = {
'eclipse_iar' : cdt.EclipseIAR,
'eclipse_armc5' : cdt.EclipseArmc5,
'gnuarmeclipse': gnuarmeclipse.GNUARMEclipse,
'qtcreator': qtcreator.QtCreator,
'zip' : zip.ZIP,
'cmsis' : cmsis.CMSIS
}

View File

@ -0,0 +1,68 @@
"""
mbed SDK
Copyright (c) 2014-2017 ARM Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from os.path import splitext, basename
from tools.targets import TARGET_MAP
from tools.export.exporters import Exporter, filter_supported
from tools.export.makefile import GccArm
class QtCreator(GccArm):
NAME = 'QtCreator'
TOOLCHAIN = 'GCC_ARM'
TARGETS = filter_supported("GCC_ARM", set())
MBED_CONFIG_HEADER_SUPPORTED = True
def generate(self):
self.resources.win_to_unix()
defines = [] # list of tuples ('D'/'U', [key, value]) (value is optional)
forced_includes = [] # list of strings
sources = [] # list of strings
include_paths = [] # list of strings
next_is_include = False
for f in self.flags['c_flags'] + self.flags['cxx_flags']:
f=f.strip()
if next_is_include:
forced_includes.append(f)
next_is_include = False
continue
if f.startswith('-D'):
defines.append(('D', f[2:].split('=', 1)))
elif f.startswith('-U'):
defines.append(('U', [f[2:]]))
elif f == "-include":
next_is_include = True
for r_type in ['headers', 'c_sources', 's_sources', 'cpp_sources']:
sources.extend(getattr(self.resources, r_type))
include_paths = self.resources.inc_dirs
ctx = {
'defines': defines,
'forced_includes': forced_includes,
'sources': sources,
'include_paths': self.resources.inc_dirs
}
for ext in ['creator', 'files', 'includes', 'config']:
self.gen_file('qtcreator/%s.tmpl' % ext, ctx, "%s.%s" % (self.project_name, ext))
# finally, generate the Makefile
super(QtCreator, self).generate()

View File

@ -0,0 +1,6 @@
{% for d in defines -%}
{% if d[0] == 'D' %}#define {% else %}#undef{% endif %} {{ d[1]|join(' ')}}
{% endfor %}
{% for i in forced_includes -%}
#include "{{i}}"
{% endfor %}

View File

@ -0,0 +1 @@
[General]

View File

@ -0,0 +1,3 @@
{% for s in sources -%}
{{s}}
{% endfor %}

View File

@ -0,0 +1,3 @@
{% for i in include_paths -%}
{{i}}
{% endfor %}