xref: /aosp_15_r20/external/swiftshader/third_party/update-spirvtools.sh (revision 03ce13f70fcc45d86ee91b7ee4cab1936a95046e)
1*03ce13f7SAndroid Build Coastguard Worker#!/bin/bash
2*03ce13f7SAndroid Build Coastguard Worker
3*03ce13f7SAndroid Build Coastguard Worker# update-spirvtools merges the latest changes from
4*03ce13f7SAndroid Build Coastguard Worker# the github.com/KhronosGroup/SPIRV-Tools into third_party/SPIRV-Tools.
5*03ce13f7SAndroid Build Coastguard Worker# This script copies the change descriptions from the squash change into the
6*03ce13f7SAndroid Build Coastguard Worker# top merge change, along with a standardized description.
7*03ce13f7SAndroid Build Coastguard WorkerREASON=$1
8*03ce13f7SAndroid Build Coastguard Worker
9*03ce13f7SAndroid Build Coastguard Workerif [ ! -z "$REASON" ]; then
10*03ce13f7SAndroid Build Coastguard Worker  REASON="\n$REASON\n"
11*03ce13f7SAndroid Build Coastguard Workerfi
12*03ce13f7SAndroid Build Coastguard Worker
13*03ce13f7SAndroid Build Coastguard WorkerTHIRD_PARTY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"
14*03ce13f7SAndroid Build Coastguard Worker
15*03ce13f7SAndroid Build Coastguard WorkerGIT_RESULT=`git subtree pull --prefix third_party/SPIRV-Tools https://github.com/KhronosGroup/SPIRV-Tools main --squash -m "Update SPIR-V Tools"`
16*03ce13f7SAndroid Build Coastguard Workerif [[ $GIT_RESULT == *"CONFLICT"* ]]; then
17*03ce13f7SAndroid Build Coastguard Worker  echo "subtree pull resulted in conflicts. Atempting to automatically resolve..."
18*03ce13f7SAndroid Build Coastguard Worker  # CONFLICT is very likely due to Android.mk being deleted in our third_party.
19*03ce13f7SAndroid Build Coastguard Worker  # Delete it, and try to continue.
20*03ce13f7SAndroid Build Coastguard Worker  git rm ${THIRD_PARTY_DIR}/SPIRV-Tools/Android.mk
21*03ce13f7SAndroid Build Coastguard Worker  git rm ${THIRD_PARTY_DIR}/SPIRV-Tools/android_test/Android.mk
22*03ce13f7SAndroid Build Coastguard Worker  git rm ${THIRD_PARTY_DIR}/SPIRV-Tools/android_test/jni/Application.mk
23*03ce13f7SAndroid Build Coastguard Worker  git -c core.editor=true merge --continue # '-c core.editor=true' prevents the editor from showing
24*03ce13f7SAndroid Build Coastguard Worker  if [ $? -ne 0 ]; then
25*03ce13f7SAndroid Build Coastguard Worker    echo "Could not automatically resolve conflicts."
26*03ce13f7SAndroid Build Coastguard Worker    exit 1
27*03ce13f7SAndroid Build Coastguard Worker  fi
28*03ce13f7SAndroid Build Coastguard Workerfi
29*03ce13f7SAndroid Build Coastguard Worker
30*03ce13f7SAndroid Build Coastguard Worker
31*03ce13f7SAndroid Build Coastguard WorkerALL_CHANGES=`git log -n 1 HEAD^2 | egrep '^(\s{4}[0-9a-f]{9}\s*.*)$'`
32*03ce13f7SAndroid Build Coastguard WorkerHEAD_CHANGE=`echo "$ALL_CHANGES" | egrep '[0-9a-f]{9}' -o -m 1`
33*03ce13f7SAndroid Build Coastguard WorkerLOG_MSG=`echo -e "Update SPIR-V Tools to $HEAD_CHANGE\n${REASON}\nChanges:\n$ALL_CHANGES\n\nCommands:\n    ./third_party/update-spirvtools.sh\n\nBug: b/123642959"`
34*03ce13f7SAndroid Build Coastguard Workergit commit --no-verify --amend -m "$LOG_MSG"
35*03ce13f7SAndroid Build Coastguard Worker
36*03ce13f7SAndroid Build Coastguard Worker# Use filter-branch to apply the Gerrit commit hook to both CLs
37*03ce13f7SAndroid Build Coastguard WorkerGIT_DIR=$(readlink -f "$(git rev-parse --git-dir)")
38*03ce13f7SAndroid Build Coastguard WorkerTMP_MSG="${GIT_DIR}/COMMIT_MSG_REWRITE"
39*03ce13f7SAndroid Build Coastguard WorkerFILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f --msg-filter \
40*03ce13f7SAndroid Build Coastguard Worker  "cat > ${TMP_MSG} && \"${GIT_DIR}/hooks/commit-msg\" ${TMP_MSG} && cat \"${TMP_MSG}\"" HEAD...HEAD~1
41*03ce13f7SAndroid Build Coastguard Workerrm -rf "${TMP_MSG}"
42