Skip to content

Commit

Permalink
Update Android_Build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishan09811 authored Dec 29, 2024
1 parent 304f2c9 commit 597b016
Showing 1 changed file with 24 additions and 31 deletions.
55 changes: 24 additions & 31 deletions .github/workflows/Android_Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,26 @@ jobs:

steps:
- name: Set BUILD_TYPE variable
run: echo "BUILD_TYPE=${{ matrix.build_type }}" >> $GITHUB_ENV
run: |
echo "BUILD_TYPE=${{ matrix.build_type }}" >> $GITHUB_ENV
git diff --exit-code --quiet -- '*.cpp' '*.h' '*.hpp' || echo "CODE_CHANGED=true" >> $GITHUB_ENV
git diff --exit-code --quiet -- submodule || echo "CODE_CHANGED=true" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Fetch submodules
run: git submodule update --init --recursive

- name: Check if code has changed
id: code_changed
run: |
# Check for changes in .cpp, .h, .hpp files or submodules
git diff --exit-code --quiet -- '*.cpp' '*.h' '*.hpp' || echo "Code changed" >> $GITHUB_ENV
git diff --exit-code --quiet -- submodule || echo "Submodules changed" >> $GITHUB_ENV
- name: Set up gradle caches
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/src/pandroid/app/src/main/jniLibs/x86_64/libAlber.so
key: ${{ runner.os }}-pandroid-x86_64-${{ github.sha }}
restore-keys: |
${{ runner.os }}-pandroid-x86_64-
- name: Cache libAlber.so (x86_64)
uses: actions/cache@v4
with:
path: ./src/pandroid/app/src/main/jniLibs/x86_64/libAlber.so
key: ${{ runner.os }}-pandroid-x86_64-libAlber-${{ github.sha }}
restore-keys: |
${{ runner.os }}-pandroid-x86_64-libAlber-
- name: Setup Vulkan SDK
uses: humbletim/[email protected]
with:
Expand All @@ -62,25 +51,29 @@ jobs:
java-version: '17'

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DBUILD_HYDRA_CORE=1 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -DANDROID_ABI=x86_64 -DENABLE_VULKAN=0 -DENABLE_USER_BUILD=ON
run: |
if [[ "${{ env.CODE_CHANGED }}" != "true" ]] || [ ! -f "./src/pandroid/app/src/main/jniLibs/x86_64/libAlber.so" ]; then
echo "Code changed, rebuilding from scratch..."
cmake -B ${{github.workspace}}/build -DBUILD_HYDRA_CORE=1 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -DANDROID_ABI=x86_64 -DENABLE_VULKAN=0 -DENABLE_USER_BUILD=ON
fi
- name: Build
run: |
# Apply patch for GLES compatibility
git apply ./.github/gles.patch
# Skip using the cache if code has changed
if [[ "${{ env.CODE_CHANGED }}" == "true" ]]; then
echo "Code changed, rebuilding from scratch..."
if [[ "${{ env.CODE_CHANGED }}" == "true" ]] || [ -f "./src/pandroid/app/src/main/jniLibs/x86_64/libAlber.so" ]; then
rm -f ./src/pandroid/app/src/main/jniLibs/x86_64/libAlber.so
fi
# Build the project with CMake
cmake --build ${{github.workspace}}/build --config ${{ env.BUILD_TYPE }}
if [[ "${{ env.CODE_CHANGED }}" != "true" ]] || [ ! -f "./src/pandroid/app/src/main/jniLibs/x86_64/libAlber.so" ]; then
# Apply patch for GLES compatibility
git apply ./.github/gles.patch
# Build the project with CMake
cmake --build ${{github.workspace}}/build --config ${{ env.BUILD_TYPE }}
# Strip the generated library and move it to the appropriate location
${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip --strip-unneeded ./build/libAlber.so
mv ./build/libAlber.so ./src/pandroid/app/src/main/jniLibs/x86_64/
# Strip the generated library and move it to the appropriate location
${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip --strip-unneeded ./build/libAlber.so
mv ./build/libAlber.so ./src/pandroid/app/src/main/jniLibs/x86_64/
fi
# Build the Android app with Gradle
cd src/pandroid
Expand All @@ -106,8 +99,8 @@ jobs:
- name: Set BUILD_TYPE variable
run: |
echo "BUILD_TYPE=${{ matrix.build_type }}" >> $GITHUB_ENV
git diff --exit-code --quiet -- '*.cpp' '*.h' '*.hpp' || echo "Code changed" >> $GITHUB_ENV
git diff --exit-code --quiet -- submodule || echo "Submodules changed" >> $GITHUB_ENV
git diff --exit-code --quiet -- '*.cpp' '*.h' '*.hpp' || echo "CODE_CHANGED=true" >> $GITHUB_ENV
git diff --exit-code --quiet -- submodule || echo "CODE_CHANGED=true" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Fetch submodules
Expand Down Expand Up @@ -140,7 +133,7 @@ jobs:

- name: Configure CMake
run: |
if [[ "${{ env.CODE_CHANGED }}" != "true" ]]; then
if [[ "${{ env.CODE_CHANGED }}" != "true" ]] || [ ! -f "./src/pandroid/app/src/main/jniLibs/arm64-v8a/libAlber.so" ]; then
echo "Code changed, rebuilding from scratch..."
cmake -B ${{github.workspace}}/build -DBUILD_HYDRA_CORE=1 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DENABLE_VULKAN=0 -DENABLE_USER_BUILD=ON -DCMAKE_CXX_FLAGS="-march=armv8-a+crypto"
fi
Expand All @@ -152,7 +145,7 @@ jobs:
rm -f ./src/pandroid/app/src/main/jniLibs/arm64-v8a/libAlber.so
fi
if [[ "${{ env.CODE_CHANGED }}" != "true" ]]; then
if [[ "${{ env.CODE_CHANGED }}" != "true" ]] || [ ! -f "./src/pandroid/app/src/main/jniLibs/arm64-v8a/libAlber.so" ]; then
# Apply patch for GLES compatibility
git apply ./.github/gles.patch
Expand Down

0 comments on commit 597b016

Please sign in to comment.