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

diligent-core: migrate to Conan v2 #23347

Merged
merged 9 commits into from
Jun 15, 2024
22 changes: 0 additions & 22 deletions recipes/diligent-core/all/CMakeLists.txt

This file was deleted.

15 changes: 15 additions & 0 deletions recipes/diligent-core/all/conan_deps.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
find_package(SPIRV-Tools REQUIRED CONFIG)
find_package(spirv-cross REQUIRED CONFIG)
find_package(volk REQUIRED CONFIG)
find_package(xxHash REQUIRED CONFIG)

if (NOT ${DILIGENT_NO_GLSLANG})
find_package(glslang REQUIRED CONFIG)
add_library(glslang INTERFACE)
target_link_libraries(glslang INTERFACE glslang::glslang)
target_include_directories(glslang INTERFACE ${glslang_INCLUDE_DIR}/glslang)
add_library(SPIRV ALIAS glslang::SPIRV)
endif()

add_library(SPIRV-Headers ALIAS SPIRV-Headers::SPIRV-Headers)
add_library(spirv-tools-core ALIAS spirv-tools::spirv-tools)
16 changes: 0 additions & 16 deletions recipes/diligent-core/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,23 @@
url: "https://github.com/DiligentGraphics/DiligentCore/archive/refs/tags/API250014.tar.gz"
sha256: "8f85fc55c6241f9215875df58a077f797e9134c9b51f330f1489df91d8553b7d"
patches:
"api.252003":
- patch_file: "patches/0023-252003-fix-warning-as-error.patch"

Check warning on line 25 in recipes/diligent-core/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0023-252 ... ^ (line: 25)
base_path: "source_subfolder"
"2.5.2":
- patch_file: "patches/0014-252-exclude-tests.patch"

Check warning on line 27 in recipes/diligent-core/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0014-252 ... ^ (line: 27)
base_path: "source_subfolder"
- patch_file: "patches/0015-252-dont-install-3d-party-license.patch"

Check warning on line 28 in recipes/diligent-core/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0015-252 ... ^ (line: 28)
base_path: "source_subfolder"
- patch_file: "patches/0016-252-fix-glslang-usage.patch"

Check warning on line 29 in recipes/diligent-core/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0016-252 ... ^ (line: 29)
base_path: "source_subfolder"
- patch_file: "patches/0017-252-fix-glslang-include.patch"

Check warning on line 30 in recipes/diligent-core/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0017-252 ... ^ (line: 30)
base_path: "source_subfolder"
- patch_file: "patches/0018-252-fix-warning-as-error.patch"

Check warning on line 31 in recipes/diligent-core/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0018-252 ... ^ (line: 31)
base_path: "source_subfolder"
"2.5.1":
- patch_file: "patches/0001-remove_warning_as_error.patch"

Check warning on line 33 in recipes/diligent-core/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0001-rem ... ^ (line: 33)
base_path: "source_subfolder"
- patch_file: "patches/0002-use_conan_dependencies.patch"

Check warning on line 34 in recipes/diligent-core/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0002-use ... ^ (line: 34)
base_path: "source_subfolder"
- patch_file: "patches/0003-use_volk_from_conan.patch"

Check warning on line 35 in recipes/diligent-core/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0003-use ... ^ (line: 35)
base_path: "source_subfolder"
- patch_file: "patches/0005-spirv-cross-namespace-override.patch"

Check warning on line 36 in recipes/diligent-core/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0005-spi ... ^ (line: 36)
base_path: "source_subfolder"
- patch_file: "patches/0006-install-linux-platform-header.diff"
base_path: "source_subfolder"
"api.250014":
- patch_file: "patches/0007-API250014-remove_warning_as_error.patch"
base_path: "source_subfolder"
- patch_file: "patches/0009-API250014-use_conan_dependencies_in_third_party.patch"
base_path: "source_subfolder"
- patch_file: "patches/0010-API250014-use_volk_from_conan.patch"
base_path: "source_subfolder"
- patch_file: "patches/0013-API250014-use-vulkan-headers-in-archiver.patch"
base_path: "source_subfolder"
- patch_file: "patches/0005-spirv-cross-namespace-override.patch"
base_path: "source_subfolder"
103 changes: 55 additions & 48 deletions recipes/diligent-core/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import cross_building, check_min_cppstd
from conan.tools.scm import Version
from conan.tools.files import rm, get, rmdir, rename, collect_libs, patches, export_conandata_patches, copy, apply_conandata_patches
from conan.tools.files import rm, get, rmdir, rename, collect_libs, export_conandata_patches, copy, apply_conandata_patches, replace_in_file

Check warning on line 6 in recipes/diligent-core/all/conanfile.py

View workflow job for this annotation

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

Unused rename imported from conan.tools.files
from conan.tools.microsoft import visual
from conan.tools.apple import is_apple_os
import os

