]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: `buildinfo.txt` improvements
authorViktor Szakats <commit@vsz.me>
Sat, 7 Sep 2024 00:43:35 +0000 (02:43 +0200)
committerViktor Szakats <commit@vsz.me>
Thu, 19 Sep 2024 13:56:30 +0000 (15:56 +0200)
- cmake: drop `configure.os`.
  This also includes OS version, but thus far it's not important enough
  to include it.
- autotools: drop redundant, autotools-only `{target|host}.vendor`.
  (it's part of the triplet in `{target|host}`.)
- swap order to `*.cpu` -> `*.os` to match triplet-order.
- cmake: drop redundant `target`.
  It's manually filled and only in a (so far) few CI jobs. Let's revisit
  when this becomes useful.
- move `buildinfo.txt` to build root.
- dist: add `buildinfo.txt` to `DISTCLEANFILES`.
- autotools: detect human readable compiler version.
- autotools: replace `XXYY` `compiler.version` with "X.Y"-style.
  (also to match cmake.)
- autotools: use distinct `compiler_id` for Apple clang: `APPLECLANG`.
  To match cmake and also because the the "X.Y"-style version number
  is the Apple version, while `XXYY` was a value roughly translated to
  mainline llvm/clang version.
- show buildinfo at the end of the configure stage, when run in CI, or
  when `CURL_BUILDINFO` or `CURL_CI` env is set.

Follow-up to 1fdea1684602a1ae2870c67b5f3e8fd34f63da95 #14802
Assisted-by: Dan Fandrich
Ref: https://github.com/curl/curl/pull/14802#issuecomment-2334942991
Closes #14822

.gitignore
CMakeLists.txt
Makefile.am
acinclude.m4
configure.ac
m4/curl-compilers.m4
tests/.gitignore
tests/CMakeLists.txt
tests/runtests.pl

index a9099e5ce42b85402e22f33092401a3515520bf2..55768f6ed156a6eef5ebbc2925b0264f61e0074d 100644 (file)
@@ -36,6 +36,7 @@ TAGS
 aclocal.m4
 aclocal.m4.bak
 autom4te.cache
+buildinfo.txt
 compile
 config.cache
 config.guess
index 5ebeb5a8b676a09ffba3acb91ee01d294d6f9447..4f2c2c0234dbd81a1b2e6e7c730103c5b6a5aa16 100644 (file)
@@ -2191,3 +2191,30 @@ if(NOT CURL_DISABLE_INSTALL)
       GROUP_READ GROUP_EXECUTE
       WORLD_READ WORLD_EXECUTE)
 endif()
+
+# Save build info for test runner to pick up and log
+if(CMAKE_OSX_SYSROOT)
+  set(_cmake_sysroot ${CMAKE_OSX_SYSROOT})
+elseif(CMAKE_SYSROOT)
+  set(_cmake_sysroot ${CMAKE_SYSROOT})
+endif()
+set(_buildinfo "\
+buildinfo.configure.tool: cmake
+buildinfo.configure.command: ${CMAKE_COMMAND}
+buildinfo.configure.version: ${CMAKE_VERSION}
+buildinfo.configure.args:${_cmake_args}
+buildinfo.configure.generator: ${CMAKE_GENERATOR}
+buildinfo.configure.make: ${CMAKE_MAKE_PROGRAM}
+buildinfo.host.cpu: ${CMAKE_HOST_SYSTEM_PROCESSOR}
+buildinfo.host.os: ${CMAKE_HOST_SYSTEM_NAME}
+buildinfo.target.cpu: ${CMAKE_SYSTEM_PROCESSOR}
+buildinfo.target.os: ${CMAKE_SYSTEM_NAME}
+buildinfo.target.flags:${_target_flags}
+buildinfo.compiler: ${CMAKE_C_COMPILER_ID}
+buildinfo.compiler.version: ${CMAKE_C_COMPILER_VERSION}
+buildinfo.sysroot: ${_cmake_sysroot}
+")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/buildinfo.txt" "# This is a generated file.  Do not edit.\n${_buildinfo}")
+if(NOT "$ENV{CURL_BUILDINFO}$ENV{CURL_CI}$ENV{CI}" STREQUAL "")
+  message(STATUS "\n${_buildinfo}")
+endif()
index e8962136bbb84b5c8e36c41e295b05b7c35b72f0..6e477f1a331097e5088ce01ba342378f74f291b3 100644 (file)
@@ -91,6 +91,8 @@ CLEANFILES = $(VC14_LIBVCXPROJ) $(VC14_SRCVCXPROJ) \
  $(VC14_20_LIBVCXPROJ) $(VC14_20_SRCVCXPROJ)       \
  $(VC14_30_LIBVCXPROJ) $(VC14_30_SRCVCXPROJ)
 
