Skip to content

Commit

Permalink
(conan-io#25281) [vulkan-validationlayers] Add support for Android
Browse files Browse the repository at this point in the history
* Build vulkan-validationlayers for Android

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* update package type to static type

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Add fPIC option

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Fix fpic management on Windows

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Remove Wayland support on Android

* Added system_libs for android

---------

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Co-authored-by: PerseoGI <perseog@jfrog.com>
  • Loading branch information
uilianries and perseoGI authored Sep 18, 2024
1 parent 4a91125 commit abb7a21
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions recipes/vulkan-validationlayers/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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"])

0 comments on commit abb7a21

Please sign in to comment.