Initial commit
This commit is contained in:
61
shaderc/all/conandata.yml
Normal file
61
shaderc/all/conandata.yml
Normal file
@@ -0,0 +1,61 @@
|
||||
sources:
|
||||
"2025.3":
|
||||
url: "https://github.com/google/shaderc/archive/refs/tags/v2025.3.tar.gz"
|
||||
sha256: "a8e4a25e5c2686fd36981e527ed05e451fcfc226bddf350f4e76181371190937"
|
||||
"2024.1":
|
||||
url: "https://github.com/google/shaderc/archive/refs/tags/v2024.1.tar.gz"
|
||||
sha256: "eb3b5f0c16313d34f208d90c2fa1e588a23283eed63b101edd5422be6165d528"
|
||||
"2023.6":
|
||||
url: "https://github.com/google/shaderc/archive/refs/tags/v2023.6.tar.gz"
|
||||
sha256: "e40fd4a87a56f6610e223122179f086d5c4f11a7e0e2aa461f0325c3a0acc6ae"
|
||||
"2021.1":
|
||||
url: "https://github.com/google/shaderc/archive/v2021.1.tar.gz"
|
||||
sha256: "047113bc4628da164a3cb845efc20d442728873f6054a68ab56d04a053f2c32b"
|
||||
patches:
|
||||
"2025.3":
|
||||
- patch_file: "patches/2025.3/use-conan-dependencies.patch"
|
||||
patch_description: "Replace third_party with Conan dependencies"
|
||||
patch_type: "conan"
|
||||
- patch_file: "patches/2021.1/adapt-update_build_version.py.patch"
|
||||
patch_description: "Adapt update_build_version.py for Conan"
|
||||
patch_type: "conan"
|
||||
- patch_file: "patches/2021.1/install-shaderc_util.patch"
|
||||
patch_description: "install() shaderc_util"
|
||||
patch_type: "conan"
|
||||
"2024.1":
|
||||
- patch_file: "patches/2023.6/use-conan-dependencies.patch"
|
||||
patch_description: "Replace third_party with Conan dependencies"
|
||||
patch_type: "conan"
|
||||
- patch_file: "patches/2021.1/adapt-update_build_version.py.patch"
|
||||
patch_description: "Adapt update_build_version.py for Conan"
|
||||
patch_type: "conan"
|
||||
- patch_file: "patches/2021.1/install-shaderc_util.patch"
|
||||
patch_description: "install() shaderc_util"
|
||||
patch_type: "conan"
|
||||
"2023.6":
|
||||
- patch_file: "patches/2023.6/use-conan-dependencies.patch"
|
||||
patch_description: "Replace third_party with Conan dependencies"
|
||||
patch_type: "conan"
|
||||
- patch_file: "patches/2021.1/adapt-update_build_version.py.patch"
|
||||
patch_description: "Adapt update_build_version.py for Conan"
|
||||
patch_type: "conan"
|
||||
- patch_file: "patches/2021.1/install-shaderc_util.patch"
|
||||
patch_description: "install() shaderc_util"
|
||||
patch_type: "conan"
|
||||
"2021.1":
|
||||
- patch_file: "patches/2021.1/use-conan-dependencies.patch"
|
||||
patch_description: "Replace third_party with Conan dependencies"
|
||||
patch_type: "conan"
|
||||
- patch_file: "patches/2021.1/adapt-update_build_version.py.patch"
|
||||
patch_description: "Adapt update_build_version.py for Conan"
|
||||
patch_type: "conan"
|
||||
- patch_file: "patches/2021.1/install-shaderc_util.patch"
|
||||
patch_description: "install() shaderc_util"
|
||||
patch_type: "conan"
|
||||
siprv_mapping:
|
||||
# TODO: bump me once newer versions are available on CCI
|
||||
"2025.3": "1.4.313.0"
|
||||
"2024.1": "1.3.261.1"
|
||||
# "2023.6": "1.3.261.1"
|
||||
"2023.6": "1.3.239.0"
|
||||
"2021.1": "1.3.224.0"
|
||||
133
shaderc/all/conanfile.py
Normal file
133
shaderc/all/conanfile.py
Normal file
@@ -0,0 +1,133 @@
|
||||
import os
|
||||
|
||||
from conan import ConanFile
|
||||
from conan.tools.build import check_min_cppstd, stdcpp_library
|
||||
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
|
||||
from conan.tools.env import VirtualBuildEnv
|
||||
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
|
||||
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
|
||||
from conan.tools.apple import fix_apple_shared_install_name
|
||||
from conan.tools.scm import Version
|
||||
|
||||
required_conan_version = ">=1.53.0"
|
||||
|
||||
|
||||
class ShadercConan(ConanFile):
|
||||
name = "shaderc"
|
||||
description = "A collection of tools, libraries and tests for shader compilation."
|
||||
license = "Apache-2.0"
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "https://github.com/google/shaderc"
|
||||
topics = ("glsl", "hlsl", "msl", "spirv", "spir-v", "glslc")
|
||||
|
||||
package_type = "library"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
}
|
||||
|
||||
def export_sources(self):
|
||||
export_conandata_patches(self)
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os == "Windows":
|
||||
del self.options.fPIC
|
||||
|
||||
def configure(self):
|
||||
if self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self, src_folder="src")
|
||||
|
||||
@property
|
||||
def _spirv_version(self):
|
||||
return self.conan_data.get("siprv_mapping")[self.version]
|
||||
|
||||
def requirements(self):
|
||||
# transitive_headers=True is not required for any of the dependencies
|
||||
self.requires(f"glslang/{self._spirv_version}")
|
||||
self.requires(f"spirv-tools/{self._spirv_version}")
|
||||
self.requires(f"spirv-headers/{self._spirv_version}")
|
||||
|
||||
def validate(self):
|
||||
if self.settings.compiler.get_safe("cppstd"):
|
||||
check_min_cppstd(self, 11)
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("cmake/[>=3.17.2 <4]")
|
||||
|
||||
def source(self):
|
||||
get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
venv = VirtualBuildEnv(self)
|
||||
venv.generate()
|
||||
|
||||
tc = CMakeToolchain(self)
|
||||
tc.cache_variables["SHADERC_SKIP_INSTALL"] = False
|
||||
tc.cache_variables["SHADERC_SKIP_EXAMPLES"] = True
|
||||
tc.cache_variables["SHADERC_SKIP_TESTS"] = True
|
||||
tc.cache_variables["ENABLE_CODE_COVERAGE"] = False
|
||||
tc.cache_variables["SHADERC_ENABLE_WERROR_COMPILE"] = False
|
||||
if is_msvc(self):
|
||||
tc.cache_variables["SHADERC_ENABLE_SHARED_CRT"] = not is_msvc_static_runtime(self)
|
||||
tc.generate()
|
||||
|
||||
self.dependencies["glslang"].cpp_info.components["glslang-core"].includedirs.append(
|
||||
os.path.join(self.dependencies["glslang"].package_folder, "include", "glslang")
|
||||
)
|
||||
|
||||
deps = CMakeDeps(self)
|
||||
deps.set_property("glslang::glslang-core", "cmake_target_name", "glslang")
|
||||
deps.set_property("glslang::osdependent", "cmake_target_name", "OSDependent")
|
||||
if(Version(self.version) < "2025.3"):
|
||||
deps.set_property("glslang::oglcompiler", "cmake_target_name", "OGLCompiler")
|
||||
deps.set_property("glslang::hlsl", "cmake_target_name", "HLSL")
|
||||
deps.set_property("glslang::spirv", "cmake_target_name", "SPIRV")
|
||||
deps.generate()
|
||||
|
||||
def build(self):
|
||||
apply_conandata_patches(self)
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def package(self):
|
||||
copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
|
||||
cmake = CMake(self)
|
||||
cmake.install()
|
||||
fix_apple_shared_install_name(self)
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
|
||||
|
||||
def package_info(self):
|
||||
if self.options.shared:
|
||||
self.cpp_info.set_property("pkg_config_name", "shaderc")
|
||||
self.cpp_info.libs = ["shaderc_shared"]
|
||||
self.cpp_info.defines.append("SHADERC_SHAREDLIB")
|
||||
else:
|
||||
self.cpp_info.set_property("pkg_config_name", "shaderc_static")
|
||||
self.cpp_info.libs = ["shaderc", "shaderc_util"]
|
||||
if stdcpp_library(self):
|
||||
self.cpp_info.system_libs.append(stdcpp_library(self))
|
||||
|
||||
if self.settings.os in ["Linux", "FreeBSD"]:
|
||||
self.cpp_info.system_libs.append("pthread")
|
||||
|
||||
self.cpp_info.requires = [
|
||||
"glslang::glslang-core",
|
||||
"glslang::osdependent",
|
||||
*(["glslang::oglcompiler", "glslang::hlsl"] if Version(self.version) < Version("2025.3") else []),
|
||||
"spirv-tools::spirv-tools-core",
|
||||
"spirv-tools::spirv-tools-opt",
|
||||
"spirv-headers::spirv-headers"
|
||||
]
|
||||
|
||||
# TODO: to remove in conan v2
|
||||
bin_path = os.path.join(self.package_folder, "bin")
|
||||
self.env_info.PATH.append(bin_path)
|
||||
@@ -0,0 +1,25 @@
|
||||
diff --git a/utils/update_build_version.py b/utils/update_build_version.py
|
||||
--- a/utils/update_build_version.py
|
||||
+++ b/utils/update_build_version.py
|
||||
@@ -128,18 +128,18 @@
|
||||
|
||||
|
||||
def main():
|
||||
- if len(sys.argv) != 5:
|
||||
+ if len(sys.argv) < 5:
|
||||
print(('usage: {} <shaderc-dir> <spirv-tools-dir> <glslang-dir> <output-file>'.format(
|
||||
sys.argv[0])))
|
||||
sys.exit(1)
|
||||
|
||||
- projects = ['shaderc', 'spirv-tools', 'glslang']
|
||||
+ projects = ['shaderc']
|
||||
new_content = ''.join([
|
||||
'"{}\\n"\n'.format(get_version_string(p, d))
|
||||
for (p, d) in zip(projects, sys.argv[1:])
|
||||
])
|
||||
|
||||
- output_file = sys.argv[4]
|
||||
+ output_file = sys.argv[-1]
|
||||
mkdir_p(os.path.dirname(output_file))
|
||||
|
||||
if os.path.isfile(output_file):
|
||||
14
shaderc/all/patches/2021.1/install-shaderc_util.patch
Normal file
14
shaderc/all/patches/2021.1/install-shaderc_util.patch
Normal file
@@ -0,0 +1,14 @@
|
||||
diff --git a/libshaderc_util/CMakeLists.txt b/libshaderc_util/CMakeLists.txt
|
||||
--- a/libshaderc_util/CMakeLists.txt
|
||||
+++ b/libshaderc_util/CMakeLists.txt
|
||||
@@ -87,3 +87,10 @@
|
||||
add_dependencies(shaderc_util_file_finder_test testdata)
|
||||
add_dependencies(shaderc_util_io_shaderc_test testdata)
|
||||
endif()
|
||||
+
|
||||
+if(SHADERC_ENABLE_INSTALL AND NOT BUILD_SHARED_LIBS)
|
||||
+ install(TARGETS shaderc_util
|
||||
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
+endif()
|
||||
17
shaderc/all/patches/2021.1/use-conan-dependencies.patch
Normal file
17
shaderc/all/patches/2021.1/use-conan-dependencies.patch
Normal file
@@ -0,0 +1,17 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -112,7 +112,12 @@
|
||||
|
||||
# Configure subdirectories.
|
||||
# We depend on these for later projects, so they should come first.
|
||||
-add_subdirectory(third_party)
|
||||
+find_package(glslang REQUIRED CONFIG)
|
||||
+find_package(SPIRV-Headers REQUIRED CONFIG)
|
||||
+find_package(SPIRV-Tools REQUIRED CONFIG)
|
||||
+set(glslang_SOURCE_DIR ${glslang_INCLUDE_DIRS})
|
||||
+set(SPIRV-Headers_SOURCE_DIR ${SPIRV-Headers_INCLUDE_DIR}/..)
|
||||
+set(spirv-tools_SOURCE_DIR ${SPIRV-Tools_INCLUDE_DIR}/..)
|
||||
|
||||
add_subdirectory(libshaderc_util)
|
||||
add_subdirectory(libshaderc)
|
||||
17
shaderc/all/patches/2023.6/use-conan-dependencies.patch
Normal file
17
shaderc/all/patches/2023.6/use-conan-dependencies.patch
Normal file
@@ -0,0 +1,17 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -120,7 +120,12 @@
|
||||
|
||||
# Configure subdirectories.
|
||||
# We depend on these for later projects, so they should come first.
|
||||
-add_subdirectory(third_party)
|
||||
+find_package(glslang REQUIRED CONFIG)
|
||||
+find_package(SPIRV-Headers REQUIRED CONFIG)
|
||||
+find_package(SPIRV-Tools REQUIRED CONFIG)
|
||||
+set(glslang_SOURCE_DIR ${glslang_INCLUDE_DIRS})
|
||||
+set(SPIRV-Headers_SOURCE_DIR ${SPIRV-Headers_INCLUDE_DIR}/..)
|
||||
+set(spirv-tools_SOURCE_DIR ${SPIRV-Tools_INCLUDE_DIR}/..)
|
||||
|
||||
add_subdirectory(libshaderc_util)
|
||||
add_subdirectory(libshaderc)
|
||||
18
shaderc/all/patches/2025.3/use-conan-dependencies.patch
Normal file
18
shaderc/all/patches/2025.3/use-conan-dependencies.patch
Normal file
@@ -0,0 +1,18 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 06f5395..76e5179 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -130,7 +130,12 @@ endif(MSVC)
|
||||
|
||||
# Configure subdirectories.
|
||||
# We depend on these for later projects, so they should come first.
|
||||
-add_subdirectory(third_party)
|
||||
+find_package(glslang REQUIRED CONFIG)
|
||||
+find_package(SPIRV-Headers REQUIRED CONFIG)
|
||||
+find_package(SPIRV-Tools REQUIRED CONFIG)
|
||||
+set(glslang_SOURCE_DIR ${glslang_INCLUDE_DIRS})
|
||||
+set(SPIRV-Headers_SOURCE_DIR ${SPIRV-Headers_INCLUDE_DIR}/..)
|
||||
+set(spirv-tools_SOURCE_DIR ${SPIRV-Tools_INCLUDE_DIR}/..)
|
||||
|
||||
add_subdirectory(libshaderc_util)
|
||||
add_subdirectory(libshaderc)
|
||||
11
shaderc/all/test_package/CMakeLists.txt
Normal file
11
shaderc/all/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(test_package LANGUAGES CXX C)
|
||||
|
||||
find_package(shaderc REQUIRED CONFIG)
|
||||
|
||||
add_executable(${PROJECT_NAME}_shaderc_c test_package_shaderc.c)
|
||||
target_link_libraries(${PROJECT_NAME}_shaderc_c PRIVATE shaderc::shaderc)
|
||||
|
||||
add_executable(${PROJECT_NAME}_shaderc_cpp test_package_shaderc.cpp)
|
||||
target_link_libraries(${PROJECT_NAME}_shaderc_cpp PRIVATE shaderc::shaderc)
|
||||
set_property(TARGET ${PROJECT_NAME}_shaderc_cpp PROPERTY CXX_STANDARD 11)
|
||||
34
shaderc/all/test_package/conanfile.py
Normal file
34
shaderc/all/test_package/conanfile.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import os
|
||||
|
||||
from conan import ConanFile
|
||||
from conan.tools.build import can_run
|
||||
from conan.tools.cmake import cmake_layout, CMake
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
|
||||
test_type = "explicit"
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str, run=True)
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if can_run(self):
|
||||
# Test programs consuming shaderc lib
|
||||
bin_path_shaderc_c = os.path.join(self.cpp.build.bindir, "test_package_shaderc_c")
|
||||
self.run(bin_path_shaderc_c, env="conanrun")
|
||||
|
||||
bin_path_shaderc_cpp = os.path.join(self.cpp.build.bindir, "test_package_shaderc_cpp")
|
||||
self.run(bin_path_shaderc_cpp, env="conanrun")
|
||||
|
||||
# Test glslc executable
|
||||
self.run(f"glslc -h", env="conanrun")
|
||||
8
shaderc/all/test_package/test_package_shaderc.c
Normal file
8
shaderc/all/test_package/test_package_shaderc.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <shaderc/shaderc.h>
|
||||
|
||||
int main() {
|
||||
shaderc_compiler_t shaderc_compiler = shaderc_compiler_initialize();
|
||||
shaderc_compiler_release(shaderc_compiler);
|
||||
|
||||
return 0;
|
||||
}
|
||||
8
shaderc/all/test_package/test_package_shaderc.cpp
Normal file
8
shaderc/all/test_package/test_package_shaderc.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <shaderc/shaderc.hpp>
|
||||
|
||||
int main() {
|
||||
shaderc::Compiler compiler;
|
||||
shaderc::CompileOptions compile_options;
|
||||
|
||||
return 0;
|
||||
}
|
||||
9
shaderc/config.yml
Normal file
9
shaderc/config.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
versions:
|
||||
"2025.3":
|
||||
folder: all
|
||||
"2024.1":
|
||||
folder: all
|
||||
"2023.6":
|
||||
folder: all
|
||||
"2021.1":
|
||||
folder: all
|
||||
Reference in New Issue
Block a user