• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2# Copyright (c) 2025 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15set -e
16
17# arg1 - path to panda_root
18function git_hash() {
19    if git --version &> /dev/null ; then
20        if git -C "$1" rev-parse &> /dev/null ; then
21            echo $(git -C "$1" rev-parse HEAD)
22        else
23            echo ""
24        fi
25    else
26        echo ""
27    fi
28}
29
30if [ $# -ne 3 ]; then
31    echo "Unvalid arguments"
32    echo "Usage: make_version_file.sh <git root dir> <input file> <output file>"
33    exit 1
34fi
35
36ROOT_DIR=$1
37INPUT=$2
38OUTPUT=$3
39HASH=$(git_hash "$ROOT_DIR")
40
41if [ -z "$HASH" ]; then
42    python3 "$ROOT_DIR/gn/build/cmake_configure_file.py" "$INPUT" "$OUTPUT"
43else
44    python3 "$ROOT_DIR/gn/build/cmake_configure_file.py" "$INPUT" "$OUTPUT" "ARK_VERSION_GIT_HASH=$HASH"
45fi
46