[Git][NTPsec/ntpsec][master] Merge upstream autorevision 1.17 release
Eric S. Raymond
gitlab at mg.gitlab.com
Mon Nov 21 16:56:28 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
cc92df38 by Matt Selsky at 2016-11-20T00:27:40-05:00
Merge upstream autorevision 1.17 release
and update our callers to avoid the need for local modifications.
- - - - -
3 changed files:
- pylib/util.py
- pylib/wscript
- wafhelpers/autorevision.sh
Changes:
=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -13,7 +13,7 @@ from ntp.packet import *
from ntp.version import *
def stdversion():
- return "%s-%s-%s %s" % (VERSION, TICK, BASENAME, DATE)
+ return "%s-%s-%s %s" % (VERSION, VCS_TICK, VCS_BASENAME, VCS_DATE)
def portsplit(hostname):
portsuffix = ""
=====================================
pylib/wscript
=====================================
--- a/pylib/wscript
+++ b/pylib/wscript
@@ -32,7 +32,7 @@ def build(ctx):
ctx(
before = ['pyc', 'pyo'],
cwd = srcnode,
- rule = 'VERSION=`cat ${SRC}` ../wafhelpers/autorevision.sh -o ${TGT[1].abspath()} -t python >${TGT[0].name}',
+ rule = 'VCS_EXTRA=`cat ${SRC}` ../wafhelpers/autorevision.sh -o ${TGT[1].abspath()} -e VERSION -t python >${TGT[0].name}',
source = "../VERSION",
target = [target3, '../wafhelpers/.autorevision-cache', '../wafhelpers/autorevision.sh'],
)
=====================================
wafhelpers/autorevision.sh
=====================================
--- a/wafhelpers/autorevision.sh
+++ b/wafhelpers/autorevision.sh
@@ -1,8 +1,5 @@
#!/bin/sh
-# Note! This version has been locally modified!
-# The "VCS_" prefix on symbols has been removed, and EXTRA has become VERSION
-
# Copyright (c) 2012 - 2016 dak180 and contributors. See
# https://opensource.org/licenses/mit-license.php or the included
# COPYING.md for licence terms.
@@ -12,20 +9,23 @@
# Usage message.
arUsage() {
- cat > "/dev/stderr" << EOF
-usage: autorevision {-t output-type | -s symbol} [-o cache-file [-f] ] [-V]
+ tee >&2 << EOF
+usage: autorevision {-t output-type | -s symbol} [-o cache-file [-f] ] [-e name] [-U] [-V]
Options include:
-t output-type = specify output type
-s symbol = specify symbol output
-o cache-file = specify cache file location
-f = force the use of cache data
+ -e name = set a different output name for VCS_EXTRA
-U = check for untracked files in svn
-V = emit version and exit
-? = help message
The following are valid output types:
- clojure = clojure file
c = C/C++ file
+ clojure = clojure file
+ cmake = CMake script file
+ csharp = CSharp properties file
h = Header for use with c/c++
hpp = Alternate C++ header strings with namespace
ini = INI file
@@ -49,26 +49,26 @@ The following are valid output types:
The following are valid symbols:
- TYPE
- BASENAME
- UUID
- NUM
- DATE
- BRANCH
- TAG
- TICK
- VERSION
- FULL_HASH
- SHORT_HASH
- WC_MODIFIED
- ACTION_STAMP
+ VCS_TYPE
+ VCS_BASENAME
+ VCS_UUID
+ VCS_NUM
+ VCS_DATE
+ VCS_BRANCH
+ VCS_TAG
+ VCS_TICK
+ VCS_EXTRA
+ VCS_FULL_HASH
+ VCS_SHORT_HASH
+ VCS_WC_MODIFIED
+ VCS_ACTION_STAMP
EOF
exit 1
}
# Config
-ARVERSION="&&ARVERSION&&"
-while getopts ":t:o:s:VfU" OPTION; do
+ARVERSION="1.17"
+while getopts ":t:o:s:e:VfU" OPTION; do
case "${OPTION}" in
t)
AFILETYPE="${OPTARG}"
@@ -82,6 +82,9 @@ while getopts ":t:o:s:VfU" OPTION; do
s)
VAROUT="${OPTARG}"
;;
+ e)
+ EXTRA_NAME="${OPTARG}"
+ ;;
U)
UNTRACKEDFILES="1"
;;
@@ -119,6 +122,7 @@ if [ ! -z "${CACHEFILE}" ] && ! echo "${CACHEFILE}" | grep -q '^\.*/'; then
fi
GENERATED_HEADER="Generated by autorevision - do not hand-hack!"
+: "${EXTRA_NAME:="VCS_EXTRA"}"
# Functions to extract data from different repo types.
# For git repos
@@ -128,68 +132,68 @@ gitRepo() {
cd "$(git rev-parse --show-toplevel)"
- TYPE="git"
+ VCS_TYPE="git"
- BASENAME="$(basename "${PWD}")"
+ VCS_BASENAME="$(basename "${PWD}")"
- UUID="$(git rev-list --max-parents=0 --date-order --reverse HEAD 2>/dev/null | sed -n 1p)"
- if [ -z "${UUID}" ]; then
- UUID="$(git rev-list --topo-order HEAD | tail -n 1)"
+ VCS_UUID="$(git rev-list --max-parents=0 --date-order --reverse HEAD 2>/dev/null | sed -n 1p)"
+ if [ -z "${VCS_UUID}" ]; then
+ VCS_UUID="$(git rev-list --topo-order HEAD | tail -n 1)"
fi
# Is the working copy clean?
test -z "$(git status --untracked-files=normal --porcelain)"
- WC_MODIFIED="${?}"
+ VCS_WC_MODIFIED="${?}"
# Enumeration of changesets
- NUM="$(git rev-list --count HEAD 2>/dev/null)"
- if [ -z "${NUM}" ]; then
+ VCS_NUM="$(git rev-list --count HEAD 2>/dev/null)"
+ if [ -z "${VCS_NUM}" ]; then
echo "warning: Counting the number of revisions may be slower due to an outdated git version less than 1.7.2.3. If something breaks, please update it." 1>&2
- NUM="$(git rev-list HEAD | wc -l)"
+ VCS_NUM="$(git rev-list HEAD | wc -l)"
fi
# This may be a git-svn remote. If so, report the Subversion revision.
if [ -z "$(git config svn-remote.svn.url 2>/dev/null)" ]; then
# The full revision hash
- FULL_HASH="$(git rev-parse HEAD)"
+ VCS_FULL_HASH="$(git rev-parse HEAD)"
# The short hash
- SHORT_HASH="$(echo "${FULL_HASH}" | cut -b 1-7)"
+ VCS_SHORT_HASH="$(echo "${VCS_FULL_HASH}" | cut -b 1-7)"
else
# The git-svn revision number
- FULL_HASH="$(git svn find-rev HEAD)"
- SHORT_HASH="${FULL_HASH}"
+ VCS_FULL_HASH="$(git svn find-rev HEAD)"
+ VCS_SHORT_HASH="${VCS_FULL_HASH}"
fi
# Current branch
- BRANCH="$(git rev-parse --symbolic-full-name --verify "$(git name-rev --name-only --no-undefined HEAD 2>/dev/null)" 2>/dev/null | sed -e 's:refs/heads/::' | sed -e 's:refs/::')"
+ VCS_BRANCH="$(git rev-parse --symbolic-full-name --verify "$(git name-rev --name-only --no-undefined HEAD 2>/dev/null)" 2>/dev/null | sed -e 's:refs/heads/::' | sed -e 's:refs/::')"
# Cache the description
local DESCRIPTION="$(git describe --long --tags 2>/dev/null)"
# Current or last tag ancestor (empty if no tags)
- TAG="$(echo "${DESCRIPTION}" | sed -e "s:-g${SHORT_HASH}\$::" -e 's:-[0-9]*$::')"
+ VCS_TAG="$(echo "${DESCRIPTION}" | sed -e "s:-g${VCS_SHORT_HASH}\$::" -e 's:-[0-9]*$::')"
- # Distance to last tag or an alias of NUM if there is no tag
+ # Distance to last tag or an alias of VCS_NUM if there is no tag
if [ ! -z "${DESCRIPTION}" ]; then
- TICK="$(echo "${DESCRIPTION}" | sed -e "s:${TAG}-::" -e "s:-g${SHORT_HASH}::")"
+ VCS_TICK="$(echo "${DESCRIPTION}" | sed -e "s:${VCS_TAG}-::" -e "s:-g${VCS_SHORT_HASH}::")"
else
- TICK="${NUM}"
+ VCS_TICK="${VCS_NUM}"
fi
# Date of the current commit
- DATE="$(TZ=UTC git show -s --date=iso-strict-local --pretty=format:%ad | sed -e 's|+00:00|Z|')"
- if [ -z "${DATE}" ]; then
+ VCS_DATE="$(TZ=UTC git show -s --date=iso-strict-local --pretty=format:%ad 2>/dev/null | sed -e 's|+00:00|Z|')"
+ if [ -z "${VCS_DATE}" ]; then
echo "warning: Action stamps require git version 2.7+." 1>&2
- DATE="$(git log -1 --pretty=format:%ci | sed -e 's: :T:' -e 's: ::' -e 's|+00:00|Z|')"
+ VCS_DATE="$(git log -1 --pretty=format:%ci | sed -e 's: :T:' -e 's: ::' -e 's|+00:00|Z|')"
local ASdis="1"
fi
# Action Stamp
if [ -z "${ASdis}" ]; then
- ACTION_STAMP="${DATE}!$(git show -s --pretty=format:%cE)"
+ VCS_ACTION_STAMP="${VCS_DATE}!$(git show -s --pretty=format:%cE)"
else
- ACTION_STAMP=""
+ VCS_ACTION_STAMP=""
fi
cd "${oldPath}"
@@ -202,48 +206,48 @@ hgRepo() {
cd "$(hg root)"
- TYPE="hg"
+ VCS_TYPE="hg"
- BASENAME="$(basename "${PWD}")"
+ VCS_BASENAME="$(basename "${PWD}")"
- UUID="$(hg log -r "0" -l 1 --template '{node}\n')"
+ VCS_UUID="$(hg log -r "0" -l 1 --template '{node}\n')"
# Is the working copy clean?
test -z "$(hg status -duram)"
- WC_MODIFIED="${?}"
+ VCS_WC_MODIFIED="${?}"
# Enumeration of changesets
- NUM="$(hg id -n | tr -d '+')"
+ VCS_NUM="$(hg id -n | tr -d '+')"
# The full revision hash
- FULL_HASH="$(hg log -r "${NUM}" -l 1 --template '{node}\n')"
+ VCS_FULL_HASH="$(hg log -r "${VCS_NUM}" -l 1 --template '{node}\n')"
# The short hash
- SHORT_HASH="$(hg id -i | tr -d '+')"
+ VCS_SHORT_HASH="$(hg id -i | tr -d '+')"
# Current bookmark (bookmarks are roughly equivalent to git's branches)
# or branch if no bookmark
- BRANCH="$(hg id -B | cut -d ' ' -f 1)"
+ VCS_BRANCH="$(hg id -B | cut -d ' ' -f 1)"
# Fall back to the branch if there are no bookmarks
- if [ -z "${BRANCH}" ]; then
- BRANCH="$(hg id -b)"
+ if [ -z "${VCS_BRANCH}" ]; then
+ VCS_BRANCH="$(hg id -b)"
fi
# Current or last tag ancestor (excluding auto tags, empty if no tags)
- TAG="$(hg log -r "${NUM}" -l 1 --template '{latesttag}\n' 2>/dev/null | sed -e 's:qtip::' -e 's:tip::' -e 's:qbase::' -e 's:qparent::' -e "s:$(hg --config 'extensions.color=' --config 'extensions.mq=' --color never qtop 2>/dev/null)::" | cut -d ' ' -f 1)"
+ VCS_TAG="$(hg log -r "${VCS_NUM}" -l 1 --template '{latesttag}\n' 2>/dev/null | sed -e 's:qtip::' -e 's:tip::' -e 's:qbase::' -e 's:qparent::' -e "s:$(hg --config 'extensions.color=' --config 'extensions.mq=' --color never qtop 2>/dev/null)::" | cut -d ' ' -f 1)"
- # Distance to last tag or an alias of NUM if there is no tag
- if [ ! -z "${TAG}" ]; then
- TICK="$(hg log -r "${NUM}" -l 1 --template '{latesttagdistance}\n' 2>/dev/null)"
+ # Distance to last tag or an alias of VCS_NUM if there is no tag
+ if [ ! -z "${VCS_TAG}" ]; then
+ VCS_TICK="$(hg log -r "${VCS_NUM}" -l 1 --template '{latesttagdistance}\n' 2>/dev/null)"
else
- TICK="${NUM}"
+ VCS_TICK="${VCS_NUM}"
fi
# Date of the current commit
- DATE="$(hg log -r "${NUM}" -l 1 --template '{date|isodatesec}\n' 2>/dev/null | sed -e 's: :T:' -e 's: ::' -e 's|+00:00|Z|')"
+ VCS_DATE="$(hg log -r "${VCS_NUM}" -l 1 --template '{date|isodatesec}\n' 2>/dev/null | sed -e 's: :T:' -e 's: ::' -e 's|+00:00|Z|')"
# Action Stamp
- ACTION_STAMP="$(TZ=UTC hg log -r "${NUM}" -l 1 --template '{date|localdate|rfc3339date}\n' 2>/dev/null | sed -e 's|+00:00|Z|')!$(hg log -r "${NUM}" -l 1 --template '{author|email}\n' 2>/dev/null)"
+ VCS_ACTION_STAMP="$(TZ=UTC hg log -r "${VCS_NUM}" -l 1 --template '{date|localdate|rfc3339date}\n' 2>/dev/null | sed -e 's|+00:00|Z|')!$(hg log -r "${VCS_NUM}" -l 1 --template '{author|email}\n' 2>/dev/null)"
cd "${oldPath}"
}
@@ -255,45 +259,45 @@ bzrRepo() {
cd "$(bzr root)"
- TYPE="bzr"
+ VCS_TYPE="bzr"
- BASENAME="$(basename "${PWD}")"
+ VCS_BASENAME="$(basename "${PWD}")"
# Currently unimplemented because more investigation is needed.
- UUID=""
+ VCS_UUID=""
# Is the working copy clean?
bzr version-info --custom --template='{clean}\n' | grep -q '1'
- WC_MODIFIED="${?}"
+ VCS_WC_MODIFIED="${?}"
# Enumeration of changesets
- NUM="$(bzr revno)"
+ VCS_NUM="$(bzr revno)"
# The full revision hash
- FULL_HASH="$(bzr version-info --custom --template='{revision_id}\n')"
+ VCS_FULL_HASH="$(bzr version-info --custom --template='{revision_id}\n')"
# The short hash
- SHORT_HASH="${NUM}"
+ VCS_SHORT_HASH="${VCS_NUM}"
# Nick of the current branch
- BRANCH="$(bzr nick)"
+ VCS_BRANCH="$(bzr nick)"
# Current or last tag ancestor (excluding auto tags, empty if no tags)
- TAG="$(bzr tags --sort=time | sed '/?$/d' | tail -n1 | cut -d ' ' -f1)"
+ VCS_TAG="$(bzr tags --sort=time | sed '/?$/d' | tail -n1 | cut -d ' ' -f1)"
- # Distance to last tag or an alias of NUM if there is no tag
- if [ ! -z "${TAG}" ]; then
- TICK="$(bzr log --line -r "tag:${TAG}.." | tail -n +2 | wc -l | sed -e 's:^ *::')"
+ # Distance to last tag or an alias of VCS_NUM if there is no tag
+ if [ ! -z "${VCS_TAG}" ]; then
+ VCS_TICK="$(bzr log --line -r "tag:${VCS_TAG}.." | tail -n +2 | wc -l | sed -e 's:^ *::')"
else
- TICK="${NUM}"
+ VCS_TICK="${VCS_NUM}"
fi
# Date of the current commit
- DATE="$(bzr version-info --custom --template='{date}\n' | sed -e 's: :T:' -e 's: ::')"
+ VCS_DATE="$(bzr version-info --custom --template='{date}\n' | sed -e 's: :T:' -e 's: ::')"
# Action Stamp
# Currently unimplemented because more investigation is needed.
- ACTION_STAMP=""
+ VCS_ACTION_STAMP=""
cd "${oldPath}"
}
@@ -303,7 +307,7 @@ bzrRepo() {
svnRepo() {
local oldPath="${PWD}"
- TYPE="svn"
+ VCS_TYPE="svn"
case "${PWD}" in
/*trunk*|/*branches*|/*tags*)
@@ -313,15 +317,15 @@ svnRepo() {
done
local fn="$(dirname "${fn}")"
if [ "${fn}" = '/' ]; then
- BASENAME="$(basename "${PWD}")"
+ VCS_BASENAME="$(basename "${PWD}")"
else
- BASENAME="$(basename "${fn}")"
+ VCS_BASENAME="$(basename "${fn}")"
fi
;;
- *) BASENAME="$(basename "${PWD}")" ;;
+ *) VCS_BASENAME="$(basename "${PWD}")" ;;
esac
- UUID="$(svn info --xml | sed -n -e 's:<uuid>::' -e 's:</uuid>::p')"
+ VCS_UUID="$(svn info --xml | sed -n -e 's:<uuid>::' -e 's:</uuid>::p')"
# Cache svnversion output
local SVNVERSION="$(svnversion)"
@@ -330,30 +334,30 @@ svnRepo() {
echo "${SVNVERSION}" | grep -q "M"
case "${?}" in
0)
- WC_MODIFIED="1"
+ VCS_WC_MODIFIED="1"
;;
1)
if [ ! -z "${UNTRACKEDFILES}" ]; then
# `svnversion` does not detect untracked files and `svn status` is really slow, so only run it if we really have to.
if [ -z "$(svn status)" ]; then
- WC_MODIFIED="0"
+ VCS_WC_MODIFIED="0"
else
- WC_MODIFIED="1"
+ VCS_WC_MODIFIED="1"
fi
else
- WC_MODIFIED="0"
+ VCS_WC_MODIFIED="0"
fi
;;
esac
# Enumeration of changesets
- NUM="$(echo "${SVNVERSION}" | cut -d : -f 1 | sed -e 's:M::' -e 's:S::' -e 's:P::')"
+ VCS_NUM="$(echo "${SVNVERSION}" | cut -d : -f 1 | sed -e 's:M::' -e 's:S::' -e 's:P::')"
# The full revision hash
- FULL_HASH="${SVNVERSION}"
+ VCS_FULL_HASH="${SVNVERSION}"
# The short hash
- SHORT_HASH="${NUM}"
+ VCS_SHORT_HASH="${VCS_NUM}"
# Current branch
case "${PWD}" in
@@ -364,33 +368,33 @@ svnRepo() {
do
base="$(basename "${fn}")"
if [ "${base}" = 'trunk' ]; then
- BRANCH='trunk'
+ VCS_BRANCH='trunk'
break
elif [ "${base}" = 'branches' ] || [ "${base}" = 'tags' ]; then
- BRANCH="${lastbase}"
+ VCS_BRANCH="${lastbase}"
break
elif [ "${base}" = '/' ]; then
- BRANCH=""
+ VCS_BRANCH=""
break
fi
local lastbase="${base}"
local fn="$(dirname "${fn}")"
done
;;
- *) BRANCH="" ;;
+ *) VCS_BRANCH="" ;;
esac
# Current or last tag ancestor (empty if no tags). But "current
# tag" can't be extracted reliably because Subversion doesn't
# have tags the way other VCSes do.
- TAG=""
- TICK=""
+ VCS_TAG=""
+ VCS_TICK=""
# Date of the current commit
- DATE="$(svn info --xml | sed -n -e 's:<date>::' -e 's:</date>::p')"
+ VCS_DATE="$(svn info --xml | sed -n -e 's:<date>::' -e 's:</date>::p')"
# Action Stamp
- ACTION_STAMP="${DATE}!$(svn log --xml -l 1 -r "${SHORT_HASH}" | sed -n -e 's:<author>::' -e 's:</author>::p')"
+ VCS_ACTION_STAMP="${VCS_DATE}!$(svn log --xml -l 1 -r "${VCS_SHORT_HASH}" | sed -n -e 's:<author>::' -e 's:</author>::p')"
cd "${oldPath}"
}
@@ -398,25 +402,26 @@ svnRepo() {
# Functions to output data in different formats.
# For bash output
+# First in list because it is used by autorevision
shOutput() {
- cat << EOF
+ tee << EOF
# ${GENERATED_HEADER}
-TYPE="${TYPE}"
-BASENAME="${BASENAME}"
-UUID="${UUID}"
-NUM="${NUM}"
-DATE="${DATE}"
-BRANCH="${BRANCH}"
-TAG="${TAG}"
-TICK="${TICK}"
-VERSION="${VERSION}"
+VCS_TYPE="${VCS_TYPE}"
+VCS_BASENAME="${VCS_BASENAME}"
+VCS_UUID="${VCS_UUID}"
+VCS_NUM="${VCS_NUM}"
+VCS_DATE="${VCS_DATE}"
+VCS_BRANCH="${VCS_BRANCH}"
+VCS_TAG="${VCS_TAG}"
+VCS_TICK="${VCS_TICK}"
+${EXTRA_NAME}="${VCS_EXTRA}"
-ACTION_STAMP="${ACTION_STAMP}"
-FULL_HASH="${FULL_HASH}"
-SHORT_HASH="${SHORT_HASH}"
+VCS_ACTION_STAMP="${VCS_ACTION_STAMP}"
+VCS_FULL_HASH="${VCS_FULL_HASH}"
+VCS_SHORT_HASH="${VCS_SHORT_HASH}"
-WC_MODIFIED="${WC_MODIFIED}"
+VCS_WC_MODIFIED="${VCS_WC_MODIFIED}"
# end
EOF
@@ -424,51 +429,76 @@ EOF
# For source C output
cOutput() {
- cat << EOF
+ tee << EOF
/* ${GENERATED_HEADER} */
-const char *TYPE = "${TYPE}";
-const char *BASENAME = "${BASENAME}";
-const char *UUID = "${UUID}";
-const int NUM = ${NUM};
-const char *DATE = "${DATE}";
-const char *BRANCH = "${BRANCH}";
-const char *TAG = "${TAG}";
-const int TICK = ${TICK};
-const char *VERSION = "${VERSION}";
+const char *VCS_TYPE = "${VCS_TYPE}";
+const char *VCS_BASENAME = "${VCS_BASENAME}";
+const char *VCS_UUID = "${VCS_UUID}";
+const int VCS_NUM = ${VCS_NUM};
+const char *VCS_DATE = "${VCS_DATE}";
+const char *VCS_BRANCH = "${VCS_BRANCH}";
+const char *VCS_TAG = "${VCS_TAG}";
+const int VCS_TICK = ${VCS_TICK};
+const char *${EXTRA_NAME} = "${VCS_EXTRA}";
-const char *ACTION_STAMP = "${ACTION_STAMP}";
-const char *FULL_HASH = "${FULL_HASH}";
-const char *SHORT_HASH = "${SHORT_HASH}";
+const char *VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}";
+const char *VCS_FULL_HASH = "${VCS_FULL_HASH}";
+const char *VCS_SHORT_HASH = "${VCS_SHORT_HASH}";
-const int WC_MODIFIED = ${WC_MODIFIED};
+const int VCS_WC_MODIFIED = ${VCS_WC_MODIFIED};
/* end */
EOF
}
+# For Cmake output
+cmakeOutput() {
+ tee << EOF
+# ${GENERATED_HEADER}
+
+set(VCS_TYPE ${VCS_TYPE})
+set(VCS_BASENAME ${VCS_BASENAME})
+set(VCS_UUID ${VCS_UUID})
+set(VCS_NUM ${VCS_NUM})
+set(VCS_DATE ${VCS_DATE})
+set(VCS_BRANCH ${VCS_BRANCH})
+set(VCS_TAG ${VCS_TAG})
+set(VCS_TICK ${VCS_TICK})
+set(${EXTRA_NAME} ${VCS_EXTRA})
+
+set(VCS_ACTION_STAMP ${VCS_ACTION_STAMP})
+set(VCS_FULL_HASH ${VCS_FULL_HASH})
+set(VCS_SHORT_HASH ${VCS_SHORT_HASH})
+
+set(VCS_WC_MODIFIED ${VCS_WC_MODIFIED})
+
+# end
+EOF
+}
+
# For header output
hOutput() {
- cat << EOF
+ tee << EOF
/* ${GENERATED_HEADER} */
#ifndef AUTOREVISION_H
#define AUTOREVISION_H
-#define TYPE "${TYPE}"
-#define BASENAME "${BASENAME}"
-#define UUID "${UUID}"
-#define NUM ${NUM}
-#define DATE "${DATE}"
-#define BRANCH "${BRANCH}"
-#define TAG "${TAG}"
-#define TICK ${TICK}
-#define VERSION "${VERSION}"
+#define VCS_TYPE "${VCS_TYPE}"
+#define VCS_BASENAME "${VCS_BASENAME}"
+#define VCS_UUID "${VCS_UUID}"
+#define VCS_NUM ${VCS_NUM}
+#define VCS_DATE "${VCS_DATE}"
+#define VCS_BRANCH "${VCS_BRANCH}"
+#define VCS_TAG "${VCS_TAG}"
+#define VCS_TICK ${VCS_TICK}
+#define ${EXTRA_NAME} "${VCS_EXTRA}"
-#define ACTION_STAMP "${ACTION_STAMP}"
-#define FULL_HASH "${FULL_HASH}"
-#define SHORT_HASH "${SHORT_HASH}"
+#define VCS_ACTION_STAMP "${VCS_ACTION_STAMP}"
+#define VCS_FULL_HASH "${VCS_FULL_HASH}"
+#define VCS_SHORT_HASH "${VCS_SHORT_HASH}"
-#define WC_MODIFIED ${WC_MODIFIED}
+#define VCS_WC_MODIFIED ${VCS_WC_MODIFIED}
#endif
@@ -478,26 +508,26 @@ EOF
# A header output for use with xcode to populate info.plist strings
xcodeOutput() {
- cat << EOF
+ tee << EOF
/* ${GENERATED_HEADER} */
#ifndef AUTOREVISION_H
#define AUTOREVISION_H
-#define TYPE ${TYPE}
-#define BASENAME ${BASENAME}
-#define UUID ${UUID}
-#define NUM ${NUM}
-#define DATE ${DATE}
-#define BRANCH ${BRANCH}
-#define TAG ${TAG}
-#define TICK ${TICK}
-#define VERSION ${VERSION}
+#define VCS_TYPE ${VCS_TYPE}
+#define VCS_BASENAME ${VCS_BASENAME}
+#define VCS_UUID ${VCS_UUID}
+#define VCS_NUM ${VCS_NUM}
+#define VCS_DATE ${VCS_DATE}
+#define VCS_BRANCH ${VCS_BRANCH}
+#define VCS_TAG ${VCS_TAG}
+#define VCS_TICK ${VCS_TICK}
+#define ${EXTRA_NAME} ${VCS_EXTRA}
-#define ACTION_STAMP ${ACTION_STAMP}
-#define FULL_HASH ${FULL_HASH}
-#define SHORT_HASH ${SHORT_HASH}
+#define VCS_ACTION_STAMP ${VCS_ACTION_STAMP}
+#define VCS_FULL_HASH ${VCS_FULL_HASH}
+#define VCS_SHORT_HASH ${VCS_SHORT_HASH}
-#define WC_MODIFIED ${WC_MODIFIED}
+#define VCS_WC_MODIFIED ${VCS_WC_MODIFIED}
#endif
@@ -507,51 +537,51 @@ EOF
# For Swift output
swiftOutput() {
- case "${WC_MODIFIED}" in
- 0) WC_MODIFIED="false" ;;
- 1) WC_MODIFIED="true" ;;
+ case "${VCS_WC_MODIFIED}" in
+ 0) VCS_WC_MODIFIED="false" ;;
+ 1) VCS_WC_MODIFIED="true" ;;
esac
# For values that may not exist depending on the type of repo we
# have read from, set them to `nil` when they are empty.
- if [ -z "${UUID}" ]; then
- UUID="nil"
+ if [ -z "${VCS_UUID}" ]; then
+ VCS_UUID="nil"
else
- UUID="\"${UUID}\""
+ VCS_UUID="\"${VCS_UUID}\""
fi
- if [ -z "${TAG}" ]; then
- TAG="nil"
+ if [ -z "${VCS_TAG}" ]; then
+ VCS_TAG="nil"
else
- TAG="\"${TAG}\""
+ VCS_TAG="\"${VCS_TAG}\""
fi
- : "${TICK:="nil"}"
- if [ -z "${VERSION}" ]; then
- VERSION="nil"
+ : "${VCS_TICK:="nil"}"
+ if [ -z "${VCS_EXTRA}" ]; then
+ VCS_EXTRA="nil"
else
- VERSION="\"${VERSION}\""
+ VCS_EXTRA="\"${VCS_EXTRA}\""
fi
- if [ -z "${ACTION_STAMP}" ]; then
- ACTION_STAMP="nil"
+ if [ -z "${VCS_ACTION_STAMP}" ]; then
+ VCS_ACTION_STAMP="nil"
else
- ACTION_STAMP="\"${ACTION_STAMP}\""
+ VCS_ACTION_STAMP="\"${VCS_ACTION_STAMP}\""
fi
- cat << EOF
+ tee << EOF
/* ${GENERATED_HEADER} */
-let TYPE = "${TYPE}"
-let BASENAME = "${BASENAME}"
-let UUID: String? = ${UUID}
-let NUM: Int = ${NUM}
-let DATE = "${DATE}"
-let BRANCH: String = "${BRANCH}"
-let TAG: String? = ${TAG}
-let TICK: Int? = ${TICK}
-let VERSION: String? = ${VERSION}
+let VCS_TYPE = "${VCS_TYPE}"
+let VCS_BASENAME = "${VCS_BASENAME}"
+let VCS_UUID: String? = ${VCS_UUID}
+let VCS_NUM: Int = ${VCS_NUM}
+let VCS_DATE = "${VCS_DATE}"
+let VCS_BRANCH: String = "${VCS_BRANCH}"
+let VCS_TAG: String? = ${VCS_TAG}
+let VCS_TICK: Int? = ${VCS_TICK}
+let ${EXTRA_NAME}: String? = ${VCS_EXTRA}
-let ACTION_STAMP: String? = ${ACTION_STAMP}
-let FULL_HASH: String = "${FULL_HASH}"
-let SHORT_HASH: String = "${SHORT_HASH}"
+let VCS_ACTION_STAMP: String? = ${VCS_ACTION_STAMP}
+let VCS_FULL_HASH: String = "${VCS_FULL_HASH}"
+let VCS_SHORT_HASH: String = "${VCS_SHORT_HASH}"
-let WC_MODIFIED: Bool = ${WC_MODIFIED}
+let VCS_WC_MODIFIED: Bool = ${VCS_WC_MODIFIED}
/* end */
EOF
@@ -559,28 +589,28 @@ EOF
# For Python output
pyOutput() {
- case "${WC_MODIFIED}" in
- 0) WC_MODIFIED="False" ;;
- 1) WC_MODIFIED="True" ;;
+ case "${VCS_WC_MODIFIED}" in
+ 0) VCS_WC_MODIFIED="False" ;;
+ 1) VCS_WC_MODIFIED="True" ;;
esac
- cat << EOF
+ tee << EOF
# ${GENERATED_HEADER}
-TYPE = "${TYPE}"
-BASENAME = "${BASENAME}"
-UUID = "${UUID}"
-NUM = ${NUM}
-DATE = "${DATE}"
-BRANCH = "${BRANCH}"
-TAG = "${TAG}"
-TICK = ${TICK}
-VERSION = "${VERSION}"
+VCS_TYPE = "${VCS_TYPE}"
+VCS_BASENAME = "${VCS_BASENAME}"
+VCS_UUID = "${VCS_UUID}"
+VCS_NUM = ${VCS_NUM}
+VCS_DATE = "${VCS_DATE}"
+VCS_BRANCH = "${VCS_BRANCH}"
+VCS_TAG = "${VCS_TAG}"
+VCS_TICK = ${VCS_TICK}
+${EXTRA_NAME} = "${VCS_EXTRA}"
-ACTION_STAMP = "${ACTION_STAMP}"
-FULL_HASH = "${FULL_HASH}"
-SHORT_HASH = "${SHORT_HASH}"
+VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}"
+VCS_FULL_HASH = "${VCS_FULL_HASH}"
+VCS_SHORT_HASH = "${VCS_SHORT_HASH}"
-WC_MODIFIED = ${WC_MODIFIED}
+VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}
# end
EOF
@@ -588,24 +618,24 @@ EOF
# For Perl output
plOutput() {
- cat << EOF
+ tee << EOF
# ${GENERATED_HEADER}
-\$TYPE = '${TYPE}';
-\$BASENAME = '${BASENAME}';
-\$UUID = '${UUID}';
-\$NUM = ${NUM};
-\$DATE = '${DATE}';
-\$BRANCH = '${BRANCH}';
-\$TAG = '${TAG}';
-\$TICK = ${TICK};
-\$VERSION = '${VERSION}';
+\$VCS_TYPE = '${VCS_TYPE}';
+\$VCS_BASENAME = '${VCS_BASENAME}';
+\$VCS_UUID = '${VCS_UUID}';
+\$VCS_NUM = ${VCS_NUM};
+\$VCS_DATE = '${VCS_DATE}';
+\$VCS_BRANCH = '${VCS_BRANCH}';
+\$VCS_TAG = '${VCS_TAG}';
+\$VCS_TICK = ${VCS_TICK};
+\$${EXTRA_NAME} = '${VCS_EXTRA}';
-\$ACTION_STAMP = '${ACTION_STAMP}';
-\$FULL_HASH = '${FULL_HASH}';
-\$SHORT_HASH = '${SHORT_HASH}';
+\$VCS_ACTION_STAMP = '${VCS_ACTION_STAMP}';
+\$VCS_FULL_HASH = '${VCS_FULL_HASH}';
+\$VCS_SHORT_HASH = '${VCS_SHORT_HASH}';
-\$WC_MODIFIED = ${WC_MODIFIED};
+\$VCS_WC_MODIFIED = ${VCS_WC_MODIFIED};
# end
1;
@@ -614,28 +644,28 @@ EOF
# For lua output
luaOutput() {
- case "${WC_MODIFIED}" in
- 0) WC_MODIFIED="false" ;;
- 1) WC_MODIFIED="true" ;;
+ case "${VCS_WC_MODIFIED}" in
+ 0) VCS_WC_MODIFIED="false" ;;
+ 1) VCS_WC_MODIFIED="true" ;;
esac
- cat << EOF
+ tee << EOF
-- ${GENERATED_HEADER}
-TYPE = "${TYPE}"
-BASENAME = "${BASENAME}"
-UUID = "${UUID}"
-NUM = ${NUM}
-DATE = "${DATE}"
-BRANCH = "${BRANCH}"
-TAG = "${TAG}"
-TICK = ${TICK}
-VERSION = "${VERSION}"
+VCS_TYPE = "${VCS_TYPE}"
+VCS_BASENAME = "${VCS_BASENAME}"
+VCS_UUID = "${VCS_UUID}"
+VCS_NUM = ${VCS_NUM}
+VCS_DATE = "${VCS_DATE}"
+VCS_BRANCH = "${VCS_BRANCH}"
+VCS_TAG = "${VCS_TAG}"
+VCS_TICK = ${VCS_TICK}
+${EXTRA_NAME} = "${VCS_EXTRA}"
-ACTION_STAMP = "${ACTION_STAMP}"
-FULL_HASH = "${FULL_HASH}"
-SHORT_HASH = "${SHORT_HASH}"
+VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}"
+VCS_FULL_HASH = "${VCS_FULL_HASH}"
+VCS_SHORT_HASH = "${VCS_SHORT_HASH}"
-WC_MODIFIED = ${WC_MODIFIED}
+VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}
-- end
EOF
@@ -643,28 +673,28 @@ EOF
# For php output
phpOutput() {
- case "${WC_MODIFIED}" in
- 0) WC_MODIFIED="false" ;;
- 1) WC_MODIFIED="true" ;;
+ case "${VCS_WC_MODIFIED}" in
+ 0) VCS_WC_MODIFIED="false" ;;
+ 1) VCS_WC_MODIFIED="true" ;;
esac
- cat << EOF
+ tee << EOF
<?php
# ${GENERATED_HEADER}
return array(
- "TYPE" => "${TYPE}",
- "BASENAME" => "${BASENAME}",
- "UUID" => "${UUID}",
- "NUM" => ${NUM},
- "DATE" => "${DATE}",
- "BRANCH" => "${BRANCH}",
- "TAG" => "${TAG}",
- "TICK" => ${TICK},
- "VERSION" => "${VERSION}",
- "ACTION_STAMP" => "${ACTION_STAMP}",
- "FULL_HASH" => "${FULL_HASH}",
- "SHORT_HASH" => "${SHORT_HASH}",
- "WC_MODIFIED" => ${WC_MODIFIED}
+ "VCS_TYPE" => "${VCS_TYPE}",
+ "VCS_BASENAME" => "${VCS_BASENAME}",
+ "VCS_UUID" => "${VCS_UUID}",
+ "VCS_NUM" => ${VCS_NUM},
+ "VCS_DATE" => "${VCS_DATE}",
+ "VCS_BRANCH" => "${VCS_BRANCH}",
+ "VCS_TAG" => "${VCS_TAG}",
+ "VCS_TICK" => ${VCS_TICK},
+ "${EXTRA_NAME}" => "${VCS_EXTRA}",
+ "VCS_ACTION_STAMP" => "${VCS_ACTION_STAMP}",
+ "VCS_FULL_HASH" => "${VCS_FULL_HASH}",
+ "VCS_SHORT_HASH" => "${VCS_SHORT_HASH}",
+ "VCS_WC_MODIFIED" => ${VCS_WC_MODIFIED}
);
# end
@@ -674,55 +704,55 @@ EOF
# For ini output
iniOutput() {
- case "${WC_MODIFIED}" in
- 0) WC_MODIFIED="false" ;;
- 1) WC_MODIFIED="true" ;;
+ case "${VCS_WC_MODIFIED}" in
+ 0) VCS_WC_MODIFIED="false" ;;
+ 1) VCS_WC_MODIFIED="true" ;;
esac
- cat << EOF
+ tee << EOF
; ${GENERATED_HEADER}
[VCS]
-TYPE = "${TYPE}"
-BASENAME = "${BASENAME}"
-UUID = "${UUID}"
-NUM = ${NUM}
-DATE = "${DATE}"
-BRANCH = "${BRANCH}"
-TAG = "${TAG}"
-TICK = ${TICK}
-VERSION = "${VERSION}"
-ACTION_STAMP = "${ACTION_STAMP}"
-FULL_HASH = "${FULL_HASH}"
-SHORT_HASH = "${SHORT_HASH}"
-WC_MODIFIED = ${WC_MODIFIED}
+VCS_TYPE = "${VCS_TYPE}"
+VCS_BASENAME = "${VCS_BASENAME}"
+VCS_UUID = "${VCS_UUID}"
+VCS_NUM = ${VCS_NUM}
+VCS_DATE = "${VCS_DATE}"
+VCS_BRANCH = "${VCS_BRANCH}"
+VCS_TAG = "${VCS_TAG}"
+VCS_TICK = ${VCS_TICK}
+${EXTRA_NAME} = "${VCS_EXTRA}"
+VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}"
+VCS_FULL_HASH = "${VCS_FULL_HASH}"
+VCS_SHORT_HASH = "${VCS_SHORT_HASH}"
+VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}
; end
EOF
}
# For javascript output
jsOutput() {
- case "${WC_MODIFIED}" in
- 1) WC_MODIFIED="true" ;;
- 0) WC_MODIFIED="false" ;;
+ case "${VCS_WC_MODIFIED}" in
+ 1) VCS_WC_MODIFIED="true" ;;
+ 0) VCS_WC_MODIFIED="false" ;;
esac
- cat << EOF
+ tee << EOF
/** ${GENERATED_HEADER} */
var autorevision = {
- TYPE: "${TYPE}",
- BASENAME: "${BASENAME}",
- UUID: "${UUID}",
- NUM: ${NUM},
- DATE: "${DATE}",
- BRANCH: "${BRANCH}",
- TAG: "${TAG}",
- TICK: ${TICK},
- VERSION: "${VERSION}",
-
- ACTION_STAMP: "${ACTION_STAMP}",
- FULL_HASH: "${FULL_HASH}",
- SHORT_HASH: "${SHORT_HASH}",
-
- WC_MODIFIED: ${WC_MODIFIED}
+ VCS_TYPE: "${VCS_TYPE}",
+ VCS_BASENAME: "${VCS_BASENAME}",
+ VCS_UUID: "${VCS_UUID}",
+ VCS_NUM: ${VCS_NUM},
+ VCS_DATE: "${VCS_DATE}",
+ VCS_BRANCH: "${VCS_BRANCH}",
+ VCS_TAG: "${VCS_TAG}",
+ VCS_TICK: ${VCS_TICK},
+ ${EXTRA_NAME}: "${VCS_EXTRA}",
+
+ VCS_ACTION_STAMP: "${VCS_ACTION_STAMP}",
+ VCS_FULL_HASH: "${VCS_FULL_HASH}",
+ VCS_SHORT_HASH: "${VCS_SHORT_HASH}",
+
+ VCS_WC_MODIFIED: ${VCS_WC_MODIFIED}
};
/** Node.js compatibility */
@@ -736,214 +766,251 @@ EOF
# For JSON output
jsonOutput() {
- case "${WC_MODIFIED}" in
- 1) WC_MODIFIED="true" ;;
- 0) WC_MODIFIED="false" ;;
+ case "${VCS_WC_MODIFIED}" in
+ 1) VCS_WC_MODIFIED="true" ;;
+ 0) VCS_WC_MODIFIED="false" ;;
esac
- cat << EOF
+ tee << EOF
{
"_comment": "${GENERATED_HEADER}",
- "TYPE": "${TYPE}",
- "BASENAME": "${BASENAME}",
- "UUID": "${UUID}",
- "NUM": ${NUM},
- "DATE": "${DATE}",
- "BRANCH":"${BRANCH}",
- "TAG": "${TAG}",
- "TICK": ${TICK},
- "VERSION": "${VERSION}",
-
- "ACTION_STAMP": "${ACTION_STAMP}",
- "FULL_HASH": "${FULL_HASH}",
- "SHORT_HASH": "${SHORT_HASH}",
-
- "WC_MODIFIED": ${WC_MODIFIED}
+ "VCS_TYPE": "${VCS_TYPE}",
+ "VCS_BASENAME": "${VCS_BASENAME}",
+ "VCS_UUID": "${VCS_UUID}",
+ "VCS_NUM": ${VCS_NUM},
+ "VCS_DATE": "${VCS_DATE}",
+ "VCS_BRANCH":"${VCS_BRANCH}",
+ "VCS_TAG": "${VCS_TAG}",
+ "VCS_TICK": ${VCS_TICK},
+ "${EXTRA_NAME}": "${VCS_EXTRA}",
+
+ "VCS_ACTION_STAMP": "${VCS_ACTION_STAMP}",
+ "VCS_FULL_HASH": "${VCS_FULL_HASH}",
+ "VCS_SHORT_HASH": "${VCS_SHORT_HASH}",
+
+ "VCS_WC_MODIFIED": ${VCS_WC_MODIFIED}
}
EOF
}
# For Java output
javaOutput() {
- case "${WC_MODIFIED}" in
- 1) WC_MODIFIED="true" ;;
- 0) WC_MODIFIED="false" ;;
+ case "${VCS_WC_MODIFIED}" in
+ 1) VCS_WC_MODIFIED="true" ;;
+ 0) VCS_WC_MODIFIED="false" ;;
esac
- cat << EOF
+ tee << EOF
/* ${GENERATED_HEADER} */
public class autorevision {
- public static final String TYPE = "${TYPE}";
- public static final String BASENAME = "${BASENAME}";
- public static final String UUID = "${UUID}";
- public static final long NUM = ${NUM};
- public static final String DATE = "${DATE}";
- public static final String BRANCH = "${BRANCH}";
- public static final String TAG = "${TAG}";
- public static final long TICK = ${TICK};
- public static final String VERSION = "${VERSION}";
-
- public static final String ACTION_STAMP = "${ACTION_STAMP}";
- public static final String FULL_HASH = "${FULL_HASH}";
- public static final String SHORT_HASH = "${SHORT_HASH}";
-
- public static final boolean WC_MODIFIED = ${WC_MODIFIED};
+ public static final String VCS_TYPE = "${VCS_TYPE}";
+ public static final String VCS_BASENAME = "${VCS_BASENAME}";
+ public static final String VCS_UUID = "${VCS_UUID}";
+ public static final long VCS_NUM = ${VCS_NUM};
+ public static final String VCS_DATE = "${VCS_DATE}";
+ public static final String VCS_BRANCH = "${VCS_BRANCH}";
+ public static final String VCS_TAG = "${VCS_TAG}";
+ public static final long VCS_TICK = ${VCS_TICK};
+ public static final String ${EXTRA_NAME} = "${VCS_EXTRA}";
+
+ public static final String VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}";
+ public static final String VCS_FULL_HASH = "${VCS_FULL_HASH}";
+ public static final String VCS_SHORT_HASH = "${VCS_SHORT_HASH}";
+
+ public static final boolean VCS_WC_MODIFIED = ${VCS_WC_MODIFIED};
+}
+EOF
+}
+
+csharpOutput() {
+ case "${VCS_WC_MODIFIED}" in
+ 1) VCS_WC_MODIFIED="true" ;;
+ 0) VCS_WC_MODIFIED="false" ;;
+ esac
+ if [ "${EXTRA_NAME}" = "VCS_EXTRA" ]; then
+ EXTRA_NAME="VcsExtra"
+ fi
+ tee << EOF
+/* ${GENERATED_HEADER} */
+
+namespace AutoRevision
+{
+ public class VersionInfo
+ {
+ public static string VcsType = "${VCS_TYPE}";
+ public static string VcsBasename = "${VCS_BASENAME}";
+ public static string VcsUuid = "${VCS_UUID}";
+ public static string VcsNum = "${VCS_NUM}";
+ public static string VcsDate = "${VCS_DATE}";
+ public static string VcsBranch = "${VCS_DATE}";
+ public static string VcsTag = "${VCS_TAG}";
+ public static string VcsTick = "${VCS_TICK}";
+ public static string ${EXTRA_NAME} = "${VCS_EXTRA}";
+ public static string VcsActionStamp = "${VCS_ACTION_STAMP}";
+ public static string VcsFullHash = "${VCS_FULL_HASH}";
+ public static string VcsShortHash = "${VCS_SHORT_HASH}";
+ public static string VcsWcModified = "${VCS_WC_MODIFIED}";
+ }
}
EOF
}
# For Java properties output
javapropOutput() {
- case "${WC_MODIFIED}" in
- 1) WC_MODIFIED="true" ;;
- 0) WC_MODIFIED="false" ;;
+ case "${VCS_WC_MODIFIED}" in
+ 1) VCS_WC_MODIFIED="true" ;;
+ 0) VCS_WC_MODIFIED="false" ;;
esac
- cat << EOF
+ tee << EOF
# ${GENERATED_HEADER}
-TYPE=${TYPE}
-BASENAME=${BASENAME}
-UUID=${UUID}
-NUM=${NUM}
-DATE=${DATE}
-BRANCH=${BRANCH}
-TAG=${TAG}
-TICK=${TICK}
-VERSION=${VERSION}
-
-ACTION_STAMP=${ACTION_STAMP}
-FULL_HASH=${FULL_HASH}
-SHORT_HASH=${SHORT_HASH}
-
-WC_MODIFIED=${WC_MODIFIED}
+VCS_TYPE=${VCS_TYPE}
+VCS_BASENAME=${VCS_BASENAME}
+VCS_UUID=${VCS_UUID}
+VCS_NUM=${VCS_NUM}
+VCS_DATE=${VCS_DATE}
+VCS_BRANCH=${VCS_BRANCH}
+VCS_TAG=${VCS_TAG}
+VCS_TICK=${VCS_TICK}
+${EXTRA_NAME}=${VCS_EXTRA}
+
+VCS_ACTION_STAMP=${VCS_ACTION_STAMP}
+VCS_FULL_HASH=${VCS_FULL_HASH}
+VCS_SHORT_HASH=${VCS_SHORT_HASH}
+
+VCS_WC_MODIFIED=${VCS_WC_MODIFIED}
EOF
}
# For m4 output
m4Output() {
- cat << EOF
+ tee << EOF
dnl ${GENERATED_HEADER}
-define(\`TYPE', \`${TYPE}')dnl
-define(\`BASENAME', \`${BASENAME}')dnl
-define(\`UUID', \`${UUID}')dnl
-define(\`NUM', \`${NUM}')dnl
-define(\`DATE', \`${DATE}')dnl
-define(\`BRANCH', \`${BRANCH}')dnl
-define(\`TAG', \`${TAG}')dnl
-define(\`TICK', \`${TICK}')dnl
-define(\`VERSION', \`${VERSION}')dnl
-define(\`ACTIONSTAMP', \`${ACTION_STAMP}')dnl
-define(\`FULLHASH', \`${FULL_HASH}')dnl
-define(\`SHORTHASH', \`${SHORT_HASH}')dnl
-define(\`WC_MODIFIED', \`${WC_MODIFIED}')dnl
+define(\`VCS_TYPE', \`${VCS_TYPE}')dnl
+define(\`VCS_BASENAME', \`${VCS_BASENAME}')dnl
+define(\`VCS_UUID', \`${VCS_UUID}')dnl
+define(\`VCS_NUM', \`${VCS_NUM}')dnl
+define(\`VCS_DATE', \`${VCS_DATE}')dnl
+define(\`VCS_BRANCH', \`${VCS_BRANCH}')dnl
+define(\`VCS_TAG', \`${VCS_TAG}')dnl
+define(\`VCS_TICK', \`${VCS_TICK}')dnl
+define(\`${EXTRA_NAME}', \`${VCS_EXTRA}')dnl
+define(\`VCS_ACTIONSTAMP', \`${VCS_ACTION_STAMP}')dnl
+define(\`VCS_FULLHASH', \`${VCS_FULL_HASH}')dnl
+define(\`VCS_SHORTHASH', \`${VCS_SHORT_HASH}')dnl
+define(\`VCS_WC_MODIFIED', \`${VCS_WC_MODIFIED}')dnl
EOF
}
# For (La)TeX output
texOutput() {
- case "${WC_MODIFIED}" in
- 0) WC_MODIFIED="false" ;;
- 1) WC_MODIFIED="true" ;;
+ case "${VCS_WC_MODIFIED}" in
+ 0) VCS_WC_MODIFIED="false" ;;
+ 1) VCS_WC_MODIFIED="true" ;;
esac
- cat << EOF
+ if [ "${EXTRA_NAME}" = "VCS_EXTRA" ]; then
+ EXTRA_NAME="vcsExtra"
+ fi
+ tee << EOF
% ${GENERATED_HEADER}
-\def \vcsType {${TYPE}}
-\def \vcsBasename {${BASENAME}}
-\def \vcsUUID {${UUID}}
-\def \vcsNum {${NUM}}
-\def \vcsDate {${DATE}}
-\def \vcsBranch {${BRANCH}}
-\def \vcsTag {${TAG}}
-\def \vcsTick {${TICK}}
-\def \vcsExtra {${VERSION}}
-\def \vcsACTIONSTAMP {${ACTION_STAMP}}
-\def \vcsFullHash {${FULL_HASH}}
-\def \vcsShortHash {${SHORT_HASH}}
-\def \vcsWCModified {${WC_MODIFIED}}
+\def \vcsType {${VCS_TYPE}}
+\def \vcsBasename {${VCS_BASENAME}}
+\def \vcsUUID {${VCS_UUID}}
+\def \vcsNum {${VCS_NUM}}
+\def \vcsDate {${VCS_DATE}}
+\def \vcsBranch {${VCS_BRANCH}}
+\def \vcsTag {${VCS_TAG}}
+\def \vcsTick {${VCS_TICK}}
+\def \\${EXTRA_NAME} {${VCS_EXTRA}}
+\def \vcsACTIONSTAMP {${VCS_ACTION_STAMP}}
+\def \vcsFullHash {${VCS_FULL_HASH}}
+\def \vcsShortHash {${VCS_SHORT_HASH}}
+\def \vcsWCModified {${VCS_WC_MODIFIED}}
\endinput
EOF
}
# For scheme output
schemeOutput() {
- case "${WC_MODIFIED}" in
- 0) WC_MODIFIED="#f" ;;
- 1) WC_MODIFIED="#t" ;;
+ case "${VCS_WC_MODIFIED}" in
+ 0) VCS_WC_MODIFIED="#f" ;;
+ 1) VCS_WC_MODIFIED="#t" ;;
esac
- cat << EOF
+ tee << EOF
;; ${GENERATED_HEADER}
-(define TYPE "${TYPE}")
-(define BASENAME "${BASENAME}")
-(define UUID "${UUID}")
-(define NUM ${NUM})
-(define DATE "${DATE}")
-(define BRANCH "${BRANCH}")
-(define TAG "${TAG}")
-(define TICK ${TICK})
-(define VERSION "${VERSION}")
-
-(define ACTION_STAMP "${ACTION_STAMP}")
-(define FULL_HASH "${FULL_HASH}")
-(define SHORT_HASH "${SHORT_HASH}")
-
-(define WC_MODIFIED ${WC_MODIFIED})
+(define VCS_TYPE "${VCS_TYPE}")
+(define VCS_BASENAME "${VCS_BASENAME}")
+(define VCS_UUID "${VCS_UUID}")
+(define VCS_NUM ${VCS_NUM})
+(define VCS_DATE "${VCS_DATE}")
+(define VCS_BRANCH "${VCS_BRANCH}")
+(define VCS_TAG "${VCS_TAG}")
+(define VCS_TICK ${VCS_TICK})
+(define ${EXTRA_NAME} "${VCS_EXTRA}")
+
+(define VCS_ACTION_STAMP "${VCS_ACTION_STAMP}")
+(define VCS_FULL_HASH "${VCS_FULL_HASH}")
+(define VCS_SHORT_HASH "${VCS_SHORT_HASH}")
+
+(define VCS_WC_MODIFIED ${VCS_WC_MODIFIED})
;; end
EOF
}
# For clojure output
clojureOutput() {
- case "${WC_MODIFIED}" in
- 0) WC_MODIFIED="false" ;;
- 1) WC_MODIFIED="true" ;;
+ case "${VCS_WC_MODIFIED}" in
+ 0) VCS_WC_MODIFIED="false" ;;
+ 1) VCS_WC_MODIFIED="true" ;;
esac
- cat << EOF
+ tee << EOF
;; ${GENERATED_HEADER}
-(def TYPE "${TYPE}")
-(def BASENAME "${BASENAME}")
-(def UUID "${UUID}")
-(def NUM ${NUM})
-(def DATE "${DATE}")
-(def BRANCH "${BRANCH}")
-(def TAG "${TAG}")
-(def TICK ${TICK})
-(def VERSION "${VERSION}")
-
-(def ACTION_STAMP "${ACTION_STAMP}")
-(def FULL_HASH "${FULL_HASH}")
-(def SHORT_HASH "${SHORT_HASH}")
-
-(def WC_MODIFIED ${WC_MODIFIED})
+(def VCS_TYPE "${VCS_TYPE}")
+(def VCS_BASENAME "${VCS_BASENAME}")
+(def VCS_UUID "${VCS_UUID}")
+(def VCS_NUM ${VCS_NUM})
+(def VCS_DATE "${VCS_DATE}")
+(def VCS_BRANCH "${VCS_BRANCH}")
+(def VCS_TAG "${VCS_TAG}")
+(def VCS_TICK ${VCS_TICK})
+(def ${EXTRA_NAME} "${VCS_EXTRA}")
+
+(def VCS_ACTION_STAMP "${VCS_ACTION_STAMP}")
+(def VCS_FULL_HASH "${VCS_FULL_HASH}")
+(def VCS_SHORT_HASH "${VCS_SHORT_HASH}")
+
+(def VCS_WC_MODIFIED ${VCS_WC_MODIFIED})
;; end
EOF
}
# For rpm spec file output
rpmOutput() {
- cat << EOF
+ tee << EOF
# ${GENERATED_HEADER}
-$([ "${TYPE}" ] && echo "%define vcs_type ${TYPE}")
-$([ "${BASENAME}" ] && echo "%define vcs_basename ${BASENAME}")
-$([ "${UUID}" ] && echo "%define vcs_uuid ${UUID}")
-$([ "${NUM}" ] && echo "%define vcs_num ${NUM}")
-$([ "${DATE}" ] && echo "%define vcs_date ${DATE}")
-$([ "${BRANCH}" ] && echo "%define vcs_branch ${BRANCH}")
-$([ "${TAG}" ] && echo "%define vcs_tag ${TAG}")
-$([ "${TICK}" ] && echo "%define vcs_tick ${TICK}")
-$([ "${VERSION}" ] && echo "%define vcs_extra ${VERSION}")
-
-$([ "${ACTION_STAMP}" ] && echo "%define vcs_action_stamp ${ACTION_STAMP}")
-$([ "${FULL_HASH}" ] && echo "%define vcs_full_hash ${FULL_HASH}")
-$([ "${SHORT_HASH}" ] && echo "%define vcs_short_hash ${SHORT_HASH}")
-
-$([ "${WC_MODIFIED}" ] && echo "%define vcs_wc_modified ${WC_MODIFIED}")
+$([ "${VCS_TYPE}" ] && echo "%define vcs_type ${VCS_TYPE}")
+$([ "${VCS_BASENAME}" ] && echo "%define vcs_basename ${VCS_BASENAME}")
+$([ "${VCS_UUID}" ] && echo "%define vcs_uuid ${VCS_UUID}")
+$([ "${VCS_NUM}" ] && echo "%define vcs_num ${VCS_NUM}")
+$([ "${VCS_DATE}" ] && echo "%define vcs_date ${VCS_DATE}")
+$([ "${VCS_BRANCH}" ] && echo "%define vcs_branch ${VCS_BRANCH}")
+$([ "${VCS_TAG}" ] && echo "%define vcs_tag ${VCS_TAG}")
+$([ "${VCS_TICK}" ] && echo "%define vcs_tick ${VCS_TICK}")
+$([ "${VCS_EXTRA}" ] && echo "%define ${EXTRA_NAME} ${VCS_EXTRA}")
+
+$([ "${VCS_ACTION_STAMP}" ] && echo "%define vcs_action_stamp ${VCS_ACTION_STAMP}")
+$([ "${VCS_FULL_HASH}" ] && echo "%define vcs_full_hash ${VCS_FULL_HASH}")
+$([ "${VCS_SHORT_HASH}" ] && echo "%define vcs_short_hash ${VCS_SHORT_HASH}")
+
+$([ "${VCS_WC_MODIFIED}" ] && echo "%define vcs_wc_modified ${VCS_WC_MODIFIED}")
# end
EOF
}
+# For C++ Header output
# shellcheck disable=SC2155,SC2039
hppOutput() {
- local NAMESPACE="$(echo "${BASENAME}" | sed -e 's:_::g' | tr '[:lower:]' '[:upper:]')"
- cat << EOF
+ local NAMESPACE="$(echo "${VCS_BASENAME}" | sed -e 's:_::g' | tr '[:lower:]' '[:upper:]')"
+ tee << EOF
/* ${GENERATED_HEADER} */
#ifndef ${NAMESPACE}_AUTOREVISION_H
@@ -953,21 +1020,21 @@ hppOutput() {
namespace $(echo "${NAMESPACE}" | tr '[:upper:]' '[:lower:]')
{
- const std::string TYPE = "${TYPE}";
- const std::string BASENAME = "${BASENAME}";
- const std::string UUID = "${UUID}";
- const int NUM = ${NUM};
- const std::string DATE = "${DATE}";
- const std::string BRANCH = "${BRANCH}";
- const std::string TAG = "${TAG}";
- const int TICK = ${TICK};
- const std::string VERSION = "${VERSION}";
-
- const std::string ACTION_STAMP = "${ACTION_STAMP}";
- const std::string FULL_HASH = "${FULL_HASH}";
- const std::string SHORT_HASH = "${SHORT_HASH}";
-
- const int WC_MODIFIED = ${WC_MODIFIED};
+ const std::string VCS_TYPE = "${VCS_TYPE}";
+ const std::string VCS_BASENAME = "${VCS_BASENAME}";
+ const std::string VCS_UUID = "${VCS_UUID}";
+ const int VCS_NUM = ${VCS_NUM};
+ const std::string VCS_DATE = "${VCS_DATE}";
+ const std::string VCS_BRANCH = "${VCS_BRANCH}";
+ const std::string VCS_TAG = "${VCS_TAG}";
+ const int VCS_TICK = ${VCS_TICK};
+ const std::string ${EXTRA_NAME} = "${VCS_EXTRA}";
+
+ const std::string VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}";
+ const std::string VCS_FULL_HASH = "${VCS_FULL_HASH}";
+ const std::string VCS_SHORT_HASH = "${VCS_SHORT_HASH}";
+
+ const int VCS_WC_MODIFIED = ${VCS_WC_MODIFIED};
}
#endif
@@ -976,53 +1043,55 @@ namespace $(echo "${NAMESPACE}" | tr '[:upper:]' '[:lower:]')
EOF
}
+# For Matlab output
matlabOutput() {
- case "${WC_MODIFIED}" in
- 0) WC_MODIFIED="FALSE" ;;
- 1) WC_MODIFIED="TRUE" ;;
+ case "${VCS_WC_MODIFIED}" in
+ 0) VCS_WC_MODIFIED="FALSE" ;;
+ 1) VCS_WC_MODIFIED="TRUE" ;;
esac
- cat << EOF
+ tee << EOF
% ${GENERATED_HEADER}
-TYPE = '${TYPE}';
-BASENAME = '${BASENAME}';
-UUID = '${UUID}';
-NUM = ${NUM};
-DATE = '${DATE}';
-BRANCH = '${BRANCH}';
-TAG = '${TAG}';
-TICK = ${TICK};
-VERSION = '${VERSION}';
+VCS_TYPE = '${VCS_TYPE}';
+VCS_BASENAME = '${VCS_BASENAME}';
+VCS_UUID = '${VCS_UUID}';
+VCS_NUM = ${VCS_NUM};
+VCS_DATE = '${VCS_DATE}';
+VCS_BRANCH = '${VCS_BRANCH}';
+VCS_TAG = '${VCS_TAG}';
+VCS_TICK = ${VCS_TICK};
+${EXTRA_NAME} = '${VCS_EXTRA}';
-ACTION_STAMP = '${ACTION_STAMP}';
-FULL_HASH = '${FULL_HASH}';
-SHORT_HASH = '${SHORT_HASH}';
+VCS_ACTION_STAMP = '${VCS_ACTION_STAMP}';
+VCS_FULL_HASH = '${VCS_FULL_HASH}';
+VCS_SHORT_HASH = '${VCS_SHORT_HASH}';
-WC_MODIFIED = ${WC_MODIFIED};
+VCS_WC_MODIFIED = ${VCS_WC_MODIFIED};
% end
EOF
}
+# For Octave output
octaveOutput() {
- cat << EOF
+ tee << EOF
% ${GENERATED_HEADER}
-TYPE = '${TYPE}';
-BASENAME = '${BASENAME}';
-UUID = '${UUID}';
-NUM = ${NUM};
-DATE = '${DATE}';
-BRANCH = '${BRANCH}';
-TAG = '${TAG}';
-TICK = ${TICK};
-VERSION = '${VERSION}';
+VCS_TYPE = '${VCS_TYPE}';
+VCS_BASENAME = '${VCS_BASENAME}';
+VCS_UUID = '${VCS_UUID}';
+VCS_NUM = ${VCS_NUM};
+VCS_DATE = '${VCS_DATE}';
+VCS_BRANCH = '${VCS_BRANCH}';
+VCS_TAG = '${VCS_TAG}';
+VCS_TICK = ${VCS_TICK};
+${EXTRA_NAME} = '${VCS_EXTRA}';
-ACTION_STAMP = '${ACTION_STAMP}';
-FULL_HASH = '${FULL_HASH}';
-SHORT_HASH = '${SHORT_HASH}';
+VCS_ACTION_STAMP = '${VCS_ACTION_STAMP}';
+VCS_FULL_HASH = '${VCS_FULL_HASH}';
+VCS_SHORT_HASH = '${VCS_SHORT_HASH}';
-WC_MODIFIED = ${WC_MODIFIED};
+VCS_WC_MODIFIED = ${VCS_WC_MODIFIED};
% end
EOF
@@ -1064,46 +1133,55 @@ multiCompare() {
# shellcheck disable=SC2155,SC2039
repoTest() {
REPONUM="0"
- if [ ! -z "$(git rev-parse HEAD 2>/dev/null)" ]; then
- local gitPath="$(git rev-parse --show-toplevel)"
+ if command -v git > /dev/null 2>&1; then
+ local gitPath="$(git rev-parse --show-toplevel 2>/dev/null)"
local gitDepth="$(pathSegment "${gitPath}")"
- REPONUM="$((REPONUM+1))"
+ if [ ! -z "${gitPath}" ]; then
+ REPONUM="$((REPONUM+1))"
+ fi
else
local gitDepth="0"
fi
- if [ ! -z "$(hg root 2>/dev/null)" ]; then
+ if command -v hg > /dev/null 2>&1; then
local hgPath="$(hg root 2>/dev/null)"
local hgDepth="$(pathSegment "${hgPath}")"
- REPONUM="$((REPONUM+1))"
+ if [ ! -z "${hgPath}" ]; then
+ REPONUM="$((REPONUM+1))"
+ fi
else
local hgDepth="0"
fi
- if [ ! -z "$(bzr root 2>/dev/null)" ]; then
+ if command -v bzr > /dev/null 2>&1; then
local bzrPath="$(bzr root 2>/dev/null)"
local bzrDepth="$(pathSegment "${bzrPath}")"
- REPONUM="$((REPONUM+1))"
+ if [ ! -z "${bzrPath}" ]; then
+ REPONUM="$((REPONUM+1))"
+ fi
else
local bzrDepth="0"
fi
- if [ ! -z "$(svn info 2>/dev/null)" ]; then
+ if command -v svn > /dev/null 2>&1; then
local stringz="<wcroot-abspath>"
local stringx="</wcroot-abspath>"
- local svnPath="$(svn info --xml | sed -n -e "s:${stringz}::" -e "s:${stringx}::p")"
+ local svnPath="$(svn info --xml 2>/dev/null | sed -n -e "s:${stringz}::" -e "s:${stringx}::p")"
# An old enough svn will not be able give us a path; default
# to 1 for that case.
- if [ -z "${svnPath}" ]; then
+ if [ ! -z "${svnPath}" ]; then
+ local svnDepth="$(pathSegment "${svnPath}")"
+ REPONUM="$((REPONUM+1))"
+ elif [ -z "${svnPath}" ] && [ -d ".svn" ]; then
local svnDepth="1"
+ REPONUM="$((REPONUM+1))"
else
- local svnDepth="$(pathSegment "${svnPath}")"
+ local svnDepth="0"
fi
- REPONUM="$((REPONUM+1))"
else
local svnDepth="0"
fi
# Do not do more work then we have to.
if [ "${REPONUM}" = "0" ]; then
- return
+ return 0
fi
# Figure out which repo is the deepest and use it.
@@ -1127,8 +1205,8 @@ if [ -f "${CACHEFILE}" ] && [ "${CACHEFORCE}" = "1" ]; then
# When requested only read from the cache to populate our symbols.
. "${CACHEFILE}"
else
- # If a value is not set through the environment set VERSION to nothing.
- : "${VERSION:=""}"
+ # If a value is not set through the environment set VCS_EXTRA to nothing.
+ : "${VCS_EXTRA:=""}"
repoTest
if [ -f "${CACHEFILE}" ] && [ "${REPONUM}" = "0" ]; then
@@ -1145,28 +1223,28 @@ fi
# -s output is handled here.
if [ ! -z "${VAROUT}" ]; then
- if [ "${VAROUT}" = "TYPE" ]; then
- echo "${TYPE}"
- elif [ "${VAROUT}" = "BASENAME" ]; then
- echo "${BASENAME}"
- elif [ "${VAROUT}" = "NUM" ]; then
- echo "${NUM}"
- elif [ "${VAROUT}" = "DATE" ]; then
- echo "${DATE}"
- elif [ "${VAROUT}" = "BRANCH" ]; then
- echo "${BRANCH}"
- elif [ "${VAROUT}" = "TAG" ]; then
- echo "${TAG}"
- elif [ "${VAROUT}" = "TICK" ]; then
- echo "${TICK}"
- elif [ "${VAROUT}" = "FULL_HASH" ]; then
- echo "${FULL_HASH}"
- elif [ "${VAROUT}" = "SHORT_HASH" ]; then
- echo "${SHORT_HASH}"
- elif [ "${VAROUT}" = "WC_MODIFIED" ]; then
- echo "${WC_MODIFIED}"
- elif [ "${VAROUT}" = "ACTION_STAMP" ]; then
- echo "${ACTION_STAMP}"
+ if [ "${VAROUT}" = "VCS_TYPE" ]; then
+ echo "${VCS_TYPE}"
+ elif [ "${VAROUT}" = "VCS_BASENAME" ]; then
+ echo "${VCS_BASENAME}"
+ elif [ "${VAROUT}" = "VCS_NUM" ]; then
+ echo "${VCS_NUM}"
+ elif [ "${VAROUT}" = "VCS_DATE" ]; then
+ echo "${VCS_DATE}"
+ elif [ "${VAROUT}" = "VCS_BRANCH" ]; then
+ echo "${VCS_BRANCH}"
+ elif [ "${VAROUT}" = "VCS_TAG" ]; then
+ echo "${VCS_TAG}"
+ elif [ "${VAROUT}" = "VCS_TICK" ]; then
+ echo "${VCS_TICK}"
+ elif [ "${VAROUT}" = "VCS_FULL_HASH" ]; then
+ echo "${VCS_FULL_HASH}"
+ elif [ "${VAROUT}" = "VCS_SHORT_HASH" ]; then
+ echo "${VCS_SHORT_HASH}"
+ elif [ "${VAROUT}" = "VCS_WC_MODIFIED" ]; then
+ echo "${VCS_WC_MODIFIED}"
+ elif [ "${VAROUT}" = "VCS_ACTION_STAMP" ]; then
+ echo "${VCS_ACTION_STAMP}"
else
echo "error: Not a valid output symbol." 1>&2
exit 1
@@ -1204,6 +1282,8 @@ if [ ! -z "${AFILETYPE}" ]; then
javaOutput
elif [ "${AFILETYPE}" = "javaprop" ]; then
javapropOutput
+ elif [ "${AFILETYPE}" = "csharp" ]; then
+ csharpOutput
elif [ "${AFILETYPE}" = "tex" ]; then
texOutput
elif [ "${AFILETYPE}" = "m4" ]; then
@@ -1220,6 +1300,8 @@ if [ ! -z "${AFILETYPE}" ]; then
matlabOutput
elif [ "${AFILETYPE}" = "octave" ]; then
octaveOutput
+ elif [ "${AFILETYPE}" = "cmake" ]; then
+ cmakeOutput
else
echo "error: Not a valid output type." 1>&2
exit 1
@@ -1229,7 +1311,8 @@ fi
# If requested, make a cache file.
if [ ! -z "${CACHEFILE}" ] && [ ! "${CACHEFORCE}" = "1" ]; then
- shOutput >${CACHEFILE}.tmp
+ EXTRA_NAME="VCS_EXTRA"
+ shOutput > "${CACHEFILE}.tmp"
# Check to see if there have been any actual changes.
if [ ! -f "${CACHEFILE}" ]; then
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/cc92df3810d3bbff1a42a68859c704106c7078a1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161121/702b434e/attachment.html>
More information about the vc
mailing list