• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -e
2# Copyright (C) 2022 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#       http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16# Script used as --workspace_status_command.
17# Must execute at the root of workspace.
18# https://docs.bazel.build/versions/main/command-line-reference.html#flag--workspace_status_command
19
20if [[ ! -f "WORKSPACE" ]]; then
21    echo "ERROR: gen_build_number.sh must be executed at the root of Bazel workspace." >&2
22    exit 1
23fi
24
25# TODO(b/228463719): figure out how to get the path properly.
26BUILD_NUMBER_FILE=out/soong/build_number.txt
27if [[ -f ${BUILD_NUMBER_FILE} ]]; then
28    BUILD_NUMBER=$(cat ${BUILD_NUMBER_FILE})
29else
30    BUILD_NUMBER=eng.${USER:0:6}.$(date '+%Y%m%d.%H%M%S')
31fi
32
33echo "BUILD_NUMBER ${BUILD_NUMBER}"