commit feb87f3cf2a9c82cf636b4327b5750d1d2f5d507 Author: Patrick Wuttke Date: Thu Jun 22 15:24:30 2023 +0200 Initial commit diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..1b63d10 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,19 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Build Test", + "type": "shell", + "command": "scons", + "options": { + "cwd": "${workspaceFolder}/test" + }, + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} \ No newline at end of file diff --git a/SConscript b/SConscript new file mode 100644 index 0000000..81e21dd --- /dev/null +++ b/SConscript @@ -0,0 +1,92 @@ + +import os + +Import('config') + +if not config.get('PROJECT_NAME'): + config['PROJECT_NAME'] = 'PROJECT' + +AddOption( + '--build_type', + dest = 'build_type', + type = 'choice', + choices = ('debug', 'release_debug', 'release', 'profile'), + nargs = 1, + action = 'store', + default = 'debug' +) + +AddOption( + '--unity', + dest = 'unity_mode', + type = 'choice', + choices = ('enable', 'disable', 'stress'), + nargs = 1, + action = 'store', + default = 'enable' +) + +AddOption( + '--variant', + dest = 'variant', + nargs = 1, + action = 'store' +) + +AddOption( + '--asan', + dest = 'enable_asan', + action = 'store_true' +) + +AddOption( + '--config_file', + dest = 'config_file', + nargs = 1, + action = 'store', + default = 'config.py' +) + +build_type = GetOption('build_type') +unity_mode = GetOption('unity_mode') +variant = GetOption('variant') +enable_asan = GetOption('enable_asan') +config_file = GetOption('config_file') + +env = Environment(tools = ['default', 'compilation_db']) + +# allow compiling to variant directories (each gets their own bin/lib/cache dirs) +if variant: + variant_dir = f'cache/variant/{variant}' + env['BIN_DIR'] = Dir(f'bin_{variant}').abspath + env['LIB_DIR'] = Dir(f'lib_{variant}').abspath + env['UNITY_CACHE_DIR'] = Dir(f'cache/variant/{variant}/unity') + env.Append(CPPDEFINES = [f'{config["PROJECT_NAME"]}_VARIANT={variant}']) +else: + variant_dir = None + env.CompilationDatabase() + env['BIN_DIR'] = Dir('bin').abspath + env['LIB_DIR'] = Dir('lib').abspath + env['UNITY_CACHE_DIR'] = Dir('cache/unity') +env['BUILD_TYPE'] = build_type +env.Append(LIBPATH = [env['LIB_DIR']]) # to allow submodules to link to each other without hassle + +# try to detect what compiler we are using +compiler_exe = os.path.basename(env['CC']) +if 'gcc' in compiler_exe: + env['COMPILER_FAMILY'] = 'gcc' +elif 'clang' in compiler_exe: + env['COMPILER_FAMILY'] = 'clang' +elif 'cl' in compiler_exe: + env['COMPILER_FAMILY'] = 'cl' +else: + env['COMPILER_FAMILY'] = 'unknown' + +# setup unity build depending on mode +if unity_mode == 'disable': + env['UNITY_DISABLE'] = True +elif unity_mode == 'stress': # compile everything in one single file to stress test the unity build + env['UNITY_MAX_SOURCES'] = 100000 # I'll hopefully never reach this + env['UNITY_MIN_FILES'] = 1 + +Return('env') diff --git a/test/.sconsign.dblite b/test/.sconsign.dblite new file mode 100644 index 0000000..087e44f Binary files /dev/null and b/test/.sconsign.dblite differ diff --git a/test/SConstruct b/test/SConstruct new file mode 100644 index 0000000..6e43849 --- /dev/null +++ b/test/SConstruct @@ -0,0 +1,6 @@ + +config = { + 'PROJECT_NAME': 'DUMMY' +} + +env = SConscript('../SConscript', exports = ['config'])