diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2022-10-11 19:17:22 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2022-10-20 15:19:04 +0200 |
commit | 3045d8f702a934a4575b53bba3903f12fcd26536 (patch) | |
tree | 64a0d4cf8fa7ca7420467186a5ae072c1d678fcc /src | |
parent | eeec54d593c7a47683170fbf5307d073f49de62d (diff) | |
download | justbuild-3045d8f702a934a4575b53bba3903f12fcd26536.tar.gz |
just: Take lexicographical first repository
... if none is specified on command line or in the config.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/main/main.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index f33ccd20..59e65f5d 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -535,8 +535,11 @@ auto DetermineRoots(CommonArguments const& cargs, std::string main_repo; - auto main_it = repo_config.find("main"); - if (main_it != repo_config.end()) { + if (cargs.main) { + main_repo = *cargs.main; + } + else if (auto main_it = repo_config.find("main"); + main_it != repo_config.end()) { if (not main_it->is_string()) { Logger::Log(LogLevel::Error, "Repository config: main has to be a string"); @@ -544,8 +547,10 @@ auto DetermineRoots(CommonArguments const& cargs, } main_repo = *main_it; } - if (cargs.main) { - main_repo = *cargs.main; + else if (auto repos_it = repo_config.find("repositories"); + repos_it != repo_config.end() and not repos_it->empty()) { + // take lexicographical first key as main (nlohmann::json is sorted) + main_repo = repos_it->begin().key(); } auto repos = nlohmann::json::object(); |