improve --version output

now showing a value like 1.4.20161008,
the same as the DEB package
This commit is contained in:
Johan Holmberg 2016-10-08 21:04:30 +02:00
parent 70e6aaa9a7
commit 136bb53a89
3 changed files with 13 additions and 8 deletions

View File

@ -32,7 +32,7 @@ set(CPACK_DEBIAN_PACKAGE_DEPENDS "ruby | ruby-interpreter")
INCLUDE(CPack) INCLUDE(CPack)
execute_process( execute_process(
COMMAND git rev-parse HEAD COMMAND git rev-parse --short HEAD
OUTPUT_VARIABLE GIT_REV OUTPUT_VARIABLE GIT_REV
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
) )
@ -48,7 +48,11 @@ message(STATUS "GIT_DATE = '${GIT_DATE}'")
execute_process( execute_process(
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ./replace_strings.pl "GIT_REV_STRING=${GIT_REV}" "GIT_DATE_STRING=${GIT_DATE}" bin/cmdtest.rb bin/cmdtest.rb.generated COMMAND ./replace_strings.pl
"GIT_REV_STRING=${GIT_REV}"
"GIT_DATE_STRING=${GIT_DATE}"
"VERSION=${CPACK_PACKAGE_VERSION}"
bin/cmdtest.rb bin/cmdtest.rb.generated
) )

View File

@ -49,10 +49,11 @@ module Cmdtest
ORIG_CWD = Dir.pwd ORIG_CWD = Dir.pwd
GIT_REV = 'GIT_REV_STRING' GIT_REV = '$GIT_REV_STRING$'
GIT_DATE = 'GIT_DATE_STRING' GIT_DATE = '$GIT_DATE_STRING$'
VERSION = '$VERSION$'
VERSION = '1.4' SHORT_VERSION = '1.4'
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@ -605,10 +606,10 @@ module Cmdtest
opts = _parse_options opts = _parse_options
if opts.shortversion if opts.shortversion
puts VERSION puts SHORT_VERSION
exit(0) exit(0)
elsif opts.version elsif opts.version
puts "Version: " + VERSION puts "Version: " + (VERSION =~ /^\$/ ? SHORT_VERSION : VERSION)
if File.directory?(File.join(TOP_DIR, ".git")) if File.directory?(File.join(TOP_DIR, ".git"))
Dir.chdir(TOP_DIR) do Dir.chdir(TOP_DIR) do
git_rev = `git rev-parse HEAD` git_rev = `git rev-parse HEAD`

View File

@ -21,7 +21,7 @@ open(my $g, '>', $outfile) || die "open($outfile)";
while (my $line = <$f>) { while (my $line = <$f>) {
for my $entry (@replace) { for my $entry (@replace) {
my ($old, $new) = @$entry; my ($old, $new) = @$entry;
$line =~ s/$old/$new/g; $line =~ s/\$$old\$/$new/g;
} }
print {$g} $line; print {$g} $line;
} }