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

[vulkan-validationlayers] Add support for Android #25281

Merged
Merged
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
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 @@
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 All @@ -48,7 +50,7 @@
dependencies_filepath = os.path.join(self.recipe_folder, "dependencies", self._dependencies_filename)
if not os.path.isfile(dependencies_filepath):
raise ConanException(f"Cannot find {dependencies_filepath}")
cached_dependencies = yaml.safe_load(open(dependencies_filepath))

Check warning on line 53 in recipes/vulkan-validationlayers/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Using open without explicitly specifying an encoding
return cached_dependencies

@property
Expand Down Expand Up @@ -90,6 +92,8 @@
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 @@
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 @@
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably needs

self.cpp_info.system_libs.extend(["android", "log"])

as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, this is the way to fix the issue @perseoGI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is still needed that replace_in_file as we saw, the issue was on the linkage stage, not during the consumption of the library.

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 @@

# 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"])
Loading