Skip to content

Commit

Permalink
Merge pull request #30 from rpavlik/openxr-android
Browse files Browse the repository at this point in the history
Openxr android
  • Loading branch information
rpavlik authored Jul 14, 2023
2 parents 216c4e2 + 0249e72 commit 3718524
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 0 deletions.
1 change: 1 addition & 0 deletions build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ set -e
./build-one.sh openxr 20230614 "$@"
./build-one.sh openxr-sdk 20230614 "$@"
./build-one.sh openxr-pregenerated-sdk 202201 "$@"
./build-one.sh openxr-android 20230713 "$@"
)
50 changes: 50 additions & 0 deletions install-android-sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Copyright 2022-2023, Collabora, Ltd. and the Monado contributors
#
# SPDX-License-Identifier: BSL-1.0

# Partially inspired by https://about.gitlab.com/blog/2018/10/24/setting-up-gitlab-ci-for-android-projects/
# and based on https://gitlab.freedesktop.org/monado/monado/-/blob/9ad98815bbc291f96c092b7aad2943ad567d65b4/.gitlab-ci/install-android-sdk.sh

set -eo pipefail
# These normally come from the environment but we have defaults
ANDROID_CLI_TOOLS=${ANDROID_CLI_TOOLS:-9477386}
ANDROID_COMPILE_SDK=${ANDROID_COMPILE_SDK:-32}
ANDROID_BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-32.0.0}
ANDROID_NDK_VERSION=${ANDROID_NDK_VERSION:-25.2.9519653}
ANDROID_CMAKE_VERSION=${ANDROID_CMAKE_VERSION:-3.22.1}
ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT:-/opt/android-sdk}

mkdir -p "$ANDROID_SDK_ROOT"
FN=commandlinetools-linux-${ANDROID_CLI_TOOLS}_latest.zip
wget https://dl.google.com/android/repository/$FN
unzip "$FN" -d "$ANDROID_SDK_ROOT/extract"
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
mv "$ANDROID_SDK_ROOT/extract/cmdline-tools/" "$ANDROID_SDK_ROOT/cmdline-tools/latest/"
mv "$ANDROID_SDK_ROOT/extract/" "$ANDROID_SDK_ROOT/cmdline-tools/"

SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager

set +o pipefail
yes | $SDKMANAGER --licenses
set -o pipefail

echo "Installing the Android compile SDK platform android-${ANDROID_COMPILE_SDK}"
echo y | $SDKMANAGER "platforms;android-${ANDROID_COMPILE_SDK}" >> /dev/null

echo "Installing the latest Android platform tools"
echo y | $SDKMANAGER "platform-tools" >> /dev/null

echo "Installing the Android NDK ${ANDROID_NDK_VERSION}"
echo y | $SDKMANAGER "ndk;${ANDROID_NDK_VERSION}" >> /dev/null

echo "Installing CMake ${ANDROID_CMAKE_VERSION}"
echo y | $SDKMANAGER "cmake;${ANDROID_CMAKE_VERSION}" >> /dev/null

echo "Installing the Android 'patcher'"
echo y | $SDKMANAGER "patcher;v4" >> /dev/null

echo "Installing the Android build tools ${ANDROID_BUILD_TOOLS}"
echo y | $SDKMANAGER "build-tools;${ANDROID_BUILD_TOOLS}" >> /dev/null

rm -rf "${ANDROID_SDK_ROOT}/.temp" "${ANDROID_SDK_ROOT}/.knownPackages"
71 changes: 71 additions & 0 deletions openxr-android.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright (c) 2019-2023, The Khronos Group Inc.
#
# SPDX-License-Identifier: Apache-2.0

FROM debian:bookworm
LABEL maintainer="Ryan Pavlik <ryan.pavlik@collabora.com>"

ENV LANG C.UTF-8


RUN env DEBIAN_FRONTEND=noninteractive apt-get update -qq && \
env DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y -qq \
ca-certificates \
cmake \
default-jdk-headless \
git \
git-lfs \
glslang-tools \
gnupg \
gradle \
ninja-build \
p7zip-full \
pkg-config \
python3 \
python3-attr \
python3-jinja2 \
python3-lxml \
python3-networkx \
unzip \
wget \
zip \
&& apt-get clean

# Set up user and group 1000:1000 for most common usage case
RUN addgroup --gid 1000 --quiet openxr
RUN useradd --shell /bin/bash --create-home --no-log-init --uid 1000 --gid 1000 openxr

### Android SDK components

# This must match android.compileSdk in all Android build.gradle files
ENV ANDROID_COMPILE_SDK=29

# This must match android.buildToolsVersion in all Android build.gradle files
ENV ANDROID_BUILD_TOOLS=30.0.3

# look up on https://developer.android.com/studio/index.html#downloads when updating other versions
ENV ANDROID_CLI_TOOLS=9477386

ENV ANDROID_NDK_VERSION=21.4.7075529

ENV ANDROID_SDK_ROOT=/opt/android-sdk

COPY install-android-sdk.sh /install-android-sdk.sh
RUN /install-android-sdk.sh

### Android NDK

ENV ANDROID_NDK_HOME=/opt/android-sdk/ndk/${ANDROID_NDK_VERSION}

# Switch to non-privileged user
USER openxr
WORKDIR /home/openxr

# Cache the gradle wrapper in the image
ENV CACHED_GRADLE_WRAPPER_VERSION=7.5
RUN mkdir -p temp_proj && \
cd temp_proj && \
gradle -Porg.gradle.daemon=false init && \
gradle -Porg.gradle.daemon=false wrapper --gradle-version=${CACHED_GRADLE_WRAPPER_VERSION} && \
cd .. && \
rm -rf temp_proj

0 comments on commit 3718524

Please sign in to comment.