mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-19 22:01:14 +00:00
compile SDL once & cross-platformize gradle tasks
This commit is contained in:
parent
b8fbd39213
commit
b81d67cf7f
@ -73,22 +73,35 @@ if (DOWNLOAD_DEPENDENCIES)
|
|||||||
# FetchContent downloads and configures dependencies
|
# FetchContent downloads and configures dependencies
|
||||||
message(STATUS "Fetching SDL3 and iniparser. This might take a while...")
|
message(STATUS "Fetching SDL3 and iniparser. This might take a while...")
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
if (WINDOWS_STORE)
|
|
||||||
FetchContent_Declare(
|
if(ANDROID)
|
||||||
SDL3
|
set(SDL3_SOURCE_DIR "${CMAKE_SOURCE_DIR}/android-project/build/_deps/sdl3-src")
|
||||||
GIT_REPOSITORY "https://github.com/Helloyunho/SDL3-uwp.git"
|
|
||||||
GIT_TAG "main"
|
add_library(SDL3 SHARED IMPORTED)
|
||||||
EXCLUDE_FROM_ALL
|
set_target_properties(SDL3 PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${SDL3_SOURCE_DIR}/build-android/${CMAKE_ANDROID_ARCH_ABI}-build/libSDL3.so"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${SDL3_SOURCE_DIR}/include"
|
||||||
)
|
)
|
||||||
|
add_library(SDL3::SDL3 ALIAS SDL3)
|
||||||
|
add_library(SDL3::Headers ALIAS SDL3)
|
||||||
else()
|
else()
|
||||||
FetchContent_Declare(
|
if (WINDOWS_STORE)
|
||||||
SDL3
|
FetchContent_Declare(
|
||||||
GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git"
|
SDL3
|
||||||
GIT_TAG "main"
|
GIT_REPOSITORY "https://github.com/Helloyunho/SDL3-uwp.git"
|
||||||
EXCLUDE_FROM_ALL
|
GIT_TAG "main"
|
||||||
)
|
EXCLUDE_FROM_ALL
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
FetchContent_Declare(
|
||||||
|
SDL3
|
||||||
|
GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git"
|
||||||
|
GIT_TAG "main"
|
||||||
|
EXCLUDE_FROM_ALL
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
FetchContent_MakeAvailable(SDL3)
|
||||||
endif()
|
endif()
|
||||||
FetchContent_MakeAvailable(SDL3)
|
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
iniparser
|
iniparser
|
||||||
@ -106,9 +119,6 @@ else()
|
|||||||
# find_package looks for already-installed system packages.
|
# find_package looks for already-installed system packages.
|
||||||
# Configure with `-DCMAKE_PREFIX_PATH="/path/to/package1;/path/to/package2"`
|
# Configure with `-DCMAKE_PREFIX_PATH="/path/to/package1;/path/to/package2"`
|
||||||
# to add search paths.
|
# to add search paths.
|
||||||
if (ANDROID)
|
|
||||||
message(STATUS "Please place the version-appropriate SDL3.aar in android-project/app/libs")
|
|
||||||
endif()
|
|
||||||
find_package(SDL3 CONFIG REQUIRED)
|
find_package(SDL3 CONFIG REQUIRED)
|
||||||
|
|
||||||
find_package(iniparser REQUIRED CONFIG COMPONENTS shared)
|
find_package(iniparser REQUIRED CONFIG COMPONENTS shared)
|
||||||
@ -761,7 +771,7 @@ endif()
|
|||||||
set(install_extra_targets)
|
set(install_extra_targets)
|
||||||
if(DOWNLOAD_DEPENDENCIES)
|
if(DOWNLOAD_DEPENDENCIES)
|
||||||
get_property(sdl3_type TARGET SDL3::SDL3 PROPERTY TYPE)
|
get_property(sdl3_type TARGET SDL3::SDL3 PROPERTY TYPE)
|
||||||
if(sdl3_type STREQUAL "SHARED_LIBRARY")
|
if(sdl3_type STREQUAL "SHARED_LIBRARY" AND NOT ANDROID)
|
||||||
list(APPEND install_extra_targets "SDL3-shared")
|
list(APPEND install_extra_targets "SDL3-shared")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'com.android.application'
|
id 'com.android.application'
|
||||||
}
|
}
|
||||||
|
def androidProject = projectDir.parentFile
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace "org.legoisland.isle"
|
namespace "org.legoisland.isle"
|
||||||
@ -15,16 +16,14 @@ android {
|
|||||||
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
arguments '-DANDROID_STL=c++_shared', "-DFETCHCONTENT_BASE_DIR=${projectDir.parentFile}/build/_deps"
|
arguments '-DANDROID_STL=c++_shared', "-DFETCHCONTENT_BASE_DIR=${androidProject}/build/_deps"
|
||||||
if (project.hasProperty('cmakeArgs')) {
|
if (project.hasProperty('cmakeArgs')) {
|
||||||
project.cmakeArgs.split(" ").each {arg -> arguments arg}
|
project.cmakeArgs.split(" ").each {arg -> arguments arg}
|
||||||
}
|
}
|
||||||
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
||||||
// abiFilters 'x86_64', 'arm64-v8a'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
version "3.30.5"
|
version "3.30.5"
|
||||||
@ -41,7 +40,6 @@ android {
|
|||||||
storePassword = System.getenv("SIGNING_STORE_PASSWORD")
|
storePassword = System.getenv("SIGNING_STORE_PASSWORD")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
@ -68,20 +66,36 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def aarDest = file("${projectDir}/libs/SDL3.aar")
|
||||||
|
tasks.register('downloadSDL3', Exec) {
|
||||||
|
workingDir = androidProject
|
||||||
|
commandLine 'cmake', '-P', 'downloadSDL3.cmake'
|
||||||
|
}
|
||||||
tasks.register('compileSDL3AndroidArchive', Exec) {
|
tasks.register('compileSDL3AndroidArchive', Exec) {
|
||||||
def rootDir = projectDir.parentFile
|
workingDir = androidProject
|
||||||
def sdl3Dir = "build/_deps/sdl3-src"
|
dependsOn(downloadSDL3)
|
||||||
def cmakeCommand = "cmake -P downloadSDL3.cmake"
|
|
||||||
def pythonCommand = "python3 ${sdl3Dir}/build-scripts/build-release.py " +
|
|
||||||
"--actions android " +
|
|
||||||
"--fast " +
|
|
||||||
"--force " +
|
|
||||||
"--root='${sdl3Dir}'"
|
|
||||||
def mvCommand = "mv ${sdl3Dir}/build-android/SDL3-*.aar ${projectDir}/libs/SDL3.aar"
|
|
||||||
|
|
||||||
commandLine 'sh', '-c', "cd ${rootDir} && ${cmakeCommand} && ${pythonCommand} && mkdir -p ${projectDir}/libs/ && ${mvCommand}"
|
def sdl3Dir = "build/_deps/sdl3-src"
|
||||||
|
commandLine 'python', "${sdl3Dir}/build-scripts/build-release.py",
|
||||||
|
'--actions', 'android',
|
||||||
|
'--fast', '--force',
|
||||||
|
"--root=${sdl3Dir}"
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
def aarFile = file("${androidProject}/${sdl3Dir}/build-android").listFiles().find {
|
||||||
|
it.name.endsWith(".aar")
|
||||||
|
}
|
||||||
|
aarDest.parentFile.mkdirs()
|
||||||
|
aarFile.renameTo(aarDest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tasks.register('ensureSDL3') {
|
||||||
|
// if DOWNLOAD_DEPENDENCIES=OFF download the version appropriate
|
||||||
|
// 'devel android zip' and place the .aar at `aarDest`
|
||||||
|
if (aarDest.exists()) { return false }
|
||||||
|
dependsOn(compileSDL3AndroidArchive)
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation files('libs/SDL3.aar').builtBy(compileSDL3AndroidArchive)
|
implementation files('libs/SDL3.aar').builtBy(ensureSDL3)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user