bool QMakeStep::init() { QmakeBuildConfiguration *qt4bc = qmakeBuildConfiguration(); const QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(target()->kit()); if (!qtVersion) return false; QString args = allArguments(); QString workingDirectory; if (qt4bc->subNodeBuild()) workingDirectory = qt4bc->subNodeBuild()->buildDir(); else workingDirectory = qt4bc->buildDirectory().toString(); FileName program = qtVersion->qmakeCommand(); QString makefile = workingDirectory; if (qt4bc->subNodeBuild()) { if (!qt4bc->subNodeBuild()->makefile().isEmpty()) makefile.append(qt4bc->subNodeBuild()->makefile()); else makefile.append(QLatin1String("/Makefile")); } else if (!qt4bc->makefile().isEmpty()) { makefile.append(QLatin1Char('/')); makefile.append(qt4bc->makefile()); } else { makefile.append(QLatin1String("/Makefile")); } // Check whether we need to run qmake bool makefileOutDated = (qt4bc->compareToImportFrom(makefile) != QmakeBuildConfiguration::MakefileMatches); if (m_forced || makefileOutDated) m_needToRunQMake = true; m_forced = false; ProcessParameters *pp = processParameters(); pp->setMacroExpander(qt4bc->macroExpander()); pp->setWorkingDirectory(workingDirectory); pp->setCommand(program.toString()); pp->setArguments(args); pp->setEnvironment(qt4bc->environment()); pp->resolveAll(); setOutputParser(new QMakeParser); QmakeProFileNode *node = static_cast<QmakeProject *>(qt4bc->target()->project())->rootQmakeProjectNode(); if (qt4bc->subNodeBuild()) node = qt4bc->subNodeBuild(); QString proFile = node->path(); m_tasks = qtVersion->reportIssues(proFile, workingDirectory); qSort(m_tasks); m_scriptTemplate = node->projectType() == ScriptTemplate; return AbstractProcessStep::init(); }
void InternalLibraryDetailsController::slotCurrentLibraryChanged() { const int currentIndex = libraryDetailsWidget()->libraryComboBox->currentIndex(); if (currentIndex >= 0) { libraryDetailsWidget()->libraryComboBox->setToolTip( libraryDetailsWidget()->libraryComboBox->itemData( currentIndex, Qt::ToolTipRole).toString()); QmakeProFileNode *proFileNode = m_proFileNodes.at(currentIndex); const QStringList configVar = proFileNode->variableValue(ConfigVar); if (creatorPlatform() == CreatorWindows) { bool useSubfolders = false; if (configVar.contains(QLatin1String("debug_and_release")) && configVar.contains(QLatin1String("debug_and_release_target"))) useSubfolders = true; libraryDetailsWidget()->useSubfoldersCheckBox->setChecked(useSubfolders); libraryDetailsWidget()->addSuffixCheckBox->setChecked(!useSubfolders); } } if (guiSignalsIgnored()) return; updateGui(); emit completeChanged(); }
void QmakeProjectManagerPluginPrivate::updateContextActions() { const Node *node = ProjectTree::findCurrentNode(); Project *project = ProjectTree::currentProject(); const ContainerNode *containerNode = node ? node->asContainerNode() : nullptr; const auto *proFileNode = dynamic_cast<const QmakeProFileNode *>(containerNode ? containerNode->rootProjectNode() : node); m_addLibraryActionContextMenu->setEnabled(proFileNode); auto *qmakeProject = qobject_cast<QmakeProject *>(QmakeManager::contextProject()); QmakeProFileNode *subProjectNode = nullptr; disableBuildFileMenus(); if (node) { auto subPriFileNode = dynamic_cast<const QmakePriFileNode *>(node); if (!subPriFileNode) subPriFileNode = dynamic_cast<QmakePriFileNode *>(node->parentProjectNode()); subProjectNode = subPriFileNode ? subPriFileNode->proFileNode() : nullptr; if (const FileNode *fileNode = node->asFileNode()) enableBuildFileMenus(fileNode->filePath()); } bool subProjectActionsVisible = false; if (qmakeProject && subProjectNode) { if (ProjectNode *rootNode = qmakeProject->rootProjectNode()) subProjectActionsVisible = subProjectNode != rootNode; } QString subProjectName; if (subProjectActionsVisible) subProjectName = subProjectNode->displayName(); m_buildSubProjectAction->setParameter(subProjectName); m_rebuildSubProjectAction->setParameter(subProjectName); m_cleanSubProjectAction->setParameter(subProjectName); m_buildSubProjectContextMenu->setParameter(proFileNode ? proFileNode->displayName() : QString()); auto buildConfiguration = (qmakeProject && qmakeProject->activeTarget()) ? static_cast<QmakeBuildConfiguration *>(qmakeProject->activeTarget()->activeBuildConfiguration()) : nullptr; bool isProjectNode = qmakeProject && proFileNode && buildConfiguration; bool isBuilding = BuildManager::isBuilding(project); bool enabled = subProjectActionsVisible && !isBuilding; m_buildSubProjectAction->setVisible(subProjectActionsVisible); m_rebuildSubProjectAction->setVisible(subProjectActionsVisible); m_cleanSubProjectAction->setVisible(subProjectActionsVisible); m_buildSubProjectContextMenu->setVisible(subProjectActionsVisible && isProjectNode); m_subProjectRebuildSeparator->setVisible(subProjectActionsVisible && isProjectNode); m_rebuildSubProjectContextMenu->setVisible(subProjectActionsVisible && isProjectNode); m_cleanSubProjectContextMenu->setVisible(subProjectActionsVisible && isProjectNode); m_buildSubProjectAction->setEnabled(enabled); m_rebuildSubProjectAction->setEnabled(enabled); m_cleanSubProjectAction->setEnabled(enabled); m_buildSubProjectContextMenu->setEnabled(enabled && isProjectNode); m_rebuildSubProjectContextMenu->setEnabled(enabled && isProjectNode); m_cleanSubProjectContextMenu->setEnabled(enabled && isProjectNode); m_runQMakeActionContextMenu->setEnabled(isProjectNode && !isBuilding && buildConfiguration->qmakeStep()); }
QmakeProFileNode *DesktopQmakeRunConfiguration::projectNode() const { QmakeProject *project = qmakeProject(); QTC_ASSERT(project, return nullptr); QmakeProFileNode *rootNode = project->rootProjectNode(); QTC_ASSERT(rootNode, return nullptr); return rootNode->findProFileFor(m_proFilePath); }
QString InternalLibraryDetailsController::suggestedIncludePath() const { const int currentIndex = libraryDetailsWidget()->libraryComboBox->currentIndex(); if (currentIndex >= 0) { QmakeProFileNode *proFileNode = m_proFileNodes.at(currentIndex); return proFileNode->filePath().toFileInfo().absolutePath(); } return QString(); }
QString InternalLibraryDetailsController::suggestedIncludePath() const { const int currentIndex = libraryDetailsWidget()->libraryComboBox->currentIndex(); QString includePath; if (currentIndex >= 0) { QmakeProFileNode *proFileNode = m_proFileNodes.at(currentIndex); QFileInfo fi(proFileNode->path()); includePath = fi.absolutePath(); } return includePath; }
AddLibraryWizard::MacLibraryType InternalLibraryDetailsController::suggestedMacLibraryType() const { const int currentIndex = libraryDetailsWidget()->libraryComboBox->currentIndex(); AddLibraryWizard::MacLibraryType type = AddLibraryWizard::NoLibraryType; if (currentIndex >= 0) { QmakeProFileNode *proFileNode = m_proFileNodes.at(currentIndex); const QStringList configVar = proFileNode->variableValue(ConfigVar); if (configVar.contains(QLatin1String("lib_bundle"))) type = AddLibraryWizard::FrameworkType; else type = AddLibraryWizard::LibraryType; } return type; }
AddLibraryWizard::LinkageType InternalLibraryDetailsController::suggestedLinkageType() const { const int currentIndex = libraryDetailsWidget()->libraryComboBox->currentIndex(); AddLibraryWizard::LinkageType type = AddLibraryWizard::NoLinkage; if (currentIndex >= 0) { QmakeProFileNode *proFileNode = m_proFileNodes.at(currentIndex); const QStringList configVar = proFileNode->variableValue(ConfigVar); if (configVar.contains(QLatin1String("staticlib")) || configVar.contains(QLatin1String("static"))) type = AddLibraryWizard::StaticLinkage; else type = AddLibraryWizard::DynamicLinkage; } return type; }
QString InternalLibraryDetailsController::snippet() const { const int currentIndex = libraryDetailsWidget()->libraryComboBox->currentIndex(); if (currentIndex < 0) return QString(); if (m_rootProjectPath.isEmpty()) return QString(); // dir of the root project QDir rootDir(m_rootProjectPath); // relative path for the project for which we insert the snippet, // it's relative to the root project const QString proRelavitePath = rootDir.relativeFilePath(proFile()); // project for which we insert the snippet const Project *project = SessionManager::projectForFile(proFile()); // the build directory of the active build configuration QDir rootBuildDir = rootDir; // If the project is unconfigured use the project dir if (ProjectExplorer::Target *t = project->activeTarget()) if (ProjectExplorer::BuildConfiguration *bc = t->activeBuildConfiguration()) rootBuildDir = bc->buildDirectory().toString(); // the project for which we insert the snippet inside build tree QFileInfo pfi(rootBuildDir.filePath(proRelavitePath)); // the project dir for which we insert the snippet inside build tree QDir projectBuildDir(pfi.absolutePath()); // current project node from combobox QFileInfo fi(proFile()); QDir projectSrcDir(fi.absolutePath()); // project node which we want to link against QmakeProFileNode *proFileNode = m_proFileNodes.at(currentIndex); TargetInformation targetInfo = proFileNode->targetInformation(); const QString targetRelativePath = appendSeparator(projectBuildDir.relativeFilePath(targetInfo.buildDir)); const QString includeRelativePath = projectSrcDir.relativeFilePath(libraryDetailsWidget()->includePathChooser->path()); const bool useSubfolders = libraryDetailsWidget()->useSubfoldersCheckBox->isChecked(); const bool addSuffix = libraryDetailsWidget()->addSuffixCheckBox->isChecked(); QString snippetMessage; QTextStream str(&snippetMessage); str << "\n"; // replace below to "PRI_OUT_PWD" when task QTBUG-13057 is done // (end enable adding libraries into .pri files as well). const QString outPwd = QLatin1String("OUT_PWD"); str << generateLibsSnippet(platforms(), macLibraryType(), targetInfo.target, targetRelativePath, outPwd, useSubfolders, addSuffix, true); str << generateIncludePathSnippet(includeRelativePath); str << generatePreTargetDepsSnippet(platforms(), linkageType(), targetInfo.target, targetRelativePath, outPwd, useSubfolders, addSuffix); return snippetMessage; }
bool QMakeStep::init(QList<const BuildStep *> &earlierSteps) { if (m_commandFuture) return false; QmakeBuildConfiguration *qmakeBc = qmakeBuildConfiguration(); const BaseQtVersion *qtVersion = QtKitInformation::qtVersion(target()->kit()); if (!qtVersion) return false; QString workingDirectory; if (qmakeBc->subNodeBuild()) workingDirectory = qmakeBc->subNodeBuild()->buildDir(); else workingDirectory = qmakeBc->buildDirectory().toString(); m_qmakeExecutable = qtVersion->qmakeCommand().toString(); m_qmakeArguments = allArguments(qtVersion); m_runMakeQmake = (qtVersion->qtVersion() >= QtVersionNumber(5, 0 ,0)); if (m_runMakeQmake) { m_makeExecutable = makeCommand(); if (m_makeExecutable.isEmpty()) return false; } else { m_makeExecutable.clear(); } QString makefile = workingDirectory; if (qmakeBc->subNodeBuild()) { if (!qmakeBc->subNodeBuild()->makefile().isEmpty()) makefile.append(qmakeBc->subNodeBuild()->makefile()); else makefile.append(QLatin1String("/Makefile")); } else if (!qmakeBc->makefile().isEmpty()) { makefile.append(QLatin1Char('/')); makefile.append(qmakeBc->makefile()); } else { makefile.append(QLatin1String("/Makefile")); } // Check whether we need to run qmake bool makefileOutDated = (qmakeBc->compareToImportFrom(makefile) != QmakeBuildConfiguration::MakefileMatches); if (m_forced || makefileOutDated) m_needToRunQMake = true; m_forced = false; ProcessParameters *pp = processParameters(); pp->setMacroExpander(qmakeBc->macroExpander()); pp->setWorkingDirectory(workingDirectory); pp->setEnvironment(qmakeBc->environment()); setOutputParser(new QMakeParser); QmakeProFileNode *node = static_cast<QmakeProject *>(qmakeBc->target()->project())->rootProjectNode(); if (qmakeBc->subNodeBuild()) node = qmakeBc->subNodeBuild(); QString proFile = node->filePath().toString(); QList<ProjectExplorer::Task> tasks = qtVersion->reportIssues(proFile, workingDirectory); Utils::sort(tasks); if (!tasks.isEmpty()) { bool canContinue = true; foreach (const ProjectExplorer::Task &t, tasks) { addTask(t); if (t.type == Task::Error) canContinue = false; }