Skip to content

Commit

Permalink
(#16131) vulkan-validationlayers: add 1.3.239.0 + modernize more for …
Browse files Browse the repository at this point in the history
…conan v2

* add vulkan-validationlayers/1.3.239.0

* modernize more

* Vulkan-ValidationLayers requires CMake >=3.17.2 since 1.3.239

see KhronosGroup/Vulkan-ValidationLayers#5032

* relocatable shared lib on macOS

* fix _cmake_new_enough() for conan v2

* add spirv-headers to requirements

it's a direct dependency, so don't rely anymore on spirv-tools to expose spirv-headers to vulkan-validationlayers since it's a private dependency of spirv-tools (it would break in conan v2)

* bump cmake

* vulkan headers is public

* use version range for cmake

* upper bound

---------

Co-authored-by: Rubén Rincón Blanco <[email protected]>
  • Loading branch information
SpaceIm and AbrilRBS authored May 5, 2023
1 parent a14d346 commit 6198be9
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 17 deletions.
7 changes: 7 additions & 0 deletions recipes/vulkan-validationlayers/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"1.3.239.0":
url: "https://github.com/KhronosGroup/Vulkan-ValidationLayers/archive/refs/tags/sdk-1.3.239.0.tar.gz"
sha256: "7aa7fb46e25e5ef0144d29c92122b631dc7c7c6804a6339f195b368ad53328e4"
"1.3.236.0":
url: "https://github.com/KhronosGroup/Vulkan-ValidationLayers/archive/refs/tags/sdk-1.3.236.0.tar.gz"
sha256: "68f2cf70b1960f85e931ef56935e6ceda1beeb214f8fa319e6b95128b02b485a"
Expand Down Expand Up @@ -27,6 +30,10 @@ sources:
url: "https://github.com/KhronosGroup/Vulkan-ValidationLayers/archive/v1.2.182.tar.gz"
sha256: "5a1f7027c06a8e5ae777d9053b5ce46f10ca623806a43332eb2da06fe46476d4"
patches:
"1.3.239.0":
- patch_file: "patches/1.3.239.0-0001-fix-cmake.patch"
patch_description: "CMake: Adapt to conan"
patch_type: "conan"
"1.3.236.0":
- patch_file: "patches/1.3.236.0-0001-fix-cmake.patch"
patch_description: "CMake: Adapt to conan"
Expand Down
35 changes: 18 additions & 17 deletions recipes/vulkan-validationlayers/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from conan import ConanFile
from conan import ConanFile, conan_version
from conan.errors import ConanException, ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import Environment, VirtualBuildEnv
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, rename, replace_in_file, rm
from conan.tools.gnu import PkgConfigDeps
from conan.tools.scm import Version
Expand All @@ -12,7 +13,7 @@
import shutil
import yaml

required_conan_version = ">=1.52.0"
required_conan_version = ">=1.55.0"


class VulkanValidationLayersConan(ConanFile):
Expand Down Expand Up @@ -69,15 +70,14 @@ def _min_cppstd(self):
@property
def _compilers_minimum_version(self):
return {
"11": {},
"17": {
"apple-clang": "9",
"clang": "6",
"gcc": "7",
"msvc": "191",
"Visual Studio": "15.7",
},
}[self._min_cppstd]
}.get(self._min_cppstd, {})

def export(self):
copy(self, f"dependencies/{self._dependencies_filename}", self.recipe_folder, self.export_folder)
Expand All @@ -96,9 +96,13 @@ def layout(self):

def requirements(self):
self.requires("robin-hood-hashing/3.11.5")
# TODO: set private=True, once the issue is resolved https://github.com/conan-io/conan/issues/9390
self.requires(self._require("spirv-tools"), private=not hasattr(self, "settings_build"))
self.requires(self._require("vulkan-headers"))
self.requires(self._require("spirv-headers"))
if Version(conan_version).major < "2":
# TODO: set private=True, once the issue is resolved https://github.com/conan-io/conan/issues/9390
self.requires(self._require("spirv-tools"), private=not hasattr(self, "settings_build"))
else:
self.requires(self._require("spirv-tools"))
self.requires(self._require("vulkan-headers"), transitive_headers=True)
if self.options.get_safe("with_wsi_xcb") or self.options.get_safe("with_wsi_xlib"):
self.requires("xorg/system")
if self._needs_wayland_for_build:
Expand All @@ -119,8 +123,8 @@ def loose_lt_semver(v1, v2):
min_length = min(len(lv1), len(lv2))
return lv1[:min_length] < lv2[:min_length]

minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False)
if minimum_version and loose_lt_semver(str(self.info.settings.compiler.version), minimum_version):
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version):
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.",
)
Expand All @@ -134,10 +138,11 @@ def loose_lt_semver(v1, v2):
def build_requirements(self):
if self._needs_pkg_config and not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/1.9.3")
if Version(self.version) >= "1.3.239":
self.tool_requires("cmake/[>=3.17.2 <4]")

def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
env = VirtualBuildEnv(self)
Expand All @@ -164,10 +169,6 @@ def generate(self):
if self._needs_pkg_config:
deps = PkgConfigDeps(self)
deps.generate()
# TODO: to remove when properly handled by conan (see https://github.com/conan-io/conan/issues/11962)
env = Environment()
env.prepend_path("PKG_CONFIG_PATH", self.generators_folder)
env.vars(self).save_script("conanbuildenv_pkg_config_path")

def _patch_sources(self):
apply_conandata_patches(self)
Expand Down Expand Up @@ -216,13 +217,13 @@ def package(self):
# Move json files to res, but keep in mind to preserve relative
# path between module library and manifest json file
rename(self, os.path.join(self.package_folder, "share"), os.path.join(self.package_folder, "res"))
fix_apple_shared_install_name(self)

def package_info(self):
self.cpp_info.libs = ["VkLayer_utils"]

manifest_subfolder = "bin" if self.settings.os == "Windows" else os.path.join("res", "vulkan", "explicit_layer.d")
vk_layer_path = os.path.join(self.package_folder, manifest_subfolder)
self.output.info(f"Prepending to VK_LAYER_PATH runtime environment variable: {vk_layer_path}")
self.runenv_info.prepend_path("VK_LAYER_PATH", vk_layer_path)
# 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)
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
spirv-headers: "cci.20210616"
spirv-tools: "2021.2"
vulkan-headers: "1.2.182"
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
spirv-headers: "cci.20210811"
spirv-tools: "2021.3"
vulkan-headers: "1.2.189"
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
spirv-headers: "1.2.198.0"
spirv-tools: "2021.4"
vulkan-headers: "1.2.198.0"
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
spirv-headers: "1.3.204.0"
spirv-tools: "1.3.204.0"
vulkan-headers: "1.3.204.1"
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
spirv-headers: "1.3.211.0"
spirv-tools: "1.3.211.0"
vulkan-headers: "1.3.211.0"
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
spirv-headers: "1.3.216.0"
spirv-tools: "1.3.216.0"
vulkan-headers: "1.3.216.0"
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
spirv-headers: "1.3.224.0"
spirv-tools: "1.3.224.0"
vulkan-headers: "1.3.224.0"
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
spirv-headers: "1.3.231.1"
spirv-tools: "1.3.231.1"
vulkan-headers: "1.3.231.1"
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
spirv-headers: "1.3.236.0"
spirv-tools: "1.3.236.0"
vulkan-headers: "1.3.236.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spirv-headers: "1.3.239.0"
spirv-tools: "1.3.239.0"
vulkan-headers: "1.3.239.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/layers/CMakeLists.txt
+++ b/layers/CMakeLists.txt
@@ -134,7 +134,7 @@ endif()

find_package(PythonInterp 3 QUIET)

-if (PYTHONINTERP_FOUND)
+if (0)
# Get the include directory of the SPIRV-Headers
get_target_property(SPIRV_HEADERS_INCLUDE_DIR SPIRV-Headers::SPIRV-Headers INTERFACE_INCLUDE_DIRECTORIES)

2 changes: 2 additions & 0 deletions recipes/vulkan-validationlayers/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"1.3.239.0":
folder: all
"1.3.236.0":
folder: all
"1.3.231.1":
Expand Down

0 comments on commit 6198be9

Please sign in to comment.