Shuffle around and improve build number injection

This commit is contained in:
RichardG867
2021-11-12 21:53:12 -03:00
parent e152eee822
commit bfe19db5b4
5 changed files with 52 additions and 33 deletions

View File

@@ -66,7 +66,6 @@ build() {
# Set argument and environment variables.
local job_name=$JOB_BASE_NAME
local build_type=$BUILD_TYPE
local build_number=$BUILD_NUMBER
local git_hash=$(echo $GIT_COMMIT | cut -c1-8)
local arch=$1
shift
@@ -76,29 +75,11 @@ build() {
# Check if at least the job name was received.
if [ -z "$job_name" ]
then
echo [!] Missing environment variables: received JOB_BASE_NAME=[$job_name] BUILD_NUMBER=[$build_number] GIT_COMMIT=[$git_hash]
echo [!] Missing environment variables: received JOB_BASE_NAME=[$JOB_BASE_NAME] BUILD_TYPE=[$BUILD_TYPE] BUILD_NUMBER=[$BUILD_NUMBER] GIT_COMMIT=[$GIT_COMMIT]
return 1
fi
# Generate the build qualifier and filename.
if echo $build_number | grep -q " "
then
# Full build qualifier.
build_qualifier="$build_number"
build_fn="-"$(echo "$build_number" | rev | cut -f1 -d" " | rev | tr '\\/:*?"<>|' '_')
elif [ ! -z "$build_number" ]
then
# Build number.
build_number=$(echo "$build_number" | sed "s/[^0-9]//g") # remove non-numeric characters
build_qualifier="build $build_number"
build_fn="-b$build_number"
else
# No build information.
build_qualifier=
build_fn=
fi
echo [-] Building [$job_name] [$build_number] [$git_hash] for [$arch] with flags [$cmake_flags]
echo [-] Building [$job_name] [$build_type] [$build_qualifier] [$git_hash] for [$arch] with flags [$cmake_flags]
# Switch to the correct directory.
cd "$cwd"
@@ -117,8 +98,8 @@ build() {
# Call build with the correct MSYSTEM.
echo [-] Switching to MSYSTEM [$msys]
cd "$cwd"
CHERE_INVOKING=yes MSYSTEM=$msys JOB_BASE_NAME=$JOB_BASE_NAME BUILD_TYPE=$BUILD_TYPE BUILD_NUMBER=$BUILD_NUMBER GIT_COMMIT=$GIT_COMMIT \
bash -lc 'exec "'$0'" -b "'$arch'" '$cmake_flags && job_exit=0 # make sure the main script exits cleanly on any success
CHERE_INVOKING=yes MSYSTEM="$msys" JOB_BASE_NAME="$JOB_BASE_NAME" BUILD_TYPE="$BUILD_TYPE" BUILD_NUMBER="$BUILD_NUMBER" GIT_COMMIT="$GIT_COMMIT" \
bash -lc 'exec "'$0'" -b "'$arch'" '$cmake_flags && job_status=0 # make sure the main script exits cleanly on any success
return $?
fi
else
@@ -215,7 +196,9 @@ EOF
# Determine additional CMake flags.
[ ! -z "$build_type" ] && local cmake_flags_extra="$cmake_flags_extra -D BUILD_TYPE=\"$build_type\""
[ ! -z "$build_qualifier" ] && local cmake_flags_extra="$cmake_flags_extra -D EMU_BUILD=\"$build_qualifier\""
[ ! -z "$build_number" ] && local cmake_flags_extra="$cmake_flags_extra -D EMU_BUILD_NUM=\"$build_number\""
[ ! -z "$git_hash" ] && local cmake_flags_extra="$cmake_flags_extra -D EMU_GIT_HASH=\"$git_hash\""
local cmake_flags_extra="$cmake_flags_extra -D EMU_COPYRIGHT_YEAR=\"$(date +%Y)\""
# Run CMake.
echo [-] Running CMake with flags [$cmake_flags $cmake_flags_extra]
@@ -338,15 +321,15 @@ EOF
fi
# All good.
echo [-] Build of [$job_name] [$build_number] [$git_hash] for [$arch] with flags [$cmake_flags] successful
job_exit=0
echo [-] Build of [$job_name] [$build_type] [$build_qualifier] [$git_hash] for [$arch] with flags [$cmake_flags] successful
job_status=0
}
# Set common variables.
project=86Box
cwd=$(pwd)
first_build=1
job_exit=1
job_status=1
# Parse arguments.
single_build=0
@@ -393,6 +376,27 @@ then
exit 100
fi
# Generate build information. Note that variable names are case sensitive.
build_number=$BUILD_NUMBER
if echo $build_number | grep -q " "
then
# A full build qualifier was specified.
build_qualifier="$build_number"
build_fn="-"$(echo "$build_number" | rev | cut -f1 -d" " | rev | tr '\\/:*?"<>|' '_')
build_number= # no build number
elif [ ! -z "$build_number" ]
then
# A build number was specified.
build_qualifier="build $build_number"
build_fn="-b$build_number"
build_number=$(echo "$build_number" | sed "s/[^0-9]//g") # remove non-numeric characters from build number
else
# No build data was specified.
build_number=
build_qualifier=
build_fn=
fi
# Run single build if requested.
if [ $single_build -ne 0 ]
then
@@ -406,6 +410,7 @@ case $JOB_BASE_NAME in
if is_windows
then
build 32 --preset=regular
build 64 --preset=regular
elif is_mac
then
build Universal --preset=regular
@@ -456,5 +461,5 @@ case $JOB_BASE_NAME in
esac
echo
echo [-] Exiting with code [$job_exit]
exit $job_exit
echo [-] Exiting with status [$job_status]
exit $job_status

View File

@@ -93,6 +93,15 @@ find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIRS})
target_link_libraries(86Box PNG::PNG)
if(NOT CMAKE_PROJECT_VERSION_PATCH)
set(CMAKE_PROJECT_VERSION_PATCH 0)
endif()
if(NOT EMU_BUILD_NUM)
set(EMU_BUILD_NUM 0)
endif()
if(NOT EMU_COPYRIGHT_YEAR)
set(EMU_COPYRIGHT_YEAR 2021)
endif()
configure_file(include/86box/version.h.in include/86box/version.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)

