| 82 | } |
| 83 | |
| 84 | QFuture<LLMQore::ToolResult> BuildProjectTool::executeAsync(const QJsonObject &input) |
| 85 | { |
| 86 | auto *project = ProjectExplorer::ProjectManager::startupProject(); |
| 87 | if (!project) { |
| 88 | return QtFuture::makeReadyFuture( |
| 89 | LLMQore::ToolResult::error("Error: No active project found. Please open a project in Qt Creator.")); |
| 90 | } |
| 91 | |
| 92 | if (ProjectExplorer::BuildManager::isBuilding(project)) { |
| 93 | return QtFuture::makeReadyFuture( |
| 94 | LLMQore::ToolResult::error("Error: Build is already in progress. Please wait for it to complete.")); |
| 95 | } |
| 96 | |
| 97 | if (m_activeBuilds.contains(project)) { |
| 98 | return QtFuture::makeReadyFuture( |
| 99 | LLMQore::ToolResult::error(QString("Error: Build is already being tracked for project '%1'.") |
| 100 | .arg(project->displayName()))); |
| 101 | } |
| 102 | |
| 103 | bool rebuild = input.value("rebuild").toBool(false); |
| 104 | bool runAfterBuild = input.value("run_after_build").toBool(false); |
| 105 | |
| 106 | LOG_MESSAGE(QString("BuildProjectTool: %1 project '%2'%3") |
| 107 | .arg(rebuild ? QString("Rebuilding") : QString("Building")) |
| 108 | .arg(project->displayName()) |
| 109 | .arg(runAfterBuild ? QString(" (run after build)") : QString())); |
| 110 | |
| 111 | auto promise = QSharedPointer<QPromise<LLMQore::ToolResult>>::create(); |
| 112 | promise->start(); |
| 113 | |
| 114 | BuildInfo buildInfo; |
| 115 | buildInfo.promise = promise; |
| 116 | buildInfo.project = project; |
| 117 | buildInfo.projectName = project->displayName(); |
| 118 | buildInfo.isRebuild = rebuild; |
| 119 | buildInfo.runAfterBuild = runAfterBuild; |
| 120 | |
| 121 | auto *buildManager = ProjectExplorer::BuildManager::instance(); |
| 122 | buildInfo.buildFinishedConnection = QObject::connect( |
| 123 | buildManager, |
| 124 | &ProjectExplorer::BuildManager::buildQueueFinished, |
| 125 | this, |
| 126 | &BuildProjectTool::onBuildQueueFinished); |
| 127 | |
| 128 | m_activeBuilds.insert(project, buildInfo); |
| 129 | |
| 130 | QMetaObject::invokeMethod( |
| 131 | qApp, |
| 132 | [project, rebuild]() { |
| 133 | if (rebuild) { |
| 134 | ProjectExplorer::BuildManager::rebuildProjectWithDependencies( |
| 135 | project, ProjectExplorer::ConfigSelection::Active); |
| 136 | } else { |
| 137 | ProjectExplorer::BuildManager::buildProjectWithDependencies( |
| 138 | project, ProjectExplorer::ConfigSelection::Active); |
| 139 | } |
| 140 | }, |
| 141 | Qt::QueuedConnection); |
nothing calls this directly
no test coverage detected