Ticket #885: generate-vers-cpp.sh

File generate-vers-cpp.sh, 960 bytes (added by mythtv@…, 14 years ago)

Shell script to generate version (meant to be placed in libs/libmyth). Replace .commands from willu's with: sh ./generate-vers-cpp.sh "$$VERSION" to use this instead. This uses a slightly different format than he does (gives VERSION and svnversion). Using a shell script increases flexibility and, I believe, maintainability.

Line 
1#!/bin/sh
2# Meant to be called as: sh ./generate-vers-cpp.sh "$$VERSION"
3# from libmyth.pro
4
5VERSION="Release $1"
6
7#
8# svnversion ../.. would be must more precise, but much slower
9# svn info tell revision checked out in THIS directory
10# svnversion checks the whole repository, detects mixed
11# check-outs, etc.
12#
13# On my machine, svn info takes 0.065 seconds (first time),
14# svnversion 8.045 seconds (first time).  Subsequent runs are much
15# faster due to caching (0.010 and 0.283, respectively), but I do not
16# believe represent the common case.
17#
18# In any case, here's the alternative to the line below if we want to
19# use svnversion (could, in theory, make this a configuration option):
20#SVNVERSION="`svnversion ../..`"
21
22SVNVERSION="`svn info . 2>/dev/null | grep Revision | awk '{print $2}'`"
23if [ "$SVNVERSION" ]
24then
25        VERSION="$VERSION, SVN Rev $SVNVERSION"
26fi
27
28cat > vers.cpp <<EOF
29#include "vers.h"
30
31const char *myth_source_version = "$VERSION";
32EOF
33