android: android release binary should only contain a shared SDL3 library

This commit is contained in:
Anonymous Maarten 2024-06-10 16:41:17 +02:00
parent dd0bb25f66
commit 657c0135b1
2 changed files with 9 additions and 22 deletions

View File

@ -36,14 +36,6 @@ ANDROID_AVAILABLE_ABIS = [
ANDROID_MINIMUM_API = 19
ANDROID_TARGET_API = 29
ANDROID_MINIMUM_NDK = 21
ANDROID_LIBRARIES = [
"dl",
"GLESv1_CM",
"GLESv2",
"log",
"android",
"OpenSLES",
]
class Executer:
@ -632,7 +624,7 @@ class Releaser:
f"-DANDROID_ABI={android_abi}",
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON",
"-DSDL_SHARED=ON",
"-DSDL_STATIC=ON",
"-DSDL_STATIC=OFF",
"-DSDL_TEST_LIBRARY=ON",
"-DSDL_DISABLE_ANDROID_JAR=OFF",
"-DSDL_TESTS=OFF",
@ -643,6 +635,7 @@ class Releaser:
"-DCMAKE_INSTALL_LIBDIR=lib",
"-DCMAKE_INSTALL_DATAROOTDIR=share",
"-DCMAKE_BUILD_TYPE=Release",
f"-DSDL_ANDROID_HOME={android_home}",
f"-G{self.cmake_generator}",
]
build_args = [
@ -663,10 +656,6 @@ class Releaser:
logger.debug("Expecting library %s", main_so_library)
assert main_so_library.is_file(), "CMake should have built a shared library (e.g. libSDL3.so)"
main_static_library = install_dir / "lib" / f"lib{self.project}.a"
logger.debug("Expecting library %s", main_static_library)
assert main_static_library.is_file(), "CMake should have built a static library (e.g. libSDL3.a)"
test_library = install_dir / "lib" / f"lib{self.project}_test.a"
logger.debug("Expecting library %s", test_library)
assert test_library.is_file(), "CMake should have built a static test library (e.g. libSDL3_test.a)"
@ -694,18 +683,14 @@ class Releaser:
zip_object.write(doc_jar_path, arcname="classes-doc.jar")
for header in (install_dir / "include" / self.project).iterdir():
zip_object.write(header, arcname=f"prefab/modules/{self.project}-shared/include/{self.project}/{header.name}")
zip_object.write(header, arcname=f"prefab/modules/{self.project}-static/include/{self.project}/{header.name}")
zip_object.write(header, arcname=f"prefab/modules/{self.project}/include/{self.project}/{header.name}")
zip_object.writestr(f"prefab/modules/{self.project}-shared/module.json", self.get_prefab_module_json_text(library_name=self.project, extra_libs=[]))
zip_object.writestr(f"prefab/modules/{self.project}-static/module.json", self.get_prefab_module_json_text(library_name=self.project, extra_libs=list(ANDROID_LIBRARIES)))
zip_object.writestr(f"prefab/modules/{self.project}/module.json", self.get_prefab_module_json_text(library_name=self.project, extra_libs=[]))
zip_object.writestr(f"prefab/modules/{self.project}_test/module.json", self.get_prefab_module_json_text(library_name=f"{self.project}_test", extra_libs=list()))
added_global_files = True
zip_object.write(main_so_library, arcname=f"prefab/modules/{self.project}-shared/libs/android.{android_abi}/lib{self.project}.so")
zip_object.writestr(f"prefab/modules/{self.project}-shared/libs/android.{android_abi}/abi.json", self.get_prefab_abi_json_text(abi=android_abi, cpp=False, shared=True))
zip_object.write(main_static_library, arcname=f"prefab/modules/{self.project}-static/libs/android.{android_abi}/lib{self.project}.a")
zip_object.writestr(f"prefab/modules/{self.project}-static/libs/android.{android_abi}/abi.json", self.get_prefab_abi_json_text(abi=android_abi, cpp=False, shared=False))
zip_object.write(main_so_library, arcname=f"prefab/modules/{self.project}/libs/android.{android_abi}/lib{self.project}.so")
zip_object.writestr(f"prefab/modules/{self.project}/libs/android.{android_abi}/abi.json", self.get_prefab_abi_json_text(abi=android_abi, cpp=False, shared=True))
zip_object.write(test_library, arcname=f"prefab/modules/{self.project}_test/libs/android.{android_abi}/lib{self.project}_test.a")
zip_object.writestr(f"prefab/modules/{self.project}_test/libs/android.{android_abi}/abi.json", self.get_prefab_abi_json_text(abi=android_abi, cpp=False, shared=False))

View File

@ -90,6 +90,8 @@ The following components are available, to be used as an argument of `find_packa
| SDL3 | The SDL3 library, available through the `SDL3::SDL3` target. This is an alias of `SDL3::SDL3-shared` or `SDL3::SDL3-static`. This component is always available. |
| Headers | The SDL3 headers, available through the `SDL3::Headers` target. This component is always available. |
SDL's CMake support guarantees a `SDL3::SDL3` target.
Neither `SDL3::SDL3-shared` nor `SDL3::SDL3-static` are guaranteed to exist.
### Using a vendored SDL
@ -337,7 +339,7 @@ endif()
# 2. Try using a vendored SDL library
if(NOT SDL3_FOUND AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL/CMakeLists.txt")
add_subdirectory(SDL)
add_subdirectory(SDL EXCLUDE_FROM_ALL)
message(STATUS "Using SDL3 via add_subdirectory")
set(SDL3_FOUND TRUE)
endif()