51 lines
2.5 KiB
Python

from SCons.Script import *
import os
import platform
import subprocess
import sys
def cook(env: Environment, remote: str = 'github', git_ref: str = '') -> dict:
if remote == 'mewin':
repo = env.Cook('GitBranch', repo_name = 'glslang_mewin', remote_url = 'https://git.mewin.de/mewin/glslang.git', git_ref = git_ref or 'master')
else:
repo = env.Cook('GitBranch', repo_name = 'glslang', remote_url = 'https://github.com/KhronosGroup/glslang.git', git_ref = git_ref or 'main')
checkout_root = repo['checkout_root']
# TODO: windows?
subprocess.run(('/usr/bin/env', 'python3', 'update_glslang_sources.py'), cwd=checkout_root, stdout=sys.stdout, stderr=sys.stderr, check=True)
# 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"'
# )
platform_source_dir = {
'Linux': 'Unix',
'Windows': 'Windows',
'Darwin': 'Unix'
}.get(platform.system(), 'Unix')
glslang_source_files = env.RGlob(os.path.join(repo['checkout_root'], 'glslang/GenericCodeGen/'), '*.cpp') \
+ env.RGlob(os.path.join(repo['checkout_root'], 'glslang/MachineIndependent/'), '*.cpp') \
+ env.RGlob(os.path.join(repo['checkout_root'], 'glslang/OGLCompilersDLL/'), '*.cpp') \
+ env.RGlob(os.path.join(repo['checkout_root'], 'glslang/ResourceLimits/'), '*.cpp') \
+ env.RGlob(os.path.join(repo['checkout_root'], 'glslang/SPIRV/'), '*.cpp') \
+ env.RGlob(os.path.join(repo['checkout_root'], f'glslang/OSDependent/{platform_source_dir}/'), '*.cpp')
env.StaticLibrary(
CPPPATH = repo['checkout_root'],
target = env['LIB_DIR'] + '/glslang_full',
source = glslang_source_files
)
return {
'CPPPATH': [checkout_root],
'LIBS': ['glslang_full']
}