]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: generate `buildinfo.txt` for test logs
authorViktor Szakats <commit@vsz.me>
Thu, 5 Sep 2024 21:23:47 +0000 (23:23 +0200)
committerViktor Szakats <commit@vsz.me>
Fri, 6 Sep 2024 19:46:04 +0000 (21:46 +0200)
Also:
- read `buildinfo.txt` from `runtests.pl` and dump it to the log.
- cmake: show `CROSS` target flag for cross-builds.
- cmake: add logic to detect arguments passed via the command-line.

It is meant to help filling out missing datapoints in the testclutch
matrix.

Closes #14802

CMakeLists.txt
acinclude.m4
configure.ac
tests/CMakeLists.txt
tests/runtests.pl

index 36f682147553f1dc8dff5368f8045cfdda556d50..42fc8e440eb3c29a6bdd6d8c83ed6189a45bf196 100644 (file)
 cmake_minimum_required(VERSION 3.7...3.16 FATAL_ERROR)
 message(STATUS "Using CMake version ${CMAKE_VERSION}")
 
+# Collect command-line arguments for buildinfo.txt.
+# Must reside at the top of the script to work as expected.
+get_cmake_property(_cache_vars CACHE_VARIABLES)
+unset(_cmake_args)
+foreach(_cache_var ${_cache_vars})
+  get_property(_cache_var_helpstring CACHE ${_cache_var} PROPERTY HELPSTRING)
+  if(_cache_var_helpstring STREQUAL "No help, variable specified on the command line.")
+    get_property(_cache_var_type CACHE ${_cache_var} PROPERTY TYPE)
+    if(_cache_var_type STREQUAL "UNINITIALIZED")
+      set(_cache_var_type)
+    else()
+      set(_cache_var_type ":${_cache_var_type}")
+    endif()
+    set(_cmake_args "${_cmake_args} -D${_cache_var}${_cache_var_type}=\"${${_cache_var}}\"")
+  endif()
+endforeach()
+
 set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
 include(Utilities)
 include(Macros)
@@ -54,36 +71,38 @@ include(CheckCCompilerFlag)
 
 project(CURL C)
 
-unset(_flags)
+unset(_target_flags)
 if(APPLE)
-  set(_flags "${_flags} APPLE")
+  set(_target_flags "${_target_flags} APPLE")
 endif()
 if(UNIX)
-  set(_flags "${_flags} UNIX")
+  set(_target_flags "${_target_flags} UNIX")
 endif()
 if(WIN32)
-  set(_flags "${_flags} WIN32")
+  set(_target_flags "${_target_flags} WIN32")
 endif()
 if(CYGWIN)
-  set(_flags "${_flags} CYGWIN")
+  set(_target_flags "${_target_flags} CYGWIN")
 endif()
 if(MSYS)
-  set(_flags "${_flags} MSYS")
+  set(_target_flags "${_target_flags} MSYS")
 endif()
 if(CMAKE_COMPILER_IS_GNUCC)
-  set(_flags "${_flags} GCC")
+  set(_target_flags "${_target_flags} GCC")
 endif()
 if(MINGW)
-  set(_flags "${_flags} MINGW")
+  set(_target_flags "${_target_flags} MINGW")
 endif()
 if(MSVC)
-  set(_flags "${_flags} MSVC")
+  set(_target_flags "${_target_flags} MSVC")
 endif()
 if(VCPKG_TOOLCHAIN)
-  set(_flags "${_flags} VCPKG")
+  set(_target_flags "${_target_flags} VCPKG")
+endif()
+if(CMAKE_CROSSCOMPILING)
+  set(_target_flags "${_target_flags} CROSS")
 endif()
-message(STATUS "CMake platform flags:${_flags}")
-unset(_flags)
+message(STATUS "CMake platform flags:${_target_flags}")
 
 if(CMAKE_CROSSCOMPILING)
   message(STATUS "Cross-compiling: "
index 6d0ea50d907a5a482bf54e8c04eab6d1bf6b4606..056a9794105b8d3860fbe6ff7536e84fcbac77f9 100644 (file)
@@ -1558,6 +1558,59 @@ use vars qw(
 _EOF
 ])
 
