From c883f3c1c777357957e30fc44cf987e8bb62c818 Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Sun, 19 Jan 2025 01:17:35 +0100 Subject: [PATCH] Added DXC recipe. --- SConscript | 4 ++++ recipes/dxc/recipe.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 recipes/dxc/recipe.py diff --git a/SConscript b/SConscript index a1b10df..7e5123c 100644 --- a/SConscript +++ b/SConscript @@ -92,6 +92,7 @@ def _parse_lib_conf(env: Environment, lib_conf: dict) -> None: CPPDEFINES = lib_conf.get('CPPDEFINES', []), LIBPATH = lib_conf.get('LIBPATH', []), LIBS = lib_conf.get('LIBS', []), + LINKFLAGS = lib_conf.get('LINKFLAGS', []), JINJA_TEMPLATE_SEARCHPATH = lib_conf.get('JINJA_TEMPLATE_SEARCHPATH', [])) def _inject_list(kwargs: dict, dependency: dict, list_name: str) -> None: @@ -107,6 +108,7 @@ def _inject_dependency(dependency, kwargs: dict, add_sources: bool = True) -> No _inject_list(kwargs, dependency, 'CPPDEFINES') _inject_list(kwargs, dependency, 'LIBPATH') _inject_list(kwargs, dependency, 'LIBS') + _inject_list(kwargs, dependency, 'LINKFLAGS') if add_sources and 'ADDITIONAL_SOURCES' in dependency and hasattr(kwargs['source'], 'extend'): kwargs['source'].extend(dependency['ADDITIONAL_SOURCES']) if 'DEPENDENCIES' in dependency: @@ -118,6 +120,7 @@ def _inject_dependency(dependency, kwargs: dict, add_sources: bool = True) -> No _inject_list(kwargs, dependency.cook_result, 'CPPDEFINES') _inject_list(kwargs, dependency.cook_result, 'LIBPATH') _inject_list(kwargs, dependency.cook_result, 'LIBS') + _inject_list(kwargs, dependency.cook_result, 'LINKFLAGS') for depdep in dependency.depdeps: _inject_dependency(depdep, kwargs) elif isinstance(dependency, _Target): @@ -126,6 +129,7 @@ def _inject_dependency(dependency, kwargs: dict, add_sources: bool = True) -> No _inject_list(kwargs, dependency.kwargs, 'LIBPATH') _inject_list(kwargs, dependency.kwargs, 'LIBS') _inject_list(kwargs, {'LIBS': [dependency]}, 'LIBS') + _inject_list(kwargs, dependency.kwargs, 'LINKFLAGS') for depdep in dependency.dependencies: _inject_dependency(depdep, kwargs) diff --git a/recipes/dxc/recipe.py b/recipes/dxc/recipe.py new file mode 100644 index 0000000..8b6a685 --- /dev/null +++ b/recipes/dxc/recipe.py @@ -0,0 +1,31 @@ + + +import re +from SCons.Script import * + + +def _git_cook(env: Environment, repo: dict) -> dict: + checkout_root = repo['checkout_root'] + build_result = env.CMakeProject(checkout_root, generate_args = [ + f'-C{repo['checkout_root']}/cmake/caches/PredefinedParams.cmake', + '-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON' + ]) + + link_flags = [] + if env['COMPILER_FAMILY'] in ('gcc', 'clang') and env['BUILD_TYPE'] != 'release': + link_flags.append(f'-Wl,-rpath,{build_result["LIBPATH"][0]}') + return { + 'CPPPATH': build_result['CPPPATH'], + 'LIBS': [env.FindLib('dxcompiler', type='shared', paths=build_result['LIBPATH'])], + 'LINKFLAGS': link_flags + } + + +env.GitRecipe( + globals = globals(), + repo_name = 'dxc', + repo_url = 'https://github.com/microsoft/DirectXShaderCompiler.git', + tag_pattern = re.compile(r'^v([0-9]+)\.([0-9]+)\.([0-9]+)$'), + tag_fn = lambda version: f'v{version[0]}.{version[1]}.{version[2]}', + cook_fn = _git_cook +)