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
This commit is contained in:
Viktor Szakats 2024-09-05 23:23:47 +02:00
parent b0a1c9bdca
commit 1fdea16846
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
5 changed files with 119 additions and 12 deletions

View File

@ -46,6 +46,23 @@
cmake_minimum_required(VERSION 3.7...3.16 FATAL_ERROR) cmake_minimum_required(VERSION 3.7...3.16 FATAL_ERROR)
message(STATUS "Using CMake version ${CMAKE_VERSION}") 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}") set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
include(Utilities) include(Utilities)
include(Macros) include(Macros)
@ -54,36 +71,38 @@ include(CheckCCompilerFlag)
project(CURL C) project(CURL C)
unset(_flags) unset(_target_flags)
if(APPLE) if(APPLE)
set(_flags "${_flags} APPLE") set(_target_flags "${_target_flags} APPLE")
endif() endif()
if(UNIX) if(UNIX)
set(_flags "${_flags} UNIX") set(_target_flags "${_target_flags} UNIX")
endif() endif()
if(WIN32) if(WIN32)
set(_flags "${_flags} WIN32") set(_target_flags "${_target_flags} WIN32")
endif() endif()
if(CYGWIN) if(CYGWIN)
set(_flags "${_flags} CYGWIN") set(_target_flags "${_target_flags} CYGWIN")
endif() endif()
if(MSYS) if(MSYS)
set(_flags "${_flags} MSYS") set(_target_flags "${_target_flags} MSYS")
endif() endif()
if(CMAKE_COMPILER_IS_GNUCC) if(CMAKE_COMPILER_IS_GNUCC)
set(_flags "${_flags} GCC") set(_target_flags "${_target_flags} GCC")
endif() endif()
if(MINGW) if(MINGW)
set(_flags "${_flags} MINGW") set(_target_flags "${_target_flags} MINGW")
endif() endif()
if(MSVC) if(MSVC)
set(_flags "${_flags} MSVC") set(_target_flags "${_target_flags} MSVC")
endif() endif()
if(VCPKG_TOOLCHAIN) if(VCPKG_TOOLCHAIN)
set(_flags "${_flags} VCPKG") set(_target_flags "${_target_flags} VCPKG")
endif() endif()
message(STATUS "CMake platform flags:${_flags}") if(CMAKE_CROSSCOMPILING)
unset(_flags) set(_target_flags "${_target_flags} CROSS")
endif()
message(STATUS "CMake platform flags:${_target_flags}")
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)
message(STATUS "Cross-compiling: " message(STATUS "Cross-compiling: "

View File

@ -1558,6 +1558,59 @@ use vars qw(
_EOF _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 CURL_CPP_P
dnl dnl
dnl Check if $cpp -P should be used for extract define values due to gcc 5 dnl Check if $cpp -P should be used for extract define values due to gcc 5

View File

@ -5237,6 +5237,7 @@ AC_CONFIG_FILES([\
AC_OUTPUT AC_OUTPUT
CURL_GENERATE_CONFIGUREHELP_PM CURL_GENERATE_CONFIGUREHELP_PM
CURL_GENERATE_BUILDINFO_TXT
SUPPORT_PROTOCOLS_LOWER=`echo "$SUPPORT_PROTOCOLS" | tr A-Z a-z` SUPPORT_PROTOCOLS_LOWER=`echo "$SUPPORT_PROTOCOLS" | tr A-Z a-z`

View File

@ -94,6 +94,25 @@ use vars qw(
1; 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-quiet "-a -s")
add_runtests(test-am "-a -am") add_runtests(test-am "-a -am")
add_runtests(test-full "-a -p -r") add_runtests(test-full "-a -p -r")

View File

@ -2583,6 +2583,21 @@ if(!$listonly) {
checksystemfeatures(); 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 # initialize configuration needed to set up servers
# TODO: rearrange things so this can be called only in runner_init() # TODO: rearrange things so this can be called only in runner_init()