Skip to content

Commit 4b696fb

Browse files
grasci-armbrondani
andauthored
[projmgr] Add RPC method ListMissingPacks (#1334) (#2242)
Co-authored-by: Daniel Brondani <[email protected]>
1 parent 2e8d330 commit 4b696fb

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

tools/projmgr/include/ProjMgrWorker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,7 @@ class ProjMgrWorker {
11261126
m_selectableCompilers.clear();
11271127
m_missingFiles.clear();
11281128
m_types = {};
1129+
m_activeTargetType.clear();
11291130
};
11301131

11311132
protected:

tools/projmgr/src/ProjMgrRpcServer.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class RpcHandler : public RpcMethods {
9898
RpcArgs::DraftProjectsInfo GetDraftProjects(const RpcArgs::DraftProjectsFilter& filter) override;
9999
RpcArgs::ConvertSolutionResult ConvertSolution(const string& solution, const string& activeTarget, const bool& updateRte) override;
100100
RpcArgs::DiscoverLayersInfo DiscoverLayers(const string& solution, const string& activeTarget) override;
101+
RpcArgs::ListMissingPacksResult ListMissingPacks(const string& solution, const string& activeTarget) override;
101102

102103
protected:
103104
enum Exception
@@ -789,4 +790,23 @@ RpcArgs::DiscoverLayersInfo RpcHandler::DiscoverLayers(const string& solution, c
789790
}
790791
}
791792

793+
RpcArgs::ListMissingPacksResult RpcHandler::ListMissingPacks(const string& solution, const string& activeTarget) {
794+
RpcArgs::ListMissingPacksResult result = {{ false }};
795+
string csolutionFile = solution;
796+
if (!CheckSolutionArg(csolutionFile, result.message)) {
797+
return result;
798+
}
799+
if (!m_manager.SetupContexts(csolutionFile, activeTarget)) {
800+
result.message = "Setup of solution contexts failed";
801+
return result;
802+
}
803+
StrVec missingPacks;
804+
m_worker.ListPacks(missingPacks, true);
805+
if (!missingPacks.empty()) {
806+
result.packs = missingPacks;
807+
}
808+
result.success = true;
809+
return result;
810+
}
811+
792812
// end of ProkMgrRpcServer.cpp

tools/projmgr/test/src/ProjMgrRpcTests.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,4 +831,24 @@ TEST_F(ProjMgrRpcTests, RpcDiscoverLayers) {
831831
EXPECT_FALSE(responses[0]["result"]["success"]);
832832
EXPECT_EQ(responses[0]["result"]["message"], "No compatible software layer found. Review required connections of the project");
833833
}
834+
835+
TEST_F(ProjMgrRpcTests, RpcListMissingPacks) {
836+
auto csolutionPath = testinput_folder + "/TestSolution/pack_missing.csolution.yml";
837+
auto requests =
838+
FormatRequest(1, "ListMissingPacks", json({ { "solution", csolutionPath }, { "activeTarget", "CM0" } })) +
839+
FormatRequest(2, "ListMissingPacks", json({ { "solution", csolutionPath }, { "activeTarget", "Gen" } })) +
840+
FormatRequest(3, "ListMissingPacks", json({ { "solution", csolutionPath }, { "activeTarget", "Unknown" } }));
841+
auto responses = RunRpcMethods(requests);
842+
843+
// valid responses
844+
EXPECT_TRUE(responses[0]["result"]["success"]);
845+
EXPECT_EQ(responses[0]["result"]["packs"][0], "ARM::[email protected]");
846+
EXPECT_TRUE(responses[1]["result"]["success"]);
847+
EXPECT_EQ(responses[1]["result"]["packs"][0], "ARM::[email protected]");
848+
849+
// unknown active target set
850+
EXPECT_FALSE(responses[2]["result"]["success"]);
851+
EXPECT_EQ(responses[2]["result"]["message"], "Setup of solution contexts failed");
852+
}
853+
834854
// end of ProjMgrRpcTests.cpp

0 commit comments

Comments
 (0)