Fixed Glslang recipe to generate an include folder and avoid mixing with system headers.

This commit is contained in:
Patrick 2023-11-11 00:30:14 +01:00
parent 14a080e618
commit 0abc33d6f8

View File

@ -1,9 +1,11 @@
from SCons.Script import *
import glob
import os
import pathlib
import platform
import shutil
import subprocess
import sys
@ -21,16 +23,16 @@ def cook(env: Environment, remote: str = 'github', git_ref: str = '') -> dict:
if not did_run_script or env['UPDATE_REPOSITORIES']:
subprocess.run(('/usr/bin/env', 'python3', 'update_glslang_sources.py'), cwd=checkout_root, stdout=sys.stdout, stderr=sys.stderr, check=True)
pathlib.Path(repo['checkout_root'], _SCRIPT_STAMPFILE).touch()
# build_result = env.Cook('CMakeProject', project_root=checkout_root, generate_args = ['-DBUILD_TESTING=OFF'])
# generator_script = os.path.join(repo['checkout_root'], 'gen_extension_headers.py')
# generator_script_input = os.path.join(repo['checkout_root'], 'glslang/ExtensionHeaders')
# generator_script_output = os.path.join(repo['checkout_root'], 'glslang/glsl_intrinsic_header.h')
# env.Command(
# target = generator_script_output,
# source = [generator_script, os.path.join(repo['checkout_root'], 'glslang/ExtensionHeaders/GL_EXT_shader_realtime_clock.glsl')],
# action = f'"$PYTHON" "{generator_script}" -i "{generator_script_input}" -o "$TARGET"'
# )
# generate the build_info.h
generator_script = os.path.join(repo['checkout_root'], 'build_info.py')
generator_script_input = os.path.join(repo['checkout_root'], 'build_info.h.tmpl')
generator_script_output = os.path.join(repo['checkout_root'], 'glslang/build_info.h')
env.Command(
target = generator_script_output,
source = [generator_script, generator_script_input, os.path.join(repo['checkout_root'], 'CHANGES.md')],
action = f'"$PYTHON" "{generator_script}" "{repo["checkout_root"]}" -i "{generator_script_input}" -o "$TARGET"'
)
platform_source_dir = {
'Linux': 'Unix',
@ -44,13 +46,33 @@ def cook(env: Environment, remote: str = 'github', git_ref: str = '') -> dict:
+ env.RGlob(os.path.join(repo['checkout_root'], 'SPIRV/'), '*.cpp') \
+ env.RGlob(os.path.join(repo['checkout_root'], f'glslang/OSDependent/{platform_source_dir}/'), '*.cpp')
# disable a few warnings when compiling with clang
additional_cxx_flags = {
'clang': ['-Wno-deprecated-copy', '-Wno-missing-field-initializers', '-Wno-gnu-redeclared-enum',
'-Wno-unused-but-set-variable', '-Wno-deprecated-enum-enum-conversion']
}.get(env['COMPILER_FAMILY'], [])
env.StaticLibrary(
CCFLAGS = env['CCFLAGS'] + additional_cxx_flags,
CPPPATH = repo['checkout_root'],
target = env['LIB_DIR'] + '/glslang_full',
source = glslang_source_files
)
# build the include folder
include_dir = os.path.join(checkout_root, 'include')
if not os.path.exists(include_dir) or env['UPDATE_REPOSITORIES']:
def copy_headers(dst, src):
os.makedirs(dst, exist_ok=True)
for file in glob.glob(os.path.join(src, '*.h')):
shutil.copy(file, dst)
copy_headers(os.path.join(include_dir, 'glslang/HLSL'), os.path.join(checkout_root, 'glslang/HLSL'))
copy_headers(os.path.join(include_dir, 'glslang/Include'), os.path.join(checkout_root, 'glslang/Include'))
copy_headers(os.path.join(include_dir, 'glslang/MachineIndependent'), os.path.join(checkout_root, 'glslang/MachineIndependent'))
copy_headers(os.path.join(include_dir, 'glslang/Public'), os.path.join(checkout_root, 'glslang/Public'))
copy_headers(os.path.join(include_dir, 'glslang/SPIRV'), os.path.join(checkout_root, 'SPIRV'))
return {
'CPPPATH': [checkout_root],
'CPPPATH': [include_dir],
'LIBS': ['glslang_full']
}