Skip to content

Commit

Permalink
Merge pull request #88 from stephengtuggy/short_sha_0.8.x
Browse files Browse the repository at this point in the history
Short SHA, other version-related changes -- Assets, 0.8.x
  • Loading branch information
stephengtuggy authored Feb 3, 2022
2 parents 979cd81 + 1303685 commit c983be4
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 21 deletions.
48 changes: 37 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#====================================
# Copyright (C) 2020-2021 Evert Vorster, Stephen G. Tuggy,
# and other vsUTCS contributors.
# Copyright (C) 2022 Stephen G. Tuggy
#
# This file is part of Vega Strike: Upon the Coldest Sea ("vsUTCS").
#
Expand All @@ -26,9 +27,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.5 FATAL_ERROR)
SET(vsUTCS_VERSION_MAJOR "0")
SET(vsUTCS_VERSION_MINOR "8")
SET(vsUTCS_VERSION_PATCH "0")

# Auto-populate with the git hash of the build
IF (DEFINED ENV{GITHUB_SHA} AND NOT "$ENV{GITHUB_SHA}" STREQUAL "")
SET (vsUTCS_VERSION_TWEAK "$ENV{GITHUB_SHA}")
IF (DEFINED ENV{SHORT_SHA} AND NOT "$ENV{SHORT_SHA}" STREQUAL "")
SET (vsUTCS_VERSION_TWEAK "$ENV{SHORT_SHA}")
ELSE ()
EXECUTE_PROCESS(
COMMAND git rev-parse --short HEAD
Expand All @@ -38,11 +40,39 @@ ELSE ()
)
ENDIF ()

SET(vsUTCS_VERSION_LONG_STR "${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}-${vsUTCS_VERSION_TWEAK}")
SET(vsUTCS_VERSION_SHORT_STR "${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}")
SET(vsUTCS_PKG_VERSION_STR "${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}")

IF (DEFINED ENV{TAG_NAME} AND NOT "$ENV{TAG_NAME}" STREQUAL "")
STRING(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" TAG_VERSION_MAJOR "$ENV{TAG_NAME}")
STRING(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" TAG_VERSION_MINOR "$ENV{TAG_NAME}")
STRING(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" TAG_VERSION_PATCH "$ENV{TAG_NAME}")
STRING(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" TAG_VERSION_TWEAK "$ENV{TAG_NAME}")

SET(TAG_VERSION_SHORT_STR "${TAG_VERSION_MAJOR}.${TAG_VERSION_MINOR}.${TAG_VERSION_PATCH}")

IF (NOT "${vsUTCS_VERSION_SHORT_STR}" VERSION_EQUAL "${TAG_VERSION_SHORT_STR}")
MESSAGE(FATAL_ERROR "!! Project version spelled out in CMake file does not match project version from TAG_NAME environment variable")
ENDIF ()
IF (NOT "${TAG_VERSION_TWEAK}" STREQUAL "")
SET(vsUTCS_VERSION_LONG_STR "${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}${TAG_VERSION_TWEAK}-${vsUTCS_VERSION_TWEAK}")
SET(vsUTCS_PKG_VERSION_STR "${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}${TAG_VERSION_TWEAK}")
ENDIF ()
ENDIF ()

# VERSION Policy
IF (POLICY CMP0048)
CMAKE_POLICY (SET CMP0048 NEW)
ENDIF (POLICY CMP0048)

PROJECT(vsUTCS
VERSION
"${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}" #.${vsUTCS_VERSION_TWEAK} # CMake only allows numeric version components, unfortunately.
)

MESSAGE("== vsUTCS Version: ${vsUTCS_VERSION_LONG_STR}")

# Let cmake find our in-tree modules
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${vsUTCS_SOURCE_DIR})

Expand Down Expand Up @@ -169,13 +199,7 @@ SET(CPACK_PACKAGE_VERSION_PATCH "${vsUTCS_VERSION_PATCH}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "vsUTCS-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
SET(CPACK_CONTACT "[email protected]")

# Source package filename
IF (DEFINED ENV{TAG_NAME})
SET(vsUTCS_PACKAGE_VERSION_STR "$ENV{TAG_NAME}")
ELSE (DEFINED ENV{TAG_NAME})
SET(vsUTCS_PACKAGE_VERSION_STR "${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}-0.${vsUTCS_VERSION_TWEAK}")
ENDIF (DEFINED ENV{TAG_NAME})
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${vsUTCS_PACKAGE_VERSION_STR}-Source")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_v${vsUTCS_PKG_VERSION_STR}-Source")
SET(CPACK_SOURCE_GENERATOR "TXZ")

IF (WIN32 AND NOT UNIX)
Expand Down Expand Up @@ -211,10 +235,11 @@ ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Linux)
# See https://cmake.org/cmake/help/v3.3/module/CPackDeb.html
SET(CPACK_DEBIAN_PACKAGE_NAME "vsUTCS")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]")
SET(CPACK_DEBIAN_PACKAGE_VERSION "${vsUTCS_PKG_VERSION_STR}")
SET(CPACK_DEBIAN_COMPRESSION_TYPE "bzip2")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "vega-strike")

SET(CPACK_PACKAGE_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}_${vsUTCS_PACKAGE_VERSION_STR}")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}_v${vsUTCS_PKG_VERSION_STR}")

