diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2022-12-16 14:34:49 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2022-12-21 14:44:08 +0100 |
commit | 0737abb8b7e6180a6b38f04d0e5d072c5d60f4ab (patch) | |
tree | ce6332382bb4c3ff5fa4477ef4a1cd13bda66df5 /src | |
parent | f519864e0492af758108c48c1ddeb1356f1c03b3 (diff) | |
download | justbuild-0737abb8b7e6180a6b38f04d0e5d072c5d60f4ab.tar.gz |
Just: Move constants from main into own header file
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/main/TARGETS | 7 | ||||
-rw-r--r-- | src/buildtool/main/constants.hpp | 23 | ||||
-rw-r--r-- | src/buildtool/main/main.cpp | 4 |
3 files changed, 32 insertions, 2 deletions
diff --git a/src/buildtool/main/TARGETS b/src/buildtool/main/TARGETS index 36a8cbff..92a0b9a3 100644 --- a/src/buildtool/main/TARGETS +++ b/src/buildtool/main/TARGETS @@ -21,6 +21,7 @@ , "analyse" , "install_cas" , "describe" + , "constants" ] , "stage": ["src", "buildtool", "main"] , "private-ldflags": @@ -135,4 +136,10 @@ , "private-deps": [["@", "json", "", "json"], ["src/utils/cpp", "json"]] , "stage": ["src", "buildtool", "main"] } +, "constants": + { "type": ["@", "rules", "CC", "library"] + , "name": ["constants"] + , "hdrs": ["constants.hpp"] + , "stage": ["src", "buildtool", "main"] + } } diff --git a/src/buildtool/main/constants.hpp b/src/buildtool/main/constants.hpp new file mode 100644 index 00000000..99a30ee2 --- /dev/null +++ b/src/buildtool/main/constants.hpp @@ -0,0 +1,23 @@ +// Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef INCLUDED_SRC_BUILDOOL_MAIN_CONSTANTS_HPP +#define INCLUDED_SRC_BUILDOOL_MAIN_CONSTANTS_HPP + +#include <string> +#include <vector> + +std::vector<std::string> const kRootMarkers{".git", "ROOT", "WORKSPACE"}; + +#endif // INCLUDED_SRC_BUILDOOL_MAIN_CONSTANTS_HPP diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index dfa25dd3..fbbef488 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -31,6 +31,7 @@ #include "src/buildtool/common/repository_config.hpp" #include "src/buildtool/compatibility/compatibility.hpp" #include "src/buildtool/main/analyse.hpp" +#include "src/buildtool/main/constants.hpp" #include "src/buildtool/main/describe.hpp" #include "src/buildtool/main/exit_codes.hpp" #include "src/buildtool/main/install_cas.hpp" @@ -440,8 +441,7 @@ void SetupHashFunction() { auto cwd = std::filesystem::current_path(); auto root = cwd.root_path(); cwd = std::filesystem::relative(cwd, root); - auto root_dir = - FindRoot(cwd, FileRoot{root}, {"ROOT", "WORKSPACE", ".git"}); + auto root_dir = FindRoot(cwd, FileRoot{root}, kRootMarkers); if (not root_dir) { Logger::Log(LogLevel::Error, "Could not determine workspace root."); std::exit(kExitFailure); |