Expand Down Expand Up @@ -34,6 +35,7 @@
def _minimum_compilers_version(self):
return {
"Visual Studio": "16",
"msvc": "192",
"gcc": "6",
"clang": "3.4",
"apple-clang": "5.1",
Expand All @@ -48,29 +50,28 @@
check_min_cppstd(self, self._minimum_cpp_standard)
min_version = self._minimum_compilers_version.get(str(self.settings.compiler))
if not min_version:
self.output.warn("{} recipe lacks information about the {} compiler support.".format(
self.output.warning("{} recipe lacks information about the {} compiler support.".format(
self.name, self.settings.compiler))
else:
if Version(self.settings.compiler.version) < min_version:
raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format(
self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version))
if self.settings.compiler == "Visual Studio" and "MT" in self.settings.compiler.runtime:
if visual.is_msvc_static_runtime(self):
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
raise ConanInvalidConfiguration("Visual Studio build with MT runtime is not supported")

def export_sources(self):
copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder, keep_path=False)
copy(self, "conan_deps.cmake", src=self.recipe_folder, dst=os.path.join(self.export_sources_folder, "src"), keep_path=False)
export_conandata_patches(self)

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

def package_id(self):
if self.settings.compiler == "Visual Studio":
if "MD" in self.settings.compiler.runtime:
self.info.settings.compiler.runtime = "MD/MDd"
else:
if visual.is_msvc(self.info):
if visual.is_msvc_static_runtime(self.info):
self.info.settings.compiler.runtime = "MT/MTd"
else:
self.info.settings.compiler.runtime = "MD/MDd"

def generate(self):
tc = CMakeToolchain(self)
Expand All @@ -79,8 +80,7 @@
tc.variables["DILIGENT_BUILD_TESTS"] = False
tc.variables["DILIGENT_NO_DXC"] = True
tc.variables["DILIGENT_NO_GLSLANG"] = not self.options.with_glslang
tc.variables["SPIRV_CROSS_NAMESPACE_OVERRIDE"] = self.options["spirv-cross"].namespace
tc.variables["BUILD_SHARED_LIBS"] = False
tc.variables["SPIRV_CROSS_NAMESPACE_OVERRIDE"] = self.dependencies["spirv-cross"].options.namespace
tc.variables["DILIGENT_CLANG_COMPILE_OPTIONS"] = ""
tc.variables["DILIGENT_MSVC_COMPILE_OPTIONS"] = ""
tc.variables["ENABLE_RTTI"] = True
Expand All @@ -92,34 +92,37 @@
deps.generate()

def layout(self):
cmake_layout(self)
cmake_layout(self, src_folder="src")

def configure(self):
if self.options.shared:
del self.options.fPIC
self.options.rm_safe("fPIC")

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
self.options.rm_safe("fPIC")

def _patch_sources(self):
patches.apply_conandata_patches(self)
apply_conandata_patches(self)
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
"project(DiligentCore)",
"project(DiligentCore)\n\ninclude(conan_deps.cmake)")

def build_requirements(self):
self.tool_requires("cmake/3.24.2")
self.tool_requires("cmake/[>=3.24 <4]")

def requirements(self):
self.requires("opengl/system")
if self.settings.os == "Linux":
self.requires("wayland/1.21.0")
self.requires("wayland/1.22.0")

self.requires("spirv-cross/1.3.224.0")
self.requires("spirv-tools/1.3.224.0")
if self.options.with_glslang:
self.requires("glslang/1.3.224.0")
self.requires("vulkan-headers/1.3.224.1")
self.requires("vulkan-headers/1.3.224.0")
self.requires("vulkan-validationlayers/1.3.224.1")
self.requires("volk/1.3.224.1")
self.requires("volk/1.3.224.0")
self.requires("xxhash/0.8.1")

if self.settings.os in ["Linux", "FreeBSD"]:
Expand All @@ -144,21 +147,25 @@
return "PLATFORM_TVOS"

def build(self):
apply_conandata_patches(self)
self._patch_sources()
cmake = CMake(self)
cmake.configure()
# By default, Diligent builds static and shared versions of every main library. We select the one we
# want based on options.shared in package(). To avoid building every intermediate library as SHARED,
# we have to disable BUILD_SHARED_LIBS.
# However, BUILD_SHARED_LIBS cannot be disabled normally (in the toolchain in configure()), because
# Conan outputs that override after the standard line that enables BUILD_SHARED_LIBS. Since the latter
# is a CACHE variable that cannot be overwritten with another set(), we have to specify it on the
# command-line, so it takes effect before the toolchain is parsed.
cmake.configure(variables={"BUILD_SHARED_LIBS": "OFF"})
cmake.build()

