ACAV f0ba4b7c9529
Abstract Syntax Tree (AST) visualization tool for C, C++, and Objective-C
Loading...
Searching...
No Matches
MakeAstRunner.h
Go to the documentation of this file.
1/*$!{
2* Aurora Clang AST Viewer (ACAV)
3*
4* Copyright (c) 2026 Min Liu
5* Copyright (c) 2026 Michael David Adams
6*
7* SPDX-License-Identifier: GPL-2.0-or-later
8*
9* This program is free software; you can redistribute it and/or modify
10* it under the terms of the GNU General Public License as published by
11* the Free Software Foundation; either version 2 of the License, or
12* (at your option) any later version.
13*
14* This program is distributed in the hope that it will be useful,
15* but WITHOUT ANY WARRANTY; without even the implied warranty of
16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17* GNU General Public License for more details.
18*
19* You should have received a copy of the GNU General Public License along
20* with this program; if not, see <https://www.gnu.org/licenses/>.
21}$!*/
22
25#pragma once
26
27#include <QElapsedTimer>
28#include <QObject>
29#include <QProcess>
30#include <QString>
31
32#include "core/LogEntry.h"
33
34namespace acav {
35
50class MakeAstRunner : public QObject {
51 Q_OBJECT
52
53public:
54 explicit MakeAstRunner(QObject *parent = nullptr);
55 ~MakeAstRunner() override;
56
62 void run(const QString &compilationDatabasePath,
63 const QString &sourceFilePath,
64 const QString &outputFilePath,
65 const QString &makeAstBinary = QString());
66
68 bool isRunning() const;
69
72 void terminate();
73
76 void kill();
77
80 void setClangResourceDir(const QString &dir) { clangResourceDir_ = dir; }
81
85 bool waitForFinished(int msecs = 30000);
86
87signals:
90 void astReady(const QString &astFilePath);
91
94 void error(const QString &errorMessage);
95
98 void progress(const QString &message);
99
101 void logMessage(const LogEntry &entry);
102
103private slots:
104 void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
105 void onProcessError(QProcess::ProcessError error);
106 void onProcessStdOut();
107 void onProcessStdErr();
108
109private:
110 QProcess *process_;
111 QString sourceFilePath_;
112 QString outputFilePath_;
113 QString clangResourceDir_;
114 QElapsedTimer elapsed_;
115 QString pendingStdout_;
116 QString pendingStderr_;
117};
118
119} // namespace acav
bool waitForFinished(int msecs=30000)
Waits for the process to finish.
void run(const QString &compilationDatabasePath, const QString &sourceFilePath, const QString &outputFilePath, const QString &makeAstBinary=QString())
Run make-ast tool for specified source file.
void error(const QString &errorMessage)
Emitted when an error occurs.
void astReady(const QString &astFilePath)
Emitted when make-ast completes successfully.
void terminate()
Attempts to terminate the process gracefully Sends SIGTERM on Unix/macOS, WM_CLOSE on Windows.
void kill()
Kills the process immediately Sends SIGKILL on Unix/macOS, forceful termination on Windows.
void setClangResourceDir(const QString &dir)
Set the Clang resource directory.
bool isRunning() const
Check if tool is currently running.
void progress(const QString &message)
Emitted with progress updates.
void logMessage(const LogEntry &entry)
Emitted when the tool produces log output.