diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-05-21 16:19:38 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-05-22 12:48:13 +0200 |
commit | a6a76cc15a2c46a0741f88d3b794c407b314052a (patch) | |
tree | ead6d93fea244f6b229604d4b36131c77cc11170 | |
parent | 47e607c02a793b0798374dfdc34c2ed7f0c843f7 (diff) | |
download | justbuild-a6a76cc15a2c46a0741f88d3b794c407b314052a.tar.gz |
just-mr: Fix wrong setup root being picked up
This fixes a bug in which the setup root was falsely being changed
by unconditionally searching early for a default configuration
files, despite one being explicitly provided at the command line.
-rw-r--r-- | src/buildtool/common/user_structs.hpp | 7 | ||||
-rw-r--r-- | src/other_tools/just_mr/main.cpp | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/buildtool/common/user_structs.hpp b/src/buildtool/common/user_structs.hpp index 9f67ed45..34101e89 100644 --- a/src/buildtool/common/user_structs.hpp +++ b/src/buildtool/common/user_structs.hpp @@ -28,10 +28,13 @@ /* Structures populated exclusively from command line with user-defined data */ +static inline const std::filesystem::path kDefaultSetupRoot = + FileSystemManager::GetCurrentDirectory(); + struct LocalPaths { // user-defined locations std::optional<std::filesystem::path> root{std::nullopt}; - std::filesystem::path setup_root{FileSystemManager::GetCurrentDirectory()}; + std::filesystem::path setup_root = kDefaultSetupRoot; std::optional<std::filesystem::path> workspace_root{ // find workspace root []() -> std::optional<std::filesystem::path> { @@ -45,7 +48,7 @@ struct LocalPaths { }); }; // default path to current dir - auto path = FileSystemManager::GetCurrentDirectory(); + auto path = kDefaultSetupRoot; auto root_path = path.root_path(); while (true) { if (is_workspace_root(path)) { diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp index f1836d23..aa1abc74 100644 --- a/src/other_tools/just_mr/main.cpp +++ b/src/other_tools/just_mr/main.cpp @@ -265,12 +265,17 @@ auto main(int argc, char* argv[]) -> int { } SetupLogging(arguments.log); + // Parse rc file, if given, and returns any configuration file found in + // known locations, with the setup root updated accordingly auto config_file = ReadJustMRRC(&arguments); // As the rc file can contain logging parameters, reset the logging // configuration SetupLogging(arguments.log); + // An explicitly given configuration file path wins. In this case, the + // default setup root must be used if (arguments.common.repository_config) { config_file = arguments.common.repository_config; + arguments.common.just_mr_paths->setup_root = kDefaultSetupRoot; } // if optional args were not read from just-mrrc or given by user, use |