File indexing completed on 2024-05-05 04:40:22
0001 /* 0002 SPDX-FileCopyrightText: 2015 Kevin Funk <kfunk@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #include "qmakeutils.h" 0008 #include <debug.h> 0009 0010 #include "qmakebuilddirchooserdialog.h" 0011 #include "qmakeconfig.h" 0012 0013 #include <interfaces/iproject.h> 0014 #include <util/path.h> 0015 0016 #include <QFile> 0017 #include <QPointer> 0018 #include <QString> 0019 0020 using namespace KDevelop; 0021 0022 bool QMakeUtils::checkForNeedingConfigure(IProject* project) 0023 { 0024 Q_ASSERT(project); 0025 0026 qCDebug(KDEV_QMAKE) << "Checking whether" << project->name() << "needs a configure run"; 0027 0028 const auto buildDir = QMakeConfig::buildDirFromSrc(project, project->path()); 0029 if (!buildDir.isValid()) { 0030 QPointer<QMakeBuildDirChooserDialog> chooser = new QMakeBuildDirChooserDialog(project); 0031 if (chooser->exec() == QDialog::Rejected) { 0032 delete chooser; 0033 return false; // cancelled, can't configure => false 0034 } 0035 delete chooser; 0036 } 0037 0038 qCDebug(KDEV_QMAKE) << "Build directory for" << project->name() << "is" << buildDir; 0039 0040 if (!QMakeConfig::isConfigured(project)) { 0041 return true; 0042 } 0043 const QString qmakeExecutable = QMakeConfig::qmakeExecutable(project); 0044 if (qmakeExecutable.isEmpty()) { 0045 return true; 0046 } 0047 const QHash<QString, QString> vars = queryQMake(project); 0048 if (vars.isEmpty()) { 0049 return true; 0050 } 0051 if (QMakeConfig::findBasicMkSpec(vars).isEmpty()) { 0052 return true; 0053 } 0054 0055 if (!QFile::exists(buildDir.toLocalFile())) { 0056 qCDebug(KDEV_QMAKE) << "build dir" << buildDir << "configured, but does not exist yet"; 0057 return true; 0058 } 0059 0060 qCDebug(KDEV_QMAKE) << "No configure needed for project" << project->name(); 0061 return false; 0062 } 0063 0064 QHash<QString, QString> QMakeUtils::queryQMake(IProject* project) 0065 { 0066 if (!project->path().toUrl().isLocalFile()) 0067 return QHash<QString, QString>(); 0068 0069 return QMakeConfig::queryQMake(QMakeConfig::qmakeExecutable(project)); 0070 }