Skip to content

Commit 658d59f

Browse files
authored
[projmgr] Ensure list target-sets accepts image-only solutions
1 parent 7638235 commit 658d59f

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

tools/projmgr/include/ProjMgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ class ProjMgr {
207207
bool UpdateRte();
208208
bool ParseAndValidateContexts();
209209
bool ProcessContexts();
210+
bool IsSolutionImageOnly();
210211
};
211212

212213
#endif // PROJMGR_H

tools/projmgr/src/ProjMgr.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ bool ProjMgr::PopulateContexts(void) {
470470
}
471471
// Check cproject separate folders and unique names
472472
const StrVec& cprojects = m_parser.GetCsolution().cprojects;
473-
if (m_activeTargetSet.empty() && cprojects.empty()) {
473+
if (!IsSolutionImageOnly() && cprojects.empty()) {
474474
ProjMgrLogger::Get().Error("projects not found", "", m_csolutionFile);
475475
return false;
476476
}
@@ -1219,4 +1219,22 @@ const string ProjMgr::GetDebugAdaptersFile(void) {
12191219
return debugAdapterFile;
12201220
}
12211221
return RteUtils::EMPTY_STRING;
1222-
}
1222+
}
1223+
1224+
bool ProjMgr::IsSolutionImageOnly() {
1225+
// when the solution has only target-set images without project-contexts it is an 'image-only' solution
1226+
bool imageOnly = false;
1227+
for (const auto& [_, type] : m_parser.GetCsolution().targetTypes) {
1228+
for (const auto& targetSet : type.targetSet) {
1229+
if (!targetSet.images.empty()) {
1230+
imageOnly = true;
1231+
for (const auto& item : targetSet.images) {
1232+
if (!item.context.empty()) {
1233+
return false;
1234+
}
1235+
}
1236+
}
1237+
}
1238+
}
1239+
return imageOnly;
1240+
}

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4155,6 +4155,9 @@ bool ProjMgrWorker::ListConfigs(vector<string>& configFiles, const string& filte
41554155
}
41564156

41574157
bool ProjMgrWorker::ListDependencies(vector<string>& dependencies, const string& filter) {
4158+
if (m_contexts.empty()) {
4159+
return false;
4160+
}
41584161
RteCondition::SetVerboseFlags(m_verbose ? VERBOSE_DEPENDENCY : m_debug ? VERBOSE_FILTER | VERBOSE_DEPENDENCY : 0);
41594162
set<string>dependenciesSet;
41604163
for (const auto& selectedContext : m_selectedContexts) {
@@ -4226,9 +4229,6 @@ bool ProjMgrWorker::ListContexts(vector<string>& contexts, const string& filter,
42264229
}
42274230

42284231
bool ProjMgrWorker::ListTargetSets(vector<string>& targetSets, const string& filter) {
4229-
if (m_contexts.empty()) {
4230-
return false;
4231-
}
42324232
vector<string> targetSetsVec;
42334233

42344234
for (const auto& [name, type] : m_parser->GetCsolution().targetTypes) {

tools/projmgr/test/src/ProjMgrUnitTests.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6886,6 +6886,19 @@ TEST_F(ProjMgrUnitTests, ListTargetSets) {
68866886
EXPECT_TRUE(errStr.find("no target-set was found with filter 'Unknown'") != string::npos);
68876887
}
68886888

6889+
TEST_F(ProjMgrUnitTests, ListTargetSetsImageOnly) {
6890+
char* argv[6];
6891+
StdStreamRedirect streamRedirect;
6892+
const string& csolution = testinput_folder + "/ImageOnly/image-only.csolution.yml";
6893+
argv[1] = (char*)"list";
6894+
argv[2] = (char*)"target-sets";
6895+
argv[3] = (char*)csolution.c_str();
6896+
EXPECT_EQ(0, RunProjMgr(4, argv, 0));
6897+
6898+
auto outStr = streamRedirect.GetOutString();
6899+
EXPECT_STREQ(outStr.c_str(), "CM0\n");
6900+
}
6901+
68896902
TEST_F(ProjMgrUnitTests, ConvertActiveTargetSet) {
68906903
char* argv[6];
68916904
StdStreamRedirect streamRedirect;

0 commit comments

Comments
 (0)