def package(self):
cmake = CMake(self)
cmake.install()
rename(self, src=os.path.join(self.package_folder, "include", "source_subfolder"),
dst=os.path.join(self.package_folder, "include", "DiligentCore"))

rmdir(self, os.path.join(self.package_folder, "Licenses"))
rmdir(self, os.path.join(self.package_folder, "lib"))
rmdir(self, os.path.join(self.package_folder, "bin"))
copy(self, "License.txt", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.package_folder, self.source_folder, "source_subfolder"))
copy(self, "License.txt", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.package_folder, self.source_folder))

if self.options.shared:
copy(self, pattern="*.dylib", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False)
Expand All @@ -184,37 +191,37 @@
self.cpp_info.libs = collect_libs(self)
# included as discussed here https://github.com/conan-io/conan-center-index/pull/10732#issuecomment-1123596308
self.cpp_info.includedirs.append(os.path.join(self.package_folder, "include"))
self.cpp_info.includedirs.append(os.path.join(self.package_folder, "include", "DiligentCore", "Common"))

self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore"))
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Common", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Platforms", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "GraphicsEngine", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "GraphicsEngineVulkan", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "GraphicsEngineOpenGL", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "GraphicsAccessories", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "GraphicsTools", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "HLSL2GLSLConverterLib", "interface"))
archiver_path = os.path.join("include", "DiligentCore", "Graphics", "Archiver", "interface")
self.cpp_info.includedirs.append(os.path.join(self.package_folder, "include", "Common"))

self.cpp_info.includedirs.append(os.path.join("include"))
self.cpp_info.includedirs.append(os.path.join("include", "Common", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Platforms", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Graphics", "GraphicsEngine", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Graphics", "GraphicsEngineVulkan", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Graphics", "GraphicsEngineOpenGL", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Graphics", "GraphicsAccessories", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Graphics", "GraphicsTools", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Graphics", "HLSL2GLSLConverterLib", "interface"))
archiver_path = os.path.join("include", "Graphics", "Archiver", "interface")
if os.path.isdir(archiver_path):
self.cpp_info.includedirs.append(archiver_path)

self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Primitives", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Platforms", "Basic", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Primitives", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Platforms", "Basic", "interface"))
if self.settings.os == "Android":
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Platforms", "Android", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Platforms", "Android", "interface"))
elif is_apple_os(self):
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Platforms", "Apple", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Platforms", "Apple", "interface"))
elif self.settings.os == "Emscripten":
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Platforms", "Emscripten", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Platforms", "Emscripten", "interface"))
elif self.settings.os == "Linux":
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Platforms", "Linux", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Platforms", "Linux", "interface"))
elif self.settings.os == "Windows":
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Platforms", "Win32", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "GraphicsEngineD3D11", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "GraphicsEngineD3D12", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Platforms", "Win32", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Graphics", "GraphicsEngineD3D11", "interface"))
self.cpp_info.includedirs.append(os.path.join("include", "Graphics", "GraphicsEngineD3D12", "interface"))

self.cpp_info.defines.append("SPIRV_CROSS_NAMESPACE_OVERRIDE={}".format(self.options["spirv-cross"].namespace))
self.cpp_info.defines.append("SPIRV_CROSS_NAMESPACE_OVERRIDE={}".format(self.dependencies["spirv-cross"].options.namespace))
self.cpp_info.defines.append("{}=1".format(self._diligent_platform()))

if self.settings.os in ["Macos", "Linux"]:
Expand Down
15 changes: 4 additions & 11 deletions recipes/diligent-core/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
find_package(diligent-core REQUIRED CONFIG)

if(WIN32)
set(FILE2STRING_PATH "${CONAN_BIN_DIRS_DILIGENT-CORE}/File2String.exe")
else()
set(FILE2STRING_PATH "${CONAN_BIN_DIRS_DILIGENT-CORE}/File2String")
endif()

set(FILE "${CONAN_RES_DIRS_DILIGENT}/HLSLDefinitions.fxh")
set(FILE "${core_INCLUDE_DIR}/../res/HLSLDefinitions.fxh")
set(CONVERTED_FILE "${PROJECT_BINARY_DIR}/HLSLDefinitions.h")

add_custom_command(OUTPUT ${CONVERTED_FILE}
COMMAND ${FILE2STRING_PATH} ${FILE} ${CONVERTED_FILE}
COMMAND File2String ${FILE} ${CONVERTED_FILE}
MAIN_DEPENDENCY ${FILE} # the primary input source file to the command
COMMENT "Processing shader ${FILE}"
VERBATIM)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
target_link_libraries(${PROJECT_NAME} diligent-core::diligent-core)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
19 changes: 13 additions & 6 deletions recipes/diligent-core/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
from conans import ConanFile, CMake, tools
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os
from conan.tools.build import cross_building

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
Loading