Drew Macrae | 399af40 | 2021-11-01 18:15:09 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright lowRISC contributors. |
| 3 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | |
| 6 | # This script will be run by bazel when the build process wants to generate |
| 7 | # information about the status of the workspace. |
| 8 | # |
| 9 | # The output will be key-value pairs in the form: |
| 10 | # KEY1 VALUE1 |
| 11 | # KEY2 VALUE2 |
| 12 | # |
| 13 | # If this script exits with a non-zero exit code, it's considered as a failure |
| 14 | # and the output will be discarded. |
| 15 | |
| 16 | git_rev=$(git rev-parse HEAD) |
| 17 | if [[ $? != 0 ]]; |
| 18 | then |
| 19 | exit 1 |
| 20 | fi |
| 21 | echo "BUILD_SCM_REVISION ${git_rev}" |
| 22 | |
| 23 | git_version=$(git describe --always) |
| 24 | if [[ $? != 0 ]]; |
| 25 | then |
| 26 | exit 1 |
| 27 | fi |
| 28 | echo "BUILD_GIT_VERSION ${git_version}" |
| 29 | |
| 30 | git diff-index --quiet HEAD -- |
| 31 | if [[ $? == 0 ]]; |
| 32 | then |
| 33 | tree_status="clean" |
| 34 | else |
| 35 | tree_status="modified" |
| 36 | fi |
| 37 | echo "BUILD_SCM_STATUS ${tree_status}" |