Skip to content

Commit

Permalink
Strip the Android shared library file.
Browse files Browse the repository at this point in the history
This cuts down the shared library size from ~11MB to ~5.5MB
  • Loading branch information
Sonicadvance1 committed Jan 20, 2016
1 parent 15226b3 commit c399eef
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
57 changes: 29 additions & 28 deletions Source/Android/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,33 @@ list(APPEND LIBS core uicommon)
set(SRCS ButtonManager.cpp
MainAndroid.cpp)

if(ANDROID)
set(DOLPHIN_EXE main)
add_library(${DOLPHIN_EXE} SHARED ${SRCS})
target_link_libraries(${DOLPHIN_EXE}
log
android
"-Wl,--no-warn-mismatch"
"-Wl,--whole-archive"
${LIBS}
"-Wl,--no-whole-archive"
)
add_custom_command(TARGET ${DOLPHIN_EXE} POST_BUILD
COMMAND mkdir ARGS -p ${CMAKE_SOURCE_DIR}/Source/Android/app/src/main/jniLibs/${ANDROID_NDK_ABI_NAME}
)
add_custom_command(TARGET ${DOLPHIN_EXE} POST_BUILD
COMMAND mkdir ARGS -p ${CMAKE_SOURCE_DIR}/Source/Android/app/src/main/assets/
)
add_custom_command(TARGET ${DOLPHIN_EXE} POST_BUILD
COMMAND cp ARGS ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}/lib${DOLPHIN_EXE}.so ${CMAKE_SOURCE_DIR}/Source/Android/app/src/main/jniLibs/${ANDROID_NDK_ABI_NAME}/
)
add_custom_command(TARGET ${DOLPHIN_EXE} POST_BUILD
COMMAND cp ARGS ${CMAKE_SOURCE_DIR}/Data/Sys/GC/* ${CMAKE_SOURCE_DIR}/Source/Android/app/src/main/assets/
)
add_custom_command(TARGET ${DOLPHIN_EXE} POST_BUILD
COMMAND cp ARGS -r ${CMAKE_SOURCE_DIR}/Data/Sys/Shaders ${CMAKE_SOURCE_DIR}/Source/Android/app/src/main/assets/
)
set(SHARED_LIB main)
add_library(${SHARED_LIB} SHARED ${SRCS})
target_link_libraries(${SHARED_LIB}
log
android
"-Wl,--no-warn-mismatch"
"-Wl,--whole-archive"
${LIBS}
"-Wl,--no-whole-archive"
)
add_custom_command(TARGET ${SHARED_LIB} POST_BUILD
COMMAND mkdir ARGS -p ${CMAKE_SOURCE_DIR}/Source/Android/app/src/main/jniLibs/${ANDROID_NDK_ABI_NAME}
)
add_custom_command(TARGET ${SHARED_LIB} POST_BUILD
COMMAND mkdir ARGS -p ${CMAKE_SOURCE_DIR}/Source/Android/app/src/main/assets/
)
add_custom_command(TARGET ${SHARED_LIB} POST_BUILD
COMMAND cp ARGS ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}/lib${SHARED_LIB}.so ${CMAKE_SOURCE_DIR}/Source/Android/app/src/main/jniLibs/${ANDROID_NDK_ABI_NAME}/
)
add_custom_command(TARGET ${SHARED_LIB} POST_BUILD
COMMAND ${CMAKE_STRIP} ${CMAKE_SOURCE_DIR}/Source/Android/app/src/main/jniLibs/${ANDROID_NDK_ABI_NAME}/lib${SHARED_LIB}.so
)
add_custom_command(TARGET ${SHARED_LIB} POST_BUILD
COMMAND cp ARGS ${CMAKE_SOURCE_DIR}/Data/Sys/GC/* ${CMAKE_SOURCE_DIR}/Source/Android/app/src/main/assets/
)
add_custom_command(TARGET ${SHARED_LIB} POST_BUILD
COMMAND cp ARGS -r ${CMAKE_SOURCE_DIR}/Data/Sys/Shaders ${CMAKE_SOURCE_DIR}/Source/Android/app/src/main/assets/
)

set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} ${DOLPHIN_EXE})
endif()
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} ${SHARED_LIB})
4 changes: 3 additions & 1 deletion Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ macro(add_dolphin_library lib srcs libs)
endmacro(add_dolphin_library)

add_subdirectory(Core)
add_subdirectory(Android/jni)
if (ANDROID)
add_subdirectory(Android/jni)
endif()
add_subdirectory(UnitTests)

if (DSPTOOL)
Expand Down

0 comments on commit c399eef

Please sign in to comment.