From: Viktor Szakats Date: Thu, 5 Sep 2024 21:23:47 +0000 (+0200) Subject: build: generate `buildinfo.txt` for test logs X-Git-Tag: curl-8_10_0~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1fdea1684602a1ae2870c67b5f3e8fd34f63da95;p=thirdparty%2Fcurl.git build: generate `buildinfo.txt` for test logs 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 36f6821475..42fc8e440e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,23 @@ 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: " diff --git a/acinclude.m4 b/acinclude.m4 index 6d0ea50d90..056a979410 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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 diff --git a/configure.ac b/configure.ac index 6bf47e2cf9..a43c813019 100644 --- a/configure.ac +++ b/configure.ac @@ -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` diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 87200fa312..ce98614348 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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") diff --git a/tests/runtests.pl b/tests/runtests.pl index 8956398166..07802ad376 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -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()