Changeset View
Changeset View
Standalone View
Standalone View
projectmanagers/qmake/qmakeconfig.cpp
Show All 26 Lines | |||||
27 | #include <KProcess> | 27 | #include <KProcess> | ||
28 | 28 | | |||
29 | #include <interfaces/iproject.h> | 29 | #include <interfaces/iproject.h> | ||
30 | #include <util/path.h> | 30 | #include <util/path.h> | ||
31 | #include "debug.h" | 31 | #include "debug.h" | ||
32 | 32 | | |||
33 | const char* QMakeConfig::CONFIG_GROUP = "QMake_Builder"; | 33 | const char* QMakeConfig::CONFIG_GROUP = "QMake_Builder"; | ||
34 | 34 | | |||
35 | const char* QMakeConfig::QMAKE_BINARY = "QMake_Binary"; | 35 | // TODO: migrate to more generic & consistent key term "QMake_Executable" | ||
36 | const char* QMakeConfig::QMAKE_EXECUTABLE = "QMake_Binary"; | ||||
36 | const char* QMakeConfig::BUILD_FOLDER = "Build_Folder"; | 37 | const char* QMakeConfig::BUILD_FOLDER = "Build_Folder"; | ||
37 | const char* QMakeConfig::INSTALL_PREFIX = "Install_Prefix"; | 38 | const char* QMakeConfig::INSTALL_PREFIX = "Install_Prefix"; | ||
38 | const char* QMakeConfig::EXTRA_ARGUMENTS = "Extra_Arguments"; | 39 | const char* QMakeConfig::EXTRA_ARGUMENTS = "Extra_Arguments"; | ||
39 | const char* QMakeConfig::BUILD_TYPE = "Build_Type"; | 40 | const char* QMakeConfig::BUILD_TYPE = "Build_Type"; | ||
40 | const char* QMakeConfig::ALL_BUILDS = "All_Builds"; | 41 | const char* QMakeConfig::ALL_BUILDS = "All_Builds"; | ||
41 | 42 | | |||
42 | namespace { | 43 | namespace { | ||
43 | 44 | | |||
Show All 12 Lines | |||||
56 | 57 | | |||
57 | /// NOTE: KConfig is not thread safe | 58 | /// NOTE: KConfig is not thread safe | ||
58 | QMutex s_buildDirMutex; | 59 | QMutex s_buildDirMutex; | ||
59 | 60 | | |||
60 | bool QMakeConfig::isConfigured(const IProject* project) | 61 | bool QMakeConfig::isConfigured(const IProject* project) | ||
61 | { | 62 | { | ||
62 | QMutexLocker lock(&s_buildDirMutex); | 63 | QMutexLocker lock(&s_buildDirMutex); | ||
63 | KConfigGroup cg(project->projectConfiguration(), CONFIG_GROUP); | 64 | KConfigGroup cg(project->projectConfiguration(), CONFIG_GROUP); | ||
64 | return cg.exists() && cg.hasKey(QMAKE_BINARY) && cg.hasKey(BUILD_FOLDER); | 65 | return cg.exists() && cg.hasKey(QMAKE_EXECUTABLE) && cg.hasKey(BUILD_FOLDER); | ||
65 | } | 66 | } | ||
66 | 67 | | |||
67 | Path QMakeConfig::buildDirFromSrc(const IProject* project, const Path& srcDir) | 68 | Path QMakeConfig::buildDirFromSrc(const IProject* project, const Path& srcDir) | ||
68 | { | 69 | { | ||
69 | QMutexLocker lock(&s_buildDirMutex); | 70 | QMutexLocker lock(&s_buildDirMutex); | ||
70 | KConfigGroup cg(project->projectConfiguration(), QMakeConfig::CONFIG_GROUP); | 71 | KConfigGroup cg(project->projectConfiguration(), QMakeConfig::CONFIG_GROUP); | ||
71 | Path buildDir = Path(cg.readEntry(QMakeConfig::BUILD_FOLDER, QString())); | 72 | Path buildDir = Path(cg.readEntry(QMakeConfig::BUILD_FOLDER, QString())); | ||
72 | lock.unlock(); | 73 | lock.unlock(); | ||
73 | 74 | | |||
74 | if (buildDir.isValid()) { | 75 | if (buildDir.isValid()) { | ||
75 | buildDir.addPath(project->path().relativePath(srcDir)); | 76 | buildDir.addPath(project->path().relativePath(srcDir)); | ||
76 | } | 77 | } | ||
77 | return buildDir; | 78 | return buildDir; | ||
78 | } | 79 | } | ||
79 | 80 | | |||
80 | QString QMakeConfig::qmakeBinary(const IProject* project) | 81 | QString QMakeConfig::qmakeExecutable(const IProject* project) | ||
81 | { | 82 | { | ||
82 | QMutexLocker lock(&s_buildDirMutex); | 83 | QMutexLocker lock(&s_buildDirMutex); | ||
83 | QString exe; | 84 | QString exe; | ||
84 | if (project) { | 85 | if (project) { | ||
85 | KSharedConfig::Ptr cfg = project->projectConfiguration(); | 86 | KSharedConfig::Ptr cfg = project->projectConfiguration(); | ||
86 | KConfigGroup group(cfg.data(), CONFIG_GROUP); | 87 | KConfigGroup group(cfg.data(), CONFIG_GROUP); | ||
87 | if (group.hasKey(QMAKE_BINARY)) { | 88 | if (group.hasKey(QMAKE_EXECUTABLE)) { | ||
88 | exe = group.readEntry(QMAKE_BINARY, QString()); | 89 | exe = group.readEntry(QMAKE_EXECUTABLE, QString()); | ||
89 | QFileInfo info(exe); | 90 | QFileInfo info(exe); | ||
90 | if (!info.exists() || !info.isExecutable()) { | 91 | if (!info.exists() || !info.isExecutable()) { | ||
91 | qWarning() << "bad QMake configured for project " << project->path().toUrl() << ":" << exe; | 92 | qWarning() << "bad QMake configured for project " << project->path().toUrl() << ":" << exe; | ||
92 | exe.clear(); | 93 | exe.clear(); | ||
93 | } | 94 | } | ||
94 | } | 95 | } | ||
95 | } | 96 | } | ||
96 | if (exe.isEmpty()) { | 97 | if (exe.isEmpty()) { | ||
97 | exe = QStandardPaths::findExecutable("qmake"); | 98 | exe = QStandardPaths::findExecutable("qmake"); | ||
98 | } | 99 | } | ||
99 | if (exe.isEmpty()) { | 100 | if (exe.isEmpty()) { | ||
100 | exe = QStandardPaths::findExecutable("qmake-qt5"); | 101 | exe = QStandardPaths::findExecutable("qmake-qt5"); | ||
101 | } | 102 | } | ||
102 | if (exe.isEmpty()) { | 103 | if (exe.isEmpty()) { | ||
103 | exe = QStandardPaths::findExecutable("qmake-qt4"); | 104 | exe = QStandardPaths::findExecutable("qmake-qt4"); | ||
104 | } | 105 | } | ||
105 | Q_ASSERT(!exe.isEmpty()); | 106 | Q_ASSERT(!exe.isEmpty()); | ||
106 | return exe; | 107 | return exe; | ||
107 | } | 108 | } | ||
108 | 109 | | |||
109 | QHash<QString, QString> QMakeConfig::queryQMake(const QString& qmakeBinary, const QStringList& args) | 110 | QHash<QString, QString> QMakeConfig::queryQMake(const QString& qmakeExecutable, const QStringList& args) | ||
110 | { | 111 | { | ||
111 | QHash<QString, QString> hash; | 112 | QHash<QString, QString> hash; | ||
112 | KProcess p; | 113 | KProcess p; | ||
113 | p.setOutputChannelMode(KProcess::OnlyStdoutChannel); | 114 | p.setOutputChannelMode(KProcess::OnlyStdoutChannel); | ||
114 | p << qmakeBinary << "-query" << args; | 115 | p << qmakeExecutable << QStringLiteral("-query") << args; | ||
115 | 116 | | |||
116 | const int rc = p.execute(); | 117 | const int rc = p.execute(); | ||
117 | if (rc != 0) { | 118 | if (rc != 0) { | ||
118 | qCWarning(KDEV_QMAKE) << "failed to execute qmake query " << p.program().join(" ") << "return code was:" << rc; | 119 | qCWarning(KDEV_QMAKE) << "failed to execute qmake query " << p.program().join(" ") << "return code was:" << rc; | ||
119 | return QHash<QString, QString>(); | 120 | return QHash<QString, QString>(); | ||
120 | } | 121 | } | ||
121 | 122 | | |||
122 | // TODO: Qt 5.5: Use QTextStream::readLineInto | 123 | // TODO: Qt 5.5: Use QTextStream::readLineInto | ||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |