2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2018-01-17 15:08:30 +01:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2019-08-01 16:08:40 +02:00
|
|
|
#include "clangtoolslogfilereader.h"
|
|
|
|
|
|
2022-03-02 04:12:25 +01:00
|
|
|
#include <utils/commandline.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)>;
|
|
|
|
|
|
2018-01-17 15:08:30 +01:00
|
|
|
class ClangToolRunner : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2020-09-11 10:22:35 +02:00
|
|
|
ClangToolRunner(QObject *parent = nullptr);
|
2018-01-17 15:08:30 +01:00
|
|
|
|
2021-07-02 07:12:33 +02:00
|
|
|
void init(const Utils::FilePath &outputDirPath, const Utils::Environment &environment);
|
2019-08-01 14:54:15 +02:00
|
|
|
void setName(const QString &name) { m_name = name; }
|
2021-08-12 09:19:55 +02:00
|
|
|
void setExecutable(const Utils::FilePath &executable) { m_executable = executable; }
|
2019-08-01 14:54:15 +02:00
|
|
|
void setArgsCreator(const ArgsCreator &argsCreator) { m_argsCreator = argsCreator; }
|
2019-08-01 16:08:40 +02:00
|
|
|
void setOutputFileFormat(const OutputFileFormat &format) { m_outputFileFormat = format; }
|
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
|
|
|
OutputFileFormat outputFileFormat() const { return m_outputFileFormat; }
|
|
|
|
|
QString fileToAnalyze() const { return m_fileToAnalyze; }
|
|
|
|
|
QString outputFilePath() const { return m_outputFilePath; }
|
2020-08-25 06:18:26 +02:00
|
|
|
QStringList mainToolArguments() const;
|
|
|
|
|
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
|
|
|
|
|
bool run(const QString &fileToAnalyze, const QStringList &compilerOptions = QStringList());
|
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);
|
|
|
|
|
|
2020-07-22 14:52:06 +02:00
|
|
|
protected:
|
|
|
|
|
QString m_overlayFilePath;
|
|
|
|
|
|
2018-01-17 15:08:30 +01:00
|
|
|
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
|
|
|
|
2019-08-29 14:25:49 +02:00
|
|
|
QString commandlineAndOutput() const;
|
2018-01-17 15:08:30 +01:00
|
|
|
|
2019-08-29 14:25:49 +02:00
|
|
|
private:
|
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-01 16:08:40 +02:00
|
|
|
OutputFileFormat m_outputFileFormat = OutputFileFormat::Yaml;
|
2019-08-01 14:54:15 +02:00
|
|
|
|
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
|