From f3ccfbe2675d5269f60a7c69e27c6bc97825e710 Mon Sep 17 00:00:00 2001 From: Matteo Italia Date: Wed, 5 Apr 2017 11:43:50 +0200 Subject: [PATCH] Added minimal support for Qt Creator projects --- tools/export/__init__.py | 2 + tools/export/qtcreator/__init__.py | 61 ++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 tools/export/qtcreator/__init__.py diff --git a/tools/export/__init__.py b/tools/export/__init__.py index be8f9c8f5b..683df2ceb0 100644 --- a/tools/export/__init__.py +++ b/tools/export/__init__.py @@ -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 } diff --git a/tools/export/qtcreator/__init__.py b/tools/export/qtcreator/__init__.py new file mode 100644 index 0000000000..49b5b7f929 --- /dev/null +++ b/tools/export/qtcreator/__init__.py @@ -0,0 +1,61 @@ +""" +mbed SDK +Copyright (c) 2014-2016 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 + + +class QtCreator(Exporter): + NAME = 'QtCreator' + TOOLCHAIN = 'GCC_ARM' + + TARGETS = filter_supported("GCC_ARM", set()) + + MBED_CONFIG_HEADER_SUPPORTED = True + + def generate(self): + self.resources.win_to_unix() + + with open("%s.creator" % self.project_name, "w") as fd: + fd.write("[General]\n") + + next_is_include = False + includes = [] + with open("%s.config" % self.project_name, "w") as fd: + for f in self.flags['c_flags'] + self.flags['cxx_flags']: + f=f.strip() + if next_is_include: + includes.append(f) + next_is_include = False + continue + if f.startswith('-D'): + fd.write("#define %s\n" % (f[2:].replace('=', ' '))) + elif f.startswith('-U'): + fd.write("#undef %s\n" % f[2:]) + elif f == "-include": + next_is_include = True + for i in includes: + fd.write("#include \"%s\"\n" % i) + + with open("%s.files" % self.project_name, "w") as fd: + for r_type in ['headers', 'c_sources', 's_sources', 'cpp_sources']: + for f in getattr(self.resources, r_type): + fd.write(f + "\n") + + with open("%s.includes" % self.project_name, "w") as fd: + for i in self.resources.inc_dirs: + fd.write(i + "\n")