Debian Codegraph @

cmake/tribits/doc/utils/gen_doc_utils.sh

raw
1 #
2 # Bash utility functions for generation of documentation.
3 #
4
5
6 #
7 # Copy a file from temp if it has changed.
8 #
9 # Usage:
10 #
11 # $ update_if_different <base_file_name> <tmpext>
12 #
13 # This function will copy from:
14 #
15 # <base_file_name>.<tmpext>
16 #
17 # to:
18 #
19 # <base_file_name>
20 #
21 # if <base_file_name>.<tmpext> diffs with <base_file_name>. This is used
22 # avoid triggering a change in the timestamp of the file <base_file_name>.
23 #
24 # This isused to create *.tmp files and then we only copy to the files
25 # actually mentioned in the Makefile if they are different. That way if the
26 # files don't change then the function will not copy over them and update
27 # their time stamp and the makefile will not rebuild the documentation. We
28 # don't want to rebuild documentation if nothing changed.
29 #
30 function update_if_different {
31 base_file_name=$1
32 tmpext=$2
33 if [ -e $base_file_name ] ; then
34 changes=`diff $base_file_name.$tmpext $base_file_name`
35 if [ "$changes" != "" ] ; then
36 echo "Copy updated file $base_file_name"
37 cp $base_file_name.$tmpext $base_file_name
38 fi
39 else
40 echo "Copy to non-existing file $base_file_name"
41 cp $base_file_name.$tmpext $base_file_name
42 fi
43 }
44
45
46 function generate_git_version_file {
47
48 _TRIBITS_TAG_PREFIX=`cat ../../../tribits_tag_prefix.txt`
49
50 if [ -e ../../../.git ] ; then
51 echo
52 echo "Generating git version"
53 echo
54 git describe --always --match="$_TRIBITS_TAG_PREFIX*" > TribitsGitVersion.txt || \
55 echo "$_TRIBITS_TAG_PREFIX.{Unknown version}" > TribitsGitVersion.txt
56 else
57 echo "$_TRIBITS_TAG_PREFIX.{Unknown version}" > TribitsGitVersion.txt
58 fi
59
60 }