| 6 |
| # 1. remove stale libtlottie.a files, so a failed build can never leave a |
| 7 | # previous artifact looking up to date |
| 8 | # 2. build the tlottie Docker image |
| 9 | # 3. run it with the right mounts and platform pin |
| 10 | # |
| 11 | # Everything about *how* tlottie itself is compiled (rustc flags, profile, |
| 12 | # features, per-ABI loop) lives in scripts/tlottie/entrypoint.sh, which runs |
| 13 | # inside the container - see that file to change build settings. |
| 14 | # |
| 15 | # No environment variables are read - paths and settings are hardcoded |
| 16 | # below. Layout this script expects (relative to this file): |
| 17 | # arm64-v8a/, armeabi-v7a/, x86/, x86_64/ - output directories |
| 18 | # scripts/tlottie/Dockerfile - build environment for tlottie |
| 19 | # ../tlottie - tlottie source (sibling of |
| 20 | # this repo checkout) |
| 21 |
| 22 | set -eu |
| 23 |
| 24 | script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) |
| 25 | tlottie_dir=$(CDPATH= cd -- "$script_dir/../tlottie" && pwd) |
| 26 | dockerfile_dir="$script_dir/scripts/tlottie" |
| 27 | image_tag=tlottie-build |
| 28 | platform=linux/amd64 |
| 29 |
| 30 | if [ ! -f "$tlottie_dir/Cargo.toml" ]; then |
| 31 | echo "error: tlottie Cargo.toml not found at $tlottie_dir/Cargo.toml" >&2 |
| 32 | exit 1 |
| 33 | fi |
| 34 |
| 35 | echo "Removing previous tlottie archives" |
| 36 | for abi in arm64-v8a armeabi-v7a x86 x86_64; do |
| 37 | dest="$script_dir/$abi/libtlottie.a" |
| 38 | if [ -f "$dest" ]; then |
| 39 | rm -f "$dest" |
| 40 | echo " removed $dest" |
| 41 | fi |
| 42 | if [ ! -d "$script_dir/$abi" ]; then |
| 43 | echo "error: output directory does not exist: $script_dir/$abi" >&2 |
| 44 | exit 1 |
| 45 | fi |
| 46 | done |
| 47 |
| 48 | echo "Building tlottie build image ($platform)" |
| 49 | # Plain "docker build" already uses BuildKit (and loads the result into the |
| 50 | # local image store) on any reasonably current Docker install. Swap for |
| 51 | # "docker buildx build --load ..." if your setup needs an explicit builder. |
| 52 | docker build \ |
| 53 | --platform "$platform" \ |
| 54 | -t "$image_tag" \ |
| 55 | "$dockerfile_dir" |
| 56 |
| 57 | echo "Running tlottie build in container" |
| 58 | docker run --rm \ |
| 59 | --platform "$platform" \ |
| 60 | -v "$script_dir:/work" \ |
| 61 | -v "$tlottie_dir:/tlottie:ro" \ |
| 62 | -e HOST_UID="$(id -u)" \ |
| 63 | -e HOST_GID="$(id -g)" \ |
| 64 | "$image_tag" |
| 65 |
| 66 | echo "All tlottie Android archives are ready." |