Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update adb to android sdk relative path #10

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions modules/UseAndroid.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,31 @@ if(NOT ANDROID_PLATFORM_VERSION)
endif()
endif()

function(android_create_apk target manifest)
function(android_create_apk target manifest local_res local_assets)
set(tools_root ${ANDROID_SDK}/build-tools/${ANDROID_BUILD_TOOLS_VERSION})
set(apk_root ${CMAKE_CURRENT_BINARY_DIR}/${target}-apk)
# TODO: can't use $<TARGET_FILE_NAME:target> here because of
# https://gitlab.kitware.com/cmake/cmake/issues/12877 -- mention that in
# limitations

# Android folder structure reference:
# https://en.wikipedia.org/wiki/Android_application_package
set(res_destination_path ${apk_root}/bin/res)
set(assets_destination_path ${apk_root}/bin/assets)
set(library_destination_path ${apk_root}/bin/lib/${CMAKE_ANDROID_ARCH_ABI})
set(library_destination ${library_destination_path}/lib${target}.so)
set(unaligned_apk ${apk_root}/${target}-unaligned.apk)
set(unsigned_apk ${apk_root}/${target}-unsigned.apk)
set(apk ${CMAKE_CURRENT_BINARY_DIR}/${target}.apk)

# Copy the library to the destination, stripping it in the process. It
# needs to be in a folder that corresponds to its ABI, otherwise the java
# Create the apk folder structure, copying in the res and assets.
# Also copy the library to the destination, stripping it in the process.
# It needs to be in a folder that corresponds to its ABI, otherwise the java
# interface won't find it. Without the strip the apk creation would take
# *ages*.
add_custom_command(OUTPUT ${library_destination}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${local_res} ${res_destination_path}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${local_assets} ${assets_destination_path}
COMMAND ${CMAKE_COMMAND} -E make_directory ${library_destination_path}
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:${target}> -o ${library_destination}
COMMENT "Copying stripped ${target} for an APK build"
Expand Down