Skip to content

Commit

Permalink
fixed automatic build number update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Wilmans committed Feb 22, 2024
1 parent 91d63ac commit c9ee1f7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
4 changes: 4 additions & 0 deletions application/DebugViewpp/UpdateBuildNr.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
@echo off

echo UpdateBuildNr.cmd updating %1
echo UpdateBuildNr.cmd updating %2

set file=%1
set xmlfile=%2
for /f "tokens=3,4,5,* delims=, " %%i in (%file%) do (
Expand Down
4 changes: 2 additions & 2 deletions application/DebugViewpp/version.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#define VERSION 1,9,0,0
#define VERSION_STR "1.9.0.0"
#define VERSION 1,9,0,24
#define VERSION_STR "1.9.0.24"
16 changes: 8 additions & 8 deletions application/DebugViewpp/version.wxi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Include>
<?define ProductVersion.Major="1" ?>
<?define ProductVersion.Minor="8" ?>
<?define ProductVersion.Revision="0" ?>
<?define ProductVersion.Build="103" ?>
<?define ProductVersion="1.8.0.103" ?>
</Include>
<?xml version="1.0" encoding="utf-8"?>
<Include>
<?define ProductVersion.Major="1" ?>
<?define ProductVersion.Minor="9" ?>
<?define ProductVersion.Revision="0" ?>
<?define ProductVersion.Build="24" ?>
<?define ProductVersion="1.9.0.24" ?>
</Include>
30 changes: 18 additions & 12 deletions cmake/CMakeLists.buildnumber.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# Set the initial build number
set(BUILD_NUMBER 0)

# Check if the build number file exists
if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/build_number.txt)
# If it exists, read the current build number from the file
file(READ ${CMAKE_SOURCE_DIR}/cmake/build_number.txt BUILD_NUMBER)
endif()
execute_process(
COMMAND cmd /C UpdateBuildNr.cmd version.h version.wxi
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/Application/DebugviewPP/"
COMMAND_ERROR_IS_FATAL ANY
)

file(READ "${CMAKE_SOURCE_DIR}/application/DebugViewpp/version.h" VERSION_FILE_CONTENTS)

# Increment the build number
math(EXPR BUILD_NUMBER "${BUILD_NUMBER} + 1")
# Regular expression to extract VERSION_STR
string(REGEX MATCH "#define VERSION_STR \"([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)\"" VERSION_STR_MATCH "${VERSION_FILE_CONTENTS}")

# Write the updated build number to the file
file(WRITE ${CMAKE_SOURCE_DIR}/cmake/build_number.txt ${BUILD_NUMBER})
# Extract the version string from the matched content
if(VERSION_STR_MATCH)
set(VERSION_STR ${CMAKE_MATCH_1})
else()
message(FATAL_ERROR "Failed to extract VERSION_STR from version.h")
endif()

# Set the build number as a CMake variable
set(DEBUGVIEW_VERSION "1.9.0.${BUILD_NUMBER}" CACHE INTERNAL "")
set(DEBUGVIEW_VERSION "${VERSION_STR}" CACHE INTERNAL "")

MESSAGE("Retrieved version: ${VERSION_STR} from version.h")

0 comments on commit c9ee1f7

Please sign in to comment.