Skip to content

Commit

Permalink
[unity]android不保留剪裁和非剪裁版本,而且不通过strip命令剪裁,通过-s链接参数效果更好(20M+ -> 15M+)
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Oct 25, 2024
1 parent deb7a84 commit 1a09599
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions unity/cli/make.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const platformCompileConfig = {
if (existsSync(`${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.a`))
return [`${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.a`];
else
return [`${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.so`, `${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.stripped.so~`];
return [`${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.so`];
}
},
'arm64': {
Expand All @@ -42,7 +42,7 @@ const platformCompileConfig = {
if (existsSync(`${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.a`))
return [`${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.a`];
else
return [`${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.so`, `${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.stripped.so~`];
return [`${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.so`];
}
},
'x64': {
Expand All @@ -59,7 +59,7 @@ const platformCompileConfig = {
if (existsSync(`${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.a`))
return [`${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.a`];
else
return [`${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.so`, `${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.stripped.so~`];
return [`${CMAKE_BUILD_PATH}/lib${cmakeAddedLibraryName}.so`];
}
}
},
Expand Down
11 changes: 6 additions & 5 deletions unity/native_src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,16 @@ elseif ( ANDROID )

list(APPEND PUERTS_COMPILE_DEFINITIONS PLATFORM_ANDROID_x64)
endif ()

target_link_options(puerts PRIVATE -s)

#set_target_properties( puerts PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/android_version.script)
#set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/android_version.script")
#set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
add_custom_command(TARGET puerts POST_BUILD
COMMAND "${ANDROID_TOOLCHAIN_PREFIX}strip" -g -S -d --strip-debug --verbose
"${CMAKE_BINARY_DIR}/libpuerts.so" -o
"${CMAKE_BINARY_DIR}/libpuerts.stripped.so~"
COMMENT "Strip debug symbols done on final binary.")
#add_custom_command(TARGET puerts POST_BUILD
# COMMAND "${ANDROID_TOOLCHAIN_PREFIX}strip" -g -S -d --strip-debug --verbose
# "${CMAKE_BINARY_DIR}/libpuerts.so"
# COMMENT "Strip debug symbols done on final binary.")

elseif ( APPLE )

Expand Down

0 comments on commit 1a09599

Please sign in to comment.