|
| 1 | +From a52d8145bcd94310d2f737cb56e15d25d9eba86f Mon Sep 17 00:00:00 2001 |
| 2 | +From: Hans Ulrich Niedermann < [email protected]> |
| 3 | +Date: Tue, 8 Oct 2024 21:21:00 +0200 |
| 4 | +Subject: [PATCH] Add extra version information to avrdude output |
| 5 | + |
| 6 | +Some downstream projects build avrdude and want to add |
| 7 | +their own version information to the avrdude version. |
| 8 | + |
| 9 | +This adds a clean way to do that without patching for both |
| 10 | +cmake and automake based builds: |
| 11 | + |
| 12 | + cmake -DEXTRA_VERSION:STRING=-arduino.1-rc1 |
| 13 | + ../configure EXTRA_VERSION=-arduino.1-rc1 |
| 14 | + |
| 15 | +After building avrdude, the last line of "avrdude -?" |
| 16 | +will now look similar to the following, depending on |
| 17 | +whether you are building an avrdude git checkout or |
| 18 | +an avrdude release: |
| 19 | + |
| 20 | + avrdude version 8.0-20240901-arduino.1-rc1 (30e19f23), https://github.com/avrdudes/avrdude |
| 21 | + avrdude version 8.1-arduino.1-rc1 (30e19f23), https://github.com/avrdudes/avrdude |
| 22 | +--- |
| 23 | + CMakeLists.txt | 5 +++-- |
| 24 | + src/configure.ac | 5 +++-- |
| 25 | + 2 files changed, 6 insertions(+), 4 deletions(-) |
| 26 | + |
| 27 | +diff --git a/CMakeLists.txt b/CMakeLists.txt |
| 28 | +index 67e38493..b40e5689 100644 |
| 29 | +--- a/CMakeLists.txt |
| 30 | ++++ b/CMakeLists.txt |
| 31 | +@@ -49,7 +49,7 @@ include(FindPackageMessage) |
| 32 | + include(GNUInstallDirs) |
| 33 | + |
| 34 | + set(CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}") |
| 35 | +-set(AVRDUDE_FULL_VERSION ${CMAKE_PROJECT_VERSION}) |
| 36 | ++set(AVRDUDE_FULL_VERSION "${CMAKE_PROJECT_VERSION}${EXTRA_VERSION}") |
| 37 | + |
| 38 | + # ===================================== |
| 39 | + # Get Git commit info |
| 40 | +@@ -91,7 +91,7 @@ if(Git_FOUND) |
| 41 | + |
| 42 | + # If the commit is not tagged, include the date and commit hash in the full version string. |
| 43 | + if(NOT GIT_COMMIT_HASH STREQUAL GIT_TAG_HASH) |
| 44 | +- set(AVRDUDE_FULL_VERSION "${CMAKE_PROJECT_VERSION}-${GIT_COMMIT_DATE} (${GIT_COMMIT_HASH})") |
| 45 | ++ set(AVRDUDE_FULL_VERSION "${CMAKE_PROJECT_VERSION}-${GIT_COMMIT_DATE}${EXTRA_VERSION} (${GIT_COMMIT_HASH})") |
| 46 | + endif() |
| 47 | + endif() |
| 48 | + |
| 49 | +@@ -374,6 +374,7 @@ if (DEBUG_CMAKE) |
| 50 | + message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}") |
| 51 | + message(STATUS "CONFIG_DIR: ${CONFIG_DIR}") |
| 52 | + message(STATUS "AVRDUDE_FULL_VERSION: ${AVRDUDE_FULL_VERSION}") |
| 53 | ++ message(STATUS "EXTRA_VERSION: ${EXTRA_VERSION}") |
| 54 | + message(STATUS "USE_EXTERNAL_LIBS: ${USE_EXTERNAL_LIBS}") |
| 55 | + message(STATUS "USE_LIBUSBWIN32: ${USE_LIBUSBWIN32}") |
| 56 | + message(STATUS "HAVE_LIBELF: ${HAVE_LIBELF}") |
| 57 | +diff --git a/src/configure.ac b/src/configure.ac |
| 58 | +index 91f6a445..c294f590 100644 |
| 59 | +--- a/src/configure.ac |
| 60 | ++++ b/src/configure.ac |
| 61 | +@@ -80,11 +80,12 @@ AC_MSG_RESULT([$PACKAGE_VERSION]) |
| 62 | + dnl Compose the full version message mirroring the cmake one, inform |
| 63 | + dnl about it and pass it on to avrdude.conf and the "avrdude -?" |
| 64 | + dnl version message |
| 65 | ++AC_ARG_VAR([EXTRA_VERSION], [extra version information to be added to version info]) |
| 66 | + AC_MSG_CHECKING([versioninfo derived AVRDUDE_FULL_VERSION]) |
| 67 | + if test "x$GIT_COMMIT_HASH" = "x$GIT_TAG_HASH"; then |
| 68 | +- AVRDUDE_FULL_VERSION="$PACKAGE_VERSION" |
| 69 | ++ AVRDUDE_FULL_VERSION="$PACKAGE_VERSION$EXTRA_VERSION" |
| 70 | + else |
| 71 | +- AVRDUDE_FULL_VERSION="$PACKAGE_VERSION ($GIT_COMMIT_HASH)" |
| 72 | ++ AVRDUDE_FULL_VERSION="$PACKAGE_VERSION$EXTRA_VERSION ($GIT_COMMIT_HASH)" |
| 73 | + fi |
| 74 | + AC_MSG_RESULT([$AVRDUDE_FULL_VERSION]) |
| 75 | + AC_DEFINE_UNQUOTED([AVRDUDE_FULL_VERSION], ["$AVRDUDE_FULL_VERSION"], |
| 76 | +-- |
| 77 | +2.46.2 |
0 commit comments