Permalink
Browse files

Add an option to simplify the version number to reduce building time

  • Loading branch information...
victorlevasseur committed Nov 20, 2016
1 parent 6badf72 commit 7e23652eef95ee67329a4664ae69f148623fd3f7
View
@@ -18,6 +18,7 @@ gd_set_option(BUILD_IDE TRUE BOOL "TRUE to build the IDE")
gd_set_option(BUILD_EXTENSIONS TRUE BOOL "TRUE to build the extensions")
gd_set_option(BUILD_TESTS FALSE BOOL "TRUE to build the tests")
gd_set_option(NO_GUI FALSE BOOL "TRUE to build without wxWidgets GUI")
gd_set_option(FULL_VERSION_NUMBER TRUE BOOL "TRUE to build GDevelop with its full version number (lastest tag + commit hash), FALSE to only use the lastest tag (avoid rebulding many source file when developping)")
#Setting up installation directory, for Linux (has to be done before "project" command).
IF(NOT WIN32)
View
@@ -3,7 +3,13 @@ cmake_policy(SET CMP0015 NEW)
project(GDVersion)
if(FULL_VERSION_NUMBER)
set(GENERATE_VERSION_SCRIPT ${PROJECT_SOURCE_DIR}/GenerateVersionFull.cmake)
else()
set(GENERATE_VERSION_SCRIPT ${PROJECT_SOURCE_DIR}/GenerateVersionLazy.cmake)
endif()
add_custom_target(GDVersion
ALL
COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/GenerateVersion.cmake ${PROJECT_SOURCE_DIR}/../Core/GDCore/Tools/
COMMAND ${CMAKE_COMMAND} -P ${GENERATE_VERSION_SCRIPT} ${PROJECT_SOURCE_DIR}/../Core/GDCore/Tools/
)
File renamed without changes.
@@ -0,0 +1,54 @@
find_package(Git)
message(WARNING "You're not using the full version number. It's not suitable for public releases and builds!")
if(GIT_FOUND)
EXECUTE_PROCESS(
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 # Only get the lastest tag's name
OUTPUT_VARIABLE GD_VERSION_STR
RESULT_VARIABLE GIT_DESCRIBE_RESULT
ERROR_VARIABLE GIT_DESCRIBE_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(VERSIONPRIV_PATH "${CMAKE_ARGV3}/VersionPriv.h")
set(ORIGINAL_CONTENT " ")
if(EXISTS "${VERSIONPRIV_PATH}")
file(READ "${VERSIONPRIV_PATH}" ORIGINAL_CONTENT)
endif()
if("${GD_VERSION_STR}" STREQUAL "")
message(STATUS "No tags found to determine the version of GDevelop!")
set(GD_VERSION_STR "0.0.0")
endif()
# Generate the version RC macro
string(REGEX REPLACE
"([0-9]*)\\.([0-9]*)\\.([0-9]*)"
"\\1,\\2,\\3,0"
GD_VERSION_RC
"${GD_VERSION_STR}")
string(REGEX REPLACE
"([0-9]*)\\.([0-9]*)\\.([0-9]*)"
"\\1, \\2, \\3, 0"
GD_VERSION_RC_STR
"${GD_VERSION_STR}")
set(NEW_CONTENT "#define GD_VERSION_STRING \"${GD_VERSION_STR}\"\n#define GD_VERSION_RC ${GD_VERSION_RC}\n#define GD_VERSION_RC_STRING \"${GD_VERSION_RC_STR}\\0\"\n#define GD_DATE_STRING __DATE__")
if(NOT ("${ORIGINAL_CONTENT}" STREQUAL "${NEW_CONTENT}"))
# Write only the version file if different from the previous one
message(STATUS "Updating VersionPriv.h header to version ${GD_VERSION_STR}.")
file(WRITE
"${VERSIONPRIV_PATH}"
"${NEW_CONTENT}")
else()
message(STATUS "VersionPriv.h already up-to-date.")
endif()
else()
file(WRITE
"${VERSIONPRIV_PATH}"
"#define GD_VERSION_STRING \"0.0.0-0-unknown\"\n#define GD_VERSION_RC 0, 0, 0, 0\n#define GD_VERSION_RC_STRING \"0, 0, 0, 0\\0\"\n#define GD_DATE_STRING __DATE__")
endif()

0 comments on commit 7e23652

Please sign in to comment.