View File

@@ -22,11 +22,13 @@
#define EMU_VERSION "@CMAKE_PROJECT_VERSION@"
#define EMU_VERSION_W LSTR(EMU_VERSION)
#define EMU_VERSION_EX "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@0"
#define EMU_VERSION_EX "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@@CMAKE_PROJECT_VERSION_PATCH@"
#define EMU_VERSION_MAJ @CMAKE_PROJECT_VERSION_MAJOR@
#define EMU_VERSION_MIN @CMAKE_PROJECT_VERSION_MINOR@
#define EMU_VERSION_PATCH @CMAKE_PROJECT_VERSION_PATCH@
#cmakedefine EMU_BUILD "@EMU_BUILD@"
#define EMU_BUILD_NUM @EMU_BUILD_NUM@
#cmakedefine EMU_GIT_HASH "@EMU_GIT_HASH@"
#ifdef EMU_BUILD
@@ -41,7 +43,7 @@
# define EMU_GIT_HASH_W LSTR(EMU_GIT_HASH)
#endif
#define COPYRIGHT_YEAR "2021"
#define COPYRIGHT_YEAR "@EMU_COPYRIGHT_YEAR@"
/* Web URL info. */
#define EMU_SITE L"86box.net"

View File

@@ -25,6 +25,9 @@
#define EMU_VERSION_EX "3.00"
#define EMU_VERSION_MAJ 3
#define EMU_VERSION_MIN 0
#define EMU_VERSION_PATCH 0
#define EMU_BUILD_NUM 0
#define EMU_VERSION_FULL EMU_VERSION
#define EMU_VERSION_FULL_W EMU_VERSION_W

View File

@@ -1283,8 +1283,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION EMU_VERSION_MAJ,EMU_VERSION_MIN,0,0
PRODUCTVERSION EMU_VERSION_MAJ,EMU_VERSION_MIN,0,0
FILEVERSION EMU_VERSION_MAJ,EMU_VERSION_MIN,EMU_VERSION_PATCH,EMU_BUILD_NUM
PRODUCTVERSION EMU_VERSION_MAJ,EMU_VERSION_MIN,EMU_VERSION_PATCH,EMU_BUILD_NUM
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -1303,7 +1303,7 @@ BEGIN
VALUE "FileDescription", EMU_NAME "\0"
VALUE "FileVersion", EMU_VERSION "\0"
VALUE "InternalName", EMU_NAME "\0"
VALUE "LegalCopyright", "Copyright \xc2\xa9 2007-2020 " EMU_NAME " contributors\0"
VALUE "LegalCopyright", "Copyright \xc2\xa9 2007-" COPYRIGHT_YEAR " " EMU_NAME " contributors\0"
VALUE "OriginalFilename", "86box.exe\0"
VALUE "ProductName", EMU_NAME "\0"
VALUE "ProductVersion", EMU_VERSION "\0"