-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added auto-detection of version string (via git).
Details: - Added build/update-version-file.sh script for auto-detecting "version" string and updating 'version' file accordingly. (If .git directory is not present, then it is assumed this copy of BLIS is a downloaded release, in which case 'version' file is left unchanged.) - Added invocation of update-version-file.sh to configure script.
- Loading branch information
Showing
4 changed files
with
186 additions
and
4 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,175 @@ | ||
#!/bin/bash | ||
# | ||
# BLIS | ||
# An object-based framework for developing high-performance BLAS-like | ||
# libraries. | ||
# | ||
# Copyright (C) 2012, The University of Texas | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are | ||
# met: | ||
# - Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# - Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# - Neither the name of The University of Texas nor the names of its | ||
# contributors may be used to endorse or promote products derived | ||
# from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
# | ||
|
||
# | ||
# update-version-file.sh | ||
# | ||
# Field G. Van Zee | ||
# | ||
|
||
|
||
print_usage() | ||
{ | ||
#local script_name | ||
|
||
# Get the script name | ||
#script_name=${0##*/} | ||
|
||
# Echo usage info | ||
echo " " | ||
echo " "$script_name | ||
echo " " | ||
echo " Field G. Van Zee" | ||
echo " " | ||
echo " Checks whether the current BLIS distribution is a git clone: if so," | ||
echo " it queries git to update the 'version' file with the latest version" | ||
echo " string; otherwise, leaves the contents of 'version' unchanged." | ||
echo " " | ||
echo " Usage:" | ||
echo " ${script_name} [options] versfile" | ||
echo " " | ||
echo " Arguments:" | ||
echo " " | ||
echo " versfile The file where the version string is stored. If versfile is" | ||
echo " is not specified, then it defaults to 'version'." | ||
echo " " | ||
echo " Options:" | ||
echo " " | ||
echo " -o SCRIPT output script name" | ||
echo " Use SCRIPT when outputting messages instead of the script's" | ||
echo " actual name." | ||
echo " " | ||
|
||
# Exit with non-zero exit status | ||
exit 1 | ||
} | ||
|
||
|
||
main() | ||
{ | ||
# -- BEGIN GLOBAL VARIABLE DECLARATIONS -- | ||
|
||
# The name of the script, stripped of any preceeding path. | ||
script_name=${0##*/} | ||
|
||
# The name of the default version file. | ||
version_file_def='version' | ||
|
||
# The name of the specified version file. | ||
version_file='' | ||
|
||
# Strings used during version query. | ||
git_describe_str='' | ||
new_version_str='' | ||
|
||
# The script name to use instead of the $0 when outputting messages. | ||
output_name='' | ||
|
||
# The git directory. | ||
gitdir='.git' | ||
|
||
# -- END GLOBAL VARIABLE DECLARATIONS -- | ||
|
||
|
||
# Process our command line options. | ||
while getopts ":ho:" opt; do | ||
case $opt in | ||
o ) output_name=$OPTARG ;; | ||
h ) print_usage ;; | ||
\? ) print_usage | ||
esac | ||
done | ||
shift $(($OPTIND - 1)) | ||
|
||
|
||
# If an output script name was given, overwrite script_name with it. | ||
if [ -n "${output_name}" ]; then | ||
|
||
script_name="${output_name}" | ||
fi | ||
|
||
|
||
echo "${script_name}: checking whether we need to update the version file." | ||
|
||
|
||
|
||
# Check the number of arguments after command line option processing. | ||
if [ $# = "0" ]; then | ||
|
||
version_file=${version_file_def} | ||
echo "${script_name}: not sure which version file to update; defaulting to '${version_file}'." | ||
|
||
elif [ $# = "1" ]; then | ||
|
||
version_file=$1 | ||
echo "${script_name}: checking version file '${version_file}'." | ||
|
||
else | ||
print_usage | ||
fi | ||
|
||
|
||
# Check if the .git dir exists; if it does not, we do nothing. | ||
if [ -d "${gitdir}" ]; then | ||
|
||
echo "${script_name}: found ${gitdir} directory; assuming git clone." | ||
|
||
echo "${script_name}: executing git describe --tags." | ||
|
||
# Query git for the version string, which is simply the current tag, | ||
# followed by a number signifying how many commits have transpired | ||
# since the tag, followed by a 'g' and a shortened hash tab. | ||
git_describe_str=$(git describe --tags) | ||
|
||
echo "${script_name}: got back ${git_describe_str}." | ||
|
||
# Strip off the commit hash label. | ||
new_version_str=$(echo ${git_describe_str} | cut -d- -f-2) | ||
|
||
echo "${script_name}: truncating to ${new_version_str}." | ||
echo "${script_name}: updating version file '${version_file}'." | ||
|
||
# Write the new version string to the version file. | ||
echo "${new_version_str}" > ${version_file} | ||
|
||
fi | ||
|
||
|
||
# Exit peacefully. | ||
return 0 | ||
} | ||
|
||
|
||
# The script's main entry point, passing all parameters given. | ||
main "$@" |
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 |
---|---|---|
@@ -1 +1 @@ | ||
0.1-alpha-0 | ||
0.0.0-1 |