| return false; | return false; | ||||
| } | } | ||||
| static std::string findTargetName( | |||||
| const BBParser::Variables &vars, | |||||
| const std::vector<SourceFile> &sources) { | |||||
| auto it = vars.find("target"); | |||||
| if (it != vars.end() && it->second.size() != 0) { | |||||
| return it->second[0]; | |||||
| } | |||||
| for (auto &source: sources) { | |||||
| const std::vector<std::string> *ptr = source.variable("target"); | |||||
| if (ptr != nullptr && ptr->size() != 0) { | |||||
| return (*ptr)[0]; | |||||
| } | |||||
| } | |||||
| return "target"; | |||||
| } | |||||
| int main(int argc, char **argv) { | int main(int argc, char **argv) { | ||||
| logger::LogContext logCtx = logger::init(); | logger::LogContext logCtx = logger::init(); | ||||
| parser.parse(variables); | parser.parse(variables); | ||||
| } | } | ||||
| // Find target | |||||
| if (target.size() == 0) { | |||||
| auto it = variables.find("target"); | |||||
| if (it == variables.end() || it->second.size() == 0) { | |||||
| target = "target"; | |||||
| } else { | |||||
| target = it->second[0]; | |||||
| } | |||||
| } | |||||
| // Find source dirs | // Find source dirs | ||||
| std::vector<std::string> sourceDirs; | std::vector<std::string> sourceDirs; | ||||
| { | { | ||||
| findSources(".", dir, sources, variables); | findSources(".", dir, sources, variables); | ||||
| } | } | ||||
| // Find target name | |||||
| if (target.size() == 0) { | |||||
| target = findTargetName(variables, sources); | |||||
| } | |||||
| switch (action) { | switch (action) { | ||||
| case Action::BUILD: | case Action::BUILD: | ||||
| // TODO: Support more types than BINARY | // TODO: Support more types than BINARY |