From 0bdb24180f7e20200e350bf3fbfcb2154e438748 Mon Sep 17 00:00:00 2001 From: BerserkD Date: Sat, 4 Jan 2020 11:07:55 -0500 Subject: [PATCH 1/6] Update android --- modules/UseAndroid.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/UseAndroid.cmake b/modules/UseAndroid.cmake index 332a123..63805de 100644 --- a/modules/UseAndroid.cmake +++ b/modules/UseAndroid.cmake @@ -80,6 +80,12 @@ function(android_create_apk target manifest) set(unsigned_apk ${apk_root}/${target}-unsigned.apk) set(apk ${CMAKE_CURRENT_BINARY_DIR}/${target}.apk) + # prepare APK structure + get_filename_component(manifest_absolute ${manifest} REALPATH) + add_custom_command(TARGET ${target}-apk PRE_BUILD + COMMAND ${tools_root}/aapt package -v -f -m -A ${apk_root}/bin/assets -S ${apk_root}/bin/res -J ${apk_root}/bin/src -M ${manifest_absolute} -I ${ANDROID_SDK}/platforms/android-${ANDROID_PLATFORM_VERSION}/android.jar + ) + # 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 @@ -97,7 +103,6 @@ function(android_create_apk target manifest) # TODO: can pass -0 so to not compress anything, yay! but then upload may # be slower # TODO: for resources i need to add -m -J src/ - get_filename_component(manifest_absolute ${manifest} REALPATH) add_custom_command(OUTPUT ${unaligned_apk} COMMAND ${tools_root}/aapt package -f -M ${manifest_absolute} -I ${ANDROID_SDK}/platforms/android-${ANDROID_PLATFORM_VERSION}/android.jar -F ${unaligned_apk} ${apk_root}/bin COMMENT "Packaging ${target}-unaligned.apk" From c7906b802b91ccb55e766329eb3cac260f57cc3a Mon Sep 17 00:00:00 2001 From: BerserkD Date: Sat, 4 Jan 2020 11:10:55 -0500 Subject: [PATCH 2/6] Update android --- modules/UseAndroid.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/UseAndroid.cmake b/modules/UseAndroid.cmake index 63805de..efbc304 100644 --- a/modules/UseAndroid.cmake +++ b/modules/UseAndroid.cmake @@ -80,12 +80,6 @@ function(android_create_apk target manifest) set(unsigned_apk ${apk_root}/${target}-unsigned.apk) set(apk ${CMAKE_CURRENT_BINARY_DIR}/${target}.apk) - # prepare APK structure - get_filename_component(manifest_absolute ${manifest} REALPATH) - add_custom_command(TARGET ${target}-apk PRE_BUILD - COMMAND ${tools_root}/aapt package -v -f -m -A ${apk_root}/bin/assets -S ${apk_root}/bin/res -J ${apk_root}/bin/src -M ${manifest_absolute} -I ${ANDROID_SDK}/platforms/android-${ANDROID_PLATFORM_VERSION}/android.jar - ) - # 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 @@ -103,6 +97,7 @@ function(android_create_apk target manifest) # TODO: can pass -0 so to not compress anything, yay! but then upload may # be slower # TODO: for resources i need to add -m -J src/ + get_filename_component(manifest_absolute ${manifest} REALPATH) add_custom_command(OUTPUT ${unaligned_apk} COMMAND ${tools_root}/aapt package -f -M ${manifest_absolute} -I ${ANDROID_SDK}/platforms/android-${ANDROID_PLATFORM_VERSION}/android.jar -F ${unaligned_apk} ${apk_root}/bin COMMENT "Packaging ${target}-unaligned.apk" @@ -133,6 +128,11 @@ function(android_create_apk target manifest) COMMENT "Installing ${target}.apk" DEPENDS ${apk}) + # prepare APK structure + add_custom_command(TARGET ${target}-apk PRE_BUILD + COMMAND ${tools_root}/aapt package -v -f -m -A ${apk_root}/bin/assets -S ${apk_root}/bin/res -J ${apk_root}/bin/src -M ${manifest_absolute} -I ${ANDROID_SDK}/platforms/android-${ANDROID_PLATFORM_VERSION}/android.jar + ) + # TODO: Could be also possible to do this, but that makes sense only for # projects that only ever have just one APK output -- have it as an option? # The COMPONENTS is useless as one can't just `ninja install/component` :( From b23f8f4aeee1fae67357e8e81c4f663e2db6ce69 Mon Sep 17 00:00:00 2001 From: BerserkD Date: Sat, 4 Jan 2020 11:14:44 -0500 Subject: [PATCH 3/6] Update android --- modules/UseAndroid.cmake | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/UseAndroid.cmake b/modules/UseAndroid.cmake index efbc304..19ce424 100644 --- a/modules/UseAndroid.cmake +++ b/modules/UseAndroid.cmake @@ -74,6 +74,11 @@ function(android_create_apk target manifest) # TODO: can't use $ 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) @@ -85,6 +90,8 @@ function(android_create_apk target manifest) # interface won't find it. Without the strip the apk creation would take # *ages*. add_custom_command(OUTPUT ${library_destination} + COMMAND ${CMAKE_COMMAND} -E make_directory ${res_destination_path} + COMMAND ${CMAKE_COMMAND} -E make_directory ${assets_destination_path} COMMAND ${CMAKE_COMMAND} -E make_directory ${library_destination_path} COMMAND ${CMAKE_STRIP} $ -o ${library_destination} COMMENT "Copying stripped ${target} for an APK build" @@ -128,11 +135,6 @@ function(android_create_apk target manifest) COMMENT "Installing ${target}.apk" DEPENDS ${apk}) - # prepare APK structure - add_custom_command(TARGET ${target}-apk PRE_BUILD - COMMAND ${tools_root}/aapt package -v -f -m -A ${apk_root}/bin/assets -S ${apk_root}/bin/res -J ${apk_root}/bin/src -M ${manifest_absolute} -I ${ANDROID_SDK}/platforms/android-${ANDROID_PLATFORM_VERSION}/android.jar - ) - # TODO: Could be also possible to do this, but that makes sense only for # projects that only ever have just one APK output -- have it as an option? # The COMPONENTS is useless as one can't just `ninja install/component` :( From 511b31f482fcfe670b0d3d7ea6eb08030bb5322f Mon Sep 17 00:00:00 2001 From: BerserkD Date: Sat, 4 Jan 2020 11:27:13 -0500 Subject: [PATCH 4/6] Update android --- modules/UseAndroid.cmake | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/UseAndroid.cmake b/modules/UseAndroid.cmake index 19ce424..7515a1e 100644 --- a/modules/UseAndroid.cmake +++ b/modules/UseAndroid.cmake @@ -68,7 +68,7 @@ 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 $ here because of @@ -85,13 +85,14 @@ function(android_create_apk target manifest) 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 make_directory ${res_destination_path} - COMMAND ${CMAKE_COMMAND} -E make_directory ${assets_destination_path} + 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} $ -o ${library_destination} COMMENT "Copying stripped ${target} for an APK build" @@ -106,7 +107,7 @@ function(android_create_apk target manifest) # TODO: for resources i need to add -m -J src/ get_filename_component(manifest_absolute ${manifest} REALPATH) add_custom_command(OUTPUT ${unaligned_apk} - COMMAND ${tools_root}/aapt package -f -M ${manifest_absolute} -I ${ANDROID_SDK}/platforms/android-${ANDROID_PLATFORM_VERSION}/android.jar -F ${unaligned_apk} ${apk_root}/bin + COMMAND ${tools_root}/aapt package -f -A ${assets_destination_path} -S ${res_destination_path} -M ${manifest_absolute} -I ${ANDROID_SDK}/platforms/android-${ANDROID_PLATFORM_VERSION}/android.jar -F ${unaligned_apk} ${apk_root}/bin COMMENT "Packaging ${target}-unaligned.apk" DEPENDS ${library_destination} ${manifest}) From e8cebec988d9d341cb1ff55f03bf272ee45c10a0 Mon Sep 17 00:00:00 2001 From: BerserkD Date: Sat, 4 Jan 2020 11:37:45 -0500 Subject: [PATCH 5/6] Update android --- modules/UseAndroid.cmake | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/UseAndroid.cmake b/modules/UseAndroid.cmake index 7515a1e..86e655e 100644 --- a/modules/UseAndroid.cmake +++ b/modules/UseAndroid.cmake @@ -85,14 +85,11 @@ function(android_create_apk target manifest local_res local_assets) set(unsigned_apk ${apk_root}/${target}-unsigned.apk) set(apk ${CMAKE_CURRENT_BINARY_DIR}/${target}.apk) - # Create the apk folder structure, copying in the res and assets. - # Also copy the library to the destination, stripping it in the process. + # 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} $ -o ${library_destination} COMMENT "Copying stripped ${target} for an APK build" @@ -107,7 +104,7 @@ function(android_create_apk target manifest local_res local_assets) # TODO: for resources i need to add -m -J src/ get_filename_component(manifest_absolute ${manifest} REALPATH) add_custom_command(OUTPUT ${unaligned_apk} - COMMAND ${tools_root}/aapt package -f -A ${assets_destination_path} -S ${res_destination_path} -M ${manifest_absolute} -I ${ANDROID_SDK}/platforms/android-${ANDROID_PLATFORM_VERSION}/android.jar -F ${unaligned_apk} ${apk_root}/bin + COMMAND ${tools_root}/aapt package -f -A ${local_assets} -S ${local_res} -M ${manifest_absolute} -I ${ANDROID_SDK}/platforms/android-${ANDROID_PLATFORM_VERSION}/android.jar -F ${unaligned_apk} ${apk_root}/bin COMMENT "Packaging ${target}-unaligned.apk" DEPENDS ${library_destination} ${manifest}) From 1b89eabccb5d16d88d00e60895bc9e4f2ead202c Mon Sep 17 00:00:00 2001 From: BerserkD Date: Sat, 4 Jan 2020 11:40:37 -0500 Subject: [PATCH 6/6] Update android --- modules/UseAndroid.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/UseAndroid.cmake b/modules/UseAndroid.cmake index 86e655e..6f61a74 100644 --- a/modules/UseAndroid.cmake +++ b/modules/UseAndroid.cmake @@ -85,11 +85,14 @@ function(android_create_apk target manifest local_res local_assets) 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. + # 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} $ -o ${library_destination} COMMENT "Copying stripped ${target} for an APK build" @@ -104,7 +107,7 @@ function(android_create_apk target manifest local_res local_assets) # TODO: for resources i need to add -m -J src/ get_filename_component(manifest_absolute ${manifest} REALPATH) add_custom_command(OUTPUT ${unaligned_apk} - COMMAND ${tools_root}/aapt package -f -A ${local_assets} -S ${local_res} -M ${manifest_absolute} -I ${ANDROID_SDK}/platforms/android-${ANDROID_PLATFORM_VERSION}/android.jar -F ${unaligned_apk} ${apk_root}/bin + COMMAND ${tools_root}/aapt package -f -M ${manifest_absolute} -I ${ANDROID_SDK}/platforms/android-${ANDROID_PLATFORM_VERSION}/android.jar -F ${unaligned_apk} ${apk_root}/bin COMMENT "Packaging ${target}-unaligned.apk" DEPENDS ${library_destination} ${manifest})