diff options
Diffstat (limited to 'src/libctor.cc')
-rw-r--r-- | src/libctor.cc | 60 |
1 files changed, 53 insertions, 7 deletions
diff --git a/src/libctor.cc b/src/libctor.cc index c7a7400..e166e51 100644 --- a/src/libctor.cc +++ b/src/libctor.cc @@ -22,6 +22,7 @@ #include "rebuild.h" #include "tasks.h" #include "build.h" +#include "unittest.h" int main(int argc, char* argv[]) { if(argc > 1 && std::string(argv[1]) == "configure") @@ -46,6 +47,7 @@ int main(int argc, char* argv[]) bool list_files{false}; bool list_targets{false}; bool no_relaunch{false}; // true means no re-launch after rebuild. + bool run_unittests{false}; dg::Options opt; int key{128}; @@ -206,12 +208,10 @@ Options: if(list_targets) { no_default_build = true; - for(const auto& task : all_tasks) + auto& targets = getTargets(settings); + for(const auto& target : targets) { - if(task->targetType() != TargetType::Object) - { - std::cout << task->name() << "\n"; - } + std::cout << target.config.target << "\n"; } } @@ -286,13 +286,44 @@ Options: } } } + else if(arg == "check") + { + build_all = false; + run_unittests = true; + + std::vector<Target> unittest_targets; + auto& targets = getTargets(settings); + for(const auto& target : targets) + { + if(target.config.type == TargetType::UnitTest) + { + unittest_targets.push_back(target); + } + } + + auto ret = build(settings, "check", unittest_targets, all_tasks); + if(ret != 0) + { + return ret; + } + } else { build_all = false; if(arg == "all") { - auto ret = build(settings, "all", all_tasks, all_tasks); + std::vector<Target> non_unittest_targets; + auto& targets = getTargets(settings); + for(const auto& target : targets) + { + if(target.config.type != TargetType::UnitTest) + { + non_unittest_targets.push_back(target); + } + } + + auto ret = build(settings, "all", non_unittest_targets, all_tasks); if(ret != 0) { return ret; @@ -311,12 +342,27 @@ Options: if(build_all) { - auto ret = build(settings, "all", all_tasks, all_tasks); + std::vector<Target> non_unittest_targets; + auto& targets = getTargets(settings); + for(const auto& target : targets) + { + if(target.config.type != TargetType::UnitTest) + { + non_unittest_targets.push_back(target); + } + } + + auto ret = build(settings, "all", non_unittest_targets, all_tasks); if(ret != 0) { return ret; } } + if(run_unittests) + { + return runUnitTests(all_tasks, settings); + } + return 0; } |