diff --git a/tools/projmgr/include/ProjMgrWorker.h b/tools/projmgr/include/ProjMgrWorker.h index 83f2f98d6..3b9ff9a57 100644 --- a/tools/projmgr/include/ProjMgrWorker.h +++ b/tools/projmgr/include/ProjMgrWorker.h @@ -1217,7 +1217,7 @@ class ProjMgrWorker { bool ProcessSequencesRelatives(ContextItem& context, bool rerun); bool ProcessSequencesRelatives(ContextItem& context, std::vector& src, const std::string& ref = std::string(), std::string outDir = std::string(), bool withHeadingDot = false, bool solutionLevel = false); bool ProcessSequencesRelatives(ContextItem& context, BuildType& build, const std::string& ref = std::string()); - bool ProcessSequenceRelative(ContextItem& context, std::string& item, const std::string& ref = std::string(), std::string outDir = std::string(), bool withHeadingDot = false, bool solutionLevel = false); + bool ProcessSequenceRelative(ContextItem& context, std::string& item, const std::string& ref = std::string(), bool genDep = true, std::string outDir = std::string(), bool withHeadingDot = false, bool solutionLevel = false); bool ProcessOutputFilenames(ContextItem& context); bool ProcessLinkerOptions(ContextItem& context); bool ProcessLinkerOptions(ContextItem& context, const LinkerItem& linker, const std::string& ref); diff --git a/tools/projmgr/src/ProjMgrWorker.cpp b/tools/projmgr/src/ProjMgrWorker.cpp index c6915784e..22e9868be 100644 --- a/tools/projmgr/src/ProjMgrWorker.cpp +++ b/tools/projmgr/src/ProjMgrWorker.cpp @@ -2637,7 +2637,7 @@ bool ProjMgrWorker::ProcessDebuggers(ContextItem& context) { context.debugger.protocol = m_activeTargetSet.debugger.protocol; if (!m_activeTargetSet.debugger.dbgconf.empty()) { context.debugger.dbgconf = m_activeTargetSet.debugger.dbgconf; - if (!ProcessSequenceRelative(context, context.debugger.dbgconf, context.csolution->directory)) { + if (!ProcessSequenceRelative(context, context.debugger.dbgconf, context.csolution->directory, false)) { return false; } if (RteFsUtils::IsRelative(context.debugger.dbgconf)) { @@ -2647,7 +2647,7 @@ bool ProjMgrWorker::ProcessDebuggers(ContextItem& context) { context.debugger.startPname = m_activeTargetSet.debugger.startPname; for (auto telnet : m_activeTargetSet.debugger.telnet) { if (!telnet.file.empty()) { - if (!ProcessSequenceRelative(context, telnet.file, context.csolution->directory)) { + if (!ProcessSequenceRelative(context, telnet.file, context.csolution->directory, false)) { return false; } } @@ -2670,7 +2670,8 @@ bool ProjMgrWorker::ProcessImages(ContextItem& context) { const vector& images = m_activeTargetSet.images; for (auto item : images) { if (!item.image.empty()) { - if (!ProcessSequenceRelative(context, item.image, context.csolution->directory)) { + // process access sequences + if (!ProcessSequenceRelative(context, item.image, context.csolution->directory, false)) { return false; } if (RteFsUtils::IsRelative(item.image)) { @@ -3549,7 +3550,8 @@ void ProjMgrWorker::ExpandPackDir(ContextItem& context, const string& pack, stri item = regex_replace(item, regEx, replacement); } -bool ProjMgrWorker::ProcessSequenceRelative(ContextItem& context, string& item, const string& ref, string outDir, bool withHeadingDot, bool solutionLevel) { +bool ProjMgrWorker::ProcessSequenceRelative(ContextItem& context, string& item, const string& ref, + bool genDep, string outDir, bool withHeadingDot, bool solutionLevel) { size_t offset = 0; bool pathReplace = false; outDir = outDir.empty() && item != context.directories.cprj ? context.directories.cprj : outDir; @@ -3610,7 +3612,7 @@ bool ProjMgrWorker::ProcessSequenceRelative(ContextItem& context, string& item, // expand access sequence ExpandAccessSequence(context, refContext, sequenceName, outDir, item, withHeadingDot); // store dependency information - if (refContext.name != context.name) { + if (genDep && refContext.name != context.name) { CollectionUtils::PushBackUniquely(context.dependsOn, refContext.name); } } else { @@ -4904,7 +4906,7 @@ std::string ProjMgrWorker::GetBoardInfoString(const std::string& vendor, bool ProjMgrWorker::ProcessSequencesRelatives(ContextItem& context, vector& src, const string& ref, string outDir, bool withHeadingDot, bool solutionLevel) { for (auto& item : src) { - if (!ProcessSequenceRelative(context, item, ref, outDir, withHeadingDot, solutionLevel)) { + if (!ProcessSequenceRelative(context, item, ref, true, outDir, withHeadingDot, solutionLevel)) { return false; } } diff --git a/tools/projmgr/test/data/TestTargetSet/cross-dependency.csolution.yml b/tools/projmgr/test/data/TestTargetSet/cross-dependency.csolution.yml new file mode 100644 index 000000000..044b8661e --- /dev/null +++ b/tools/projmgr/test/data/TestTargetSet/cross-dependency.csolution.yml @@ -0,0 +1,29 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json + +solution: + + compiler: AC6 + + target-types: + - type: CM4 + device: RteTest_ARMCM4_NOFP + target-set: + - set: + images: + - project-context: project + - project-context: project2 + - image: $OutDir(project)$/project.bin + - image: $OutDir(project2)$/project2.bin + debugger: + name: J-Link + dbgconf: $ProjectDir(project)$/$Dname$.dbgconf + telnet: + - mode: file + file: $OutDir(project2)$/telnet.log + + projects: + - project: project.cproject.yml + - project: project2.cproject.yml + + packs: + - pack: ARM::RteTest_DFP diff --git a/tools/projmgr/test/data/TestTargetSet/project2.cproject.yml b/tools/projmgr/test/data/TestTargetSet/project2.cproject.yml new file mode 100644 index 000000000..42a444d17 --- /dev/null +++ b/tools/projmgr/test/data/TestTargetSet/project2.cproject.yml @@ -0,0 +1,7 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/cproject.schema.json + +project: + + components: + - component: Startup + - component: CORE diff --git a/tools/projmgr/test/src/ProjMgrUnitTests.cpp b/tools/projmgr/test/src/ProjMgrUnitTests.cpp index 3a59ea316..87cb9b691 100644 --- a/tools/projmgr/test/src/ProjMgrUnitTests.cpp +++ b/tools/projmgr/test/src/ProjMgrUnitTests.cpp @@ -7324,3 +7324,23 @@ TEST_F(ProjMgrUnitTests, WestSupport) { testinput_folder + "/WestSupport/ref/core1.Debug+CM0.cbuild.yml"); } +TEST_F(ProjMgrUnitTests, TargetSetDependencies) { + char* argv[5]; + const string& csolution = testinput_folder + "/TestTargetSet/cross-dependency.csolution.yml"; + argv[1] = (char*)"convert"; + argv[2] = (char*)csolution.c_str(); + argv[3] = (char*)"--active"; + argv[4] = (char*)"CM4"; + EXPECT_EQ(0, RunProjMgr(5, argv, m_envp)); + const YAML::Node& cbuildRun = YAML::LoadFile(testinput_folder + "/TestTargetSet/out/cross-dependency+CM4.cbuild-run.yml"); + // check access sequences were correctly expanded: bin images, dbgconf and telnet file + EXPECT_EQ("project/CM4/project.bin", cbuildRun["cbuild-run"]["output"][2]["file"].as()); + EXPECT_EQ("project2/CM4/project2.bin", cbuildRun["cbuild-run"]["output"][3]["file"].as()); + EXPECT_EQ("../RteTest_ARMCM4_NOFP.dbgconf", cbuildRun["cbuild-run"]["debugger"]["dbgconf"].as()); + EXPECT_EQ("../../../../../project2/CM4/telnet.log", cbuildRun["cbuild-run"]["debugger"]["telnet"][0]["file"].as()); + + // ensure dependencies are not set + const YAML::Node& cbuildIdx = YAML::LoadFile(testinput_folder + "/TestTargetSet/cross-dependency.cbuild-idx.yml"); + EXPECT_FALSE(cbuildIdx["build-idx"]["cbuilds"][0]["depends-on"].IsDefined()); + EXPECT_FALSE(cbuildIdx["build-idx"]["cbuilds"][1]["depends-on"].IsDefined()); +}