Skip to content

Commit 5625ff6

Browse files
authored
[projmgr] Remove orphaned cbuild-run.yml
1 parent 3e0a1ea commit 5625ff6

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

tools/projmgr/src/ProjMgrCbuildRun.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,21 @@ void ProjMgrCbuildRun::SetProcessorsNode(YAML::Node node, const vector<Processor
271271

272272
//-- ProjMgrYamlEmitter::GenerateCbuildRun --------------------------------------------------------
273273
bool ProjMgrYamlEmitter::GenerateCbuildRun(const RunDebugType& debugRun) {
274+
// remove cbuild-run file if it was generated in the $SolutionDir()$ by csolution lower than 2.11.0
275+
const string olderCbuildRun = RteFsUtils::ParentPath(debugRun.solution) + '/' +
276+
debugRun.solutionName + '+' + debugRun.targetType + ".cbuild-run.yml";
277+
if (RteFsUtils::Exists(olderCbuildRun)) {
278+
try {
279+
const YAML::Node& cbuildRun = YAML::LoadFile(olderCbuildRun);
280+
const auto& generatedBy = cbuildRun["cbuild-run"]["generated-by"].as<string>();
281+
const auto& tool = RteUtils::ExtractPrefix(generatedBy, " version");
282+
const auto& version = RteUtils::ExtractSuffix(generatedBy, "version ");
283+
if (tool == "csolution" && VersionCmp::Compare(version, "2.11.0") < 0) {
284+
RteFsUtils::RemoveFile(olderCbuildRun);
285+
}
286+
} catch (YAML::Exception&) {}
287+
}
288+
274289
// generate cbuild-run.yml
275290
m_cbuildRun = debugRun.cbuildRun;
276291
RteFsUtils::NormalizePath(m_cbuildRun, m_outputDir);

tools/projmgr/src/ProjMgrRpcServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ RpcArgs::DraftProjectsInfo RpcHandler::GetDraftProjects(const RpcArgs::DraftProj
676676
}
677677

678678
RpcArgs::ConvertSolutionResult RpcHandler::ConvertSolution(const string& solution, const string& activeTarget, const bool& updateRte) {
679-
RpcArgs::ConvertSolutionResult result = { false };
679+
RpcArgs::ConvertSolutionResult result = {{ false }};
680680
const auto csolutionFile = RteFsUtils::MakePathCanonical(solution);
681681
if (!regex_match(csolutionFile, regex(".*\\.csolution\\.(yml|yaml)"))) {
682682
result.message = solution + " is not a *.csolution.yml file";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cbuild-run:
2+
generated-by: csolution version 2.10.0

tools/projmgr/test/src/ProjMgrUnitTests.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6718,6 +6718,9 @@ TEST_F(ProjMgrUnitTests, TestRunDebug) {
67186718
testinput_folder + "/TestRunDebug/ref/run-debug+TestHW2.cbuild-run.yml");
67196719
ProjMgrTestEnv::CompareFile(testoutput_folder + "/out/run-debug/TestHW2/run-debug+TestHW2.cbuild.yml",
67206720
testinput_folder + "/TestRunDebug/ref/run-debug+TestHW2.cbuild.yml");
6721+
6722+
// Check cbuild-run file generated by csolution 2.10.0 was removed
6723+
EXPECT_FALSE(RteFsUtils::Exists(testinput_folder + "/TestRunDebug/run-debug+TestHW.cbuild-run.yml"));
67216724
}
67226725

67236726
TEST_F(ProjMgrUnitTests, TestRunDebugCustom) {

0 commit comments

Comments
 (0)