SET(CPACK_DEBIAN_PACKAGE_SECTION "Amusements/Games")
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://www.vega-strike.org")
Expand All @@ -228,6 +253,7 @@ ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Linux)
SET(CPACK_RPM_PACKAGE_LICENSE "GPLv3") # See ../LICENSE
SET(CPACK_RPM_PACKAGE_URL "https://www.vega-strike.org")
SET(CPACK_RPM_PACKAGE_NAME "vsUTCS")
SET(CPACK_RPM_PACKAGE_VERSION "${vsUTCS_PKG_VERSION_STR}")
SET(CPACK_RPM_PACKAGE_REQUIRES "Vega-Strike")

# Figure out the filename
Expand All @@ -237,7 +263,7 @@ ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Linux)
SET(vsUTCS_LINUX_VERSION_STR "${LINUX_VERSION_ID}")
ENDIF (LINUX_CODENAME)

SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}_${vsUTCS_PACKAGE_VERSION_STR}-${LINUX_ID}-${vsUTCS_LINUX_VERSION_STR}")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}_v${vsUTCS_PKG_VERSION_STR}-${LINUX_ID}-${vsUTCS_LINUX_VERSION_STR}")
SET(CPACK_GENERATOR "RPM")
ENDIF ()
ELSE (WIN32 AND NOT UNIX)
Expand Down
27 changes: 19 additions & 8 deletions script/build
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# https://github.com/Taose/Vegastrike-taose/wiki/How-to-Build
#====================================

# Copyright (C) 2020 Stephen G. Tuggy and other vsUTCS contributors
# Copyright (C) 2020-2022 Stephen G. Tuggy and other vsUTCS contributors
#
# This file is part of Vega Strike: Upon the Coldest Sea ("vsUTCS").
#
Expand All @@ -32,28 +32,39 @@
set -e

echo "--------------------------"
echo "--- build | 2020-08-23 ---"
echo "--- build | 2022-01-23 ---"
echo "--------------------------"

#----------------------------------
# validate parameters
#----------------------------------

ROOT_DIR=$(pwd)
BUILD_DIR=$ROOT_DIR/build
SRC_DIR=$ROOT_DIR
BUILD_DIR="${ROOT_DIR}/build"
BIN_DIR="${ROOT_DIR}/bin"
SRC_DIR="${ROOT_DIR}"
COMMAND=""

echo "ROOT_DIR: ${ROOT_DIR}"
echo "BUILD_DIR: ${BUILD_DIR}"

# -p creates if the target doesn't exist, noop otherwise
mkdir -pv $BUILD_DIR && cd $BUILD_DIR
mkdir -pv "${BUILD_DIR}" && cd "${BUILD_DIR}"

cmake $@ $SRC_DIR
cmake $@ "${SRC_DIR}"

# for a clean build only
# mut we can do it manually
#make clean

# compile now using all cpus and show compilation commands
make -j $(nproc) VERBOSE=1
# MAX_THREADS_TO_BUILD_WITH=8
NUM_THREADS_TO_BUILD_WITH=$(getconf _NPROCESSORS_ONLN)
# if [ ${NUM_THREADS_TO_BUILD_WITH} -gt ${MAX_THREADS_TO_BUILD_WITH} ]
# then
# NUM_THREADS_TO_BUILD_WITH=${MAX_THREADS_TO_BUILD_WITH}
# fi

VERBOSE=1 cmake --build "${BUILD_DIR}" -j ${NUM_THREADS_TO_BUILD_WITH}

cd $ROOT_DIR
cd "${ROOT_DIR}"
4 changes: 2 additions & 2 deletions script/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# @usage : script/cibuild
# @param : none
#====================================
# Copyright (C) 2020-2021 Stephen G Tuggy and other vsUTCS contributors
# Copyright (C) 2020-2022 Stephen G Tuggy and other vsUTCS contributors
#
# This file is part of Vega Strike: Upon the Coldest Sea ("vsUTCS").
#
Expand All @@ -31,7 +31,7 @@ then
DST_DOCKER_IMG_NAME="building-vsutcs:$(echo $FROM | sed 's/:/_/' | sed 's/\//_/')"
DOCKER_CONTAINER_NAME="building-vsutcs_$(echo $FROM | sed 's/:/_/' | sed 's/\//_/')"
docker build --build-arg from=$SRC_DOCKER_IMG_NAME -t $DST_DOCKER_IMG_NAME .
docker run --env IS_RELEASE=$IS_RELEASE --env TAG_NAME=$TAG_NAME --env GITHUB_SHA=$GITHUB_SHA --env FLAGS=$FLAGS --name $DOCKER_CONTAINER_NAME $DST_DOCKER_IMG_NAME $FLAGS
docker run --env IS_RELEASE=$IS_RELEASE --env TAG_NAME=$TAG_NAME --env GITHUB_SHA=$GITHUB_SHA --env SHORT_SHA=$SHORT_SHA --env FLAGS="${FLAGS}" --name $DOCKER_CONTAINER_NAME $DST_DOCKER_IMG_NAME
if [ $IS_RELEASE -eq 1 ]
then
docker cp $DOCKER_CONTAINER_NAME:/usr/src/vsUTCS/packages .
Expand Down

0 comments on commit c983be4

Please sign in to comment.