diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2025-04-22 11:09:17 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2025-04-22 13:50:57 +0200 |
commit | a212d87be891c5146021b6442063ed39a4a1cd4a (patch) | |
tree | 9df2902cf7f8bf9d70917ab87865517e9bdc71c3 /src/other_tools | |
parent | ba51f59519847a3d298fd176d93a0b6c64f452c1 (diff) | |
download | justbuild-a212d87be891c5146021b6442063ed39a4a1cd4a.tar.gz |
Remove redundant calls to std::filesystem::absolute
...when calling std::filesystem::weakly_canonical, since the latter converts the argument path to an absolute path internally.
Diffstat (limited to 'src/other_tools')
-rw-r--r-- | src/other_tools/just_mr/cli.hpp | 28 | ||||
-rw-r--r-- | src/other_tools/just_mr/fetch.cpp | 8 | ||||
-rw-r--r-- | src/other_tools/just_mr/main.cpp | 7 | ||||
-rw-r--r-- | src/other_tools/just_mr/rc.cpp | 3 | ||||
-rw-r--r-- | src/other_tools/ops_maps/critical_git_op_map.hpp | 4 |
5 files changed, 21 insertions, 29 deletions
diff --git a/src/other_tools/just_mr/cli.hpp b/src/other_tools/just_mr/cli.hpp index 96760b0d..de1ac9d0 100644 --- a/src/other_tools/just_mr/cli.hpp +++ b/src/other_tools/just_mr/cli.hpp @@ -152,8 +152,8 @@ static inline void SetupMultiRepoCommonArguments( app->add_option_function<std::string>( "-C, --repository-config", [clargs](auto const& repository_config_raw) { - clargs->repository_config = std::filesystem::weakly_canonical( - std::filesystem::absolute(repository_config_raw)); + clargs->repository_config = + std::filesystem::weakly_canonical(repository_config_raw); }, "Repository-description file to use.") ->type_name("FILE"); @@ -161,8 +161,7 @@ static inline void SetupMultiRepoCommonArguments( "--absent", [clargs](auto const& file_raw) { clargs->absent_repository_file = - std::filesystem::weakly_canonical( - std::filesystem::absolute(file_raw)); + std::filesystem::weakly_canonical(file_raw); }, "File specifying the repositories to consider absent (overrides the " "pragma in the config file).") @@ -170,8 +169,8 @@ static inline void SetupMultiRepoCommonArguments( app->add_option_function<std::string>( "--local-build-root", [clargs](auto const& local_build_root_raw) { - clargs->just_mr_paths->root = std::filesystem::weakly_canonical( - std::filesystem::absolute(local_build_root_raw)); + clargs->just_mr_paths->root = + std::filesystem::weakly_canonical(local_build_root_raw); }, "Root for CAS, repository space, etc.") ->type_name("PATH"); @@ -179,8 +178,7 @@ static inline void SetupMultiRepoCommonArguments( "--checkout-locations", [clargs](auto const& checkout_locations_raw) { clargs->checkout_locations_file = - std::filesystem::weakly_canonical( - std::filesystem::absolute(checkout_locations_raw)); + std::filesystem::weakly_canonical(checkout_locations_raw); }, "Specification file for checkout locations.") ->type_name("CHECKOUT_LOCATIONS"); @@ -198,8 +196,7 @@ static inline void SetupMultiRepoCommonArguments( "--distdir", [clargs](auto const& distdir_raw) { clargs->explicit_distdirs.emplace_back( - std::filesystem::weakly_canonical(std::filesystem::absolute( - std::filesystem::path(distdir_raw)))); + std::filesystem::weakly_canonical(distdir_raw)); }, "Directory to look for distfiles before fetching.") ->type_name("PATH") @@ -212,8 +209,8 @@ static inline void SetupMultiRepoCommonArguments( app->add_option_function<std::string>( "--fetch-cacert", [clargs](auto const& cacert_raw) { - clargs->ca_info->ca_bundle = std::filesystem::weakly_canonical( - std::filesystem::absolute(cacert_raw)); + clargs->ca_info->ca_bundle = + std::filesystem::weakly_canonical(cacert_raw); }, "CA certificate bundle to use for SSL verification when fetching " "archives from remote.") @@ -230,8 +227,7 @@ static inline void SetupMultiRepoCommonArguments( app->add_option_function<std::string>( "--rc", [clargs](auto const& rc_path_raw) { - clargs->rc_path = std::filesystem::weakly_canonical( - std::filesystem::absolute(rc_path_raw)); + clargs->rc_path = std::filesystem::weakly_canonical(rc_path_raw); }, "Use just-mrrc file from custom path.") ->type_name("RCFILE"); @@ -335,8 +331,8 @@ static inline void SetupMultiRepoFetchArguments( app->add_option_function<std::string>( "-o", [clargs](auto const& fetch_dir_raw) { - clargs->fetch_dir = std::filesystem::weakly_canonical( - std::filesystem::absolute(fetch_dir_raw)); + clargs->fetch_dir = + std::filesystem::weakly_canonical(fetch_dir_raw); }, "Directory to write distfiles when fetching.") ->type_name("PATH"); diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp index 0dd3a155..3585d2f3 100644 --- a/src/other_tools/just_mr/fetch.cpp +++ b/src/other_tools/just_mr/fetch.cpp @@ -86,8 +86,7 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config, if (not fetch_dir) { for (auto const& d : common_args.just_mr_paths->distdirs) { if (FileSystemManager::IsDirectory(d)) { - fetch_dir = std::filesystem::weakly_canonical( - std::filesystem::absolute(d)); + fetch_dir = std::filesystem::weakly_canonical(d); break; } } @@ -147,9 +146,8 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config, std::filesystem::path(repo_path->String()); if (not repo_path_as_path.is_absolute()) { repo_path_as_path = std::filesystem::weakly_canonical( - std::filesystem::absolute( - common_args.just_mr_paths->setup_root / - repo_path_as_path)); + common_args.just_mr_paths->setup_root / + repo_path_as_path); } // only warn if repo workspace differs to invocation workspace if (not is_subpath( diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp index 963d4f97..f1836d23 100644 --- a/src/other_tools/just_mr/main.cpp +++ b/src/other_tools/just_mr/main.cpp @@ -285,15 +285,14 @@ auto main(int argc, char* argv[]) -> int { if (not arguments.common.just_mr_paths->root) { forward_build_root = false; arguments.common.just_mr_paths->root = - std::filesystem::weakly_canonical( - std::filesystem::absolute(kDefaultBuildRoot)); + std::filesystem::weakly_canonical(kDefaultBuildRoot); } if (not arguments.common.checkout_locations_file and FileSystemManager::IsFile(std::filesystem::weakly_canonical( - std::filesystem::absolute(kDefaultCheckoutLocationsFile)))) { + kDefaultCheckoutLocationsFile))) { arguments.common.checkout_locations_file = std::filesystem::weakly_canonical( - std::filesystem::absolute(kDefaultCheckoutLocationsFile)); + kDefaultCheckoutLocationsFile); } if (arguments.common.just_mr_paths->distdirs.empty()) { arguments.common.just_mr_paths->distdirs.emplace_back( diff --git a/src/other_tools/just_mr/rc.cpp b/src/other_tools/just_mr/rc.cpp index 67ef3e24..bcb217cf 100644 --- a/src/other_tools/just_mr/rc.cpp +++ b/src/other_tools/just_mr/rc.cpp @@ -103,8 +103,7 @@ namespace { // set default if rcpath not given if (not clargs->common.norc) { if (not rc_path) { - rc_path = std::filesystem::weakly_canonical( - std::filesystem::absolute(kDefaultRCPath)); + rc_path = std::filesystem::weakly_canonical(kDefaultRCPath); } else { if (not FileSystemManager::IsFile(*rc_path)) { diff --git a/src/other_tools/ops_maps/critical_git_op_map.hpp b/src/other_tools/ops_maps/critical_git_op_map.hpp index 3e5a07ee..1494e3b3 100644 --- a/src/other_tools/ops_maps/critical_git_op_map.hpp +++ b/src/other_tools/ops_maps/critical_git_op_map.hpp @@ -74,8 +74,8 @@ class CriticalGitOpGuard { std::scoped_lock<std::mutex> const lock(critical_key_mutex_); // try emplace a new value - auto const canonical_path = std::filesystem::weakly_canonical( - std::filesystem::absolute(new_key.params.target_path)); + auto const canonical_path = + std::filesystem::weakly_canonical(new_key.params.target_path); auto result = curr_critical_key_.try_emplace(canonical_path, new_key); // If the insertion happens, there are no keys to wait for. std::nullopt // is returned. |