File indexing completed on 2024-04-28 04:39:10
0001 /* 0002 SPDX-FileCopyrightText: 2006-2007 Andreas Pakulat <apaku@gmx.de> 0003 SPDX-FileCopyrightText: 2008 Hamish Rodda <rodda@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "qmakejob.h" 0009 0010 #include <debug.h> 0011 #include "qmakeconfig.h" 0012 0013 #include <interfaces/iproject.h> 0014 #include <outputview/ioutputview.h> 0015 #include <outputview/outputmodel.h> 0016 #include <project/projectmodel.h> 0017 #include <makebuilder/imakebuilder.h> 0018 #include <util/commandexecutor.h> 0019 #include <util/path.h> 0020 0021 #include <QDir> 0022 #include <KLocalizedString> 0023 0024 using namespace KDevelop; 0025 0026 QMakeJob::QMakeJob(QObject* parent) 0027 : OutputExecuteJob(parent) 0028 { 0029 setCapabilities(Killable); 0030 setFilteringStrategy(OutputModel::CompilerFilter); 0031 setProperties(NeedWorkingDirectory | PortableMessages | DisplayStderr | IsBuilderHint); 0032 setToolTitle(i18nc("@title:window", "QMake")); 0033 setStandardToolView(IOutputView::BuildView); 0034 setBehaviours(IOutputView::AllowUserClose | IOutputView::AutoScroll ); 0035 } 0036 0037 void QMakeJob::start() 0038 { 0039 qCDebug(KDEV_QMAKEBUILDER) << "Running qmake in" << workingDirectory(); 0040 0041 if (!m_project) { 0042 setError(NoProjectError); 0043 setErrorText(i18n("No project specified.")); 0044 emitResult(); 0045 return; 0046 } 0047 0048 // create build directory if it does not exist yet 0049 QDir::temp().mkpath(workingDirectory().toLocalFile()); 0050 0051 OutputExecuteJob::start(); 0052 } 0053 0054 QUrl QMakeJob::workingDirectory() const 0055 { 0056 if (!m_project) { 0057 return QUrl(); 0058 } 0059 0060 return QMakeConfig::buildDirFromSrc(m_project, m_project->path()).toUrl(); 0061 } 0062 0063 QStringList QMakeJob::commandLine() const 0064 { 0065 if (!m_project) { 0066 return {}; 0067 } 0068 0069 const QStringList args{ 0070 QMakeConfig::qmakeExecutable(m_project), 0071 m_project->path().toUrl().toLocalFile(), 0072 }; 0073 0074 return args; 0075 } 0076 0077 void QMakeJob::setProject(KDevelop::IProject* project) 0078 { 0079 m_project = project; 0080 0081 if (m_project) 0082 setObjectName(i18n("QMake: %1", m_project->name())); 0083 } 0084 0085 void QMakeJob::slotFailed(QProcess::ProcessError error) 0086 { 0087 qCDebug(KDEV_QMAKEBUILDER) << error; 0088 0089 if (!m_killed) { 0090 setError(ConfigureError); 0091 // FIXME need more detail i guess 0092 setErrorText(i18n("Configure error")); 0093 } 0094 emitResult(); 0095 } 0096 0097 void QMakeJob::slotCompleted(int code) 0098 { 0099 if (code != 0) { 0100 setError(FailedShownError); 0101 } 0102 emitResult(); 0103 } 0104 0105 bool QMakeJob::doKill() 0106 { 0107 m_killed = true; 0108 m_cmd->kill(); 0109 return true; 0110 } 0111 0112 #include "moc_qmakejob.cpp"