updated build system

This commit is contained in:
Scott E. Graves 2024-07-09 13:25:46 -05:00
parent 0c414fc8a6
commit 5fb66dc6ee
5 changed files with 65 additions and 46 deletions

1
.gitignore vendored
View File

@ -6,7 +6,6 @@ cspell.json
support/Dockerfile
dist/
deps/
repertory/librepertory/src/common.cpp
scripts/cleanup.cmd
scripts/cleanup.sh
version.rc

View File

@ -31,11 +31,19 @@ if(PROJECT_BUILD)
${ADDITIONAL_SOURCES}
)
unset(PROJECT_GIT_REV CACHE)
unset(PROJECT_VERSION CACHE)
include(project.cmake)
if (PROJECT_VERSION)
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/dist/version.sh "export PROJECT_VERSION=${PROJECT_VERSION}")
add_definitions(-DPROJECT_VERSION=${PROJECT_VERSION})
add_definitions(-DPROJECT_VERSION=\"${PROJECT_VERSION}\")
endif()
if (PROJECT_GIT_REV)
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/dist/git_rev.sh "export PROJECT_GIT_REV=${PROJECT_GIT_REV}")
add_definitions(-DPROJECT_GIT_REV=\"${PROJECT_GIT_REV}\")
endif()
else()
message(STATUS "-=[CMake Settings]=-")

View File

@ -1,8 +1,17 @@
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE PROJECT_GIT_REV
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(REPERTORY_MAJOR 2)
set(REPERTORY_MINOR 0)
set(REPERTORY_REV 2)
set(REPERTORY_RELEASE_NUM 0)
set(REPERTORY_RELEASE_ITER rc)
set(PROJECT_VERSION ${REPERTORY_MAJOR}.${REPERTORY_MINOR}.${REPERTORY_REV}-${REPERTORY_RELEASE_ITER})
set(REPERTORY_VER_FILEVERSION ${REPERTORY_MAJOR},${REPERTORY_MINOR},${REPERTORY_REV},${REPERTORY_RELEASE_NUM})
@ -28,12 +37,6 @@ if (PROJECT_IS_MINGW)
set(PROJECT_WINDOWS_VERSION_RC ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${PROJECT_NAME}/version.rc)
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/lib${PROJECT_NAME}/src/common.cpp.in
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/lib${PROJECT_NAME}/src/common.cpp
@ONLY
)
set(CMAKE_CXX_FLAGS "-include common.hpp ${CMAKE_CXX_FLAGS}")
add_project_library(lib${PROJECT_NAME} "" "" "${PROJECT_ADDITIONAL_SOURCES}")

View File

@ -1,35 +1,35 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "types/repertory.hpp"
#include "utils/utils.hpp"
namespace repertory {
auto get_repertory_git_revision() -> const std::string & {
static const std::string git_revision = "@REPERTORY_GIT_REV@";
return git_revision;
}
auto get_repertory_version() -> const std::string & {
static const std::string version = "@PROJECT_VERSION@";
return version;
}
} // namespace repertory
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "types/repertory.hpp"
#include "utils/utils.hpp"
namespace repertory {
auto get_repertory_git_revision() -> const std::string & {
static const std::string git_revision = PROJECT_GIT_REV;
return git_revision;
}
auto get_repertory_version() -> const std::string & {
static const std::string version = PROJECT_VERSION;
return version;
}
} // namespace repertory

View File

@ -8,8 +8,12 @@ CURRENT_DIR=$(realpath ${CURRENT_DIR})
. "${CURRENT_DIR}/env.sh" "$3" "$4" "$5" "$6" "$7"
if [ -f "../dist/version.sh" ]; then
source ../dist/version.sh
if [ -f "${CURRENT_DIR}/../dist/version.sh" ]; then
source ${CURRENT_DIR}/../dist/version.sh
fi
if [ -f "${CURRENT_DIR}/../dist/git_rev.sh" ]; then
source ${CURRENT_DIR}/../dist/git_rev.sh
fi
function exit_and_clean() {
@ -23,6 +27,11 @@ if [ "${PROJECT_VERSION}" == "" ]; then
exit 1
fi
if [ "${PROJECT_GIT_REV}" == "" ]; then
echo "Project git revision not set"
exit 1
fi
if [ ! -d "${PROJECT_DIST_DIR}" ]; then
echo "Dist directory not found: ${PROJECT_DIST_DIR}"
exit 1
@ -39,7 +48,7 @@ PACKAGE_ROOT=$(realpath ${PACKAGE_ROOT})
rsync -av --progress ${PACKAGE_ROOT}/ ${TEMP_DIR}/ || exit_and_clean "Failed to rsync" 1
pushd "${DEST_DIR}"
tar cvzf ${PROJECT_APP_NAME}_${PROJECT_VERSION}_${PROJECT_BUILD_ARCH}_${PROJECT_OS}.tar.gz -C ${TEMP_DIR} . || exit_and_clean "Failed to create archive" 1
tar cvzf ${PROJECT_APP_NAME}_${PROJECT_VERSION}_${PROJECT_GIT_REV}_${PROJECT_BUILD_ARCH}_${PROJECT_OS}.tar.gz -C ${TEMP_DIR} . || exit_and_clean "Failed to create archive" 1
popd
exit_and_clean "Created package successfully" 0