Skip to content

Commit 64d2b86

Browse files
committed
android: support Google Play 16 kiB page size requirement
Manual backport of 6fd9f47
1 parent 32e47b7 commit 64d2b86

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

Android.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ LOCAL_SHARED_LIBRARIES := SDL2
1313

1414
LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/include
1515

16+
# https://developer.android.com/guide/practices/page-sizes
17+
LOCAL_LDFLAGS += "-Wl,-z,max-page-size=16384"
18+
LOCAL_LDFLAGS += "-Wl,-z,common-page-size=16384"
19+
1620
include $(BUILD_SHARED_LIBRARY)

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ add_library(SDL2_net
8585
)
8686

8787
add_library(SDL2_net::${sdl2_net_export_name} ALIAS SDL2_net)
88+
sdl_add_platform_link_options(SDL2_net)
8889
target_include_directories(SDL2_net
8990
PRIVATE
9091
"${CMAKE_CURRENT_LIST_DIR}/src"
@@ -291,14 +292,17 @@ if(SDL2NET_SAMPLES)
291292
add_executable(showinterfaces examples/showinterfaces.c)
292293
target_compile_definitions(showinterfaces PRIVATE SDL_MAIN_HANDLED)
293294
target_link_libraries(showinterfaces PRIVATE SDL2_net::${sdl2_net_export_name} ${sdl2_target_name})
295+
sdl_add_platform_link_options(showinterfaces)
294296

295297
add_executable(chat examples/chat.c examples/chat.h)
296298
if(TARGET SDL2::SDL2main)
297299
target_link_libraries(chat PRIVATE SDL2::SDL2main)
298300
endif()
299301
target_link_libraries(chat PRIVATE SDL2_net::${sdl2_net_export_name} SDL2::SDL2test ${sdl2_target_name})
302+
sdl_add_platform_link_options(chat)
300303

301304
add_executable(chatd examples/chatd.c examples/chat.h)
302305
target_compile_definitions(chatd PRIVATE SDL_MAIN_HANDLED)
303306
target_link_libraries(chatd PRIVATE SDL2_net::${sdl2_net_export_name} ${sdl2_target_name})
307+
sdl_add_platform_link_options(chatd)
304308
endif()

cmake/PrivateSdlFunctions.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,10 @@ function(sdl_target_link_options_no_undefined TARGET)
287287
endif()
288288
endif()
289289
endfunction()
290+
291+
function(sdl_add_platform_link_options TARGET)
292+
if(ANDROID)
293+
target_link_options(${TARGET} PRIVATE "-Wl,-z,max-page-size=16384")
294+
target_link_options(${TARGET} PRIVATE "-Wl,-z,common-page-size=16384")
295+
endif()
296+
endfunction()

0 commit comments

Comments
 (0)