+DISTCLEANFILES = buildinfo.txt
+
 bin_SCRIPTS = curl-config
 
 SUBDIRS = lib docs src scripts
index d0f492bd4964f37f7b917ff3d2dbe9d2757aa603..9f5e373d12ebdd06b761447dce2aaae393c4f9d2 100644 (file)
@@ -1559,11 +1559,11 @@ _EOF
 ])
 
 
-dnl CURL_GENERATE_BUILDINFO_TXT
+dnl CURL_PREPARE_BUILDINFO
 dnl -------------------------------------------------
 dnl Save build info for test runner to pick up and log
 
-AC_DEFUN([CURL_GENERATE_BUILDINFO_TXT], [
+AC_DEFUN([CURL_PREPARE_BUILDINFO], [
   curl_pflags=""
   case $host in
     *-apple-*) curl_pflags="${curl_pflags} APPLE";;
@@ -1592,22 +1592,19 @@ AC_DEFUN([CURL_GENERATE_BUILDINFO_TXT], [
     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
+  curl_buildinfo="
+buildinfo.configure.tool: configure
+buildinfo.configure.args: $ac_configure_args
+buildinfo.host: $build
+buildinfo.host.cpu: $build_cpu
+buildinfo.host.os: $build_os
+buildinfo.target: $host
+buildinfo.target.cpu: $host_cpu
+buildinfo.target.os: $host_os
+buildinfo.target.flags: $curl_pflags
+buildinfo.compiler: $compiler_id
+buildinfo.compiler.version: $compiler_ver
+buildinfo.sysroot: $lt_sysroot"
 ])
 
 
index a42f42ccc1aa8586aec7573f9ff80705264aa5f0..cec382a3d0aefca58a63e05aff811c3954aa2189 100644 (file)
@@ -533,7 +533,7 @@ if test X"$want_werror" = Xyes; then
     if test "$compiler_num" -ge "500"; then
       CURL_CFLAG_EXTRAS="$CURL_CFLAG_EXTRAS -pedantic-errors"
     fi
-  elif test "$compiler_id" = "CLANG"; then
+  elif test "$compiler_id" = "CLANG" -o "$compiler_id" = "APPLECLANG"; then
     CURL_CFLAG_EXTRAS="$CURL_CFLAG_EXTRAS -pedantic-errors"
   fi
 fi
@@ -5250,7 +5250,6 @@ AC_CONFIG_FILES([\
 AC_OUTPUT
 
 CURL_GENERATE_CONFIGUREHELP_PM
-CURL_GENERATE_BUILDINFO_TXT
 
 SUPPORT_PROTOCOLS_LOWER=`echo "$SUPPORT_PROTOCOLS" | tr A-Z a-z`
 
@@ -5318,3 +5317,9 @@ if test -n "$experimental"; then
     AC_MSG_WARN([$a is enabled but marked EXPERIMENTAL. Use with caution!])
   done
 fi
+
+CURL_PREPARE_BUILDINFO
+echo "[@%:@] This is a generated file.  Do not edit.${curl_buildinfo}" > ./buildinfo.txt
+if test -n "$CURL_BUILDINFO$CURL_CI$CI"; then
+  AC_MSG_NOTICE([${curl_buildinfo}])
+fi
index 240aa2b0b1096a023397aff979ff92e4212e38a3..e2f851df6879b91fe604fc97c6b041c6d3235419 100644 (file)
@@ -33,6 +33,7 @@ dnl Verify if the C compiler being used is known.
 AC_DEFUN([CURL_CHECK_COMPILER], [
   #
   compiler_id="unknown"
+  compiler_ver=""
   compiler_num="0"
   #
   flags_dbg_yes="unknown"
@@ -95,13 +96,17 @@ AC_DEFUN([CURL_CHECK_COMPILER_CLANG], [
       AC_MSG_RESULT([no])
       compiler_id="CLANG"
     fi
-    AC_MSG_CHECKING([compiler version])
+    AC_MSG_CHECKING([if compiler is Apple clang])
     fullclangver=`$CC -v 2>&1 | grep version`
     if echo $fullclangver | grep 'Apple' >/dev/null; then
+      AC_MSG_RESULT([yes])
       appleclang=1
+      compiler_id="APPLECLANG"
     else
+      AC_MSG_RESULT([no])
       appleclang=0
     fi
+    AC_MSG_CHECKING([compiler version])
     clangver=`echo $fullclangver | grep "based on LLVM " | "$SED" 's/.*(based on LLVM \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*)/\1/'`
     if test -z "$clangver"; then
       clangver=`echo $fullclangver | "$SED" 's/.*version \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*/\1/'`
@@ -111,6 +116,7 @@ AC_DEFUN([CURL_CHECK_COMPILER_CLANG], [
     fi
     clangvhi=`echo $clangver | cut -d . -f1`
     clangvlo=`echo $clangver | cut -d . -f2`
+    compiler_ver="$clangver"
     compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null`
     if test "$appleclang" = '1' && test "$oldapple" = '0'; then
       dnl Starting with Xcode 7 / clang 3.7, Apple clang won't tell its upstream version
@@ -192,6 +198,7 @@ AC_DEFUN([CURL_CHECK_COMPILER_GNU_C], [
     else
       gccvlo="0"
     fi
+    compiler_ver="$gccver"
     compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null`
     AC_MSG_RESULT([gcc '$compiler_num' (raw: '$gccver')])
     flags_dbg_yes="-g"
@@ -264,6 +271,7 @@ AC_DEFUN([CURL_CHECK_COMPILER_INTEL_C], [
     AC_MSG_RESULT([yes])
     AC_MSG_CHECKING([compiler version])
     compiler_num="$curl_cv_def___INTEL_COMPILER"
+    compiler_ver=`echo "$compiler_num" | cut -c -2 | $SED 's/^0//'`.`echo "$compiler_num" | cut -c 3-4 | $SED 's/^0//'`
     AC_MSG_RESULT([Intel C '$compiler_num'])
     CURL_CHECK_DEF([__unix__], [], [silent])
     if test "$curl_cv_have_def___unix__" = "yes"; then
@@ -386,7 +394,7 @@ AC_DEFUN([CURL_CONVERT_INCLUDE_TO_ISYSTEM], [
   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
   AC_MSG_CHECKING([convert -I options to -isystem])
   if test "$compiler_id" = "GNU_C" ||
-    test "$compiler_id" = "CLANG"; then
+    test "$compiler_id" = "CLANG" -o "$compiler_id" = "APPLECLANG"; then
     AC_MSG_RESULT([yes])
     tmp_has_include="no"
     tmp_chg_FLAGS="$CFLAGS"
@@ -513,7 +521,7 @@ AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [
     #
     case "$compiler_id" in
         #
-      CLANG)
+      CLANG|APPLECLANG)
         #
         dnl Disable warnings for unused arguments, otherwise clang will
         dnl warn about compile-time arguments used during link-time, like
@@ -782,7 +790,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
     #
     case "$compiler_id" in
         #
-      CLANG)
+      CLANG|APPLECLANG)
         #
         if test "$want_warnings" = "yes"; then
           tmp_CFLAGS="$tmp_CFLAGS -pedantic"
@@ -1370,7 +1378,7 @@ AC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [
   tmp_CFLAGS=""
   tmp_EXTERN=""
   case "$compiler_id" in
-    CLANG)
+    CLANG|APPLECLANG)
       dnl All versions of clang support -fvisibility=
       tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
       tmp_CFLAGS="-fvisibility=hidden"
index c002c730a4eb7d285d00aed47e54c17b849f4e6b..42b5430ca4bf682d62df9345e301eb78e3549c3f 100644 (file)
@@ -4,7 +4,6 @@
 
 *pid
 *.1.dist
-buildinfo.txt
 configurehelp.pm
 curl_client_key
 curl_client_key.pub
index ce986143487d6a531a2d1342f6b9ff19870dc72a..87200fa312a28b5007b7dcde13dface8aaf99f17 100644 (file)
@@ -94,25 +94,6 @@ 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 dfeb8fdbd57a17e7d1fa5f0ad6fd3a291d3770b9..b688283fb4aaf329868f99cf220bc8bc3aa539b6 100755 (executable)
@@ -2598,11 +2598,11 @@ if(!$listonly) {
 # Output information about the curl build
 #
 if(!$listonly) {
-    if(open(my $fd, "<", "buildinfo.txt")) {
+    if(open(my $fd, "<", "../buildinfo.txt")) {
         while(my $line = <$fd>) {
             chomp $line;
             if($line && $line !~ /^#/) {
-                logmsg("* buildinfo.$line\n");
+                logmsg("* $line\n");
             }
         }
         close($fd);