summaryrefslogtreecommitdiff
path: root/src/buildtool/common
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-09-10 18:51:20 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-09-13 14:41:00 +0200
commitf60d39620b29aeaf1addeb244bdd6e15ddf4894c (patch)
tree2617d65884c975b3fc63dd48e58242ec36138246 /src/buildtool/common
parented8f24fb246142ffaa88707ae86b53c34df82986 (diff)
downloadjustbuild-f60d39620b29aeaf1addeb244bdd6e15ddf4894c.tar.gz
Rename Compatibility class to ProtocolTraits
...and move it to the common stage.
Diffstat (limited to 'src/buildtool/common')
-rw-r--r--src/buildtool/common/TARGETS8
-rw-r--r--src/buildtool/common/cli.hpp4
-rw-r--r--src/buildtool/common/protocol_traits.hpp32
3 files changed, 41 insertions, 3 deletions
diff --git a/src/buildtool/common/TARGETS b/src/buildtool/common/TARGETS
index e20f2996..1f280d78 100644
--- a/src/buildtool/common/TARGETS
+++ b/src/buildtool/common/TARGETS
@@ -20,7 +20,7 @@
[ "clidefaults"
, "retry_cli"
, ["src/buildtool/build_engine/expression", "expression"]
- , ["src/buildtool/compatibility", "compatibility"]
+ , ["src/buildtool/common", "protocol_traits"]
, ["src/buildtool/logging", "log_level"]
, ["src/buildtool/logging", "logging"]
, ["src/buildtool/main", "build_utils"]
@@ -192,4 +192,10 @@
]
, "stage": ["src", "buildtool", "common"]
}
+, "protocol_traits":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["protocol_traits"]
+ , "hdrs": ["protocol_traits.hpp"]
+ , "stage": ["src", "buildtool", "common"]
+ }
}
diff --git a/src/buildtool/common/cli.hpp b/src/buildtool/common/cli.hpp
index 79beaadb..c388879e 100644
--- a/src/buildtool/common/cli.hpp
+++ b/src/buildtool/common/cli.hpp
@@ -32,8 +32,8 @@
#include "nlohmann/json.hpp"
#include "src/buildtool/build_engine/expression/evaluator.hpp"
#include "src/buildtool/common/clidefaults.hpp"
+#include "src/buildtool/common/protocol_traits.hpp"
#include "src/buildtool/common/retry_cli.hpp"
-#include "src/buildtool/compatibility/compatibility.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/main/build_utils.hpp"
#include "src/utils/cpp/path.hpp"
@@ -686,7 +686,7 @@ static inline auto SetupCompatibilityArguments(
gsl::not_null<CLI::App*> const& app) {
app->add_flag_function(
"--compatible",
- [](auto /*unused*/) { Compatibility::SetCompatible(); },
+ [](auto /*unused*/) { ProtocolTraits::Instance().SetCompatible(); },
"At increased computational effort, be compatible with the original "
"remote build execution protocol. As the change affects identifiers, "
"the flag must be used consistently for all related invocations.");
diff --git a/src/buildtool/common/protocol_traits.hpp b/src/buildtool/common/protocol_traits.hpp
new file mode 100644
index 00000000..49850233
--- /dev/null
+++ b/src/buildtool/common/protocol_traits.hpp
@@ -0,0 +1,32 @@
+// 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_BUILDTOOL_COMMON_PROTOCOL_TRAITS_HPP
+#define INCLUDED_SRC_BUILDTOOL_COMMON_PROTOCOL_TRAITS_HPP
+
+class ProtocolTraits final {
+ public:
+ [[nodiscard]] static auto Instance() noexcept -> ProtocolTraits& {
+ static ProtocolTraits instance{};
+ return instance;
+ }
+ [[nodiscard]] auto IsCompatible() const noexcept -> bool {
+ return compatible_;
+ }
+ void SetCompatible(bool value = true) noexcept { compatible_ = value; }
+
+ private:
+ bool compatible_ = false;
+};
+#endif // INCLUDED_SRC_BUILDTOOL_COMMON_PROTOCOL_TRAITS_HPP