This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename publication date to version info
This is now generated by git.
TODO:
Merge with the git logic used for the tarballs
Test when building from tarballs
Test that it updates the version properly
Fixes #529
- Loading branch information
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# | ||
# (c)2018 KiCad Developers | ||
# (c)2018 Nick Østergaard | ||
# | ||
# CMake module to find produce version information | ||
# | ||
# Variables generated: | ||
# | ||
# KICAD_VERSION A git describe string | ||
# KICAD_VERSION_DATE The date of the last commit | ||
# | ||
|
||
|
||
|
||
macro( create_git_version_info _git_src_path ) | ||
# Include Git support to automagically create version header file. | ||
find_package( Git ) | ||
message( STATUS "Source path is ${_git_src_path}" ) | ||
|
||
if( GIT_FOUND ) | ||
set( _Git_SAVED_LC_ALL "$ENV{LC_ALL}" ) | ||
set( ENV{LC_ALL} C ) | ||
|
||
execute_process( | ||
COMMAND | ||
${GIT_EXECUTABLE} describe --dirty --tags | ||
WORKING_DIRECTORY "${_git_src_path}" | ||
OUTPUT_VARIABLE _git_DESCRIBE | ||
ERROR_VARIABLE _git_log_error | ||
RESULT_VARIABLE _git_log_result | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
execute_process( | ||
COMMAND | ||
${GIT_EXECUTABLE} show -s --format=%ci | ||
WORKING_DIRECTORY "${_git_src_path}" | ||
OUTPUT_VARIABLE _git_DATE_CI | ||
ERROR_VARIABLE _git_log_error | ||
RESULT_VARIABLE _git_log_result | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
message( STATUS "${_git_DATE_CI} 0 10 _git_DATE " ) | ||
|
||
string( SUBSTRING ${_git_DATE_CI} 0 10 _git_DATE ) | ||
|
||
set( ENV{LC_ALL} ${_Git_SAVED_LC_ALL} ) | ||
endif() | ||
|
||
if( _git_DESCRIBE ) | ||
set( KICAD_VERSION "${_git_DESCRIBE}" ) | ||
set( KICAD_VERSION_DATE "${_git_DATE}" ) | ||
endif() | ||
|
||
set( _wvi_new_version_text | ||
"// Do not modify this file, it was automatically generated by CMake. | ||
Published on ${KICAD_VERSION_DATE} | ||
`${KICAD_VERSION}` | ||
" ) | ||
|
||
set( _wvi_write_version_file ON ) | ||
|
||
set( OUTPUT_FILE "${PROJECT_BINARY_DIR}/src/version_info.txt") | ||
|
||
# Only write the header if it has changed, to avoid rebuilds | ||
if( EXISTS ${OUTPUT_FILE} ) | ||
file( READ ${OUTPUT_FILE} _wvi_old_version_text ) | ||
if( _wvi_old_version_text STREQUAL _wvi_new_version_text ) | ||
message( STATUS "Not updating ${OUTPUT_FILE}" ) | ||
set( _wvi_write_version_file OFF ) | ||
endif() | ||
endif() | ||
|
||
if( _wvi_write_version_file ) | ||
message( STATUS "Writing ${OUTPUT_FILE} file with version: ${KICAD_VERSION}" ) | ||
file( WRITE ${OUTPUT_FILE} ${_wvi_new_version_text} ) | ||
endif() | ||
|
||
# There should always be a valid version file. Otherwise, we might miss it. | ||
if( NOT EXISTS ${OUTPUT_FILE} ) | ||
message( FATAL_ERROR "Configuration failed to write file ${OUTPUT_FILE}." ) | ||
endif() | ||
endmacro() | ||
|
||
create_git_version_info( "${PROJECT_SOURCE_DIR}" ) | ||
|
||
|
||
# -DOUTPUT_FILE=${CMAKE_BINARY_DIR}/kicad_build_version.h | ||
# -DSRC_PATH=${PROJECT_SOURCE_DIR} |