From abb7a2177aea742e1b12a0ad1aa3e145f8e06948 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 18 Sep 2024 13:42:51 +0200 Subject: [PATCH] (#25281) [vulkan-validationlayers] Add support for Android * Build vulkan-validationlayers for Android Signed-off-by: Uilian Ries * update package type to static type Signed-off-by: Uilian Ries * Add fPIC option Signed-off-by: Uilian Ries * Fix fpic management on Windows Signed-off-by: Uilian Ries * Remove Wayland support on Android * Added system_libs for android --------- Signed-off-by: Uilian Ries Co-authored-by: PerseoGI --- .../vulkan-validationlayers/all/conanfile.py | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/recipes/vulkan-validationlayers/all/conanfile.py b/recipes/vulkan-validationlayers/all/conanfile.py index 8d5cc5e6efcf4..9806017bf17ae 100644 --- a/recipes/vulkan-validationlayers/all/conanfile.py +++ b/recipes/vulkan-validationlayers/all/conanfile.py @@ -23,14 +23,16 @@ class VulkanValidationLayersConan(ConanFile): topics = ("vulkan", "validation-layers") homepage = "https://github.com/KhronosGroup/Vulkan-ValidationLayers" url = "https://github.com/conan-io/conan-center-index" - + package_type = "static-library" settings = "os", "arch", "compiler", "build_type" options = { + "fPIC": [True, False], "with_wsi_xcb": [True, False], "with_wsi_xlib": [True, False], "with_wsi_wayland": [True, False], } default_options = { + "fPIC": True, "with_wsi_xcb": True, "with_wsi_xlib": True, "with_wsi_wayland": True, @@ -90,6 +92,8 @@ def config_options(self): del self.options.with_wsi_xcb del self.options.with_wsi_xlib del self.options.with_wsi_wayland + if self.settings.os == "Windows": + del self.options.fPIC def layout(self): cmake_layout(self, src_folder="src") @@ -153,9 +157,13 @@ def generate(self): tc.variables["VULKAN_HEADERS_INSTALL_DIR"] = self.dependencies["vulkan-headers"].package_folder.replace("\\", "/") tc.variables["USE_CCACHE"] = False if self.settings.os in ["Linux", "FreeBSD"]: - tc.variables["BUILD_WSI_XCB_SUPPORT"] = self.options.with_wsi_xcb - tc.variables["BUILD_WSI_XLIB_SUPPORT"] = self.options.with_wsi_xlib - tc.variables["BUILD_WSI_WAYLAND_SUPPORT"] = self.options.with_wsi_wayland + tc.variables["BUILD_WSI_XCB_SUPPORT"] = self.options.get_safe("with_wsi_xcb") + tc.variables["BUILD_WSI_XLIB_SUPPORT"] = self.options.get_safe("with_wsi_xlib") + tc.variables["BUILD_WSI_WAYLAND_SUPPORT"] = self.options.get_safe("with_wsi_wayland") + elif self.settings.os == "Android": + tc.variables["BUILD_WSI_XCB_SUPPORT"] = False + tc.variables["BUILD_WSI_XLIB_SUPPORT"] = False + tc.variables["BUILD_WSI_WAYLAND_SUPPORT"] = False tc.variables["BUILD_WERROR"] = False tc.variables["BUILD_TESTS"] = False tc.variables["INSTALL_TESTS"] = False @@ -190,6 +198,14 @@ def _patch_sources(self): os.path.join(self.generators_folder, "SPIRV-ToolsConfig.cmake"), os.path.join(self.generators_folder, "SPIRV-Tools-optConfig.cmake"), ) + if self.settings.os == "Android": + # INFO: libVkLayer_utils.a: error: undefined symbol: __android_log_print + # https://github.com/KhronosGroup/Vulkan-ValidationLayers/commit/a26638ae9fdd8c40b56d4c7b72859a5b9a0952c9 + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "VkLayer_utils PUBLIC Vulkan::Headers", "VkLayer_utils PUBLIC Vulkan::Headers -landroid -llog") + if not self.options.get_safe("fPIC"): + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "CMAKE_POSITION_INDEPENDENT_CODE ON", "CMAKE_POSITION_INDEPENDENT_CODE OFF") def build(self): self._patch_sources() @@ -239,3 +255,6 @@ def package_info(self): # TODO: to remove after conan v2, it allows to not break consumers still relying on virtualenv generator self.env_info.VK_LAYER_PATH.append(vk_layer_path) + + if self.settings.os == "Android": + self.cpp_info.system_libs.extend(["android", "log"])