From 1110808a9d39d4b808aef724c861a2e1a38d2a69 Mon Sep 17 00:00:00 2001
From: Devtools Arcadia <arcadia-devtools@yandex-team.ru>
Date: Mon, 7 Feb 2022 18:08:42 +0300
Subject: intermediate changes ref:cde9a383711a11544ce7e107a78147fb96cc4029

---
 library/cpp/build_info/build_info.cpp.in     |  5 +++++
 library/cpp/build_info/build_info.h          | 14 ++++++++++++++
 library/cpp/build_info/build_info_static.cpp | 27 +++++++++++++++++++++++++++
 library/cpp/build_info/build_info_static.h   | 13 +++++++++++++
 library/cpp/build_info/sandbox.cpp.in        | 27 +++++++++++++++++++++++++++
 library/cpp/build_info/sandbox.h             | 12 ++++++++++++
 library/cpp/build_info/ya.make               | 24 ++++++++++++++++++++++++
 7 files changed, 122 insertions(+)
 create mode 100644 library/cpp/build_info/build_info.cpp.in
 create mode 100644 library/cpp/build_info/build_info.h
 create mode 100644 library/cpp/build_info/build_info_static.cpp
 create mode 100644 library/cpp/build_info/build_info_static.h
 create mode 100644 library/cpp/build_info/sandbox.cpp.in
 create mode 100644 library/cpp/build_info/sandbox.h
 create mode 100644 library/cpp/build_info/ya.make

(limited to 'library/cpp/build_info')

diff --git a/library/cpp/build_info/build_info.cpp.in b/library/cpp/build_info/build_info.cpp.in
new file mode 100644
index 0000000000..71403af13e
--- /dev/null
+++ b/library/cpp/build_info/build_info.cpp.in
@@ -0,0 +1,5 @@
+#include <library/cpp/build_info/build_info.h>
+
+extern "C" const char* GetBuildType() {
+    return "@BUILD_TYPE@";
+}
diff --git a/library/cpp/build_info/build_info.h b/library/cpp/build_info/build_info.h
new file mode 100644
index 0000000000..a494870ba3
--- /dev/null
+++ b/library/cpp/build_info/build_info.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "sandbox.h"
+#include "build_info_static.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+const char* GetBuildType();
+
+#if defined(__cplusplus)
+}
+#endif
diff --git a/library/cpp/build_info/build_info_static.cpp b/library/cpp/build_info/build_info_static.cpp
new file mode 100644
index 0000000000..238fb1ecb0
--- /dev/null
+++ b/library/cpp/build_info/build_info_static.cpp
@@ -0,0 +1,27 @@
+#include "build_info_static.h"
+
+#include <library/cpp/build_info/buildinfo_data.h>
+
+extern "C" const char* GetCompilerVersion() {
+#if defined(BUILD_COMPILER_VERSION)
+    return BUILD_COMPILER_VERSION;
+#else
+    return "";
+#endif
+}
+
+extern "C" const char* GetCompilerFlags() {
+#if defined(BUILD_COMPILER_FLAGS)
+    return BUILD_COMPILER_FLAGS;
+#else
+    return "";
+#endif
+}
+
+extern "C" const char* GetBuildInfo() {
+#if defined(BUILD_INFO)
+    return BUILD_INFO;
+#else
+    return "";
+#endif
+}
diff --git a/library/cpp/build_info/build_info_static.h b/library/cpp/build_info/build_info_static.h
new file mode 100644
index 0000000000..9bf9939dd9
--- /dev/null
+++ b/library/cpp/build_info/build_info_static.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+const char* GetCompilerVersion();
+const char* GetCompilerFlags(); // "-std=c++14 -DNDEBUG -O2 -m64 ..."
+const char* GetBuildInfo();     // Compiler version and flags
+
+#if defined(__cplusplus)
+}
+#endif
diff --git a/library/cpp/build_info/sandbox.cpp.in b/library/cpp/build_info/sandbox.cpp.in
new file mode 100644
index 0000000000..ac3b2d9004
--- /dev/null
+++ b/library/cpp/build_info/sandbox.cpp.in
@@ -0,0 +1,27 @@
+#include <library/cpp/build_info/sandbox.h>
+#include <library/cpp/string_utils/base64/base64.h>
+#include <util/generic/string.h>
+#include <util/string/subst.h>
+
+extern "C" const char* GetSandboxTaskId() {
+    return "@SANDBOX_TASK_ID@";
+}
+
+class TKosherVersionHolder {
+public:
+    const char* Version() const {
+        if (!Version_) {
+            TString version = "@KOSHER_SVN_VERSION@";
+            SubstGlobal(version, ".", "=");
+            Version_ = Base64Decode(version);
+        }
+        return Version_.c_str();
+    }
+private:
+    mutable TString Version_;
+};
+
+// Experimental code for RMDEV-365
+extern "C" const char* GetKosherSvnVersion() {
+    return Singleton<TKosherVersionHolder>()->Version();
+}
diff --git a/library/cpp/build_info/sandbox.h b/library/cpp/build_info/sandbox.h
new file mode 100644
index 0000000000..924ff89c8c
--- /dev/null
+++ b/library/cpp/build_info/sandbox.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+const char* GetSandboxTaskId();
+const char* GetKosherSvnVersion();
+
+#if defined(__cplusplus)
+}
+#endif
diff --git a/library/cpp/build_info/ya.make b/library/cpp/build_info/ya.make
new file mode 100644
index 0000000000..99886a8893
--- /dev/null
+++ b/library/cpp/build_info/ya.make
@@ -0,0 +1,24 @@
+LIBRARY()
+
+OWNER(
+    mvel
+    snowball
+    heretic
+)
+
+DEFAULT(SANDBOX_TASK_ID 0)
+DEFAULT(KOSHER_SVN_VERSION "")
+
+CREATE_BUILDINFO_FOR(buildinfo_data.h)
+
+PEERDIR(
+    library/cpp/string_utils/base64
+)
+
+SRCS(
+    sandbox.cpp.in
+    build_info.cpp.in
+    build_info_static.cpp
+)
+
+END()
-- 
cgit v1.2.3