Skip to content
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
18 changes: 14 additions & 4 deletions tools/projmgr/include/ProjMgrLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ProjMgrLogger {
void Info(const std::string& msg, const std::string& context = std::string(),
const std::string& file = std::string(), const int line = 0, const int column = 0);

/**
/**
* @brief print debug
* @param message
*/
Expand All @@ -78,15 +78,25 @@ class ProjMgrLogger {
static bool IsQuiet() { return m_quiet || m_silent; }

/**
* @brief flag to suppress infos and warnings
* @brief check if in verbose mode
* @return true if verbose
*/
static bool IsVerbose() { return m_verbose; }

/**
* @brief flag to suppress infos and warnings
*/
static bool m_quiet;

/**
* @brief flag to suppress all output and redirect cout to string buffer
/**
* @brief flag to suppress all output and redirect cout to string buffer
*/
static bool m_silent;

/**
* @brief flag to enable verbose for infos
*/
static bool m_verbose;

/**
* @brief get errors
Expand Down
7 changes: 7 additions & 0 deletions tools/projmgr/src/ProjMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ int ProjMgr::ParseCommandLine(int argc, char** argv) {
m_cbuildgen = parseResult.count("cbuildgen");
m_worker.SetCbuild2Cmake(!m_cbuildgen);
ProjMgrLogger::m_quiet = parseResult.count("quiet");
ProjMgrLogger::m_verbose = m_verbose;
m_rpcServer.SetContentLengthHeader(parseResult.count("content-length"));
m_rpcServer.SetDebug(m_debug);
m_locked = parseResult.count("locked");
Expand Down Expand Up @@ -313,6 +314,12 @@ int ProjMgr::ParseCommandLine(int argc, char** argv) {
return PrintUsage(optionsDict, m_command, m_args) ? -1 : 1;
}

// Validate mutually exclusive options
if (ProjMgrLogger::m_quiet && ProjMgrLogger::m_verbose) {
ProjMgrLogger::Get().Error("command line options '--quiet' and '--verbose' are mutually exclusive");
return ErrorCode::ERROR;
}

// Set load packs policy
if (!SetLoadPacksPolicy()) {
return ErrorCode::ERROR;
Expand Down
3 changes: 2 additions & 1 deletion tools/projmgr/src/ProjMgrLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static constexpr const char* PROJMGR_INFO = "info";

bool ProjMgrLogger::m_quiet = false;
bool ProjMgrLogger::m_silent = false;
bool ProjMgrLogger::m_verbose = false;

// singleton instance
static unique_ptr<ProjMgrLogger> theProjMgrLogger = 0;
Expand Down Expand Up @@ -73,7 +74,7 @@ void ProjMgrLogger::Info(const string& msg, const string& context,
const string mark = (line > 0 ? ":" + to_string(line) : "") + (column > 0 ? ":" + to_string(column) : "");
CollectionUtils::PushBackUniquely(m_infos[context],
(file.empty() ? "" : RteUtils::ExtractFileName(file) + mark + " - ") + msg);
if (!IsQuiet() ) {
if (!IsQuiet() && IsVerbose()) {
cout << (file.empty() ? "" : file + mark + " - ") << PROJMGR_INFO << PROJMGR_TOOL << msg << endl;
}
}
Expand Down
6 changes: 6 additions & 0 deletions tools/projmgr/test/data/TestLayers/ref/config.cbuild-idx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ build-idx:
configuration: .CompatibleLayers+RteTest_ARMCM3
clayers:
- clayer: config.clayer.yml
messages:
info:
- "valid configuration #1: (context 'config.CompatibleLayers+RteTest_ARMCM3')\n ${DEVTOOLS(data)}/TestLayers/config.clayer.yml\n set: set1.select1 (connect R - set 1 select 1)\n ${DEVTOOLS(data)}/TestLayers/config.cproject.yml\n set: set1.select1 (project X - set 1 select 1)\n ${DEVTOOLS(packs)}/ARM/RteTest_DFP/0.2.0/Layers/config1.clayer.yml (layer type: Config1)\n set: set1.select1 (connect A - set 1 select 1)\n set: set2.select1 (connect C - set 2 select 1)\n ${DEVTOOLS(packs)}/ARM/RteTest_DFP/0.2.0/Layers/config2.clayer.yml (layer type: Config2)\n set: set1.select1 (connect F - set 1 select 1)\n"
- "valid configuration #2: (context 'config.CompatibleLayers+RteTest_ARMCM3')\n ${DEVTOOLS(data)}/TestLayers/config.clayer.yml\n set: set1.select1 (connect R - set 1 select 1)\n ${DEVTOOLS(data)}/TestLayers/config.cproject.yml\n set: set1.select1 (project X - set 1 select 1)\n ${DEVTOOLS(packs)}/ARM/RteTest_DFP/0.2.0/Layers/config1.clayer.yml (layer type: Config1)\n set: set1.select1 (connect A - set 1 select 1)\n set: set2.select1 (connect C - set 2 select 1)\n ${DEVTOOLS(packs)}/ARM/RteTest_DFP/0.2.0/Layers/config3.clayer.yml (layer type: Config2)\n set: set3.select1 (connect F - set 3 select 1)\n"
- "valid configuration #3: (context 'config.CompatibleLayers+RteTest_ARMCM3')\n ${DEVTOOLS(data)}/TestLayers/config.clayer.yml\n set: set1.select2 (connect S - set 1 select 2)\n ${DEVTOOLS(data)}/TestLayers/config.cproject.yml\n set: set1.select2 (project Y - set 1 select 2)\n ${DEVTOOLS(packs)}/ARM/RteTest_DFP/0.2.0/Layers/config1.clayer.yml (layer type: Config1)\n set: set1.select2 (connect B - set 1 select 2)\n set: set2.select2 (connect D - set 2 select 2)\n ${DEVTOOLS(packs)}/ARM/RteTest_DFP/0.2.0/Layers/config2.clayer.yml (layer type: Config2)\n set: set1.select2 (connect G - set 1 select 2)\n"
- "valid configuration #4: (context 'config.CompatibleLayers+RteTest_ARMCM3')\n ${DEVTOOLS(data)}/TestLayers/config.clayer.yml\n set: set1.select2 (connect S - set 1 select 2)\n ${DEVTOOLS(data)}/TestLayers/config.cproject.yml\n set: set1.select2 (project Y - set 1 select 2)\n ${DEVTOOLS(packs)}/ARM/RteTest_DFP/0.2.0/Layers/config1.clayer.yml (layer type: Config1)\n set: set1.select2 (connect B - set 1 select 2)\n set: set2.select2 (connect D - set 2 select 2)\n ${DEVTOOLS(packs)}/ARM/RteTest_DFP/0.2.0/Layers/config3.clayer.yml (layer type: Config2)\n set: set3.select2 (connect G - set 3 select 2)\n"
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ build-idx:
configuration: +RteTest_ARMCM3
clayers:
- clayer: select.clayer.yml
messages:
info:
- "valid configuration #1: (context 'no_compiler+RteTest_ARMCM3')\n ${DEVTOOLS(data)}/TestLayers/no_compiler.cproject.yml\n set: set1.select1 (project X - set 1 select 1)\n ${DEVTOOLS(data)}/TestLayers/select.clayer.yml (layer type: Board)\n set: set1.select1 (provided connections A and B - set 1 select 1)\n"
- "valid configuration #2: (context 'no_compiler+RteTest_ARMCM3')\n ${DEVTOOLS(data)}/TestLayers/no_compiler.cproject.yml\n set: set1.select2 (project Y - set 1 select 2)\n ${DEVTOOLS(data)}/TestLayers/select.clayer.yml (layer type: Board)\n set: set1.select2 (provided connections B and C - set 1 select 2)\n"
4 changes: 4 additions & 0 deletions tools/projmgr/test/data/TestLayers/ref/select.cbuild-idx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ build-idx:
configuration: +RteTest_ARMCM3
clayers:
- clayer: select.clayer.yml
messages:
info:
- "valid configuration #1: (context 'select+RteTest_ARMCM3')\n ${DEVTOOLS(data)}/TestLayers/select.cproject.yml\n set: set1.select1 (project X - set 1 select 1)\n ${DEVTOOLS(data)}/TestLayers/select.clayer.yml (layer type: Board)\n set: set1.select1 (provided connections A and B - set 1 select 1)\n"
- "valid configuration #2: (context 'select+RteTest_ARMCM3')\n ${DEVTOOLS(data)}/TestLayers/select.cproject.yml\n set: set1.select2 (project Y - set 1 select 2)\n ${DEVTOOLS(data)}/TestLayers/select.clayer.yml (layer type: Board)\n set: set1.select2 (provided connections B and C - set 1 select 2)\n"
17 changes: 13 additions & 4 deletions tools/projmgr/test/src/ProjMgrGeneratorUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "ProjMgr.h"
#include "ProjMgrTestEnv.h"
#include "ProjMgrLogger.h"
#include "RteFsUtils.h"
#include "gtest/gtest.h"
#include <regex>
Expand All @@ -17,6 +18,12 @@ class ProjMgrGeneratorUnitTests : public ProjMgrGenerator, public ::testing::Tes
protected:
ProjMgrGeneratorUnitTests() {}
virtual ~ProjMgrGeneratorUnitTests() {}

void TearDown() {
// return mode to normal to avoid affecting other tests
ProjMgrLogger::m_quiet = false;
ProjMgrLogger::m_verbose = false;
}
};

TEST_F(ProjMgrGeneratorUnitTests, GetStringFromVector) {
Expand Down Expand Up @@ -159,7 +166,7 @@ TEST_F(ProjMgrGeneratorUnitTests, DryRunIncapableGenerator) {
}

TEST_F(ProjMgrGeneratorUnitTests, DryRun) {
char* argv[7], *envp[2];
char* argv[8], *envp[2];
string gcc = "GCC_TOOLCHAIN_11_2_1=" + testinput_folder;
envp[0] = (char*)gcc.c_str();
envp[1] = (char*)'\0';
Expand All @@ -172,6 +179,7 @@ TEST_F(ProjMgrGeneratorUnitTests, DryRun) {
argv[4] = (char*)"-g";
argv[5] = (char*)"RteTestGeneratorIdentifier";
argv[6] = (char*)"--dry-run";
argv[7] = (char*)"--verbose";

const string generatorInputFile = testinput_folder + "/TestSolution/tmp/TestProject3_1.Debug+TypeA.cbuild-gen.yml";
const string generatorDestination = testinput_folder + "/TestSolution/TestProject3_1/gendir";
Expand All @@ -181,7 +189,7 @@ TEST_F(ProjMgrGeneratorUnitTests, DryRun) {
RteFsUtils::RemoveDir(generatorDestination);
RteFsUtils::RemoveDir(rteDir);

EXPECT_EQ(0, ProjMgr::RunProjMgr(7, argv, envp));
EXPECT_EQ(0, ProjMgr::RunProjMgr(8, argv, envp));

ProjMgrTestEnv::CompareFile(testinput_folder + "/TestSolution/ref/TestProject3_1.Debug+TypeA.cbuild-gen.yml", generatorInputFile, ProjMgrTestEnv::StripAbsoluteFunc);

Expand All @@ -208,7 +216,7 @@ TEST_F(ProjMgrGeneratorUnitTests, DryRun) {
}

TEST_F(ProjMgrGeneratorUnitTests, DryRunNoLdScript) {
char* argv[7], *envp[2];
char* argv[8], *envp[2];
string gcc = "GCC_TOOLCHAIN_11_2_1=" + testinput_folder;
envp[0] = (char*)gcc.c_str();
envp[1] = (char*)'\0';
Expand All @@ -221,6 +229,7 @@ TEST_F(ProjMgrGeneratorUnitTests, DryRunNoLdScript) {
argv[4] = (char*)"-g";
argv[5] = (char*)"RteTestGeneratorIdentifier";
argv[6] = (char*)"--dry-run";
argv[7] = (char*)"--verbose";

const string generatorInputFile = testinput_folder + "/TestSolution/tmp/TestProject3_5.Debug+TypeA.cbuild-gen.yml";
const string generatorDestination = testinput_folder + "/TestSolution/TestProject3_5/gendir";
Expand All @@ -230,7 +239,7 @@ TEST_F(ProjMgrGeneratorUnitTests, DryRunNoLdScript) {
RteFsUtils::RemoveDir(generatorDestination);
RteFsUtils::RemoveDir(rteDir);

EXPECT_EQ(0, ProjMgr::RunProjMgr(7, argv, envp));
EXPECT_EQ(0, ProjMgr::RunProjMgr(8, argv, envp));

ProjMgrTestEnv::CompareFile(testinput_folder + "/TestSolution/ref/TestProject3_5.Debug+TypeA.cbuild-gen.yml", generatorInputFile, ProjMgrTestEnv::StripAbsoluteFunc);

Expand Down
Loading
Loading