From feb87f3cf2a9c82cf636b4327b5750d1d2f5d507 Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Thu, 22 Jun 2023 15:24:30 +0200 Subject: [PATCH] Initial commit --- .vscode/tasks.json | 19 +++++++++ SConscript | 92 ++++++++++++++++++++++++++++++++++++++++++ test/.sconsign.dblite | Bin 0 -> 332 bytes test/SConstruct | 6 +++ 4 files changed, 117 insertions(+) create mode 100644 .vscode/tasks.json create mode 100644 SConscript create mode 100644 test/.sconsign.dblite create mode 100644 test/SConstruct 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 0000000000000000000000000000000000000000..087e44f534fdd3b05f9671b57e833b8583f6d0ee GIT binary patch literal 332 zcmY+8&uRie4906&>8iC4&?m5$x%dQHDpbLX^jO6CqXu?omd&hSL9qASjPF}#WR&I* z@=Nl4e8=oOYCXg{Ftr4ahZj6%=fQp3UA#MszHXFfdWj%nhmB?Gr}4x3de0|*`{e@< zs4c;+UAl|8(?(1d7oI?2#tjtuGu&_gJ&CTVl|k4be>3%@HkGkDabH4N6`;VU&68ZI z06eEWiGwmv$^f04ESfHNrbcjf37Th*jik1XF}FEAhhQP*|6Cmpr9r