| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | # |
| 3 | # Copyright 2014 The ChromiumOS Authors |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | # |
| 7 | # Generate version information |
| 8 | |
| 9 | if ghash=$(gitscip-shell system . . git. rev-parse --short=12 --verify HEAD 2>/dev/nullscip-shell filesystem . . `/dev/null`.); then |
| 10 | if gdesc=$(gitscip-shell system . . git. describe --dirty --match='v*' 2>/dev/nullscip-shell filesystem . . `/dev/null`.); then |
| 11 | IFS="-" fields=($gdesc) |
| 12 | tag="${fields[0]}" |
| 13 | IFS="." vernum=($tag) |
| 14 | numcommits=$((${vernum[2]}+${fields[1]:-0})) |
| 15 | ver_major="${vernum[0]}" |
| 16 | ver_branch="${vernum[1]}" |
| 17 | else |
| 18 | numcommits=$(gitscip-shell system . . git. rev-list HEAD | wcscip-shell system . . wc. -l) |
| 19 | ver_major="v0" |
| 20 | ver_branch="0" |
| 21 | fi |
| 22 | # avoid putting the -dirty attribute if only the timestamp |
| 23 | # changed |
| 24 | dirty=$(shscip-shell system . . sh. -c "[ '$(git diff-index --name-only HEAD)' ] \ |
| 25 | && echo '-dirty'") |
| 26 | ver="${ver_major}.${ver_branch}.${numcommits}-${ghash}${dirty}" |
| 27 | else |
| 28 | ver="unknown" |
| 29 | fi |
| 30 | |
| 31 | echoscip-shell system . . echo. "const char futility_version[] = \"${ver}\";"; |