Changeset View
Changeset View
Standalone View
Standalone View
plugins/cmake/cmakeutils.cpp
Show First 20 Lines • Show All 159 Lines • ▼ Show 20 Line(s) | |||||
160 | 160 | | |||
161 | } // namespace | 161 | } // namespace | ||
162 | 162 | | |||
163 | namespace CMake | 163 | namespace CMake | ||
164 | { | 164 | { | ||
165 | 165 | | |||
166 | KDevelop::Path::List resolveSystemDirs(KDevelop::IProject* project, const QStringList& dirs) | 166 | KDevelop::Path::List resolveSystemDirs(KDevelop::IProject* project, const QStringList& dirs) | ||
167 | { | 167 | { | ||
168 | const KDevelop::Path buildDir(CMake::currentBuildDir(project)); | 168 | const KDevelop::Path buildDir(CMake::currentBuildDir(project, true)); | ||
169 | const KDevelop::Path installDir(CMake::currentInstallDir(project)); | 169 | const KDevelop::Path installDir(CMake::currentInstallDir(project)); | ||
170 | 170 | | |||
171 | KDevelop::Path::List newList; | 171 | KDevelop::Path::List newList; | ||
172 | newList.reserve(dirs.size()); | 172 | newList.reserve(dirs.size()); | ||
173 | foreach(const QString& s, dirs) | 173 | foreach(const QString& s, dirs) | ||
174 | { | 174 | { | ||
175 | KDevelop::Path dir; | 175 | KDevelop::Path dir; | ||
176 | if(s.startsWith(QLatin1String("#[bin_dir]"))) | 176 | if(s.startsWith(QLatin1String("#[bin_dir]"))) | ||
Show All 18 Lines | 189 | // qCDebug(CMAKE) << "resolved" << s << "to" << d; | |||
195 | } | 195 | } | ||
196 | return newList; | 196 | return newList; | ||
197 | } | 197 | } | ||
198 | 198 | | |||
199 | ///NOTE: when you change this, update @c defaultConfigure in cmakemanagertest.cpp | 199 | ///NOTE: when you change this, update @c defaultConfigure in cmakemanagertest.cpp | ||
200 | bool checkForNeedingConfigure( KDevelop::IProject* project ) | 200 | bool checkForNeedingConfigure( KDevelop::IProject* project ) | ||
201 | { | 201 | { | ||
202 | const QString currentRuntime = ICore::self()->runtimeController()->currentRuntime()->name(); | 202 | const QString currentRuntime = ICore::self()->runtimeController()->currentRuntime()->name(); | ||
203 | const KDevelop::Path builddir = currentBuildDir(project); | 203 | const KDevelop::Path builddir = currentBuildDir(project, true); | ||
204 | const bool isValid = (buildDirRuntime(project, -1) == currentRuntime || buildDirRuntime(project, -1).isEmpty()) && builddir.isValid(); | 204 | const bool isValid = (buildDirRuntime(project, -1) == currentRuntime || buildDirRuntime(project, -1).isEmpty()) && builddir.isValid(); | ||
205 | 205 | | |||
206 | if( !isValid ) | 206 | if( !isValid ) | ||
207 | { | 207 | { | ||
208 | CMakeBuildDirChooser bd; | 208 | CMakeBuildDirChooser bd; | ||
209 | 209 | | |||
210 | bd.setProject( project ); | 210 | bd.setProject( project ); | ||
211 | const auto builddirs = CMake::allBuildDirs(project); | 211 | const auto builddirs = CMake::allBuildDirs(project, true); | ||
212 | bd.setAlreadyUsed( builddirs ); | 212 | bd.setAlreadyUsed( builddirs ); | ||
213 | bd.setShowAvailableBuildDirs(!builddirs.isEmpty()); | 213 | bd.setShowAvailableBuildDirs(!builddirs.isEmpty()); | ||
214 | bd.setCMakeExecutable(currentCMakeExecutable(project)); | 214 | bd.setCMakeExecutable(currentCMakeExecutable(project)); | ||
215 | 215 | | |||
216 | if( !bd.exec() ) | 216 | if( !bd.exec() ) | ||
217 | { | 217 | { | ||
218 | return false; | 218 | return false; | ||
219 | } | 219 | } | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | |||||
288 | { | 288 | { | ||
289 | if (!project) { | 289 | if (!project) { | ||
290 | return {}; | 290 | return {}; | ||
291 | } | 291 | } | ||
292 | 292 | | |||
293 | return project->path().cd(CMake::projectRootRelative(project)); | 293 | return project->path().cd(CMake::projectRootRelative(project)); | ||
294 | } | 294 | } | ||
295 | 295 | | |||
296 | KDevelop::Path currentBuildDir( KDevelop::IProject* project, int builddir ) | 296 | KDevelop::Path currentBuildDir( KDevelop::IProject* project, bool canonical, int builddir ) | ||
297 | { | 297 | { | ||
298 | return KDevelop::Path(readBuildDirParameter( project, Config::Specific::buildDirPathKey, QString(), builddir )); | 298 | KDevelop::Path buildDir(readBuildDirParameter( project, Config::Specific::buildDirPathKey, QString(), builddir )); | ||
299 | if (canonical) { | ||||
300 | return KDevelop::Path(QFileInfo(buildDir.toLocalFile()).canonicalFilePath()); | ||||
301 | } else { | ||||
302 | return buildDir; | ||||
303 | } | ||||
299 | } | 304 | } | ||
300 | 305 | | |||
301 | KDevelop::Path commandsFile(KDevelop::IProject* project) | 306 | KDevelop::Path commandsFile(KDevelop::IProject* project) | ||
302 | { | 307 | { | ||
303 | auto currentBuildDir = CMake::currentBuildDir(project); | 308 | auto currentBuildDir = CMake::currentBuildDir(project); | ||
304 | if (currentBuildDir.isEmpty()) { | 309 | if (currentBuildDir.isEmpty()) { | ||
305 | return {}; | 310 | return {}; | ||
306 | } | 311 | } | ||
▲ Show 20 Lines • Show All 308 Lines • ▼ Show 20 Line(s) | 612 | { | |||
615 | baseGrp.deleteEntry(Config::buildDirOverrideIndexKey); | 620 | baseGrp.deleteEntry(Config::buildDirOverrideIndexKey); | ||
616 | } | 621 | } | ||
617 | 622 | | |||
618 | ICMakeDocumentation* cmakeDocumentation() | 623 | ICMakeDocumentation* cmakeDocumentation() | ||
619 | { | 624 | { | ||
620 | return KDevelop::ICore::self()->pluginController()->extensionForPlugin<ICMakeDocumentation>(QStringLiteral("org.kdevelop.ICMakeDocumentation")); | 625 | return KDevelop::ICore::self()->pluginController()->extensionForPlugin<ICMakeDocumentation>(QStringLiteral("org.kdevelop.ICMakeDocumentation")); | ||
621 | } | 626 | } | ||
622 | 627 | | |||
623 | QStringList allBuildDirs(KDevelop::IProject* project) | 628 | QStringList allBuildDirs(KDevelop::IProject* project, bool canonical) | ||
624 | { | 629 | { | ||
625 | QStringList result; | 630 | QStringList result; | ||
626 | int bdCount = buildDirCount(project); | 631 | int bdCount = buildDirCount(project); | ||
627 | for (int i = 0; i < bdCount; ++i) | 632 | for (int i = 0; i < bdCount; ++i) { | ||
628 | result += buildDirGroup( project, i ).readEntry( Config::Specific::buildDirPathKey ); | 633 | QString buildDir = buildDirGroup( project, i ).readEntry( Config::Specific::buildDirPathKey ); | ||
634 | if (canonical) { | ||||
635 | result += QFileInfo(buildDir).canonicalFilePath(); | ||||
636 | } else { | ||||
637 | result += buildDir; | ||||
638 | } | ||||
639 | } | ||||
629 | return result; | 640 | return result; | ||
630 | } | 641 | } | ||
631 | 642 | | |||
632 | QString executeProcess(const QString& execName, const QStringList& args) | 643 | QString executeProcess(const QString& execName, const QStringList& args) | ||
633 | { | 644 | { | ||
634 | Q_ASSERT(!execName.isEmpty()); | 645 | Q_ASSERT(!execName.isEmpty()); | ||
635 | qCDebug(CMAKE) << "Executing:" << execName << "::" << args; | 646 | qCDebug(CMAKE) << "Executing:" << execName << "::" << args; | ||
636 | 647 | | |||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |