2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2018-01-17 15:08:30 +01:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-01-10 17:51:34 +01:00
|
|
|
#include <cppeditor/clangdiagnosticconfig.h>
|
|
|
|
|
|
2022-03-02 04:12:25 +01:00
|
|
|
#include <utils/commandline.h>
|
2023-01-10 17:51:34 +01:00
|
|
|
#include <utils/environment.h>
|
2022-06-16 10:34:01 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2018-01-17 15:08:30 +01:00
|
|
|
|
2019-08-29 14:25:49 +02:00
|
|
|
#include <memory>
|
|
|
|
|
|
2018-01-17 15:08:30 +01:00
|
|
|
namespace ClangTools {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2019-08-01 14:54:15 +02:00
|
|
|
using ArgsCreator = std::function<QStringList(const QStringList &baseOptions)>;
|
|
|
|
|
|
2023-01-10 17:51:34 +01:00
|
|
|
struct AnalyzeInputData
|
|
|
|
|
{
|
|
|
|
|
CppEditor::ClangToolType tool = CppEditor::ClangToolType::Tidy;
|
|
|
|
|
CppEditor::ClangDiagnosticConfig config;
|
|
|
|
|
Utils::FilePath outputDirPath;
|
|
|
|
|
Utils::Environment environment;
|
|
|
|
|
};
|
2018-01-17 15:08:30 +01:00
|
|
|
class ClangToolRunner : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2023-01-10 17:51:34 +01:00
|
|
|
ClangToolRunner(const AnalyzeInputData &input, QObject *parent = nullptr);
|
2018-01-17 15:08:30 +01:00
|
|
|
|
2020-07-22 14:52:06 +02:00
|
|
|
void setVFSOverlay(const QString overlayFilePath) { m_overlayFilePath = overlayFilePath; }
|
2019-08-01 14:54:15 +02:00
|
|
|
|
2019-08-01 15:18:32 +02:00
|
|
|
QString name() const { return m_name; }
|
2021-08-12 09:19:55 +02:00
|
|
|
Utils::FilePath executable() const { return m_executable; }
|
2019-08-29 14:25:49 +02:00
|
|
|
QString fileToAnalyze() const { return m_fileToAnalyze; }
|
|
|
|
|
QString outputFilePath() const { return m_outputFilePath; }
|
2020-08-25 06:18:26 +02:00
|
|
|
bool supportsVFSOverlay() const;
|
2019-08-29 14:25:49 +02:00
|
|
|
|
|
|
|
|
// compilerOptions is expected to contain everything except:
|
|
|
|
|
// (1) file to analyze
|
|
|
|
|
// (2) -o output-file
|
2023-01-10 17:51:34 +01:00
|
|
|
bool run(const QString &fileToAnalyze, const QStringList &compilerOptions = {});
|
2018-01-17 15:08:30 +01:00
|
|
|
|
|
|
|
|
signals:
|
2019-08-29 14:25:49 +02:00
|
|
|
void finishedWithSuccess(const QString &fileToAnalyze);
|
2018-01-17 15:08:30 +01:00
|
|
|
void finishedWithFailure(const QString &errorMessage, const QString &errorDetails);
|
|
|
|
|
|
|
|
|
|
private:
|
2019-08-29 14:25:49 +02:00
|
|
|
void onProcessOutput();
|
2022-04-14 09:14:31 +02:00
|
|
|
void onProcessDone();
|
2018-01-17 15:08:30 +01:00
|
|
|
|
2023-01-10 17:51:34 +01:00
|
|
|
QStringList mainToolArguments() const;
|
2019-08-29 14:25:49 +02:00
|
|
|
QString commandlineAndOutput() const;
|
2018-01-17 15:08:30 +01:00
|
|
|
|
2023-01-06 13:13:52 +01:00
|
|
|
QString m_overlayFilePath;
|
2021-07-02 07:12:33 +02:00
|
|
|
Utils::FilePath m_outputDirPath;
|
2022-06-16 10:34:01 +02:00
|
|
|
Utils::QtcProcess m_process;
|
2018-01-17 15:08:30 +01:00
|
|
|
|
2019-08-01 14:54:15 +02:00
|
|
|
QString m_name;
|
2021-08-12 09:19:55 +02:00
|
|
|
Utils::FilePath m_executable;
|
2019-08-01 14:54:15 +02:00
|
|
|
ArgsCreator m_argsCreator;
|
|
|
|
|
|
2019-08-29 14:25:49 +02:00
|
|
|
QString m_fileToAnalyze;
|
|
|
|
|
QString m_outputFilePath;
|
2021-04-30 17:10:00 +02:00
|
|
|
Utils::CommandLine m_commandLine;
|
2018-01-17 15:08:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ClangTools
|