@@ -461,13 +461,38 @@ Commands SwBuild::getCommands() const
461461 if (targets_to_build.empty ())
462462 throw SW_RUNTIME_ERROR (" no targets were selected for building" );
463463
464- auto ttb = targets_to_build;
464+ StringSet in_ttb;
465+ StringSet in_ttb_exclude;
466+ for (auto &t : build_settings[" target-to-build" ].getArray ())
467+ in_ttb.insert (t);
468+ for (auto &t : build_settings[" target-to-exclude" ].getArray ())
469+ {
470+ if (in_ttb.find (t) != in_ttb.end ())
471+ throw SW_RUNTIME_ERROR (" Target " + t + " specified both in include and exclude lists" );
472+ in_ttb_exclude.insert (t);
473+ }
474+
475+ decltype (targets_to_build) ttb;
465476
466477 // detect all targets to build
467478 // some static builds won't build deps, because there's no dependent link files
468479 // (e.g. build static png, zlib won't be built)
469480 for (auto &[p, tgts] : targets_to_build)
470481 {
482+ if (!in_ttb.empty ())
483+ {
484+ auto i = in_ttb.find (p.toString ());
485+ if (i == in_ttb.end ())
486+ continue ;
487+ in_ttb.erase (i);
488+ }
489+ if (in_ttb_exclude.find (p.toString ()) != in_ttb_exclude.end ())
490+ {
491+ continue ;
492+ }
493+
494+ ttb[p] = tgts;
495+
471496 // one target may be loaded twice
472497 // we take only the latest, because it is has correct set of command deps per requested settings
473498 std::map<TargetSettings, ITarget*> latest_targets;
@@ -518,6 +543,15 @@ Commands SwBuild::getCommands() const
518543 }
519544 }
520545
546+ if (!in_ttb.empty ())
547+ {
548+ String s;
549+ for (auto &t : in_ttb)
550+ s += t + " , " ;
551+ s.resize (s.size () - 2 );
552+ throw SW_RUNTIME_ERROR (" Cannot make targets: " + s + " : no such targets" );
553+ }
554+
521555 //
522556 auto cl_show_output = build_settings[" show_output" ] == " true" ;
523557 auto cl_write_output_to_file = build_settings[" write_output_to_file" ] == " true" ;
0 commit comments