diff options
Diffstat (limited to 'SConstruct')
-rw-r--r-- | SConstruct | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/SConstruct b/SConstruct index 6bb129a174..17cf779d4a 100644 --- a/SConstruct +++ b/SConstruct @@ -149,7 +149,7 @@ opts.Add(BoolVariable('builtin_libwebsockets', "Use the built-in libwebsockets l opts.Add(BoolVariable('builtin_mbedtls', "Use the built-in mbedTLS library", True)) opts.Add(BoolVariable('builtin_miniupnpc', "Use the built-in miniupnpc library", True)) opts.Add(BoolVariable('builtin_opus', "Use the built-in Opus library", True)) -opts.Add(BoolVariable('builtin_pcre2', "Use the built-in PCRE2 library)", True)) +opts.Add(BoolVariable('builtin_pcre2', "Use the built-in PCRE2 library", True)) opts.Add(BoolVariable('builtin_recast', "Use the built-in Recast library", True)) opts.Add(BoolVariable('builtin_squish', "Use the built-in squish library", True)) opts.Add(BoolVariable('builtin_xatlas', "Use the built-in xatlas library", True)) @@ -161,8 +161,8 @@ opts.Add("CXX", "C++ compiler") opts.Add("CC", "C compiler") opts.Add("LINK", "Linker") opts.Add("CCFLAGS", "Custom flags for both the C and C++ compilers") -opts.Add("CXXFLAGS", "Custom flags for the C++ compiler") opts.Add("CFLAGS", "Custom flags for the C compiler") +opts.Add("CXXFLAGS", "Custom flags for the C++ compiler") opts.Add("LINKFLAGS", "Custom flags for the linker") # add platform specific options @@ -189,7 +189,7 @@ Help(opts.GenerateHelpText(env_base)) # generate help # add default include paths -env_base.Append(CPPPATH=['#editor', '#']) +env_base.Prepend(CPPPATH=['#', '#editor']) # configure ENV for platform env_base.platform_exporters = platform_exporters @@ -226,6 +226,23 @@ if env_base['platform'] != "": elif env_base['p'] != "": selected_platform = env_base['p'] env_base["platform"] = selected_platform +else: + # Missing `platform` argument, try to detect platform automatically + if sys.platform.startswith('linux'): + selected_platform = 'x11' + elif sys.platform == 'darwin': + selected_platform = 'osx' + elif sys.platform == 'win32': + selected_platform = 'windows' + else: + print("Could not detect platform automatically. Supported platforms:") + for x in platform_list: + print("\t" + x) + print("\nPlease run SCons again and select a valid platform: platform=<string>") + + if selected_platform != "": + print("Automatically detected platform: " + selected_platform) + env_base["platform"] = selected_platform if selected_platform in platform_list: tmppath = "./platform/" + selected_platform @@ -271,17 +288,18 @@ if selected_platform in platform_list: CCFLAGS = env.get('CCFLAGS', '') env['CCFLAGS'] = '' - env.Append(CCFLAGS=str(CCFLAGS).split()) CFLAGS = env.get('CFLAGS', '') env['CFLAGS'] = '' - env.Append(CFLAGS=str(CFLAGS).split()) + CXXFLAGS = env.get('CXXFLAGS', '') + env['CXXFLAGS'] = '' + env.Append(CXXFLAGS=str(CXXFLAGS).split()) + LINKFLAGS = env.get('LINKFLAGS', '') env['LINKFLAGS'] = '' - env.Append(LINKFLAGS=str(LINKFLAGS).split()) flag_list = platform_flags[selected_platform] @@ -319,18 +337,19 @@ if selected_platform in platform_list: if (env["warnings"] == 'extra'): # FIXME: enable -Wclobbered once #26351 is fixed - # FIXME: enable -Wlogical-op and -Wduplicated-branches once #27594 is merged + # FIXME: enable -Wduplicated-branches once #27594 is merged # Note: enable -Wimplicit-fallthrough for Clang (already part of -Wextra for GCC) # once we switch to C++11 or later (necessary for our FALLTHROUGH macro). - env.Append(CCFLAGS=['-Wall', '-Wextra', '-Wno-unused-parameter', - '-Wctor-dtor-privacy', '-Wnon-virtual-dtor'] + env.Append(CCFLAGS=['-Wall', '-Wextra', '-Wno-unused-parameter'] + all_plus_warnings + shadow_local_warning) + env.Append(CXXFLAGS=['-Wctor-dtor-privacy', '-Wnon-virtual-dtor']) if methods.using_gcc(env): - env['CCFLAGS'] += ['-Wno-clobbered', '-Walloc-zero', '-Wnoexcept', - '-Wduplicated-cond', '-Wplacement-new=1', '-Wstringop-overflow=4'] + env.Append(CCFLAGS=['-Wno-clobbered', '-Walloc-zero', + '-Wduplicated-cond', '-Wstringop-overflow=4', '-Wlogical-op']) + env.Append(CXXFLAGS=['-Wnoexcept', '-Wplacement-new=1']) version = methods.get_compiler_version(env) if version != None and version[0] >= '9': - env['CCFLAGS'] += ['-Wattribute-alias=2'] + env.Append(CCFLAGS=['-Wattribute-alias=2']) elif (env["warnings"] == 'all'): env.Append(CCFLAGS=['-Wall'] + shadow_local_warning) elif (env["warnings"] == 'moderate'): @@ -490,13 +509,13 @@ if selected_platform in platform_list: if (conf.CheckCHeader(header[0])): env.AppendUnique(CPPDEFINES=[header[1]]) -else: +elif selected_platform != "": - print("No valid target platform selected.") + print("Invalid target platform: " + selected_platform) print("The following platforms were detected:") for x in platform_list: print("\t" + x) - print("\nPlease run SCons again with the argument: platform=<string>") + print("\nPlease run SCons again and select a valid platform: platform=<string>") # The following only makes sense when the env is defined, and assumes it is if 'env' in locals(): @@ -560,7 +579,7 @@ if 'env' in locals(): # (filename, size, weight). current_time = time.time() file_stat = [(x[0], x[1][0], (current_time - x[1][1])) for x in file_stat] - # Sort by the most resently accessed files (most sensible to keep) first + # Sort by the most recently accessed files (most sensible to keep) first file_stat.sort(key=lambda x: x[2]) # Search for the first entry where the storage limit is # reached |