mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 18:41:14 +00:00
dont cmake -> gradle -> cmake
This commit is contained in:
parent
bb0bbe397e
commit
efbe78e7d9
22
.github/workflows/ci.yml
vendored
22
.github/workflows/ci.yml
vendored
@ -47,8 +47,8 @@ jobs:
|
||||
- { name: 'Emscripten', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, emsdk: true, werror: true, clang-tidy: false, cmake-wrapper: 'emcmake' }
|
||||
- { 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, cmake-args: ' -DANDROID_NDK_PATH=$ANDROID_NDK_HOME' }
|
||||
- { name: 'Android (Debug)', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, android: true, werror: true, clang-tidy: false, debug: true, cmake-args: ' -DANDROID_NDK_PATH=$ANDROID_NDK_HOME' }
|
||||
- { 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 }}
|
||||
@ -118,9 +118,24 @@ jobs:
|
||||
if: ${{ matrix.android }}
|
||||
uses: android-actions/setup-android@v3
|
||||
with:
|
||||
packages: 'ndk;26.3.11579264 cmake;3.30.5'
|
||||
packages: 'cmake;3.30.5'
|
||||
|
||||
- name: Build (Android)
|
||||
if: ${{ matrix.android }}
|
||||
run: |
|
||||
cd android-project && \
|
||||
./gradlew assemble${{ matrix.debug == 'true' && 'Debug' || 'Release' }} \
|
||||
--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' }} \
|
||||
-Werror=dev"
|
||||
|
||||
- name: Configure (CMake)
|
||||
if: ${{ !matrix.android }}
|
||||
run: |
|
||||
${{ matrix.cmake-wrapper || '' }} cmake -S . -B build -G "${{ matrix.generator }}" \
|
||||
${{ matrix.cmake-args || '' }} \
|
||||
@ -134,6 +149,7 @@ jobs:
|
||||
-Werror=dev
|
||||
|
||||
- name: Build (CMake)
|
||||
if: ${{ !matrix.android }}
|
||||
run: cmake --build build --verbose --config Release
|
||||
|
||||
- name: Package (CPack)
|
||||
|
||||
@ -55,7 +55,7 @@ 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)
|
||||
set(ANDROID_NDK_PATH "" CACHE PATH "Path to Android NDK")
|
||||
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,13 +68,14 @@ message(STATUS "Isle extensions: ${ISLE_EXTENSIONS}")
|
||||
message(STATUS "Isle debugging: ${ISLE_DEBUG}")
|
||||
message(STATUS "Compile shaders: ${ISLE_COMPILE_SHADERS}")
|
||||
|
||||
add_library(Isle::iniparser INTERFACE IMPORTED)
|
||||
if (NOT ANDROID_SDL)
|
||||
add_library(Isle::iniparser INTERFACE IMPORTED)
|
||||
endif()
|
||||
|
||||
if (DOWNLOAD_DEPENDENCIES)
|
||||
# FetchContent downloads and configures dependencies
|
||||
message(STATUS "Fetching SDL3 and iniparser. This might take a while...")
|
||||
include(FetchContent)
|
||||
# FIXME: properly build and source the .aar
|
||||
if (WINDOWS_STORE)
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
@ -92,6 +93,10 @@ if (DOWNLOAD_DEPENDENCIES)
|
||||
endif()
|
||||
FetchContent_MakeAvailable(SDL3)
|
||||
|
||||
if (ANDROID_SDL)
|
||||
return()
|
||||
endif()
|
||||
|
||||
FetchContent_Declare(
|
||||
iniparser
|
||||
GIT_REPOSITORY "https://gitlab.com/iniparser/iniparser.git"
|
||||
@ -117,41 +122,6 @@ else()
|
||||
target_link_libraries(Isle::iniparser INTERFACE iniparser-shared)
|
||||
endif()
|
||||
|
||||
# Effectively use as a gate for running the Android build
|
||||
if (ANDROID_NDK_PATH)
|
||||
|
||||
FetchContent_GetProperties(SDL3)
|
||||
|
||||
set(SDL_ANDROID_ARCHIVE "${CMAKE_SOURCE_DIR}/android-project/app/libs/SDL3.aar")
|
||||
add_custom_command(OUTPUT "${SDL_ANDROID_ARCHIVE}"
|
||||
COMMAND ${Python3_EXECUTABLE} "${SDL3_SOURCE_DIR}/build-scripts/build-release.py"
|
||||
--actions android
|
||||
--fast
|
||||
--android-ndk-home=${ANDROID_NDK_PATH}
|
||||
--force
|
||||
--root="${SDL3_SOURCE_DIR}"
|
||||
COMMAND sh -c "cp ${sdl3_SOURCE_DIR}/build-android/SDL3-*.aar ${SDL_ANDROID_ARCHIVE}"
|
||||
COMMENT "Generating SDL3.aar for android-project"
|
||||
)
|
||||
|
||||
set(GRADLEW "${CMAKE_SOURCE_DIR}/android-project/gradlew")
|
||||
if(CMAKE_BUILD_TYPE MATCHES "^Rel")
|
||||
set(GRADLE_TASK "assembleRelease")
|
||||
else()
|
||||
set(GRADLE_TASK "assembleDebug")
|
||||
endif()
|
||||
|
||||
add_custom_target(ANDROID_GRADLE_BUILD ALL
|
||||
DEPENDS "${SDL_ANDROID_ARCHIVE}"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/android-project"
|
||||
COMMAND "${GRADLEW}" ${GRADLE_TASK} -PcmakeArgs="-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DISLE_USE_DX5=${ISLE_USE_DX5} -DISLE_BUILD_CONFIG=${ISLE_BUILD_CONFIG} -DENABLE_CLANG_TIDY=${ENABLE_CLANG_TIDY} -DISLE_WERROR=${ISLE_WERROR} -DISLE_DEBUG=${ISLE_DEBUG} -Werror=dev"
|
||||
VERBATIM
|
||||
COMMENT "Building Android APK with Gradle"
|
||||
)
|
||||
message(STATUS "SDL AAR")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
if (ENABLE_CLANG_TIDY)
|
||||
find_program(CLANG_TIDY_BIN NAMES "clang-tidy" ENV "LLVM_ROOT" REQUIRED)
|
||||
@ -542,7 +512,7 @@ endif()
|
||||
|
||||
if (ISLE_BUILD_APP)
|
||||
|
||||
if(ANDROID)
|
||||
if (ANDROID)
|
||||
function(add_executable TARGET PLATFORM)
|
||||
add_library(${TARGET} SHARED ${ARGN})
|
||||
endfunction()
|
||||
|
||||
@ -15,7 +15,7 @@ android {
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments '-DANDROID_STL=c++_shared'
|
||||
arguments '-DANDROID_STL=c++_shared', "-DFETCHCONTENT_BASE_DIR=${projectDir.parentFile.parentFile}/build/_deps"
|
||||
if (project.hasProperty('cmakeArgs')) {
|
||||
project.cmakeArgs.split(" ").each {arg -> arguments arg}
|
||||
}
|
||||
@ -34,7 +34,7 @@ android {
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
minifyEnabled true
|
||||
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
@ -47,6 +47,20 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation files('libs/SDL3.aar')
|
||||
tasks.register('downloadSDL3AndroidArchive', Exec) {
|
||||
def rootDir = projectDir.parentFile.parentFile
|
||||
def sdl3Dir = "build/_deps/sdl3-src"
|
||||
def cmakeCommand = "cmake -B build -DANDROID_SDL=TRUE"
|
||||
def pythonCommand = "python3 ${sdl3Dir}/build-scripts/build-release.py " +
|
||||
"--actions android " +
|
||||
"--fast " +
|
||||
"--force " +
|
||||
"--root='build/_deps/sdl3-src/'"
|
||||
def mvCommand = "mv ${sdl3Dir}/build-android/SDL3-*.aar ${projectDir}/libs/SDL3.aar"
|
||||
|
||||
commandLine 'sh', '-c', "cd ${rootDir} && ${cmakeCommand} && ${pythonCommand} && mkdir -p ${projectDir}/libs/ && ${mvCommand}"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation files('libs/SDL3.aar').builtBy(downloadSDL3AndroidArchive)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user