2015-10-01 12:45:06 +02:00
|
|
|
/****************************************************************************
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
2016-01-15 14:57:14 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:14 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
2016-01-15 14:57:14 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-10-25 12:30:43 +02:00
|
|
|
#include "../qtcreatorcrashhandler/crashhandlersetup.h"
|
|
|
|
|
|
2016-02-01 09:56:12 +01:00
|
|
|
#include <QCommandLineParser>
|
2015-06-01 18:51:55 +02:00
|
|
|
#include <QCoreApplication>
|
2015-07-30 10:05:09 +02:00
|
|
|
#include <QLoggingCategory>
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
#include <connectionserver.h>
|
2016-06-29 16:49:56 +02:00
|
|
|
#include <clangcodemodelserver.h>
|
2016-07-04 16:07:45 +02:00
|
|
|
#include <clangcodemodelclientproxy.h>
|
|
|
|
|
|
2018-01-08 10:24:01 +01:00
|
|
|
#include <iostream>
|
2018-12-07 14:35:26 +01:00
|
|
|
#include <clocale>
|
2018-01-08 10:24:01 +01:00
|
|
|
|
2016-07-04 16:07:45 +02:00
|
|
|
using ClangBackEnd::ClangCodeModelClientProxy;
|
|
|
|
|
using ClangBackEnd::ClangCodeModelServer;
|
|
|
|
|
using ClangBackEnd::ConnectionServer;
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-02-01 09:56:12 +01:00
|
|
|
QString processArguments(QCoreApplication &application)
|
|
|
|
|
{
|
|
|
|
|
QCommandLineParser parser;
|
|
|
|
|
parser.setApplicationDescription(QStringLiteral("Qt Creator Clang backend process."));
|
|
|
|
|
parser.addHelpOption();
|
|
|
|
|
parser.addVersionOption();
|
|
|
|
|
parser.addPositionalArgument(QStringLiteral("connection"), QStringLiteral("Connection"));
|
|
|
|
|
|
|
|
|
|
parser.process(application);
|
|
|
|
|
|
|
|
|
|
if (parser.positionalArguments().isEmpty())
|
|
|
|
|
parser.showHelp(1);
|
|
|
|
|
|
2020-11-16 21:58:53 +01:00
|
|
|
return parser.positionalArguments().constFirst();
|
2016-02-01 09:56:12 +01:00
|
|
|
}
|
|
|
|
|
|
2018-01-08 10:24:01 +01:00
|
|
|
#ifdef Q_OS_WIN
|
2020-11-11 14:04:17 +02:00
|
|
|
#include <windows.h>
|
2019-09-19 11:53:11 +02:00
|
|
|
static void messageOutput(QtMsgType type, const QMessageLogContext &/*context*/,
|
|
|
|
|
const QString &msg)
|
2018-01-08 10:24:01 +01:00
|
|
|
{
|
2019-09-19 11:53:11 +02:00
|
|
|
OutputDebugStringW(msg.toStdWString().c_str());
|
2018-01-08 10:24:01 +01:00
|
|
|
std::wcout << msg.toStdWString() << std::endl;
|
|
|
|
|
if (type == QtFatalMsg)
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
2018-01-08 10:24:01 +01:00
|
|
|
#ifdef Q_OS_WIN
|
2019-09-19 11:53:11 +02:00
|
|
|
qInstallMessageHandler(&messageOutput);
|
2018-01-08 10:24:01 +01:00
|
|
|
#endif
|
2015-06-01 18:51:55 +02:00
|
|
|
QCoreApplication::setOrganizationName(QStringLiteral("QtProject"));
|
|
|
|
|
QCoreApplication::setOrganizationDomain(QStringLiteral("qt-project.org"));
|
2015-06-16 11:56:00 +02:00
|
|
|
QCoreApplication::setApplicationName(QStringLiteral("ClangBackend"));
|
2015-06-01 18:51:55 +02:00
|
|
|
QCoreApplication::setApplicationVersion(QStringLiteral("1.0.0"));
|
|
|
|
|
|
|
|
|
|
QCoreApplication application(argc, argv);
|
2018-12-07 14:35:26 +01:00
|
|
|
|
|
|
|
|
// Some tidy checks use locale-dependent conversion functions and thus might throw exceptions.
|
|
|
|
|
std::setlocale(LC_NUMERIC, "C");
|
|
|
|
|
|
2016-10-25 12:30:43 +02:00
|
|
|
CrashHandlerSetup setupCrashHandler(QCoreApplication::applicationName(),
|
|
|
|
|
CrashHandlerSetup::DisableRestart);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-10-25 12:30:43 +02:00
|
|
|
const QString connection = processArguments(application);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2018-11-23 11:28:10 +01:00
|
|
|
// Printing the stack strace might dead lock as clang's stack printer allocates memory.
|
|
|
|
|
if (qEnvironmentVariableIntValue("QTC_CLANG_ENABLE_STACKTRACES"))
|
|
|
|
|
clang_enableStackTraces();
|
2015-11-18 15:26:28 +01:00
|
|
|
|
2016-07-04 16:07:45 +02:00
|
|
|
ClangCodeModelServer clangCodeModelServer;
|
2016-08-17 15:29:37 +02:00
|
|
|
ConnectionServer<ClangCodeModelServer, ClangCodeModelClientProxy> connectionServer;
|
2016-08-04 15:26:53 +02:00
|
|
|
connectionServer.setServer(&clangCodeModelServer);
|
2016-08-17 15:29:37 +02:00
|
|
|
connectionServer.start(connection);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
return application.exec();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|