Compare commits

...

2 Commits

2 changed files with 36 additions and 12 deletions

View File

@ -97,6 +97,8 @@ Import('config')
if not config.get('PROJECT_NAME'):
config['PROJECT_NAME'] = 'PROJECT'
if not config.get('CXX_STANDARD'):
config['CXX_STANDARD'] = 'c++20'
if not config.get('PREPROCESSOR_PREFIX'):
config['PREPROCESSOR_PREFIX'] = config['PROJECT_NAME'].upper() # TODO: may be nicer?
@ -266,7 +268,7 @@ elif unity_mode == 'stress': # compile everything in one single file to stress t
# setup compiler specific options
if env['COMPILER_FAMILY'] == 'gcc' or env['COMPILER_FAMILY'] == 'clang':
env.Append(CCFLAGS = ['-Wall', '-Wextra', '-Werror', '-Wstrict-aliasing', '-pedantic'])
env.Append(CXXFLAGS = ['-std=c++20'])
env.Append(CXXFLAGS = [f'-std={config["CXX_STANDARD"]}'])
if build_type != 'release':
env.Append(LINKFLAGS = [f'-Wl,-rpath,{env["LIB_DIR"]}'])
env['LINKCOM'] = env['LINKCOM'].replace('$_LIBFLAGS', '-Wl,--start-group $_LIBFLAGS -Wl,--end-group')
@ -299,7 +301,7 @@ if env['COMPILER_FAMILY'] == 'gcc' or env['COMPILER_FAMILY'] == 'clang':
elif env['COMPILER_FAMILY'] == 'cl':
# C4201: nonstandard extension used : nameless struct/union - I use it and want to continue using it
# C4127: conditional expression is constant - some libs (CRC, format) don't compile with this enabled # TODO: fix?
env.Append(CCFLAGS = ['/W4', '/WX', '/wd4201', '/wd4127', '/std:c++20', '/permissive-', '/EHsc', '/FS', '/Zc:char8_t'])
env.Append(CCFLAGS = ['/W4', '/WX', '/wd4201', '/wd4127', f'/std:{config["CXX_STANDARD"]}', '/permissive-', '/EHsc', '/FS', '/Zc:char8_t'])
env.Append(CPPDEFINES = ['_CRT_SECURE_NO_WARNINGS']) # I'd like to not use MSVC specific versions of functions because they are "safer" ...
if build_type == 'debug':
env.Append(CCFLAGS = ['/Od', '/Zi'], LINKFLAGS = ' /DEBUG')

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']
}