1*c8dee2aaSAndroid Build Coastguard Worker#!/bin/bash -e 2*c8dee2aaSAndroid Build Coastguard Worker 3*c8dee2aaSAndroid Build Coastguard Worker# Copyright 2023 Google LLC 4*c8dee2aaSAndroid Build Coastguard Worker# 5*c8dee2aaSAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be 6*c8dee2aaSAndroid Build Coastguard Worker# found in the LICENSE file. 7*c8dee2aaSAndroid Build Coastguard Worker 8*c8dee2aaSAndroid Build Coastguard Worker# Write the SKIA_VERSION to a JavaScript file. 9*c8dee2aaSAndroid Build Coastguard Worker 10*c8dee2aaSAndroid Build Coastguard Workerif [ "$1" == "" ] 11*c8dee2aaSAndroid Build Coastguard Workerthen 12*c8dee2aaSAndroid Build Coastguard Worker echo "Must supply output version.js file path." >&2 13*c8dee2aaSAndroid Build Coastguard Worker exit 1 14*c8dee2aaSAndroid Build Coastguard Workerfi 15*c8dee2aaSAndroid Build Coastguard Worker 16*c8dee2aaSAndroid Build Coastguard WorkerGIT="git" 17*c8dee2aaSAndroid Build Coastguard Workerif test -f "/cipd/bin/git"; then 18*c8dee2aaSAndroid Build Coastguard Worker # The `cd` Docker image includes git at this location. If present use it. 19*c8dee2aaSAndroid Build Coastguard Worker # This image us used when building this target via Louhi. 20*c8dee2aaSAndroid Build Coastguard Worker GIT="/cipd/bin/git" 21*c8dee2aaSAndroid Build Coastguard Workerfi 22*c8dee2aaSAndroid Build Coastguard Worker 23*c8dee2aaSAndroid Build Coastguard WorkerSCRIPT_DIR=$(dirname $(realpath $0)) 24*c8dee2aaSAndroid Build Coastguard WorkerVERSION_JS_PATH=$1 25*c8dee2aaSAndroid Build Coastguard WorkerGIT_REVISION=$($GIT -C ${SCRIPT_DIR} rev-parse HEAD) 26*c8dee2aaSAndroid Build Coastguard WorkerOUTPUT_DIR=$(dirname ${VERSION_JS_PATH}) 27*c8dee2aaSAndroid Build Coastguard Worker 28*c8dee2aaSAndroid Build Coastguard Workermkdir -p $(dirname ${VERSION_JS_PATH}) 29*c8dee2aaSAndroid Build Coastguard Workerecho "const SKIA_VERSION = '${GIT_REVISION}';" > ${VERSION_JS_PATH} 30