xref: /llvm-project/libcxx/utils/ci/vendor/android/run-buildbot-container (revision d0c8e268c1ed9bbbd07be0efd93a91737c7bb1fe)
1#!/usr/bin/env bash
2
3# Similar to libcxx/utils/ci/run-buildbot-container, but adds additional options
4# needed for running Android tests.
5
6set -e
7
8MONOREPO_ROOT="$(git rev-parse --show-toplevel)"
9if [[ ! -d "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android" ]]; then
10    echo "Was unable to find the root of the LLVM monorepo; are you running from within the monorepo?"
11    exit 1
12fi
13
14DOCKER_OPTIONS=(-it)
15DOCKER_OPTIONS+=(--volume "${MONOREPO_ROOT}:/llvm")
16DOCKER_OPTIONS+=(--workdir "/llvm")
17DOCKER_OPTIONS+=(--cap-add=SYS_PTRACE)
18
19# Mount this volume to allow the main image to share its copy of the Android
20# platform tools with the emulator image, ensuring that the adb versions match.
21# This argument will create a new volume if it doesn't already exist.
22DOCKER_OPTIONS+=(--volume android-platform-tools:/mnt/android-platform-tools)
23
24# Pass through the Docker socket so that the buildbot can start a sibling
25# container running an Android emulator.
26if [ -S /var/run/docker.sock ]; then
27    DOCKER_OPTIONS+=(--volume /var/run/docker.sock:/var/run/docker.sock)
28fi
29
30docker run "${DOCKER_OPTIONS[@]}" ghcr.io/libcxx/android-buildkite-builder \
31    bash -c 'git config --global --add safe.directory /llvm; (/opt/android/container-setup.sh && exec bash)'
32