Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate .Cbuild-idx.yml file with all contexts info #1136

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions tools/projmgr/src/ProjMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,15 @@ bool ProjMgr::RunConfigure(bool printConfig) {
if (!m_worker.InitializeModel()) {
return false;
}
vector<ContextItem*> allContexts;
vector<string> orderedContexts;
m_worker.GetYmlOrderedContexts(orderedContexts);
// Process contexts
bool error = false;
m_processedContexts.clear();
for (auto& contextName : orderedContexts) {
auto& contextItem = (*contexts)[contextName];
allContexts.push_back(&contextItem);
if (!m_worker.IsContextSelected(contextName)) {
continue;
}
Expand All @@ -481,6 +483,14 @@ bool ProjMgr::RunConfigure(bool printConfig) {
ProjMgrLogger::Info(infoMsg);
}
}

// Generate cbuild index
if (!allContexts.empty()) {
if (!m_emitter.GenerateCbuildIndex(m_parser, allContexts, m_outputDir)) {
return false;
}
}

return !error;
}

Expand Down Expand Up @@ -516,13 +526,6 @@ bool ProjMgr::RunConvert(void) {
return false;
}
}

// Generate cbuild index
if (!m_processedContexts.empty()) {
if (!m_emitter.GenerateCbuildIndex(m_parser, m_processedContexts, m_outputDir)) {
return false;
}
}
return !error;
}

Expand Down
3 changes: 3 additions & 0 deletions tools/projmgr/src/ProjMgrYamlEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,9 @@ bool ProjMgrYamlEmitter::GenerateCbuildIndex(ProjMgrParser& parser, const vector
ProjMgrYamlCbuild cbuild(rootNode[YAML_BUILD_IDX], contexts, parser, directory);

if (!cbuild.CompareFile(filename, rootNode)) {
if (!RteFsUtils::Exists(directory)) {
RteFsUtils::CreateDirectories(directory);
}
ofstream fileStream(filename);
if (!fileStream) {
ProjMgrLogger::Error(filename, "file cannot be written");
Expand Down
8 changes: 6 additions & 2 deletions tools/projmgr/test/src/ProjMgrUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3420,7 +3420,9 @@ TEST_F(ProjMgrUnitTests, RunProjMgr_UpdateRte) {
const string rteDir = testinput_folder + "/TestSolution/TestProject1/RTE/";
const string configFile = rteDir + "Device/RteTest_ARMCM0/startup_ARMCM0.c";
const string baseFile = configFile + "[email protected]";
const string& testdir = testoutput_folder + "/OutputDir";
RteFsUtils::RemoveDir(rteDir);
RteFsUtils::RemoveDir(testdir);
RteFsUtils::CreateFile(configFile, "// config file");
RteFsUtils::CreateFile(baseFile, "// config file@base");

Expand All @@ -3433,7 +3435,7 @@ TEST_F(ProjMgrUnitTests, RunProjMgr_UpdateRte) {
argv[3] = (char*)"-c";
argv[4] = (char*)"test1.Debug+CM0";
argv[5] = (char*)"-o";
argv[6] = (char*)testoutput_folder.c_str();
argv[6] = (char*)testdir.c_str();
argv[7] = (char*)"-v";
EXPECT_EQ(0, RunProjMgr(8, argv, 0));
EXPECT_TRUE(RteFsUtils::Exists(rteDir + "/_Debug_CM0/RTE_Components.h"));
Expand All @@ -3445,10 +3447,12 @@ info csolution: config files for each component:\n\
- .*/TestSolution/TestProject1/RTE/Device/RteTest_ARMCM0/ARMCM0_ac6.sct \\([email protected]\\)\n\
- .*/TestSolution/TestProject1/RTE/Device/RteTest_ARMCM0/startup_ARMCM0.c \\([email protected]\\) \\([email protected]\\)\n\
- .*/TestSolution/TestProject1/RTE/Device/RteTest_ARMCM0/system_ARMCM0.c \\([email protected]\\)\n\
.*/test.cbuild-idx.yml - info csolution: file generated successfully\n\
";

auto outStr = streamRedirect.GetOutString();
EXPECT_TRUE(regex_match(outStr, regex(expected)));
EXPECT_TRUE(regex_match(outStr, regex(expected))) <<
"Expected regex: \n" << expected << "\nActual:\n" << outStr;

streamRedirect.ClearStringStreams();
argv[1] = (char*)"list";
Expand Down
Loading