From aabbf51d3a991288febf651d81130c3edb060e48 Mon Sep 17 00:00:00 2001 From: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com> Date: Mon, 8 Nov 2021 11:01:56 -0800 Subject: [PATCH] [android_compat_fixes] added support for non-NDK distributed Vulkan validation layer library paths (required for Android NDK r23+) Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com> --- .../Platform/Android/VkValidation_android.cmake | 10 +++++++++- cmake/Tools/Platform/Android/android_support.py | 9 ++++++++- .../Tools/Platform/Android/generate_android_project.py | 8 +++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/cmake/3rdParty/Platform/Android/VkValidation_android.cmake b/cmake/3rdParty/Platform/Android/VkValidation_android.cmake index dc1c918aad..dbc6db88a1 100644 --- a/cmake/3rdParty/Platform/Android/VkValidation_android.cmake +++ b/cmake/3rdParty/Platform/Android/VkValidation_android.cmake @@ -6,4 +6,12 @@ # # -set(VKVALIDATION_RUNTIME_DEPENDENCIES $<$>:${LY_NDK_DIR}/sources/third_party/vulkan/src/build-android/jniLibs/arm64-v8a/libVkLayer_khronos_validation.so>) +set(LY_ANDROID_VULKAN_VALIDATION_PATH "${LY_NDK_DIR}/sources/third_party/vulkan/src/build-android/jniLibs" CACHE PATH "Path to the Vulkan Validation Layers libs for Android") + +if(NOT EXISTS ${LY_ANDROID_VULKAN_VALIDATION_PATH}) + message(FATAL_ERROR + "Unable to locate the Android Vulkan validation layer libs at ${LY_ANDROID_VULKAN_VALIDATION_PATH}. " + "If using NDK r23 or above, these libs are distributed separately via https://github.com/KhronosGroup/Vulkan-ValidationLayers") +endif() + +set(VKVALIDATION_RUNTIME_DEPENDENCIES $<$>:${LY_ANDROID_VULKAN_VALIDATION_PATH}/arm64-v8a/libVkLayer_khronos_validation.so>) diff --git a/cmake/Tools/Platform/Android/android_support.py b/cmake/Tools/Platform/Android/android_support.py index 97aae7bf21..054897262c 100755 --- a/cmake/Tools/Platform/Android/android_support.py +++ b/cmake/Tools/Platform/Android/android_support.py @@ -471,7 +471,7 @@ class AndroidProjectGenerator(object): def __init__(self, engine_root, build_dir, android_sdk_path, build_tool, android_sdk_platform, android_native_api_level, android_ndk, project_path, third_party_path, cmake_version, override_cmake_path, override_gradle_path, gradle_version, gradle_plugin_version, - override_ninja_path, include_assets_in_apk, asset_mode, asset_type, signing_config, native_build_path, is_test_project=False, + override_ninja_path, include_assets_in_apk, asset_mode, asset_type, signing_config, native_build_path, vulkan_validation_path, is_test_project=False, overwrite_existing=True, unity_build_enabled=False): """ Initialize the object with all the required parameters needed to create an Android Project. The parameters should be verified before initializing this object @@ -495,6 +495,8 @@ class AndroidProjectGenerator(object): :param asset_mode: :param asset_type: :param signing_config: Optional signing configuration arguments + :param native_build_path: Override the native build staging path in gradle + :param vulkan_validation_path: Override the path to where the Vulkan Validation Layers libraries are (required when using NDK r23+) :param is_test_project: Flag to indicate if this is a unit test runner project. (If true, project_path, asset_mode, asset_type, and include_assets_in_apk are ignored) :param overwrite_existing: Flag to overwrite existing project files when being generated, or skip if they already exist. """ @@ -535,6 +537,8 @@ class AndroidProjectGenerator(object): self.native_build_path = native_build_path + self.vulkan_validation_path = vulkan_validation_path + self.asset_mode = asset_mode self.asset_type = asset_type @@ -820,6 +824,9 @@ class AndroidProjectGenerator(object): f'"-DLY_3RDPARTY_PATH={template_third_party_path}"', f'"-DLY_UNITY_BUILD={template_unity_build}"'] + if self.vulkan_validation_path: + cmake_argument_list.append(f'"-DLY_ANDROID_VULKAN_VALIDATION_PATH={pathlib.PurePath(self.vulkan_validation_path).as_posix()}"') + if not self.is_test_project: cmake_argument_list.append(f'"-DLY_PROJECTS={pathlib.PurePath(self.project_path).as_posix()}"') else: diff --git a/cmake/Tools/Platform/Android/generate_android_project.py b/cmake/Tools/Platform/Android/generate_android_project.py index 0ab213cfc5..fe0d787d38 100755 --- a/cmake/Tools/Platform/Android/generate_android_project.py +++ b/cmake/Tools/Platform/Android/generate_android_project.py @@ -223,6 +223,11 @@ def main(args): default=None, required=False) + parser.add_argument('--vulkan-validation-path', + help='Override path to where the Vulkan Validation Layers libraries are. Required for use with NDK r23+', + default=None, + required=False) + # Asset Options parser.add_argument(INCLUDE_APK_ASSETS_ARGUMENT_NAME, action='store_true', @@ -409,7 +414,8 @@ def main(args): is_test_project=is_test_project, overwrite_existing=parsed_args.overwrite_existing, unity_build_enabled=parsed_args.enable_unity_build, - native_build_path=parsed_args.native_build_path) + native_build_path=parsed_args.native_build_path, + vulkan_validation_path=parsed_args.vulkan_validation_path) generator.execute()