@@ -84,16 +84,26 @@ void ProjMgrWorker::AddImageOnlyContext() {
8484}
8585
8686bool ProjMgrWorker::AddContexts (ProjMgrParser& parser, ContextDesc& descriptor, const string& cprojectFile) {
87- error_code ec;
8887 ContextItem context;
88+ context.cdefault = &parser.GetCdefault ();
89+ context.csolution = &parser.GetCsolution ();
8990 std::map<std::string, CprojectItem>& cprojects = parser.GetCprojects ();
9091 if (cprojects.find (cprojectFile) == cprojects.end ()) {
9192 ProjMgrLogger::Get ().Error (" cproject not parsed, adding context failed" , " " , cprojectFile);
9293 return false ;
9394 }
9495 context.cproject = &cprojects.at (cprojectFile);
95- context.cdefault = &parser.GetCdefault ();
96- context.csolution = &parser.GetCsolution ();
96+
97+ // west app
98+ if (!descriptor.west .app .empty ()) {
99+ context.west = descriptor.west ;
100+ RteFsUtils::NormalizePath (context.west .app , context.csolution ->directory );
101+ context.imageOnly = true ;
102+ // context.cproject = &cprojects[westApp];
103+ context.cproject ->output .baseName = " zephyr" ;
104+ context.cproject ->name = context.west .projectId ;
105+ context.cproject ->output .type = { " elf" , " hex" };
106+ }
97107
98108 // No build/target-types
99109 if (context.csolution ->buildTypes .empty () && context.csolution ->targetTypes .empty ()) {
@@ -2204,7 +2214,7 @@ bool ProjMgrWorker::ProcessConfigFiles(ContextItem& context) {
22042214 }
22052215 }
22062216 // Linker script
2207- if (context.outputTypes .elf .on ) {
2217+ if (context.outputTypes .elf .on && !context. imageOnly ) {
22082218 if (context.linker .autoGen ) {
22092219 if (!context.linker .script .empty ()) {
22102220 ProjMgrLogger::Get ().Warn (" conflict: automatic linker script generation overrules specified script '" + context.linker .script + " '" , context.name );
@@ -2863,6 +2873,10 @@ bool ProjMgrWorker::ProcessPrecedences(ContextItem& context, BoardOrDevice proce
28632873 error |= true ;
28642874 }
28652875
2876+ if (!context.west .device .empty ()) {
2877+ context.cproject ->target .device = context.west .device ;
2878+ }
2879+
28662880 StringCollection device = {
28672881 &context.device ,
28682882 {
@@ -2901,7 +2915,7 @@ bool ProjMgrWorker::ProcessPrecedences(ContextItem& context, BoardOrDevice proce
29012915 if (!ProcessCompilerPrecedence (compiler, true )) {
29022916 error |= true ;
29032917 }
2904- if (!context.imageOnly && !ProcessToolchain (context)) {
2918+ if (( !context.imageOnly || !context. west . app . empty ()) && !ProcessToolchain (context)) {
29052919 error |= true ;
29062920 }
29072921
@@ -2914,6 +2928,9 @@ bool ProjMgrWorker::ProcessPrecedences(ContextItem& context, BoardOrDevice proce
29142928 context.variables [RteConstants::AS_PNAME] = deviceItem.pname ;
29152929 context.variables [RteConstants::AS_BNAME] = boardItem.name ;
29162930 context.variables [RteConstants::AS_COMPILER] = context.toolchain .name ;
2931+ context.variables .insert ({ WEST_BOARD, ProjMgrUtils::GetWestBoard (boardItem.name ) });
2932+ context.west .board = context.west .board .empty () ? context.variables .at (WEST_BOARD) :
2933+ RteUtils::ExpandAccessSequences (context.west .board , context.variables );
29172934
29182935 // Add cdefault misc into csolution
29192936 if (context.cdefault ) {
@@ -3129,6 +3146,10 @@ bool ProjMgrWorker::ProcessPrecedences(ContextItem& context, BoardOrDevice proce
31293146 CollectionUtils::AddStringItemsUniquely (definesAsmRef, setup.definesAsm );
31303147 }
31313148
3149+ // Merge west defines
3150+ CollectionUtils::AddStringItemsUniquely (context.west .westDefs , context.controls .target .westDefs );
3151+ CollectionUtils::AddStringItemsUniquely (context.west .westDefs , context.controls .build .westDefs );
3152+
31323153 // Includes
31333154 vector<string> projectAddPaths, projectDelPaths;
31343155 CollectionUtils::AddStringItemsUniquely (projectAddPaths, context.controls .cproject .addpaths );
0 commit comments