Files
DroidDeck/tools/seed_worktree.sh
T
Kurt Himebauch 95aab3703f fix(build): helper script edits no longer invalidate the prepared runtime, and every build uses CI's NDK (#3116)
* fix(build): helper script edits no longer invalidate the prepared runtime, and every build uses CI's NDK

* docs(agents): helper script edits no longer need build_local.sh
2026-11-23 21:55:27 -05:00

47 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
repo_root=$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
common=$(git -C "${repo_root}" rev-parse --path-format=absolute --git-common-dir)
main_root=$(dirname "${common}")
[[ "${main_root}" != "${repo_root}" && -d "${main_root}/app/build" ]] || exit 0
paths=(
app/build/prepared-assets app/build/runtime-inputs.json app/build/runtimeAssets
app/build/packs app/build/localPackAssets app/build/packs-local-aside app/build/quest-inputs
app/build/rustJniLibs app/build/vkbridgeJniLibs
app/src/main/assets/directaudio app/src/main/assets/droiddeck-esync app/src/main/assets/linuxfs
app/src/main/assets/desktop-removal app/src/main/assets/hybris
app/src/main/jniLibs/arm64-v8a
app/src/main/rust/stores/target
)
for path in "${paths[@]}"; do
[[ -e "${main_root}/${path}" ]] || continue
if [[ -d "${main_root}/${path}" ]]; then
if [[ -n "$(ls -A "${repo_root}/${path}" 2>/dev/null)" ]]; then
# A directory holding only tracked files (jniLibs) still lacks every built library.
[[ -z "$(git -C "${repo_root}" ls-files --others -- "${path}")" ]] || continue
cp -Rn "${main_root}/${path}/." "${repo_root}/${path}/"
continue
fi
mkdir -p "$(dirname "${repo_root}/${path}")"
staged=$(mktemp -d "${repo_root}/${path}.seed.XXXXXX")
trap 'rm -rf "${staged}"' EXIT
cp -R "${main_root}/${path}/." "${staged}/"
if [[ -d "${repo_root}/${path}" ]] && ! rmdir "${repo_root}/${path}" 2>/dev/null; then
rm -rf "${staged}"; trap - EXIT; continue
fi
if [[ -e "${repo_root}/${path}" ]]; then
rm -rf "${staged}"; trap - EXIT; continue
fi
mv "${staged}" "${repo_root}/${path}"
trap - EXIT
elif [[ ! -e "${repo_root}/${path}" ]]; then
mkdir -p "$(dirname "${repo_root}/${path}")"
staged=$(mktemp "${repo_root}/${path}.seed.XXXXXX")
trap 'rm -f "${staged}"' EXIT
cp "${main_root}/${path}" "${staged}"
mv "${staged}" "${repo_root}/${path}"
trap - EXIT
fi
done