From 68b6f20ff3b3670108a217a5c5a61644789df0e4 Mon Sep 17 00:00:00 2001 From: Kylie C Date: Mon, 11 Aug 2025 21:33:21 -0400 Subject: [PATCH] cmake script & ci cleanup use a cmake script to downoad SDL3 sources for aar building --- .github/workflows/ci.yml | 13 +++++-------- CMakeLists.txt | 9 +-------- android-project/app/build.gradle | 8 ++++---- android-project/downloadSDL3.cmake | 13 +++++++++++++ 4 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 android-project/downloadSDL3.cmake diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46bacbf5..9b2f0999 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,6 @@ jobs: - { name: 'Nintendo 3DS', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, n3ds: true, werror: true, clang-tidy: false, container: 'devkitpro/devkitarm:latest', cmake-args: '-DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/3DS.cmake' } - { name: 'Xbox One', os: 'windows-latest', generator: 'Visual Studio 17 2022', dx5: false, config: false, msvc: true, werror: false, clang-tidy: false, vc-arch: 'amd64', cmake-args: '-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.26100.0', xbox-one: true} - { name: 'Android', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, android: true, werror: true, clang-tidy: false,} - - { name: 'Android (Debug)', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, android: true, werror: true, clang-tidy: false, debug: true } steps: - name: Setup vcvars if: ${{ !!matrix.msvc }} @@ -83,7 +82,7 @@ jobs: chmod a+x /opt/devkitpro/tools/bin/makerom - name: Install Linux dependencies (apt-get) - if: ${{ matrix.linux || matrix.android }} + if: ${{ matrix.linux }} run: | sudo apt-get update sudo apt-get install -y \ @@ -124,14 +123,14 @@ jobs: if: ${{ matrix.android }} run: | cd android-project && \ - ./gradlew assemble${{ matrix.debug == 'true' && 'Debug' || 'Release' }} \ + ./gradlew assembleRelease \ --info \ -PcmakeArgs="-DCMAKE_BUILD_TYPE=Release -DISLE_USE_DX5=${{ !!matrix.dx5 }} \ -DISLE_BUILD_CONFIG=${{ !!matrix.config }} \ -DENABLE_CLANG_TIDY=${{ !!matrix.clang-tidy }} \ -DISLE_WERROR=${{ !!matrix.werror }} \ - -DISLE_DEBUG=${{ matrix.debug || 'OFF' }} \ + -DISLE_DEBUG=OFF \ -Werror=dev" - name: Configure (CMake) @@ -205,10 +204,8 @@ jobs: - name: Package (Android) if: ${{ matrix.android }} run: | - cd build - mkdir -p dist - find ../ -name '*.apk' - mv ../android-project/app/build/outputs/apk/*/*.apk dist/ + mkdir -p build/dist + mv android-project/app/build/outputs/apk/*/*.apk build/dist/ - name: Package Assets Separately if: matrix.build-assets diff --git a/CMakeLists.txt b/CMakeLists.txt index b887ccdb..6e564a9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,6 @@ cmake_dependent_option(ISLE_COMPILE_SHADERS "Compile shaders" ON "SDL_SHADERCROS option(CMAKE_POSITION_INDEPENDENT_CODE "Build with -fPIC" ON) option(ENABLE_CLANG_TIDY "Enable clang-tidy") option(DOWNLOAD_DEPENDENCIES "Download dependencies" ON) -option(ANDROID_SDL "Download SDL for Android Archive" OFF) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" CACHE PATH "Directory where to put executables and dll") set(ISLE_EMSCRIPTEN_HOST "" CACHE STRING "Host URL for Emscripten streaming (e.g., https://test.com)") cmake_dependent_option(BUILD_SHARED_LIBS "Build lego1 as a shared library" ON "NOT EMSCRIPTEN" OFF) @@ -68,9 +67,7 @@ message(STATUS "Isle extensions: ${ISLE_EXTENSIONS}") message(STATUS "Isle debugging: ${ISLE_DEBUG}") message(STATUS "Compile shaders: ${ISLE_COMPILE_SHADERS}") -if (NOT ANDROID_SDL) - add_library(Isle::iniparser INTERFACE IMPORTED) -endif() +add_library(Isle::iniparser INTERFACE IMPORTED) if (DOWNLOAD_DEPENDENCIES) # FetchContent downloads and configures dependencies @@ -93,10 +90,6 @@ if (DOWNLOAD_DEPENDENCIES) endif() FetchContent_MakeAvailable(SDL3) - if (ANDROID_SDL) - return() - endif() - FetchContent_Declare( iniparser GIT_REPOSITORY "https://gitlab.com/iniparser/iniparser.git" diff --git a/android-project/app/build.gradle b/android-project/app/build.gradle index 2e3e4a00..e57dd49d 100644 --- a/android-project/app/build.gradle +++ b/android-project/app/build.gradle @@ -15,7 +15,7 @@ android { externalNativeBuild { cmake { - arguments '-DANDROID_STL=c++_shared', "-DFETCHCONTENT_BASE_DIR=${projectDir.parentFile.parentFile}/build/_deps" + arguments '-DANDROID_STL=c++_shared', "-DFETCHCONTENT_BASE_DIR=${projectDir.parentFile}/build/_deps" if (project.hasProperty('cmakeArgs')) { project.cmakeArgs.split(" ").each {arg -> arguments arg} } @@ -48,9 +48,9 @@ android { } tasks.register('compileSDL3AndroidArchive', Exec) { - def rootDir = projectDir.parentFile.parentFile + def rootDir = projectDir.parentFile def sdl3Dir = "build/_deps/sdl3-src" - def cmakeCommand = "cmake -B build -DANDROID_SDL=TRUE" + def cmakeCommand = "cmake -P downloadSDL3.cmake" def pythonCommand = "python3 ${sdl3Dir}/build-scripts/build-release.py " + "--actions android " + "--fast " + @@ -62,5 +62,5 @@ tasks.register('compileSDL3AndroidArchive', Exec) { } dependencies { - implementation files('libs/SDL3.aar').builtBy(downloadSDL3AndroidArchive) + implementation files('libs/SDL3.aar').builtBy(compileSDL3AndroidArchive) } diff --git a/android-project/downloadSDL3.cmake b/android-project/downloadSDL3.cmake new file mode 100644 index 00000000..77479e86 --- /dev/null +++ b/android-project/downloadSDL3.cmake @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.25...4.0 FATAL_ERROR) + +include(FetchContent) + +set(FETCHCONTENT_BASE_DIR "build/_deps") + +FetchContent_Populate( + SDL3 + GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git" + GIT_TAG "main" + SOURCE_DIR "build/_deps/sdl3-src" + BINARY_DIR "build/_deps/sdl3-build" +)