diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
index 24fee7e7..5e00230b 100644
--- a/.github/workflows/codeql.yml
+++ b/.github/workflows/codeql.yml
@@ -7,9 +7,7 @@ name: CodeQL
on:
push:
- # branches: ['master', '[0-9]?.[0-9]?.x']
pull_request:
- # branches: ['master', '[0-9]?.[0-9]?.x']
jobs:
analyze:
@@ -29,15 +27,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
with:
- # We must fetch at least the immediate parents so that if this is
- # a pull request then we can checkout the head.
fetch-depth: 2
- # If this run was triggered by a pull request event, then checkout
- # the head of the pull request instead of the merge commit.
- - run: git checkout HEAD^2
- if: ${{ github.event_name == 'pull_request' }}
-
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
@@ -48,18 +39,6 @@ jobs:
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
- # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
- # If this step fails, then you should remove it and run the build manually (see below)
- # - name: Autobuild
- # uses: github/codeql-action/autobuild@v1
-
- # âšī¸ Command-line programs to run using the OS shell.
- # đ https://git.io/JvXDl
-
- # âī¸ If the Autobuild fails above, remove it and uncomment the following three lines
- # and modify them (or add more) to build your code if your project
- # uses a compiled language
-
- name: Bootstrap and Build the Code
run: script/cibuild
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b7b73ab9..567fb349 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,8 +21,33 @@
# along with vsUTCS. If not, see .
-CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
-PROJECT(vsUTCS)
+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}")
+ELSE ()
+ EXECUTE_PROCESS(
+ COMMAND git rev-parse --short HEAD
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ OUTPUT_VARIABLE vsUTCS_VERSION_TWEAK
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ENDIF ()
+
+PROJECT(vsUTCS
+ VERSION
+ "${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}" #.${vsUTCS_VERSION_TWEAK} # CMake only allows numeric version components, unfortunately.
+)
+
+# Let cmake find our in-tree modules
+SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${vsUTCS_SOURCE_DIR})
+
+# Detect available Linux Distros that can be built for
+FIND_PACKAGE(LinuxDistro REQUIRED)
SET(CPACK_IGNORE_FILES
build/
@@ -138,9 +163,9 @@ SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "3D space combat and trading game")
SET(CPACK_PACKAGE_VENDOR "Vega Strike")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/documentation/readme.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/vega-license.txt")
-SET(CPACK_PACKAGE_VERSION_MAJOR "0")
-SET(CPACK_PACKAGE_VERSION_MINOR "8")
-SET(CPACK_PACKAGE_VERSION_PATCH "0")
+SET(CPACK_PACKAGE_VERSION_MAJOR "${vsUTCS_VERSION_MAJOR}")
+SET(CPACK_PACKAGE_VERSION_MINOR "${vsUTCS_VERSION_MINOR}")
+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 "maintainers@vega-strike.org")
@@ -148,7 +173,7 @@ SET(CPACK_CONTACT "maintainers@vega-strike.org")
IF (DEFINED ENV{TAG_NAME})
SET(vsUTCS_PACKAGE_VERSION_STR "$ENV{TAG_NAME}")
ELSE (DEFINED ENV{TAG_NAME})
- SET(vsUTCS_PACKAGE_VERSION_STR "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
+ 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_GENERATOR "TXZ")
@@ -180,40 +205,8 @@ ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Linux)
MESSAGE("-- Configuring Packaging for Linux")
SET(CPACK_GENERATOR "TXZ")
- # Gather info about Linux distro and release (if applicable).
- IF (CMAKE_SYSTEM_NAME STREQUAL Linux)
- EXECUTE_PROCESS(
- COMMAND sh -c "cat /etc/os-release | grep ^ID= | sed 's/^ID=//' | tr -d '\"\n'"
- OUTPUT_VARIABLE LINUX_ID)
- EXECUTE_PROCESS(
- COMMAND sh -c "cat /etc/os-release | grep ^VERSION_CODENAME= | sed 's/^VERSION_CODENAME=//' | tr -d '\"\n'"
- OUTPUT_VARIABLE LINUX_CODENAME)
- EXECUTE_PROCESS(
- COMMAND sh -c "cat /etc/os-release | grep ^VERSION_ID= | sed 's/^VERSION_ID=//' | tr -d '\"\n'"
- OUTPUT_VARIABLE LINUX_VERSION_ID)
- ENDIF (CMAKE_SYSTEM_NAME STREQUAL Linux)
-
- # SET(LSB_EXISTS FALSE)
- # SET(LSB_LINUX_DISTRIBUTION "Unknown")
- # SET(LSB_LINUX_DISTRIBUTION_CODENAME "Unknown")
-
- # # Lookup the LSB Data - this is known for Ubuntu, but also used by other distros too.
- # # and may help with distro-sub-selection
- # FIND_PROGRAM(LSB_RELEASE_EXEC lsb_release)
- # IF (LSB_RELEASE_EXEC)
- # EXECUTE_PROCESS(COMMAND ${LSB_RELEASE_EXEC} --codename --short
- # OUTPUT_VARIABLE LSB_LINUX_DISTRIBUTION_CODENAME
- # OUTPUT_STRIP_TRAILING_WHITESPACE)
- # EXECUTE_PROCESS(COMMAND ${LSB_RELEASE_EXEC} --id --short
- # OUTPUT_VARIABLE LSB_LINUX_DISTRIBUTION
- # OUTPUT_STRIP_TRAILING_WHITESPACE)
- # SET(LSB_EXISTS TRUE)
- # MESSAGE("Found Linux Distribution Release Name: ${LSB_LINUX_DISTRIBUTION_CODENAME}")
- # ENDIF (LSB_RELEASE_EXEC)
-
# "DEB"
- FIND_PROGRAM(HAS_APT NAMES apt-get apt)
- IF (HAS_APT)
+ IF (VS_CAN_BUILD_DEB)
MESSAGE("-- Configuring Debian Packaging")
# See https://cmake.org/cmake/help/v3.3/module/CPackDeb.html
SET(CPACK_DEBIAN_PACKAGE_NAME "vsUTCS")
@@ -221,32 +214,15 @@ ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Linux)
SET(CPACK_DEBIAN_COMPRESSION_TYPE "bzip2")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "vega-strike")
- # Debian Version: /etc/debian_version - /
- # IF (NOT LSB_EXISTS)
- # SET(USE_DEBIAN_VERSION TRUE)
- # FILE(READ "/etc/debian_version" DEBIAN_VERSION_DATA)
- # STRING(REGEX MATCH "^(.+)\/.*$" DEBIAN_VERSION_DATA DEBIAN_RELEASE_VERSION)
- # ELSE (NOT LSB_EXISTS)
- # SET(USE_DEBIAN_VERSION FALSE)
- # SET(DEBIAN_RELEASE_VERSION "Debian Derivative Release Version ${LSB_LINUX_DISTRIBUTION_CODENAME}")
- # ENDIF (NOT LSB_EXISTS)
-
- # IF (USE_DEBIAN_VERSION)
- # SET(CPACK_PACKAGE_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}_${vsUTCS_PACKAGE_VERSION_STR}-debian-${DEBIAN_RELEASE_VERSION}_x86_64")
- # ELSE (USE_DEBIAN_VERSION)
- # SET(CPACK_PACKAGE_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}_${vsUTCS_PACKAGE_VERSION_STR}-${LSB_LINUX_DISTRIBUTION}-${LSB_LINUX_DISTRIBUTION_CODENAME}_x86_64")
- # ENDIF (USE_DEBIAN_VERSION)
-
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}_${vsUTCS_PACKAGE_VERSION_STR}")
SET(CPACK_DEBIAN_PACKAGE_SECTION "Amusements/Games")
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://www.vega-strike.org")
SET(CPACK_GENERATOR "DEB")
- ENDIF (HAS_APT)
+ ENDIF ()
# "RPM"
- FIND_PROGRAM(HAS_RPMBUILD rpmbuild)
- IF (HAS_RPMBUILD)
+ IF (VS_CAN_BUILD_RPM)
MESSAGE("-- Configuring RPM Packaging")
# See https://cmake.org/cmake/help/v3.3/module/CPackRPM.html
SET(CPACK_RPM_PACKAGE_LICENSE "GPLv3") # See ../LICENSE
@@ -263,7 +239,7 @@ ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Linux)
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}_${vsUTCS_PACKAGE_VERSION_STR}-${LINUX_ID}-${vsUTCS_LINUX_VERSION_STR}")
SET(CPACK_GENERATOR "RPM")
- ENDIF (HAS_RPMBUILD)
+ ENDIF ()
ELSE (WIN32 AND NOT UNIX)
MESSAGE("-- Configuring Packaging for Unknown Platforms - \"${CMAKE_SYSTEM_NAME}\"")
# Unknown Platform --> Just do compressed tarball
diff --git a/FindLinuxDistro.cmake b/FindLinuxDistro.cmake
new file mode 100644
index 00000000..d5181e27
--- /dev/null
+++ b/FindLinuxDistro.cmake
@@ -0,0 +1,93 @@
+# - FindLinuxDistro.cmake
+# This module detects the Linux Distro and package build tooling, and provides
+# some variables for the primary CMake script to utilize to decide what to build.
+#
+# ========================
+# Example Usage:
+#
+# FIND_PACKAGE(LinuxDistro, REQUIRED)
+#
+# Output Variables:
+# LINUX_ETC_OS_RELEASE_EXISTS
+# Does /etc/os-release exist?
+#
+# LINUX_ID
+# Linux Distro Name (semi-authoritative)
+# Only valid if LINUX_ETC_OS_RELEASE_EXISTS is TRUE
+#
+# LINUX_CODENAME
+# Linux Distro Code Name (semi-authoritative)
+# Only valid if LINUX_ETC_OS_RELEASE_EXISTS is TRUE
+#
+# LINUX_VERSION_ID
+# Linux Distro Version (semi-authoritative)
+# Only valid if LINUX_ETC_OS_RELEASE_EXISTS is TRUE
+#
+# LSB_EXISTS
+# Is the distro an LSB Compliant Distro?
+#
+# LSB_LINUX_DISTRIBUTION
+# Using LSB Tooling, what is the host distro family? (authoritative)
+# Only valid if LSB_EXISTS is TRUE
+#
+# LSB_LINUX_DISTRIBUTION_CODENAME
+# Using LSB Tooling, what is the host distro code name? (authoritative)
+# Only valid if LSB_EXISTS is TRUE
+#
+# VS_CAN_BUILD_DEB
+# Does the host have tooling installed to build Debian (DEB) Packages?
+#
+# VS_CAN_BUILD_RPM
+# Does the host have the tooling installed to build RPM Packages?
+#
+
+IF (CMAKE_SYSTEM_NAME STREQUAL Linux)
+
+ SET(LINUX_ETC_OS_RELEASE_EXISTS FALSE)
+ SET(LINUX_ID "Unknown")
+ SET(LINUX_CODENAME "Unknown")
+ SET(LINUX_VERSION_ID "Unknown")
+ IF (EXISTS "/etc/os-release")
+ SET(LINUX_ETC_OS_RELEASE_EXISTS TRUE)
+ # Gather info about Linux distro and release (if applicable) for later use down below.
+ EXECUTE_PROCESS(
+ COMMAND sh -c "cat /etc/os-release | grep ^ID= | sed 's/^ID=//' | tr -d '\"\n'"
+ OUTPUT_VARIABLE LINUX_ID)
+ EXECUTE_PROCESS(
+ COMMAND sh -c "cat /etc/os-release | grep ^VERSION_CODENAME= | sed 's/^VERSION_CODENAME=//' | tr -d '\"\n'"
+ OUTPUT_VARIABLE LINUX_CODENAME)
+ EXECUTE_PROCESS(
+ COMMAND sh -c "cat /etc/os-release | grep ^VERSION_ID= | sed 's/^VERSION_ID=//' | tr -d '\"\n'"
+ OUTPUT_VARIABLE LINUX_VERSION_ID)
+ ENDIF (EXISTS "/etc/os-release")
+
+ # lsb_release -i --> but then it'll find `Ubuntu` instead of Debian so will have to map more
+
+ # we can probably more reliably detect via checking for different packager commands
+ # `lsb_release` doesn't always work correctly, so it's easier to read the underlying file
+ # if it exists. It doesn't always exist. Debian doesn't use it, but Ubuntu does.
+ SET(LSB_EXISTS FALSE)
+ SET(LSB_LINUX_DISTRIBUTION "Unknown")
+ SET(LSB_LINUX_DISTRIBUTION_CODENAME "Unknown")
+
+ # Lookup the LSB Data - this is known for Ubuntu, but also used by other distros too.
+ # and may help with distro-sub-selection
+ FIND_PROGRAM(LSB_RELEASE_EXEC lsb_release)
+ IF (LSB_RELEASE_EXEC)
+ EXECUTE_PROCESS(COMMAND ${LSB_RELEASE_EXEC} --codename --short
+ OUTPUT_VARIABLE LSB_LINUX_DISTRIBUTION_CODENAME
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ EXECUTE_PROCESS(COMMAND ${LSB_RELEASE_EXEC} --id --short
+ OUTPUT_VARIABLE LSB_LINUX_DISTRIBUTION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ SET(LSB_EXISTS TRUE)
+ MESSAGE("Found Linux Distribution Release Name: ${LSB_LINUX_DISTRIBUTION_CODENAME}")
+ ENDIF (LSB_RELEASE_EXEC)
+
+ # Definitively detect Debian Package Build tools
+ FIND_PROGRAM(VS_CAN_BUILD_DEB NAMES dpkg-buildpackage)
+
+ # Definitively detect RPM Package Build Tools
+ FIND_PROGRAM(VS_CAN_BUILD_RPM rpmbuild)
+
+ENDIF (CMAKE_SYSTEM_NAME STREQUAL Linux)