aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/svnversion
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/svnversion
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/svnversion')
-rw-r--r--library/cpp/svnversion/svn_interface.c1
-rw-r--r--library/cpp/svnversion/svnversion.cpp33
-rw-r--r--library/cpp/svnversion/svnversion.h13
-rw-r--r--library/cpp/svnversion/test/main.cpp30
-rw-r--r--library/cpp/svnversion/test/ya.make6
-rw-r--r--library/cpp/svnversion/ya.make12
6 files changed, 95 insertions, 0 deletions
diff --git a/library/cpp/svnversion/svn_interface.c b/library/cpp/svnversion/svn_interface.c
new file mode 100644
index 0000000000..12884956b1
--- /dev/null
+++ b/library/cpp/svnversion/svn_interface.c
@@ -0,0 +1 @@
+// See build/scripts/c_templates/svn_interface.c instead.
diff --git a/library/cpp/svnversion/svnversion.cpp b/library/cpp/svnversion/svnversion.cpp
new file mode 100644
index 0000000000..4c9761fa75
--- /dev/null
+++ b/library/cpp/svnversion/svnversion.cpp
@@ -0,0 +1,33 @@
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define FROM_IMPL
+#include "svnversion.h"
+
+#include <util/generic/strbuf.h>
+
+extern "C" void PrintProgramSvnVersion() {
+ puts(GetProgramSvnVersion());
+}
+
+extern "C" void PrintSvnVersionAndExit0() {
+ PrintProgramSvnVersion();
+ exit(0);
+}
+
+extern "C" void PrintSvnVersionAndExitEx(int argc, char* argv[], const char* opts) {
+ if (2 == argc) {
+ for (TStringBuf all = opts, versionOpt; all.NextTok(';', versionOpt);) {
+ if (versionOpt == argv[1]) {
+ PrintSvnVersionAndExit0();
+ }
+ }
+ }
+}
+
+extern "C" void PrintSvnVersionAndExit(int argc, char* argv[]) {
+ PrintSvnVersionAndExitEx(argc, argv, "--version");
+}
+
+#undef FROM_IMPL
diff --git a/library/cpp/svnversion/svnversion.h b/library/cpp/svnversion/svnversion.h
new file mode 100644
index 0000000000..b99615daa9
--- /dev/null
+++ b/library/cpp/svnversion/svnversion.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#if !defined(FROM_IMPL)
+#define PROGRAM_VERSION GetProgramSvnVersion()
+#define ARCADIA_SOURCE_PATH GetArcadiaSourcePath()
+#define PRINT_VERSION PrintSvnVersionAndExit(argc, (char**)argv)
+#define PRINT_VERSION_EX(opts) PrintSvnVersionAndExitEx(argc, (char**)argv, opts)
+#endif
+
+#include <util/system/compiler.h>
+
+// Automatically generated functions.
+#include "build/scripts/c_templates/svnversion.h"
diff --git a/library/cpp/svnversion/test/main.cpp b/library/cpp/svnversion/test/main.cpp
new file mode 100644
index 0000000000..3c8209047f
--- /dev/null
+++ b/library/cpp/svnversion/test/main.cpp
@@ -0,0 +1,30 @@
+#include <build/scripts/c_templates/svnversion.h>
+#include <util/stream/str.h>
+#include <util/system/compiler.h>
+#include <util/stream/output.h>
+
+// ya make -DFORCE_VCS_INFO_UPDATE --vcs-file=<vcs.json> library/cpp/svnversion/test/
+// ./library/svnversion/test/test[.exe]
+int main() {
+ Cout << "GetProgramSvnVersion(): " << GetProgramSvnVersion() << Endl;
+ Cout << "PrintProgramSvnVersion(): " << Endl; PrintProgramSvnVersion();
+ Cout << "GetArcadiaSourcePath(): " << GetArcadiaSourcePath() << Endl;
+ Cout << "GetArcadiaSourceUrl(): " << GetArcadiaSourceUrl() << Endl;
+ Cout << "GetArcadiaLastChange(): " << GetArcadiaLastChange() << Endl;
+ Cout << "GetArcadiaLastChangeNum(): " << GetArcadiaLastChangeNum() << Endl;
+ Cout << "GetArcadiaLastAuthor(): " << GetArcadiaLastAuthor() << Endl;
+ Cout << "GetProgramSvnRevision(): " << GetProgramSvnRevision() << Endl;
+ Cout << "GetProgramHash(): " << GetProgramHash() << Endl;
+ Cout << "GetProgramCommitId(): " << GetProgramCommitId() << Endl;
+ Cout << "GetProgramScmData(): " << GetProgramScmData() << Endl;
+ Cout << "GetProgramBuildUser(): " << GetProgramBuildUser() << Endl;
+ Cout << "GetProgramBuildHost(): " << GetProgramBuildHost() << Endl;
+ Cout << "GetProgramBuildDate(): " << GetProgramBuildDate() << Endl;
+ Cout << "GetVCS(): " << GetVCS() << Endl;
+ Cout << "GetBranch(): " << GetBranch() << Endl;
+ Cout << "GetTag(): " << GetTag() << Endl;
+ Cout << "GetArcadiaPatchNumber(): " << GetArcadiaPatchNumber() << Endl;
+ Cout << "GetVCSDirty(): " << GetVCSDirty() << Endl;
+ return 0;
+}
+
diff --git a/library/cpp/svnversion/test/ya.make b/library/cpp/svnversion/test/ya.make
new file mode 100644
index 0000000000..59c0a2d970
--- /dev/null
+++ b/library/cpp/svnversion/test/ya.make
@@ -0,0 +1,6 @@
+OWNER(g:cpp-contrib)
+
+PROGRAM()
+PEERDIR(library/cpp/svnversion)
+SRCS(main.cpp)
+END()
diff --git a/library/cpp/svnversion/ya.make b/library/cpp/svnversion/ya.make
new file mode 100644
index 0000000000..04e1a4c4fd
--- /dev/null
+++ b/library/cpp/svnversion/ya.make
@@ -0,0 +1,12 @@
+OWNER(g:cpp-contrib)
+
+LIBRARY()
+
+SRCS(
+ svnversion.cpp
+ svn_interface.c
+)
+END()
+RECURSE(
+ test
+)