[Tarantool-patches] [PATCH v2 2/2] build: add bundled curl and c-ares to version output

Serge Petrenko sergepetrenko at tarantool.org
Tue Jan 21 14:54:32 MSK 2020


Since we may use bundled lubcurl and c-ares, it can be useful to know
the exact curl and c-ares versions tarantool was built with.

Follow-up #4591
---
 cmake/BuildAres.cmake     | 10 ++++++++++
 cmake/BuildLibCURL.cmake  | 10 ++++++++++
 src/lua/init.c            | 14 ++++++++++++++
 src/main.cc               |  6 ++++++
 src/trivia/config.h.cmake |  4 ++++
 test/box-py/args.result   |  8 ++++++++
 test/box-py/args.test.py  |  5 ++++-
 7 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/cmake/BuildAres.cmake b/cmake/BuildAres.cmake
index 0f9f174ce..7be6f5b00 100644
--- a/cmake/BuildAres.cmake
+++ b/cmake/BuildAres.cmake
@@ -4,6 +4,16 @@ macro(ares_build)
     set(ARES_BINARY_DIR ${PROJECT_BINARY_DIR}/build/ares/work)
     set(ARES_INSTALL_DIR ${PROJECT_BINARY_DIR}/build/ares/dest)
 
+    # Get bundled ares version for `tarantool -v` output.
+    if (EXISTS "${ARES_SOURCE_DIR}/.git" AND GIT)
+        execute_process (COMMAND ${GIT} describe HEAD
+            OUTPUT_VARIABLE BUNDLED_ARES_VERSION
+            OUTPUT_STRIP_TRAILING_WHITESPACE
+            WORKING_DIRECTORY ${ARES_SOURCE_DIR})
+            string(REPLACE cares- "" BUNDLED_ARES_VERSION ${BUNDLED_ARES_VERSION})
+            string(REPLACE _ . BUNDLED_ARES_VERSION ${BUNDLED_ARES_VERSION})
+    endif()
+
     # See BuildLibCURL.cmake for details.
     set(ARES_CFLAGS "")
     if (TARGET_OS_DARWIN AND NOT "${CMAKE_OSX_SYSROOT}" STREQUAL "")
diff --git a/cmake/BuildLibCURL.cmake b/cmake/BuildLibCURL.cmake
index 756297878..aff34cbf0 100644
--- a/cmake/BuildLibCURL.cmake
+++ b/cmake/BuildLibCURL.cmake
@@ -4,6 +4,16 @@ macro(curl_build)
     set(LIBCURL_BINARY_DIR ${PROJECT_BINARY_DIR}/build/curl/work)
     set(LIBCURL_INSTALL_DIR ${PROJECT_BINARY_DIR}/build/curl/dest)
 
+    # Get bundled curl version for `tarantool -v` output.
+    if (EXISTS "${LIBCURL_SOURCE_DIR}/.git" AND GIT)
+        execute_process (COMMAND ${GIT} describe HEAD
+            OUTPUT_VARIABLE BUNDLED_CURL_VERSION
+            OUTPUT_STRIP_TRAILING_WHITESPACE
+            WORKING_DIRECTORY ${LIBCURL_SOURCE_DIR})
+            string(REPLACE curl- "" BUNDLED_CURL_VERSION ${BUNDLED_CURL_VERSION})
+            string(REPLACE _ . BUNDLED_CURL_VERSION ${BUNDLED_CURL_VERSION})
+    endif()
+
     if (BUILD_STATIC)
         set(LIBZ_LIB_NAME libz.a)
     else()
diff --git a/src/lua/init.c b/src/lua/init.c
index 097dd8495..437175260 100644
--- a/src/lua/init.c
+++ b/src/lua/init.c
@@ -427,6 +427,20 @@ luaopen_tarantool(lua_State *L)
 	lua_pushstring(L, TARANTOOL_C_FLAGS);
 	lua_settable(L, -3);
 
+#ifdef BUNDLED_CURL_VERSION
+	/* build.curl */
+	lua_pushstring(L, "curl");
+	lua_pushstring(L, BUNDLED_CURL_VERSION);
+	lua_settable(L, -3);
+#endif
+
+#ifdef BUNDLED_ARES_VERSION
+	/* build.c_ares */
+	lua_pushstring(L, "c_ares");
+	lua_pushstring(L, BUNDLED_ARES_VERSION);
+	lua_settable(L, -3);
+#endif
+
 	lua_settable(L, -3);    /* box.info.build */
 	return 1;
 }
