diff --git a/tools/projmgr/include/ProjMgr.h b/tools/projmgr/include/ProjMgr.h index 259602b3c..24067f34e 100644 --- a/tools/projmgr/include/ProjMgr.h +++ b/tools/projmgr/include/ProjMgr.h @@ -21,7 +21,8 @@ enum ErrorCode { SUCCESS = 0, ERROR = 1, - VARIABLE_NOT_DEFINED + VARIABLE_NOT_DEFINED = 2, + COMPILER_NOT_DEFINED = 3, }; /** diff --git a/tools/projmgr/include/ProjMgrWorker.h b/tools/projmgr/include/ProjMgrWorker.h index 220c34cf8..9dc049ee2 100644 --- a/tools/projmgr/include/ProjMgrWorker.h +++ b/tools/projmgr/include/ProjMgrWorker.h @@ -697,6 +697,12 @@ class ProjMgrWorker { */ bool HasVarDefineError(); + /** + * @brief check whether compiler is not defined and there are selectable ones + * @return true if error is set + */ + bool HasCompilerDefineError(); + /** * @brief get list of detected undefined layer variables * @return list of undefined layer variables diff --git a/tools/projmgr/src/ProjMgr.cpp b/tools/projmgr/src/ProjMgr.cpp index 6168b48b1..18e7e82cd 100644 --- a/tools/projmgr/src/ProjMgr.cpp +++ b/tools/projmgr/src/ProjMgr.cpp @@ -387,6 +387,10 @@ int ProjMgr::ProcessCommands() { if (m_worker.HasVarDefineError()) { return ErrorCode::VARIABLE_NOT_DEFINED; } + // Check if compiler not defined and there are selectable ones + if (m_worker.HasCompilerDefineError()) { + return ErrorCode::COMPILER_NOT_DEFINED; + } if (!convSuccess) { return ErrorCode::ERROR; } diff --git a/tools/projmgr/src/ProjMgrWorker.cpp b/tools/projmgr/src/ProjMgrWorker.cpp index 2770e7ad0..54a12bbee 100644 --- a/tools/projmgr/src/ProjMgrWorker.cpp +++ b/tools/projmgr/src/ProjMgrWorker.cpp @@ -5030,6 +5030,10 @@ bool ProjMgrWorker::HasVarDefineError() { return (m_undefLayerVars.size() > 0 ? true : false); } +bool ProjMgrWorker::HasCompilerDefineError() { + return (m_undefCompiler && !m_selectableCompilers.empty()); +} + const set& ProjMgrWorker::GetUndefLayerVars() { return m_undefLayerVars; } diff --git a/tools/projmgr/test/src/ProjMgrUnitTests.cpp b/tools/projmgr/test/src/ProjMgrUnitTests.cpp index 19174364a..d39c7d885 100644 --- a/tools/projmgr/test/src/ProjMgrUnitTests.cpp +++ b/tools/projmgr/test/src/ProjMgrUnitTests.cpp @@ -6188,7 +6188,7 @@ TEST_F(ProjMgrUnitTests, SelectableToolchains) { argv[3] = (char*)"-o"; argv[4] = (char*)testoutput_folder.c_str(); argv[5] = (char*)"--cbuildgen"; - EXPECT_EQ(1, RunProjMgr(6, argv, m_envp)); + EXPECT_EQ(ErrorCode::COMPILER_NOT_DEFINED, RunProjMgr(6, argv, m_envp)); const string err = streamRedirect.GetErrorString(); const string expectedErr = \ "error csolution: compiler undefined, use '--toolchain' option or add 'compiler: ' to yml input, selectable values can be found in cbuild-idx.yml";