@@ -4197,10 +4197,22 @@ vector<RteBoard*> ProjMgrWorker::GetCompatibleBoards(ContextItem& context) {
41974197 return compatibleBoards;
41984198}
41994199
4200- bool ProjMgrWorker::IsBoardListCompatible (const vector<RteBoard*> compatibleBoards, const Collection<RteItem*>& boards) {
4201- if (boards.empty () || compatibleBoards.empty ()) {
4200+ bool ProjMgrWorker::IsBoardListCompatible (const ContextItem& context, const vector<RteBoard*> compatibleBoards, const Collection<RteItem*>& boards) {
4201+ if (compatibleBoards.empty ()) {
4202+ // no board/device is selected
42024203 return true ;
42034204 }
4205+ if (boards.empty () && !context.board .empty ()) {
4206+ // example without boards = reference application (hardware agnostic example)
4207+ // ref app requires at least a clayer type "board" for the selected board
4208+ const auto & clayers = context.rteFilteredModel ->GetLayerDescriptors ();
4209+ for (const auto & clayer : clayers) {
4210+ if (RteUtils::EqualNoCase (clayer->GetTypeString (), " board" )) {
4211+ return true ;
4212+ }
4213+ }
4214+ return false ;
4215+ }
42044216 for (const auto & board : boards) {
42054217 for (const auto & compatibleBoard : compatibleBoards) {
42064218 if ((compatibleBoard->GetVendorString () == board->GetVendorString ()) &&
@@ -4231,12 +4243,13 @@ std::vector<ExampleItem> ProjMgrWorker::CollectExamples(ContextItem& context) {
42314243 for (const auto & rteExample : rteExamples) {
42324244 Collection<RteItem*> boards;
42334245 boards = rteExample->GetChildrenByTag (" board" , boards);
4234- if (!IsBoardListCompatible (compatibleBoards, boards)) {
4246+ if (!IsBoardListCompatible (context, compatibleBoards, boards)) {
42354247 continue ;
42364248 }
42374249 ExampleItem example;
42384250 example.name = rteExample->GetName ();
4239- example.description = rteExample->GetChildText (" description" );
4251+ example.description = rteExample->GetDescription ();
4252+ example.pack = rteExample->GetPackageID (true );
42404253 string folder = rteExample->GetFolderString ();
42414254 RteFsUtils::NormalizePath (folder, rteExample->GetAbsolutePackagePath ());
42424255 example.doc = rteExample->GetDocValue ();
@@ -4306,44 +4319,31 @@ bool ProjMgrWorker::ListExamples(vector<string>& examples, const string& filter)
43064319 const auto & collectedExamples = CollectExamples (context);
43074320
43084321 for (const auto & exampleItem : collectedExamples) {
4309- string example = exampleItem.name ;
4310- example += exampleItem.version .empty () ? " " : " @" + exampleItem.version ;
4311- example += " \n description: " + exampleItem.description ;
4312- example += " \n doc: " + exampleItem.doc ;
4313- if (!exampleItem.archive .empty ()) {
4314- example += " \n archive: " + exampleItem.archive ;
4315- }
4316- for (const auto & [name, environment] : exampleItem.environments ) {
4317- example += " \n environment: " + name + " \n load: " + environment.load ;
4318- example += " \n folder: " + environment.folder ;
4319- }
4320- if (!exampleItem.boards .empty ()) {
4321- example += " \n boards:" ;
4322- for (const auto & board : exampleItem.boards ) {
4323- example += " \n " + board.vendor + " ::" + board.name ;
4324- }
4325- }
4326- if (!exampleItem.components .empty ()) {
4327- example += " \n components:" ;
4328- for (const auto & component : exampleItem.components ) {
4329- example += " \n " + component;
4330- }
4331- }
4332- if (!exampleItem.categories .empty ()) {
4333- example += " \n categories:" ;
4334- for (const auto & category : exampleItem.categories ) {
4335- example += " \n " + category;
4336- }
4322+ if (!filter.empty () && exampleItem.name .find (filter) == string::npos) {
4323+ continue ;
43374324 }
4338- if (!exampleItem.keywords .empty ()) {
4339- example += " \n keywords:" ;
4340- for (const auto & keyword : exampleItem.keywords ) {
4341- example += " \n " + keyword;
4325+ string example = exampleItem.boards .empty () ? " Reference Application: " : " " ;
4326+ example += exampleItem.name ;
4327+ example += exampleItem.version .empty () ? " " : " @" + exampleItem.version ;
4328+ example += " (" + exampleItem.pack + " )" ;
4329+ if (m_verbose) {
4330+ example += " \n description: " + exampleItem.description ;
4331+ example += " \n doc: " + exampleItem.doc ;
4332+ if (!exampleItem.archive .empty ()) {
4333+ example += " \n archive: " + exampleItem.archive ;
4334+ }
4335+ for (const auto & [name, environment] : exampleItem.environments ) {
4336+ example += " \n environment: " + name + " \n load: " + environment.load ;
4337+ example += " \n folder: " + environment.folder ;
4338+ }
4339+ if (!exampleItem.boards .empty ()) {
4340+ example += " \n boards:" ;
4341+ for (const auto & board : exampleItem.boards ) {
4342+ example += " \n " + board.vendor + " ::" + board.name ;
4343+ }
43424344 }
43434345 }
4344- if (filter.empty () || example.find (filter) != string::npos) {
4345- examples.push_back (example);
4346- }
4346+ examples.push_back (example);
43474347 }
43484348 return true ;
43494349}
0 commit comments