blob: e8dc548a9f24e47d6d780f19a199532009d49358 [file] [log] [blame]
Drew Macrae399af402021-11-01 18:15:09 +00001#!/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
16git_rev=$(git rev-parse HEAD)
17if [[ $? != 0 ]];
18then
19 exit 1
20fi
21echo "BUILD_SCM_REVISION ${git_rev}"
22
23git_version=$(git describe --always)
24if [[ $? != 0 ]];
25then
26 exit 1
27fi
28echo "BUILD_GIT_VERSION ${git_version}"
29
30git diff-index --quiet HEAD --
31if [[ $? == 0 ]];
32then
33 tree_status="clean"
34else
35 tree_status="modified"
36fi
37echo "BUILD_SCM_STATUS ${tree_status}"