From 191accbb431abc9b941f5d763a438d9c48abcb16 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 14:10:37 +0000 Subject: [PATCH 01/16] replace 'CppTools::RawProjectParts' with 'ProjectExplorer::RawProjectParts' --- src/project_manager/ros_project.cpp | 4 ++-- src/project_manager/ros_project.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/project_manager/ros_project.cpp b/src/project_manager/ros_project.cpp index 8af23ebb..619bbd8a 100644 --- a/src/project_manager/ros_project.cpp +++ b/src/project_manager/ros_project.cpp @@ -476,7 +476,7 @@ void ROSProject::buildCppCodeModel(const ROSUtils::WorkspaceInfo workspaceInfo, } } - CppTools::RawProjectParts rpps; + ProjectExplorer::RawProjectParts rpps; ToolChain *cxxToolChain = ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); @@ -506,7 +506,7 @@ void ROSProject::buildCppCodeModel(const ROSUtils::WorkspaceInfo workspaceInfo, for (const ROSUtils::PackageTargetInfo& targetInfo : buildInfo.targets) { - CppTools::RawProjectPart rpp; + ProjectExplorer::RawProjectPart rpp; const QString defineArg = Utils::transform(targetInfo.defines, [](const QString &s) -> QString { QString result = QString::fromLatin1("#define ") + s; diff --git a/src/project_manager/ros_project.h b/src/project_manager/ros_project.h index d176302c..8871b04c 100644 --- a/src/project_manager/ros_project.h +++ b/src/project_manager/ros_project.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -108,7 +108,7 @@ private slots: struct CppToolsFutureResults { - CppTools::RawProjectParts parts; + ProjectExplorer::RawProjectParts parts; ROSUtils::PackageInfoMap wsPackageInfo; ROSUtils::PackageBuildInfoMap wsPackageBuildInfo; }; From 3854950b804d3788168a43a4f916af9fb36ca1ed Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 14:00:01 +0000 Subject: [PATCH 02/16] adapt command line formatting --- src/project_manager/ros_catkin_make_step.cpp | 12 +++++----- src/project_manager/ros_catkin_make_step.h | 2 +- src/project_manager/ros_catkin_tools_step.cpp | 12 +++++----- src/project_manager/ros_catkin_tools_step.h | 2 +- src/project_manager/ros_colcon_step.cpp | 22 ++++++++++++------- src/project_manager/ros_colcon_step.h | 2 +- 6 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/project_manager/ros_catkin_make_step.cpp b/src/project_manager/ros_catkin_make_step.cpp index 30ff1d70..a9b7c410 100644 --- a/src/project_manager/ros_catkin_make_step.cpp +++ b/src/project_manager/ros_catkin_make_step.cpp @@ -128,8 +128,7 @@ bool ROSCatkinMakeStep::init() // addToEnvironment() to not screw up the users run environment. env.set(QLatin1String("LC_ALL"), QLatin1String("C")); pp->setEnvironment(env); - pp->setCommand(Utils::FilePath::fromString(makeCommand())); - pp->setArguments(allArguments(bc->cmakeBuildType())); + pp->setCommandLine(makeCommand(allArguments(bc->cmakeBuildType()))); pp->resolveAll(); // If we are cleaning, then make can fail with an error code, but that doesn't mean @@ -202,9 +201,11 @@ QString ROSCatkinMakeStep::allArguments(ROSUtils::BuildType buildType, bool incl return args; } -QString ROSCatkinMakeStep::makeCommand() const +Utils::CommandLine ROSCatkinMakeStep::makeCommand(const QString &args) const { - return QLatin1String("catkin_make"); + Utils::CommandLine cmd(QLatin1String("catkin_make")); + cmd.addArgs(args, Utils::CommandLine::RawType::Raw); + return cmd; } void ROSCatkinMakeStep::stdOutput(const QString &line) @@ -302,8 +303,7 @@ void ROSCatkinMakeStepWidget::updateDetails() param.setMacroExpander(bc->macroExpander()); param.setWorkingDirectory(workspaceInfo.buildPath); param.setEnvironment(bc->environment()); - param.setCommand(Utils::FilePath::fromString(m_makeStep->makeCommand())); - param.setArguments(m_makeStep->allArguments(bc->cmakeBuildType(), false)); + param.setCommandLine(m_makeStep->makeCommand(m_makeStep->allArguments(bc->cmakeBuildType(), false))); m_summaryText = param.summary(displayName()); emit updateSummary(); } diff --git a/src/project_manager/ros_catkin_make_step.h b/src/project_manager/ros_catkin_make_step.h index 4dce229f..6901570e 100644 --- a/src/project_manager/ros_catkin_make_step.h +++ b/src/project_manager/ros_catkin_make_step.h @@ -55,7 +55,7 @@ class ROSCatkinMakeStep : public ProjectExplorer::AbstractProcessStep BuildTargets buildTarget() const; void setBuildTarget(const BuildTargets &target); QString allArguments(ROSUtils::BuildType buildType, bool includeDefault = true) const; - QString makeCommand() const; + Utils::CommandLine makeCommand(const QString &args) const; void stdOutput(const QString &line) override; QVariantMap toMap() const override; diff --git a/src/project_manager/ros_catkin_tools_step.cpp b/src/project_manager/ros_catkin_tools_step.cpp index 067c3728..c035cb32 100644 --- a/src/project_manager/ros_catkin_tools_step.cpp +++ b/src/project_manager/ros_catkin_tools_step.cpp @@ -140,8 +140,7 @@ bool ROSCatkinToolsStep::init() // addToEnvironment() to not screw up the users run environment. env.set(QLatin1String("LC_ALL"), QLatin1String("C")); pp->setEnvironment(env); - pp->setCommand(Utils::FilePath::fromString(makeCommand())); - pp->setArguments(allArguments(bc->cmakeBuildType())); + pp->setCommandLine(makeCommand(allArguments(bc->cmakeBuildType()))); pp->resolveAll(); // If we are cleaning, then make can fail with an error code, but that doesn't mean @@ -229,9 +228,11 @@ QString ROSCatkinToolsStep::allArguments(ROSUtils::BuildType buildType, bool inc return args; } -QString ROSCatkinToolsStep::makeCommand() const +Utils::CommandLine ROSCatkinToolsStep::makeCommand(const QString &args) const { - return QLatin1String("catkin"); + Utils::CommandLine cmd(QLatin1String("catkin")); + cmd.addArgs(args, Utils::CommandLine::RawType::Raw); + return cmd; } void ROSCatkinToolsStep::stdOutput(const QString &line) @@ -383,8 +384,7 @@ void ROSCatkinToolsStepWidget::updateDetails() param.setMacroExpander(bc->macroExpander()); param.setEnvironment(bc->environment()); param.setWorkingDirectory(Utils::FilePath::fromString(m_makeStep->m_catkinToolsWorkingDir)); - param.setCommand(Utils::FilePath::fromString(m_makeStep->makeCommand())); - param.setArguments(m_makeStep->allArguments(bc->cmakeBuildType(), false)); + param.setCommandLine(m_makeStep->makeCommand(m_makeStep->allArguments(bc->cmakeBuildType(), false))); m_summaryText = param.summary(displayName()); emit updateSummary(); } diff --git a/src/project_manager/ros_catkin_tools_step.h b/src/project_manager/ros_catkin_tools_step.h index 75d5eed4..eb991ba3 100644 --- a/src/project_manager/ros_catkin_tools_step.h +++ b/src/project_manager/ros_catkin_tools_step.h @@ -67,7 +67,7 @@ class ROSCatkinToolsStep : public ProjectExplorer::AbstractProcessStep void setActiveProfile(const QString &profileName); QString allArguments(ROSUtils::BuildType buildType, bool includeDefault = true) const; - QString makeCommand() const; + Utils::CommandLine makeCommand(const QString &args) const; void stdOutput(const QString &line) override; QVariantMap toMap() const override; diff --git a/src/project_manager/ros_colcon_step.cpp b/src/project_manager/ros_colcon_step.cpp index 0f6f131b..3a5d6a17 100644 --- a/src/project_manager/ros_colcon_step.cpp +++ b/src/project_manager/ros_colcon_step.cpp @@ -128,8 +128,7 @@ bool ROSColconStep::init() // addToEnvironment() to not screw up the users run environment. env.set(QLatin1String("LC_ALL"), QLatin1String("C")); pp->setEnvironment(env); - pp->setCommand(Utils::FilePath::fromString(makeCommand())); - pp->setArguments(allArguments(bc->cmakeBuildType())); + pp->setCommandLine(makeCommand(allArguments(bc->cmakeBuildType()))); pp->resolveAll(); // If we are cleaning, then make can fail with an error code, but that doesn't mean @@ -200,16 +199,24 @@ QString ROSColconStep::allArguments(ROSUtils::BuildType buildType, bool includeD return args; } -QString ROSColconStep::makeCommand() const +Utils::CommandLine ROSColconStep::makeCommand(const QString &args) const { + QLatin1String exec; switch(m_target) { case BUILD: - return QLatin1String("colcon"); + exec = QLatin1String("colcon"); + break; case CLEAN: - return QLatin1String("rm"); + exec = QLatin1String("rm"); + break; default: - return QLatin1String("colcon"); + exec = QLatin1String("colcon"); + break; } + + Utils::CommandLine cmd(exec); + cmd.addArgs(args, Utils::CommandLine::RawType::Raw); + return cmd; } void ROSColconStep::stdOutput(const QString &line) @@ -305,8 +312,7 @@ void ROSColconStepWidget::updateDetails() param.setMacroExpander(bc->macroExpander()); param.setWorkingDirectory(workspaceInfo.buildPath); param.setEnvironment(bc->environment()); - param.setCommand(Utils::FilePath::fromString(m_makeStep->makeCommand())); - param.setArguments(m_makeStep->allArguments(bc->cmakeBuildType(), false)); + param.setCommandLine(m_makeStep->makeCommand(m_makeStep->allArguments(bc->cmakeBuildType(), false))); m_summaryText = param.summary(displayName()); emit updateSummary(); } diff --git a/src/project_manager/ros_colcon_step.h b/src/project_manager/ros_colcon_step.h index c9acea82..215f9469 100644 --- a/src/project_manager/ros_colcon_step.h +++ b/src/project_manager/ros_colcon_step.h @@ -56,7 +56,7 @@ class ROSColconStep : public ProjectExplorer::AbstractProcessStep void setBuildTarget(const BuildTargets &target); QString allArguments(ROSUtils::BuildType buildType, bool includeDefault = true) const; - QString makeCommand() const; + Utils::CommandLine makeCommand(const QString &args) const; void stdOutput(const QString &line) override; QVariantMap toMap() const override; From 6e8a6a6186627b8ec3f7446aa4406cd4ed13b7b2 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 14:01:48 +0000 Subject: [PATCH 03/16] adapt type for environment variables --- src/project_manager/ros_build_configuration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/project_manager/ros_build_configuration.cpp b/src/project_manager/ros_build_configuration.cpp index 7a980847..1f1f573d 100644 --- a/src/project_manager/ros_build_configuration.cpp +++ b/src/project_manager/ros_build_configuration.cpp @@ -169,7 +169,7 @@ ROSProject *ROSBuildConfiguration::project() void ROSBuildConfiguration::updateQtEnvironment(const Utils::Environment &env) { - QList diff = baseEnvironment().diff(env); + const Utils::NameValueItems diff = baseEnvironment().diff(env); if (!diff.isEmpty()) setUserEnvironmentChanges(diff); } From cd2a9d62221fbf7d88661bc02f8232cd08b920b3 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 14:02:42 +0000 Subject: [PATCH 04/16] remove 'RunStepList::project' --- src/project_manager/ros_run_step.cpp | 5 ----- src/project_manager/ros_run_step.h | 1 - 2 files changed, 6 deletions(-) diff --git a/src/project_manager/ros_run_step.cpp b/src/project_manager/ros_run_step.cpp index fcd97a3f..cf4c45a1 100644 --- a/src/project_manager/ros_run_step.cpp +++ b/src/project_manager/ros_run_step.cpp @@ -430,10 +430,5 @@ ProjectExplorer::Target *RunStepList::target() const return 0; } -ProjectExplorer::Project *RunStepList::project() const -{ - return target()->project(); -} - } // namespace Internal } // namespace ROSProjectManager diff --git a/src/project_manager/ros_run_step.h b/src/project_manager/ros_run_step.h index 195fbb0f..7742c4f4 100644 --- a/src/project_manager/ros_run_step.h +++ b/src/project_manager/ros_run_step.h @@ -182,7 +182,6 @@ class RunStepList : public ProjectExplorer::ProjectConfiguration RunStep *at(int position); ProjectExplorer::Target *target() const; - ProjectExplorer::Project *project() const override; virtual QVariantMap toMap() const override; bool fromMap(const QVariantMap &map) override; From cdac7f966fe3ead70ec1d1de28abf25a2e93f4eb Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 15:00:32 +0000 Subject: [PATCH 05/16] adapt 'ROSBuildConfiguration::initialize' --- src/project_manager/ros_build_configuration.cpp | 15 ++++++--------- src/project_manager/ros_build_configuration.h | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/project_manager/ros_build_configuration.cpp b/src/project_manager/ros_build_configuration.cpp index 1f1f573d..37e48f2d 100644 --- a/src/project_manager/ros_build_configuration.cpp +++ b/src/project_manager/ros_build_configuration.cpp @@ -69,24 +69,21 @@ ROSBuildConfiguration::ROSBuildConfiguration(Target *parent, Core::Id id) { } -void ROSBuildConfiguration::initialize(const ProjectExplorer::BuildInfo &info) +void ROSBuildConfiguration::initialize() { - BuildConfiguration::initialize(info); + BuildConfiguration::initialize(); - auto extraInfo = info.extraInfo.value(); + const ROSExtraBuildInfo extra_info = extraInfo().value(); - setDisplayName(info.displayName); - setDefaultDisplayName(info.displayName); - setBuildDirectory(info.buildDirectory); - setBuildSystem(extraInfo.buildSystem); - setCMakeBuildType(extraInfo.cmakeBuildType); + setBuildSystem(extra_info.buildSystem); + setCMakeBuildType(extra_info.cmakeBuildType); BuildStepList *buildSteps = stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); BuildStepList *cleanSteps = stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN); Q_ASSERT(buildSteps); Q_ASSERT(cleanSteps); - switch (extraInfo.buildSystem) + switch (extra_info.buildSystem) { case ROSUtils::CatkinMake: { diff --git a/src/project_manager/ros_build_configuration.h b/src/project_manager/ros_build_configuration.h index fb6008d3..6ffbb561 100644 --- a/src/project_manager/ros_build_configuration.h +++ b/src/project_manager/ros_build_configuration.h @@ -57,7 +57,7 @@ class ROSBuildConfiguration : public ProjectExplorer::BuildConfiguration public: ROSBuildConfiguration(ProjectExplorer::Target *parent, Core::Id id); - void initialize(const ProjectExplorer::BuildInfo &info) override; + void initialize() override; ProjectExplorer::NamedWidget *createConfigWidget() override; QList createSubConfigWidgets() override; From 07caa73fe1de55ce3aba7a771eb705f255b2a945 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 15:07:53 +0000 Subject: [PATCH 06/16] adapt 'ROSBuildConfigurationFactory::availableBuilds' --- .../ros_build_configuration.cpp | 22 +++++-------------- src/project_manager/ros_build_configuration.h | 6 ++--- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/project_manager/ros_build_configuration.cpp b/src/project_manager/ros_build_configuration.cpp index 37e48f2d..9d609d50 100644 --- a/src/project_manager/ros_build_configuration.cpp +++ b/src/project_manager/ros_build_configuration.cpp @@ -198,29 +198,17 @@ ROSBuildConfigurationFactory::~ROSBuildConfigurationFactory() { } -QList ROSBuildConfigurationFactory::availableBuilds(const Target *parent) const +QList ROSBuildConfigurationFactory::availableBuilds(const Kit *k, + const Utils::FilePath &projectPath, + bool forSetup) const { - QList result; - - // Need to create a ROS Setting widget where the user sets the default build system to use here. - ROSUtils::BuildSystem buildSystem = static_cast(parent->project())->defaultBuildSystem(); + Q_UNUSED(forSetup); - for (int type = ROSUtils::BuildTypeDebug; type <= ROSUtils::BuildTypeUserDefined; ++type) - { - ProjectExplorer::BuildInfo info = createBuildInfo(parent->kit(), buildSystem, ROSUtils::BuildType(type)); - result << info; - } - - return result; -} - -QList ROSBuildConfigurationFactory::availableSetups(const Kit *k, const QString &projectPath) const -{ QList result; // Need to create a ROS Setting widget where the user sets the default build system to use here. ROSUtils::ROSProjectFileContent projectFileContent; - ROSUtils::parseQtCreatorWorkspaceFile(Utils::FilePath::fromString(projectPath), projectFileContent); + ROSUtils::parseQtCreatorWorkspaceFile(projectPath, projectFileContent); for (int type = ROSUtils::BuildTypeDebug; type <= ROSUtils::BuildTypeUserDefined; ++type) { ProjectExplorer::BuildInfo info = createBuildInfo(k, projectFileContent.defaultBuildSystem, ROSUtils::BuildType(type)); diff --git a/src/project_manager/ros_build_configuration.h b/src/project_manager/ros_build_configuration.h index 6ffbb561..1a43ab07 100644 --- a/src/project_manager/ros_build_configuration.h +++ b/src/project_manager/ros_build_configuration.h @@ -100,9 +100,9 @@ class ROSBuildConfigurationFactory : public ProjectExplorer::BuildConfigurationF explicit ROSBuildConfigurationFactory(); ~ROSBuildConfigurationFactory(); - QList availableBuilds(const ProjectExplorer::Target *parent) const override; - QList availableSetups(const ProjectExplorer::Kit *k, - const QString &projectPath) const override; + QList availableBuilds(const ProjectExplorer::Kit *k, + const Utils::FilePath &projectPath, + bool forSetup) const override; private: ProjectExplorer::BuildInfo createBuildInfo(const ProjectExplorer::Kit *k, const ROSUtils::BuildSystem &build_system, const ROSUtils::BuildType &type) const; From 9a3ce102255068d47c469f444ed168ea61573652 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 15:10:22 +0000 Subject: [PATCH 07/16] adapt Qt version management --- src/project_manager/ros_project.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/project_manager/ros_project.cpp b/src/project_manager/ros_project.cpp index 619bbd8a..7c4fb5db 100644 --- a/src/project_manager/ros_project.cpp +++ b/src/project_manager/ros_project.cpp @@ -456,12 +456,12 @@ void ROSProject::buildCppCodeModel(const ROSUtils::WorkspaceInfo workspaceInfo, const Utils::FilePath sysRoot = SysRootKitAspect::sysRoot(k); - CppTools::ProjectPart::QtVersion activeQtVersion = CppTools::ProjectPart::NoQt; + Utils::QtVersion activeQtVersion = Utils::QtVersion::None; if (QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(k)) { if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0)) - activeQtVersion = CppTools::ProjectPart::Qt4; + activeQtVersion = Utils::QtVersion::Qt4; else - activeQtVersion = CppTools::ProjectPart::Qt5; + activeQtVersion = Utils::QtVersion::Qt5; } // Get all of the workspace includes directories From e38e003cea8f250723d5c170318e076bf9ae0e26 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 15:12:40 +0000 Subject: [PATCH 08/16] remove 'ROSProjectNode::removeFiles' --- src/project_manager/ros_project_nodes.cpp | 6 ------ src/project_manager/ros_project_nodes.h | 2 -- 2 files changed, 8 deletions(-) diff --git a/src/project_manager/ros_project_nodes.cpp b/src/project_manager/ros_project_nodes.cpp index 3776b71b..ced5b68e 100644 --- a/src/project_manager/ros_project_nodes.cpp +++ b/src/project_manager/ros_project_nodes.cpp @@ -81,12 +81,6 @@ bool ROSProjectNode::addFiles(const QStringList &filePaths, QStringList *notAdde return true; } -bool ROSProjectNode::removeFiles(const QStringList &filePaths, QStringList *notRemoved) -{ - ProjectExplorer::ProjectNode::removeFiles(filePaths, notRemoved); - return true; -} - bool ROSProjectNode::deleteFiles(const QStringList &filePaths) { ProjectExplorer::ProjectNode::deleteFiles(filePaths); diff --git a/src/project_manager/ros_project_nodes.h b/src/project_manager/ros_project_nodes.h index e4621e09..d04304a6 100644 --- a/src/project_manager/ros_project_nodes.h +++ b/src/project_manager/ros_project_nodes.h @@ -47,8 +47,6 @@ class ROSProjectNode : public ProjectExplorer::ProjectNode bool addFiles(const QStringList &filePaths, QStringList *notAdded = nullptr) override; - bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = nullptr) override; - bool deleteFiles(const QStringList &filePaths) override; bool renameFile(const QString &filePath, const QString &newFilePath) override; From 0776e200c9a1d4403cfcb5b558dd4ce223388bbe Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 15:13:58 +0000 Subject: [PATCH 09/16] adapt 'setInferiorExecutable' --- src/project_manager/ros_run_configuration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/project_manager/ros_run_configuration.cpp b/src/project_manager/ros_run_configuration.cpp index 36e27845..6ef59db7 100644 --- a/src/project_manager/ros_run_configuration.cpp +++ b/src/project_manager/ros_run_configuration.cpp @@ -244,7 +244,7 @@ void ROSDebugRunWorker::pidFound(ProjectExplorer::DeviceProcessItem process) m_timer.stop(); setAttachPid(Utils::ProcessHandle(process.pid)); setId(tr("Process %1").arg(process.pid)); - setInferiorExecutable(process.exe); + setInferiorExecutable(Utils::FilePath::fromString(process.exe)); setStartMode(Debugger::AttachExternal); setCloseMode(Debugger::DetachAtClose); setContinueAfterAttach(m_debugContinueOnAttach); From ae9f4c51ec8275890e3051dd6d44df42b3dd28cd Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 15:42:27 +0000 Subject: [PATCH 10/16] adapt 'ProjectExplorer::Project' constructor --- src/project_manager/ros_project.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/project_manager/ros_project.cpp b/src/project_manager/ros_project.cpp index 7c4fb5db..afd32d79 100644 --- a/src/project_manager/ros_project.cpp +++ b/src/project_manager/ros_project.cpp @@ -126,7 +126,7 @@ static FolderNode *recursiveFindOrCreateFolderNode(FolderNode *folder, const int UPDATE_INTERVAL = 300; ROSProject::ROSProject(const Utils::FilePath &fileName) : - ProjectExplorer::Project(Constants::ROS_MIME_TYPE, fileName, [this]() { refresh(); }), + ProjectExplorer::Project(Constants::ROS_MIME_TYPE, fileName), m_cppCodeModelUpdater(new CppTools::CppProjectUpdater), m_project_loaded(false), m_asyncUpdateFutureInterface(nullptr), From d518670785f5d002b3a6404a614ff773d16c8564 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 15:45:17 +0000 Subject: [PATCH 11/16] remove 'SimpleRunWorkerFactory' --- src/project_manager/ros_project_plugin.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/project_manager/ros_project_plugin.cpp b/src/project_manager/ros_project_plugin.cpp index c85cf410..b8839528 100644 --- a/src/project_manager/ros_project_plugin.cpp +++ b/src/project_manager/ros_project_plugin.cpp @@ -95,8 +95,6 @@ class ROSProjectPluginPrivate settingsPage(new ROSSettingsPage(settings)) { settings->fromSettings(ICore::settings()); - - runDebugWorkerFactory.addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE); } ROSRunConfigurationFactory runConfigFactory; @@ -106,9 +104,6 @@ class ROSProjectPluginPrivate ROSTestStepFactory rosTestStepFactory; ROSCatkinTestResultsStepFactory rosCatkinTestResultsStepFactory; - SimpleRunWorkerFactory runWorkerFactory; - SimpleRunWorkerFactory runDebugWorkerFactory; - ROSBuildConfigurationFactory buildConfigFactory; ROSCatkinMakeStepFactory catkinMakeStepFactory; ROSCatkinToolsStepFactory catkinToolsStepFactory; From baa7e3ed5da5c715e3f897a7fcadb28da10ca719 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 15:48:25 +0000 Subject: [PATCH 12/16] replace 'addTarget(createTarget())' with 'addTargetForKit' --- src/project_manager/ros_project.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/project_manager/ros_project.cpp b/src/project_manager/ros_project.cpp index afd32d79..57f19ceb 100644 --- a/src/project_manager/ros_project.cpp +++ b/src/project_manager/ros_project.cpp @@ -578,7 +578,7 @@ Project::RestoreResult ROSProject::fromMap(const QVariantMap &map, QString *erro Kit *defaultKit = KitManager::defaultKit(); if (!activeTarget() && defaultKit) - addTarget(createTarget(defaultKit)); + addTargetForKit(defaultKit); // Sanity check: We need both a buildconfiguration and a runconfiguration! QList targetList = targets(); From 3608cc24a6c39a252b90102b322e89e0d5ee4d55 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 15:57:43 +0000 Subject: [PATCH 13/16] adapt code model update --- src/project_manager/ros_project.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/project_manager/ros_project.cpp b/src/project_manager/ros_project.cpp index 57f19ceb..a2d2f155 100644 --- a/src/project_manager/ros_project.cpp +++ b/src/project_manager/ros_project.cpp @@ -559,7 +559,7 @@ void ROSProject::updateCppCodeModel() QtSupport::CppKitInfo kitInfo(this); QTC_ASSERT(kitInfo.isValid(), return); - m_cppCodeModelUpdater->update({this, kitInfo, std::move(m_futureBuildCodeModelWatcher.result().parts)}); + m_cppCodeModelUpdater->update({this, kitInfo, rosBuildConfiguration()->environment(), m_futureBuildCodeModelWatcher.result().parts}); m_asyncBuildCodeModelFutureInterface->reportFinished(); delete m_asyncBuildCodeModelFutureInterface; From 315b0d5df990e11ab5c6104f85f1216dd19825c8 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 16:08:14 +0000 Subject: [PATCH 14/16] adapt 'builtInHeaderPaths' --- src/project_manager/ros_project.cpp | 7 ++++--- src/project_manager/ros_project.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/project_manager/ros_project.cpp b/src/project_manager/ros_project.cpp index a2d2f155..b2ddd465 100644 --- a/src/project_manager/ros_project.cpp +++ b/src/project_manager/ros_project.cpp @@ -433,11 +433,11 @@ void ROSProject::asyncUpdateCppCodeModel(bool success) // TODO: Figure out why running this async causes segfaults if (async) { - Utils::runAsync(ProjectExplorer::ProjectExplorerPlugin::sharedThreadPool(), QThread::LowestPriority, [this, workspaceInfo, k]() { ROSProject::buildCppCodeModel(workspaceInfo, projectFilePath(), m_workspaceFiles, k, m_wsPackageInfo, m_wsPackageBuildInfo, *m_asyncBuildCodeModelFutureInterface); }); + Utils::runAsync(ProjectExplorer::ProjectExplorerPlugin::sharedThreadPool(), QThread::LowestPriority, [this, workspaceInfo, k, current_environment]() { ROSProject::buildCppCodeModel(workspaceInfo, projectFilePath(), m_workspaceFiles, k, current_environment, m_wsPackageInfo, m_wsPackageBuildInfo, *m_asyncBuildCodeModelFutureInterface); }); } else { - ROSProject::buildCppCodeModel(workspaceInfo, projectFilePath(), m_workspaceFiles, k, m_wsPackageInfo, m_wsPackageBuildInfo, *m_asyncBuildCodeModelFutureInterface); + ROSProject::buildCppCodeModel(workspaceInfo, projectFilePath(), m_workspaceFiles, k, current_environment, m_wsPackageInfo, m_wsPackageBuildInfo, *m_asyncBuildCodeModelFutureInterface); } } } @@ -446,6 +446,7 @@ void ROSProject::buildCppCodeModel(const ROSUtils::WorkspaceInfo workspaceInfo, const Utils::FilePath projectFilePath, const QStringList workspaceFiles, const Kit *k, + const Utils::Environment &env, const ROSUtils::PackageInfoMap wsPackageInfo, const ROSUtils::PackageBuildInfoMap wsPackageBuildInfo, QFutureInterface &fi) @@ -523,7 +524,7 @@ void ROSProject::buildCppCodeModel(const ROSUtils::WorkspaceInfo workspaceInfo, rpp.setMacros(ProjectExplorer::Macro::toMacros(defineArg.toUtf8())); QSet toolChainIncludes; - for (const HeaderPath &hp : cxxToolChain->builtInHeaderPaths(targetInfo.flags, sysRoot)) { + for (const HeaderPath &hp : cxxToolChain->builtInHeaderPaths(targetInfo.flags, sysRoot, env)) { toolChainIncludes.insert(hp.path); } diff --git a/src/project_manager/ros_project.h b/src/project_manager/ros_project.h index 8871b04c..de054d30 100644 --- a/src/project_manager/ros_project.h +++ b/src/project_manager/ros_project.h @@ -127,6 +127,7 @@ private slots: const Utils::FilePath projectFilePath, const QStringList workspaceFiles, const ProjectExplorer::Kit *k, + const Utils::Environment &env, const ROSUtils::PackageInfoMap wsPackageInfo, const ROSUtils::PackageBuildInfoMap wsPackageBuildInfo, QFutureInterface &fi); From 19e3df426cf2fe06a0ac61c71e85487e300ff095 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 4 Jan 2021 15:41:59 +0000 Subject: [PATCH 15/16] implement minimal 'BuildSystem' to control parsing --- src/project_manager/ros_build_system.cpp | 31 ++++++++++++++++++++++++ src/project_manager/ros_build_system.h | 27 +++++++++++++++++++++ src/project_manager/ros_project.cpp | 11 ++++++--- src/project_manager/ros_project.h | 2 ++ 4 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 src/project_manager/ros_build_system.cpp create mode 100644 src/project_manager/ros_build_system.h diff --git a/src/project_manager/ros_build_system.cpp b/src/project_manager/ros_build_system.cpp new file mode 100644 index 00000000..2f00bc86 --- /dev/null +++ b/src/project_manager/ros_build_system.cpp @@ -0,0 +1,31 @@ +#include "ros_build_system.h" + +#include "ros_build_configuration.h" + +using namespace ProjectExplorer; + +namespace ROSProjectManager { +namespace Internal { + +// -------------------------------------------------------------------- +// ROSBuildSystem: +// -------------------------------------------------------------------- + +ROSBuildSystem::ROSBuildSystem(ROSProject *p) + : BuildSystem(p) +{ + // +} + +bool ROSBuildSystem::validateParsingContext(const ParsingContext &ctx) +{ + return ctx.project && qobject_cast(ctx.buildConfiguration); +} + +void ROSBuildSystem::parseProject(ParsingContext &&ctx) +{ + ctx.guard.markAsSuccess(); +} + +} // namespace Internal +} // namespace ROSProjectManager diff --git a/src/project_manager/ros_build_system.h b/src/project_manager/ros_build_system.h new file mode 100644 index 00000000..9a4f4e3f --- /dev/null +++ b/src/project_manager/ros_build_system.h @@ -0,0 +1,27 @@ +#pragma once + +#include + +namespace ROSProjectManager { +namespace Internal { + +class ROSProject; + +// -------------------------------------------------------------------- +// ROSBuildSystem: +// -------------------------------------------------------------------- + +class ROSBuildSystem : public ProjectExplorer::BuildSystem +{ + Q_OBJECT + +public: + explicit ROSBuildSystem(ROSProject *project); + +protected: + bool validateParsingContext(const ParsingContext &ctx) final; + void parseProject(ParsingContext &&ctx) final; +}; + +} // namespace Internal +} // namespace ROSProjectManager diff --git a/src/project_manager/ros_project.cpp b/src/project_manager/ros_project.cpp index b2ddd465..8ad59af3 100644 --- a/src/project_manager/ros_project.cpp +++ b/src/project_manager/ros_project.cpp @@ -129,6 +129,7 @@ ROSProject::ROSProject(const Utils::FilePath &fileName) : ProjectExplorer::Project(Constants::ROS_MIME_TYPE, fileName), m_cppCodeModelUpdater(new CppTools::CppProjectUpdater), m_project_loaded(false), + m_build_system(nullptr), m_asyncUpdateFutureInterface(nullptr), m_asyncBuildCodeModelFutureInterface(nullptr) { @@ -270,7 +271,9 @@ void ROSProject::updateProjectTree() } } - emitParsingFinished(true); + // delete the build system and its parse guard to notify that parsing finished + delete m_build_system; + m_build_system = nullptr; } void ROSProject::buildProjectTree(const Utils::FilePath projectFilePath, const QStringList watchDirectories, QFutureInterface &fi) @@ -373,8 +376,10 @@ void ROSProject::fileSystemChanged(const QString &path) void ROSProject::asyncUpdate() { - if (!isParsing()) - emitParsingStarted(); + if (!m_build_system) { + m_build_system = new ROSBuildSystem(this); + m_build_system->requestParse(); + } m_futureWatcher.waitForFinished(); diff --git a/src/project_manager/ros_project.h b/src/project_manager/ros_project.h index de054d30..61259636 100644 --- a/src/project_manager/ros_project.h +++ b/src/project_manager/ros_project.h @@ -23,6 +23,7 @@ #include "ros_project_plugin.h" #include "ros_utils.h" +#include "ros_build_system.h" #include #include @@ -96,6 +97,7 @@ private slots: QStringList m_workspaceFiles; QStringList m_workspaceDirectories; bool m_project_loaded; + ROSBuildSystem *m_build_system; struct FutureWatcherResults From 6f9d137af05a733bcc701b7a17ec17ea4580b42e Mon Sep 17 00:00:00 2001 From: v4hn Date: Fri, 15 Jan 2021 11:30:20 +0100 Subject: [PATCH 16/16] remove java-style iterators https://github.com/qt-creator/qt-creator/commit/1b4766e26c6bd522ec49237075669ac025c47b20 disabled these classes upstream, so the plugin should not use them either. --- src/project_manager/ros_project.cpp | 7 +++---- src/project_manager/ros_utils.cpp | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/project_manager/ros_project.cpp b/src/project_manager/ros_project.cpp index 8ad59af3..2365c8c2 100644 --- a/src/project_manager/ros_project.cpp +++ b/src/project_manager/ros_project.cpp @@ -295,13 +295,11 @@ void ROSProject::buildProjectTree(const Utils::FilePath projectFilePath, const Q const ProjectExplorer::FolderNode::FolderNodeFactory &factory = [](const Utils::FilePath &fn) { return std::make_unique(fn); }; std::vector> childNodes; - QHashIterator item(results.workspaceContent); + QHash::const_iterator item = results.workspaceContent.constBegin(); int cnt = 0; double max = results.workspaceContent.size(); - while (item.hasNext()) + while(item != results.workspaceContent.constEnd()) { - item.next(); - if (item.value().files.empty()) { // This is required so empty directories show up in project tree Utils::FilePath empty_directory = Utils::FilePath::fromString(item.key()); @@ -325,6 +323,7 @@ void ROSProject::buildProjectTree(const Utils::FilePath projectFilePath, const Q cnt += 1; fi.setProgressValue(static_cast(100.0 * static_cast(cnt) / max)); + ++item; } project_node->addNestedNodes(std::move(childNodes), Utils::FilePath(), factory); diff --git a/src/project_manager/ros_utils.cpp b/src/project_manager/ros_utils.cpp index 79d0f8bb..b2a41d7c 100644 --- a/src/project_manager/ros_utils.cpp +++ b/src/project_manager/ros_utils.cpp @@ -527,11 +527,9 @@ ROSUtils::PackageInfoMap ROSUtils::getWorkspacePackageInfo(const WorkspaceInfo & PackageInfoMap wsPackageInfo; QMap packages = ROSUtils::getWorkspacePackagePaths(workspaceInfo); - QMapIterator it(packages); - while (it.hasNext()) + for(const auto& it : packages) { - it.next(); - Utils::FilePath pkgXml = Utils::FilePath::fromString(it.value()).pathAppended("package.xml"); + Utils::FilePath pkgXml = Utils::FilePath::fromString(it).pathAppended("package.xml"); ROSUtils::PackageInfo packageInfo; ROSPackageXmlParser pkgParser; if (pkgParser.parsePackageXml(pkgXml, packageInfo))