Skip to content

Commit

Permalink
Add Android images (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meakk authored Jan 30, 2025
1 parent b448ee0 commit c0f08a1
Show file tree
Hide file tree
Showing 3 changed files with 277 additions and 6 deletions.
50 changes: 44 additions & 6 deletions .github/workflows/build_docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
- main
workflow_dispatch:

env:
VTK_SHA: 1ab19927725cb4b86af8afaf255ed0ffc9fc913a

jobs:

build_f3d-ci:
Expand All @@ -26,7 +29,7 @@ jobs:
with:
push: ${{ github.ref == 'refs/heads/main' }}
tags: ghcr.io/f3d-app/f3d-ci:latest
file: ci/Dockerfile
context: "{{defaultContext}}:ci"

build_f3d-wasm:
runs-on: ubuntu-latest
Expand All @@ -43,14 +46,49 @@ jobs:
uses: docker/build-push-action@v6
with:
push: ${{ github.ref == 'refs/heads/main' }}
tags: ghcr.io/f3d-app/f3d-wasm:latest
file: webassembly/Dockerfile
tags: ghcr.io/f3d-app/f3d-wasm:${{ env.VTK_SHA }}
context: "{{defaultContext}}:webassembly"
build-args: |
CMAKE_BUILD_PARALLEL_LEVEL=4
ASSIMP_VERSION=v5.4.2
DRACO_VERSION=1.5.7
OCCT_VERSION=V7_8_1
VTK_VERSION=${{ env.VTK_SHA }}
build_f3d-android:
strategy:
fail-fast: false
matrix:
arch: [armeabi-v7a, arm64-v8a, x86, x86_64]

runs-on: ubuntu-latest
steps:

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
push: ${{ github.ref == 'refs/heads/main' }}
tags: ghcr.io/f3d-app/f3d-android-${{ matrix.arch }}:${{ env.VTK_SHA }}
context: "{{defaultContext}}:android"
build-args: |
ANDROID_API=34
ANDROID_ARCH=${{ matrix.arch }}
ANDROID_NDK=r26b
CMAKE_BUILD_PARALLEL_LEVEL=4
ALEMBIC_VERSION=1.8.8
ASSIMP_VERSION=v5.4.2
DRACO_VERSION=1.5.7
IMATH_VERSION=v3.1.12
OCCT_VERSION=V7_8_1
VTK_VERSION=6a898fd91da30d3ff903416bf856f0d1cea82cdf
OPENEXR_VERSION=v3.3.2
VTK_VERSION=${{ env.VTK_SHA }}
build_f3d-superbuild-ci:
runs-on: ubuntu-latest
Expand All @@ -68,7 +106,7 @@ jobs:
with:
push: ${{ github.ref == 'refs/heads/main' }}
tags: ghcr.io/f3d-app/f3d-superbuild-ci:latest
file: superbuild/Dockerfile
context: "{{defaultContext}}:superbuild"

build_f3d-wheels-manylinux-ci:
runs-on: ubuntu-latest
Expand All @@ -87,4 +125,4 @@ jobs:
with:
push: ${{ github.ref == 'refs/heads/main' }}
tags: ghcr.io/f3d-app/f3d-wheels-manylinux-ci:latest
file: wheels-manylinux/Dockerfile
context: "{{defaultContext}}:wheels-manylinux"
225 changes: 225 additions & 0 deletions android/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
FROM ubuntu:24.04 AS base

ARG CMAKE_BUILD_PARALLEL_LEVEL=8
ENV CMAKE_BUILD_PARALLEL_LEVEL=$CMAKE_BUILD_PARALLEL_LEVEL

ARG ANDROID_NDK
RUN [ -n "$ANDROID_NDK" ]

ARG ANDROID_API
RUN [ -n "$ANDROID_API" ]
ENV ANDROID_API=$ANDROID_API

ARG ANDROID_ARCH
RUN [ -n "$ANDROID_ARCH" ]
ENV ANDROID_ARCH=$ANDROID_ARCH

# Install generic compilation tools
RUN apt update && apt install -y \
build-essential \
cmake \
default-jdk \
git \
unzip \
wget

# Install NDK
RUN wget https://dl.google.com/android/repository/android-ndk-$ANDROID_NDK-linux.zip
RUN unzip -qq android-ndk-$ANDROID_NDK-linux.zip && rm -rf android-ndk-$ANDROID_NDK-linux.zip
RUN mv android-ndk-$ANDROID_NDK /ndk

# Copy toolchain
COPY android-toolchain.cmake /

######################################
# IMath
######################################
FROM base AS imath

ARG IMATH_VERSION
RUN [ -n "$IMATH_VERSION" ]

ADD https://github.com/AcademySoftwareFoundation/Imath/archive/refs/tags/$IMATH_VERSION.tar.gz /imath-src.tar.gz

RUN mkdir -p /imath-src && tar -xzf /imath-src.tar.gz -C /imath-src --strip-components 1 && rm -rf /imath-src.tar.gz

RUN cmake -S /imath-src -B /imath-build \
-DBUILD_TESTING=OFF \
-DBUILD_SHARED_LIBS==OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/android-toolchain.cmake \
-DCMAKE_INSTALL_PREFIX:PATH=/depends

RUN cmake --build /imath-build --target install && rm -rf /imath-src /imath-build

######################################
# Alembic
######################################
FROM imath AS alembic

ARG ALEMBIC_VERSION
RUN [ -n "$ALEMBIC_VERSION" ]

ADD https://github.com/alembic/alembic/archive/refs/tags/$ALEMBIC_VERSION.tar.gz /alembic-src.tar.gz

RUN mkdir -p /alembic-src && tar -xzf /alembic-src.tar.gz -C /alembic-src --strip-components 1 && rm -rf /alembic-src.tar.gz

RUN cmake -S /alembic-src -B /alembic-build \
-DALEMBIC_LIB_INSTALL_DIR=lib \
-DALEMBIC_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/android-toolchain.cmake \
-DCMAKE_INSTALL_PREFIX:PATH=/depends \
-DCMAKE_PREFIX_PATH:PATH=/depends \
-DUSE_BINARIES=OFF \
-DUSE_TESTS=OFF

RUN cmake --build /alembic-build --target install && rm -rf /alembic-src /alembic-build

######################################
# Assimp
######################################
FROM base AS assimp

ARG ASSIMP_VERSION
RUN [ -n "$ASSIMP_VERSION" ]

ADD https://github.com/assimp/assimp/archive/refs/tags/$ASSIMP_VERSION.tar.gz /assimp-src.tar.gz

RUN mkdir -p /assimp-src && tar -xzf /assimp-src.tar.gz -C /assimp-src --strip-components 1 && rm -rf /assimp-src.tar.gz

RUN cmake -S /assimp-src -B /assimp-build \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_TOOLCHAIN_FILE=/android-toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX:PATH=/depends \
-DASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT=OFF \
-DASSIMP_BUILD_ASSIMP_TOOLS=OFF \
-DASSIMP_BUILD_3MF_IMPORTER=ON \
-DASSIMP_BUILD_COLLADA_IMPORTER=ON \
-DASSIMP_BUILD_DXF_IMPORTER=ON \
-DASSIMP_BUILD_FBX_IMPORTER=ON \
-DASSIMP_BUILD_OFF_IMPORTER=ON \
-DASSIMP_BUILD_X_IMPORTER=ON \
-DASSIMP_BUILD_SAMPLES=OFF \
-DASSIMP_BUILD_TESTS=OFF \
-DASSIMP_BUILD_ZLIB=OFF \
-DASSIMP_NO_EXPORT=ON \
-DASSIMP_WARNINGS_AS_ERRORS=OFF

RUN cmake --build /assimp-build --target install && rm -rf /assimp-src /assimp-build

######################################
# OCCT
######################################
FROM base AS occt

ARG OCCT_VERSION
RUN [ -n "$OCCT_VERSION" ]

ADD https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/$OCCT_VERSION.tar.gz /occt-src.tar.gz

RUN mkdir -p /occt-src && tar -xzf /occt-src.tar.gz -C /occt-src --strip-components 1 && rm -rf /occt-src.tar.gz

RUN cmake -S /occt-src -B /occt-build \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_TOOLCHAIN_FILE=/android-toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX:PATH=/depends \
-DBUILD_ADDITIONAL_TOOLKITS="TKDESTEP;TKDEIGES;TKMesh;TKBinXCAF" \
-DBUILD_DOC_Overview=OFF \
-DBUILD_LIBRARY_TYPE=Static \
-DBUILD_MODULE_ApplicationFramework=OFF \
-DBUILD_MODULE_DETools=OFF \
-DBUILD_MODULE_DataExchange=OFF \
-DBUILD_MODULE_Draw=OFF \
-DBUILD_MODULE_FoundationClasses=OFF \
-DBUILD_MODULE_ModelingAlgorithms=OFF \
-DBUILD_MODULE_ModelingData=OFF \
-DBUILD_MODULE_Visualization=OFF \
-DUSE_FREETYPE=OFF

RUN cmake --build /occt-build --target install && rm -rf /occt-src /occt-build

######################################
# Draco
######################################
FROM base AS draco

ARG CMAKE_BUILD_PARALLEL_LEVEL=8
ARG DRACO_VERSION
RUN [ -n "$DRACO_VERSION" ]

ADD https://github.com/google/draco/archive/refs/tags/$DRACO_VERSION.tar.gz /draco-src.tar.gz

RUN mkdir -p /draco-src && tar -xzf /draco-src.tar.gz -C /draco-src --strip-components 1 && rm -rf /draco-src.tar.gz

RUN cmake -S /draco-src -B /draco-build \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_TOOLCHAIN_FILE=/android-toolchain.cmake \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX:PATH=/depends \
-DDRACO_BACKWARDS_COMPATIBILITY=OFF \
-DDRACO_JS_GLUE=OFF

RUN cmake --build /draco-build --target install && rm -rf /draco-src /draco-build

######################################
# OpenEXR
######################################
FROM imath AS openexr

ARG CMAKE_BUILD_PARALLEL_LEVEL=8
ARG OPENEXR_VERSION
RUN [ -n "$OPENEXR_VERSION" ]

ADD https://github.com/AcademySoftwareFoundation/openexr/archive/refs/tags/$OPENEXR_VERSION.tar.gz /openexr-src.tar.gz

RUN mkdir -p /openexr-src && tar -xzf /openexr-src.tar.gz -C /openexr-src --strip-components 1 && rm -rf /openexr-src.tar.gz

RUN cmake -S /openexr-src -B /openexr-build \
-DBUILD_TESTING=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_TOOLCHAIN_FILE=/android-toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX:PATH=/depends \
-DOPENEXR_BUILD_TOOLS=OFF \
-DOPENEXR_BUILD_EXAMPLES=OFF

RUN cmake --build /openexr-build --target install && rm -rf /openexr-src /openexr-build

######################################
# VTK
######################################
FROM base AS vtk

ARG VTK_VERSION
RUN [ -n "$VTK_VERSION" ]

ADD https://gitlab.kitware.com/vtk/vtk/-/archive/$VTK_VERSION/vtk-$VTK_VERSION.tar.gz /vtk-src.tar.gz

RUN mkdir -p /vtk-src && tar -xzf /vtk-src.tar.gz -C /vtk-src --strip-components 1 && rm -rf /vtk-src.tar.gz

RUN cmake -S /vtk-src -B /vtk-build \
-DANDROID_ARCH_ABI=$ANDROID_ARCH \
-DANDROID_NATIVE_API_LEVEL=$ANDROID_API \
-DANDROID_NDK=/ndk \
-DCMAKE_BUILD_TYPE=Release \
-DVTK_ANDROID_BUILD=ON

RUN cmake --build /vtk-build && rm -rf /vtk-src

######################################
# Copy artifacts from previous builds
######################################
FROM base

ENV CMAKE_TOOLCHAIN_FILE=/android-toolchain.cmake

COPY --from=alembic /depends /depends
COPY --from=assimp /depends /depends
COPY --from=draco /depends /depends
COPY --from=occt /depends /depends
COPY --from=openexr /depends /depends
COPY --from=vtk /vtk-build/CMakeExternals/Install/vtk-android /depends
8 changes: 8 additions & 0 deletions android/android-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-android-with-the-ndk
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION $ENV{ANDROID_API})

set(CMAKE_ANDROID_ARCH_ABI $ENV{ANDROID_ARCH})
set(CMAKE_ANDROID_NDK /ndk)

set(CMAKE_FIND_ROOT_PATH /depends)

0 comments on commit c0f08a1

Please sign in to comment.