From b45fec75610a05ecf1e01b6b27807e20be5cd94b Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Mon, 16 Sep 2024 09:50:36 +0200 Subject: [PATCH] Added enable_hlsl option to glslang. --- addons/gitbranch.py | 9 ++++++++- recipes/glslang/recipe.py | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/addons/gitbranch.py b/addons/gitbranch.py index a332496..7808807 100644 --- a/addons/gitbranch.py +++ b/addons/gitbranch.py @@ -2,6 +2,7 @@ from git import Repo from git.exc import GitError import hashlib +import inspect from SCons.Script import * Import('env') @@ -86,7 +87,13 @@ def _git_recipe(env: Environment, globals: dict, repo_name, repo_url, cook_fn, v assert ref_fn git_ref = ref_fn(env, version) repo = env.GitBranch(repo_name = _repo_name(env), remote_url = _repo_url(env), git_ref = git_ref) - return cook_fn(env, repo) + + cook_signature = inspect.signature(cook_fn) + kwargs = {} + if 'options' in cook_signature.parameters: + kwargs['options'] = options + + return cook_fn(env, repo, **kwargs) globals['versions'] = _versions globals['dependencies'] = _dependencies diff --git a/recipes/glslang/recipe.py b/recipes/glslang/recipe.py index 532553c..c1a4d16 100644 --- a/recipes/glslang/recipe.py +++ b/recipes/glslang/recipe.py @@ -9,8 +9,9 @@ from SCons.Script import * _SCRIPT_STAMPFILE = '.spp_script_run' -def _git_cook(env: Environment, repo) -> dict: +def _git_cook(env: Environment, repo, options: dict = {}) -> dict: checkout_root = repo['checkout_root'] + enable_hlsl = options.get('enable_hlsl', False) # TODO: windows? did_run_script = os.path.exists(os.path.join(repo['checkout_root'], _SCRIPT_STAMPFILE)) @@ -45,6 +46,8 @@ def _git_cook(env: Environment, repo) -> dict: + env.RGlob(os.path.join(repo['checkout_root'], 'glslang/ResourceLimits/'), '*.cpp') \ + env.RGlob(os.path.join(repo['checkout_root'], 'SPIRV/'), '*.cpp') \ + [os.path.join(repo['checkout_root'], f'glslang/OSDependent/{platform_source_dir}/ossource.cpp')] + if enable_hlsl: + glslang_source_files.extend(env.RGlob(os.path.join(repo['checkout_root'], 'glslang/HLSL/'), '*.cpp')) # disable warnings additional_cxx_flags = { @@ -52,9 +55,15 @@ def _git_cook(env: Environment, repo) -> dict: 'gcc': ['-w'], 'cl': ['/w'] }.get(env['COMPILER_FAMILY'], []) + additional_cppdefines = [] + + if enable_hlsl: + additional_cppdefines.append('ENABLE_HLSL=1') + env.StaticLibrary( CCFLAGS = env['CCFLAGS'] + additional_cxx_flags, CPPPATH = repo['checkout_root'], + CPPDEFINES = list(env['CPPDEFINES']) + additional_cppdefines, target = env['LIB_DIR'] + '/glslang_full', source = glslang_source_files )