+
+dnl CURL_GENERATE_BUILDINFO_TXT
+dnl -------------------------------------------------
+dnl Save build info for test runner to pick up and log
+
+AC_DEFUN([CURL_GENERATE_BUILDINFO_TXT], [
+  curl_pflags=""
+  case $host in
+    *-apple-*) curl_pflags="${curl_pflags} APPLE";;
+  esac
+  if test "$curl_cv_native_windows" = 'yes'; then
+    curl_pflags="${curl_pflags} WIN32"
+  else
+    case $host in
+      *-*-*bsd*|*-*-aix*|*-*-hpux*|*-*-interix*|*-*-irix*|*-*-linux*|*-*-solaris*|*-*-sunos*|*-apple-*|*-*-cygwin*|*-*-msys*)
+        curl_pflags="${curl_pflags} UNIX";;
+    esac
+  fi
+  case $host_os in
+    cygwin*|msys*) curl_pflags="${curl_pflags} CYGWIN";;
+  esac
+  case $host_os in
+    msys*) curl_pflags="${curl_pflags} MSYS";;
+  esac
+  if test "x$compiler_id" = 'xGNU_C'; then
+    curl_pflags="${curl_pflags} GCC"
+  fi
+  case $host_os in
+    mingw*) curl_pflags="${curl_pflags} MINGW";;
+  esac
+  if test "x$cross_compiling" = 'xyes'; then
+    curl_pflags="${curl_pflags} CROSS"
+  fi
+  squeeze curl_pflags
+  cat >./tests/buildinfo.txt <<_EOF
+[@%:@] This is a generated file.  Do not edit.
+configure.tool: configure
+configure.args: $ac_configure_args
+host: $build
+host.os: $build_os
+host.cpu: $build_cpu
+host.vendor: $build_vendor
+target: $host
+target.os: $host_os
+target.cpu: $host_cpu
+target.vendor: $host_vendor
+target.flags: $curl_pflags
+compiler: $compiler_id
+compiler.version: $compiler_num
+_EOF
+])
+
+
 dnl CURL_CPP_P
 dnl
 dnl Check if $cpp -P should be used for extract define values due to gcc 5
index 6bf47e2cf9725547d7a2387b4260c7ea8ee4ec1c..a43c81301977f0ef76ad4b0519973ea29c8b6917 100644 (file)
@@ -5237,6 +5237,7 @@ AC_CONFIG_FILES([\
 AC_OUTPUT
 
 CURL_GENERATE_CONFIGUREHELP_PM
+CURL_GENERATE_BUILDINFO_TXT
 
 SUPPORT_PROTOCOLS_LOWER=`echo "$SUPPORT_PROTOCOLS" | tr A-Z a-z`
 
index 87200fa312a28b5007b7dcde13dface8aaf99f17..ce986143487d6a531a2d1342f6b9ff19870dc72a 100644 (file)
@@ -94,6 +94,25 @@ use vars qw(
 1;
 ")
 
+# Save build info for test runner to pick up and log
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/buildinfo.txt" "# This is a generated file.  Do not edit.
+configure.tool: cmake
+configure.command: ${CMAKE_COMMAND}
+configure.version: ${CMAKE_VERSION}
+configure.os: ${CMAKE_SYSTEM}
+configure.args:${_cmake_args}
+configure.generator: ${CMAKE_GENERATOR}
+configure.make: ${CMAKE_MAKE_PROGRAM}
+host.os: ${CMAKE_HOST_SYSTEM_NAME}
+host.cpu: ${CMAKE_HOST_SYSTEM_PROCESSOR}
+target: ${CMAKE_C_COMPILER_TARGET}
+target.os: ${CMAKE_SYSTEM_NAME}
+target.cpu: ${CMAKE_SYSTEM_PROCESSOR}
+target.flags:${_target_flags}
+compiler: ${CMAKE_C_COMPILER_ID}
+compiler.version: ${CMAKE_C_COMPILER_VERSION}
+")
+
 add_runtests(test-quiet     "-a -s")
 add_runtests(test-am        "-a -am")
 add_runtests(test-full      "-a -p -r")
index 8956398166e33cd9c5863f68979a26266940a9e4..07802ad37618a5eb8aa13ef847de82b8e169b052 100755 (executable)
@@ -2583,6 +2583,21 @@ if(!$listonly) {
     checksystemfeatures();
 }
 
+#######################################################################
+# Output information about the curl build
+#
+if(!$listonly) {
+    if(open(my $fd, "<", "buildinfo.txt")) {
+        while(my $line = <$fd>) {
+            chomp $line;
+            if($line && $line !~ /^#/) {
+                logmsg("* buildinfo.$line\n");
+            }
+        }
+        close($fd);
+    }
+}
+
 #######################################################################
 # initialize configuration needed to set up servers
 # TODO: rearrange things so this can be called only in runner_init()