diff --git a/src/main.cc b/src/main.cc
index e674d85b1..098b97013 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -675,6 +675,12 @@ print_version(void)
 	printf("%s %s\n", tarantool_package(), tarantool_version());
 	printf("Target: %s\n", BUILD_INFO);
 	printf("Build options: %s\n", BUILD_OPTIONS);
+#ifdef BUNDLED_CURL_VERSION
+	printf("Bundled libCURL version: %s\n", BUNDLED_CURL_VERSION);
+#endif
+#ifdef BUNDLED_ARES_VERSION
+	printf("Bundled c-ares version: %s\n", BUNDLED_ARES_VERSION);
+#endif
 	printf("Compiler: %s\n", COMPILER_INFO);
 	printf("C_FLAGS:%s\n", TARANTOOL_C_FLAGS);
 	printf("CXX_FLAGS:%s\n", TARANTOOL_CXX_FLAGS);
diff --git a/src/trivia/config.h.cmake b/src/trivia/config.h.cmake
index 226f83128..c541beb31 100644
--- a/src/trivia/config.h.cmake
+++ b/src/trivia/config.h.cmake
@@ -42,6 +42,10 @@
 #define TARANTOOL_LIBEXT "so"
 #endif
 
+/** Is set to the version of builtin libcurl used. */
+#cmakedefine BUNDLED_CURL_VERSION "${BUNDLED_CURL_VERSION}"
+/** Is set to the version of builtin c-ares used. */
+#cmakedefine BUNDLED_ARES_VERSION "${BUNDLED_ARES_VERSION}"
 /**
  * Defined if cpuid() instruction is available.
  */
diff --git a/test/box-py/args.result b/test/box-py/args.result
index 54629edea..cb1131eb3 100644
--- a/test/box-py/args.result
+++ b/test/box-py/args.result
@@ -47,6 +47,8 @@ tarantool --version
 Tarantool 2.minor.patch-<rev>-<commit>
 Target: platform <build>
 Build options: flags
+Curl 7.66.patch
+c-ares 1.15.patch-<rev>-<commit>
 Compiler: cc
 C_FLAGS: flags
 CXX_FLAGS: flags
@@ -55,6 +57,8 @@ tarantool -v
 Tarantool 2.minor.patch-<rev>-<commit>
 Target: platform <build>
 Build options: flags
+Curl 7.66.patch
+c-ares 1.15.patch-<rev>-<commit>
 Compiler: cc
 C_FLAGS: flags
 CXX_FLAGS: flags
@@ -63,6 +67,8 @@ tarantool -V
 Tarantool 2.minor.patch-<rev>-<commit>
 Target: platform <build>
 Build options: flags
+Curl 7.66.patch
+c-ares 1.15.patch-<rev>-<commit>
 Compiler: cc
 C_FLAGS: flags
 CXX_FLAGS: flags
@@ -114,6 +120,8 @@ tarantool -V ${SOURCEDIR}/test/box-py/args.lua 1 2 3
 Tarantool 2.minor.patch-<rev>-<commit>
 Target: platform <build>
 Build options: flags
+Curl 7.66.patch
+c-ares 1.15.patch-<rev>-<commit>
 Compiler: cc
 C_FLAGS: flags
 CXX_FLAGS: flags
diff --git a/test/box-py/args.test.py b/test/box-py/args.test.py
index f89c5bb09..59b0f4b4c 100644
--- a/test/box-py/args.test.py
+++ b/test/box-py/args.test.py
@@ -16,7 +16,10 @@ sys.stdout.push_filter("unrecognized option.*", "unrecognized option")
 server.test_option("-Z")
 server.test_option("--no-such-option")
 server.test_option("--no-such-option --version")
-sys.stdout.push_filter(".* (\d+)\.\d+\.\d(-\d+-\w+)?", "Tarantool \\1.minor.patch-<rev>-<commit>")
+sys.stdout.push_filter("Tarantool (\d+)\.\d+\.\d(-\d+-\w+)?", "Tarantool \\1.minor.patch-<rev>-<commit>")
+sys.stdout.push_filter("Bundled libCURL version: (\d+).(\d+)\.\d+", "Curl \\1.\\2.patch")
+sys.stdout.push_filter("Bundled c-ares version: (\d+)\.(\d+)\.\d(-\d+-\w+)?",
+                       "c-ares \\1.\\2.patch-<rev>-<commit>")
 sys.stdout.push_filter("Target: .*", "Target: platform <build>")
 sys.stdout.push_filter(".*Disable shared arena since.*\n", "")
 sys.stdout.push_filter("Build options: .*", "Build options: flags")
-- 
2.21.0 (Apple Git-122)



More information about the Tarantool-patches mailing list