From f9e463bce2607c5136acc79ecd495f8b62b8e5ad Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sun, 24 Sep 2017 23:06:45 -0400 Subject: [PATCH 1/5] Use EnumVariable for choice-based build options. --- SConstruct | 10 +++++----- platform/android/detect.py | 3 ++- platform/haiku/detect.py | 3 ++- platform/osx/detect.py | 3 ++- platform/windows/detect.py | 3 ++- platform/x11/detect.py | 3 ++- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/SConstruct b/SConstruct index 964222c7a0c..3e6231cdc2a 100644 --- a/SConstruct +++ b/SConstruct @@ -132,10 +132,10 @@ opts = Variables(customs, ARGUMENTS) # Target build options opts.Add('arch', "Platform-dependent architecture (arm/arm64/x86/x64/mips/etc)", '') -opts.Add('bits', "Target platform bits (default/32/64/fat)", 'default') +opts.Add(EnumVariable('bits', "Target platform bits", 'default', ('default', '32', '64', 'fat'))) opts.Add('p', "Platform (alias for 'platform')", '') -opts.Add('platform', "Target platform: any in " + str(platform_list), '') -opts.Add('target', "Compilation target (debug/release_debug/release)", 'debug') +opts.Add('platform', "Target platform (%s)" % ('|'.join(platform_list), ), '') +opts.Add(EnumVariable('target', "Compilation target", 'debug', ('debug', 'release_debug', 'release'))) opts.Add('tools', "Build the tools a.k.a. the Godot editor (yes/no)", 'yes') # Components @@ -152,7 +152,7 @@ opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all opts.Add('unix_global_settings_path', "UNIX-specific path to system-wide settings. Currently only used for templates", '') opts.Add('verbose', "Enable verbose output for the compilation (yes/no)", 'no') opts.Add('vsproj', "Generate Visual Studio Project. (yes/no)", 'no') -opts.Add('warnings', "Set the level of warnings emitted during compilation (extra/all/moderate/no)", 'no') +opts.Add(EnumVariable('warnings', "Set the level of warnings emitted during compilation", 'no', ('extra', 'all', 'moderate', 'no'))) opts.Add('progress', "Show a progress indicator during build (yes/no)", 'yes') opts.Add('dev', "If yes, alias for verbose=yes warnings=all (yes/no)", 'no') @@ -186,7 +186,7 @@ opts.Add("LINKFLAGS", "Custom flags for the linker") for k in platform_opts.keys(): opt_list = platform_opts[k] for o in opt_list: - opts.Add(o[0], o[1], o[2]) + opts.Add(o) for x in module_list: opts.Add('module_' + x + '_enabled', "Enable module '" + x + "' (yes/no)", "yes") diff --git a/platform/android/detect.py b/platform/android/detect.py index c1ac54c5876..6640a053fe6 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -18,11 +18,12 @@ def can_build(): def get_opts(): + from SCons.Variables import EnumVariable return [ ('ANDROID_NDK_ROOT', 'Path to the Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)), ('ndk_platform', 'Target platform (android-, e.g. "android-18")', "android-18"), - ('android_arch', 'Target architecture (armv7/armv6/arm64v8/x86)', "armv7"), + EnumVariable('android_arch', 'Target architecture', "armv7", ('armv7', 'armv6', 'arm64v8', 'x86')), ('android_neon', 'Enable NEON support (armv7 only)', "yes"), ('android_stl', 'Enable Android STL support (for modules)', "no") ] diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index 61ee32d2ddf..50f9783dd2d 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -19,9 +19,10 @@ def can_build(): def get_opts(): + from SCons.Variables import EnumVariable return [ - ('debug_symbols', 'Add debug symbols to release version (yes/no/full)', 'yes') + EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')), ] diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 24302b5ff92..3ae95f188d8 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -19,10 +19,11 @@ def can_build(): def get_opts(): + from SCons.Variables import EnumVariable return [ ('osxcross_sdk', 'OSXCross SDK version', 'darwin14'), - ('debug_symbols', 'Add debug symbols to release version (yes/no/full)', 'yes'), + EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')), ] diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 053ea466f3e..1b7a9926685 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -49,6 +49,7 @@ def can_build(): def get_opts(): + from SCons.Variables import EnumVariable mingw32 = "" mingw64 = "" @@ -65,7 +66,7 @@ def get_opts(): ('mingw_prefix_32', 'MinGW prefix (Win32)', mingw32), ('mingw_prefix_64', 'MinGW prefix (Win64)', mingw64), ('use_lto', 'Use link time optimization (when using MingW)', 'no'), - ('debug_symbols', 'Add debug symbols to release version (yes/no/full)', 'yes') + EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')), ] diff --git a/platform/x11/detect.py b/platform/x11/detect.py index b9b4ad82016..be21aa8f8ec 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -45,6 +45,7 @@ def can_build(): return True def get_opts(): + from SCons.Variables import EnumVariable return [ ('use_llvm', 'Use the LLVM compiler', 'no'), @@ -54,7 +55,7 @@ def get_opts(): ('use_lto', 'Use link time optimization', 'no'), ('pulseaudio', 'Detect & use pulseaudio', 'yes'), ('udev', 'Use udev for gamepad connection callbacks', 'no'), - ('debug_symbols', 'Add debug symbols to release version (yes/no/full)', 'yes') + EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')), ] From ffab67b8daea8e3379824105439eba8226b72fde Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 25 Sep 2017 00:04:49 -0400 Subject: [PATCH 2/5] Use BoolVariable in target/component/advanced options. --- SConstruct | 56 +++++++++++++++++------------------ drivers/SCsub | 6 ++-- editor/SCsub | 2 +- modules/etc/config.py | 2 +- modules/squish/config.py | 2 +- modules/tinyexr/config.py | 2 +- platform/android/detect.py | 2 +- platform/iphone/detect.py | 2 +- platform/javascript/detect.py | 2 +- platform/server/detect.py | 2 +- platform/uwp/detect.py | 4 +-- platform/windows/SCsub | 2 +- platform/x11/detect.py | 2 +- scene/3d/SCsub | 2 +- 14 files changed, 44 insertions(+), 44 deletions(-) diff --git a/SConstruct b/SConstruct index 3e6231cdc2a..8b1770a86ab 100644 --- a/SConstruct +++ b/SConstruct @@ -136,25 +136,25 @@ opts.Add(EnumVariable('bits', "Target platform bits", 'default', ('default', '32 opts.Add('p', "Platform (alias for 'platform')", '') opts.Add('platform', "Target platform (%s)" % ('|'.join(platform_list), ), '') opts.Add(EnumVariable('target', "Compilation target", 'debug', ('debug', 'release_debug', 'release'))) -opts.Add('tools', "Build the tools a.k.a. the Godot editor (yes/no)", 'yes') +opts.Add(BoolVariable('tools', "Build the tools a.k.a. the Godot editor", True)) # Components -opts.Add('deprecated', "Enable deprecated features (yes/no)", 'yes') -opts.Add('gdscript', "Build GDSCript support (yes/no)", 'yes') -opts.Add('minizip', "Build minizip archive support (yes/no)", 'yes') -opts.Add('xaudio2', "XAudio2 audio driver (yes/no)", 'no') -opts.Add('xml', "XML format support for resources (yes/no)", 'yes') +opts.Add(BoolVariable('deprecated', "Enable deprecated features", True)) +opts.Add(BoolVariable('gdscript', "Build GDSCript support", True)) +opts.Add(BoolVariable('minizip', "Build minizip archive support", True)) +opts.Add(BoolVariable('xaudio2', "XAudio2 audio driver", False)) +opts.Add(BoolVariable('xml', "XML format support for resources", True)) # Advanced options -opts.Add('disable_3d', "Disable 3D nodes for smaller executable (yes/no)", 'no') -opts.Add('disable_advanced_gui', "Disable advance 3D gui nodes and behaviors (yes/no)", 'no') +opts.Add(BoolVariable('disable_3d', "Disable 3D nodes for smaller executable", False)) +opts.Add(BoolVariable('disable_advanced_gui', "Disable advance 3D gui nodes and behaviors", False)) opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all generated binary files", '') opts.Add('unix_global_settings_path', "UNIX-specific path to system-wide settings. Currently only used for templates", '') -opts.Add('verbose', "Enable verbose output for the compilation (yes/no)", 'no') -opts.Add('vsproj', "Generate Visual Studio Project. (yes/no)", 'no') +opts.Add(BoolVariable('verbose', "Enable verbose output for the compilation", False)) +opts.Add(BoolVariable('vsproj', "Generate Visual Studio Project.", False)) opts.Add(EnumVariable('warnings', "Set the level of warnings emitted during compilation", 'no', ('extra', 'all', 'moderate', 'no'))) -opts.Add('progress', "Show a progress indicator during build (yes/no)", 'yes') -opts.Add('dev', "If yes, alias for verbose=yes warnings=all (yes/no)", 'no') +opts.Add(BoolVariable('progress', "Show a progress indicator during build", True)) +opts.Add(BoolVariable('dev', "If yes, alias for verbose=yes warnings=all", False)) # Thirdparty libraries opts.Add('builtin_enet', "Use the builtin enet library (yes/no)", 'yes') @@ -213,7 +213,7 @@ if (env_base['target'] == 'debug'): env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE']) -if (env_base['deprecated'] == 'no'): +if not env_base['deprecated']: env_base.Append(CPPFLAGS=['-DDISABLE_DEPRECATED']) env_base.platforms = {} @@ -237,11 +237,11 @@ if selected_platform in platform_list: else: env = env_base.Clone() - if (env["dev"] == "yes"): + if env['dev']: env["warnings"] = "all" - env["verbose"] = "yes" + env['verbose'] = True - if env['vsproj'] == "yes": + if env['vsproj']: env.vs_incs = [] env.vs_srcs = [] @@ -319,19 +319,19 @@ if selected_platform in platform_list: suffix = "." + selected_platform if (env["target"] == "release"): - if (env["tools"] == "yes"): + if env["tools"]: print("Tools can only be built with targets 'debug' and 'release_debug'.") sys.exit(255) suffix += ".opt" env.Append(CCFLAGS=['-DNDEBUG']) elif (env["target"] == "release_debug"): - if (env["tools"] == "yes"): + if env["tools"]: suffix += ".opt.tools" else: suffix += ".opt.debug" else: - if (env["tools"] == "yes"): + if env["tools"]: suffix += ".tools" else: suffix += ".debug" @@ -386,22 +386,22 @@ if selected_platform in platform_list: # to test 64 bits compiltion # env.Append(CPPFLAGS=['-m64']) - if (env['tools'] == 'yes'): + if env['tools']: env.Append(CPPFLAGS=['-DTOOLS_ENABLED']) - if (env['disable_3d'] == 'yes'): + if env['disable_3d']: env.Append(CPPFLAGS=['-D_3D_DISABLED']) - if (env['gdscript'] == 'yes'): + if env['gdscript']: env.Append(CPPFLAGS=['-DGDSCRIPT_ENABLED']) - if (env['disable_advanced_gui'] == 'yes'): + if env['disable_advanced_gui']: env.Append(CPPFLAGS=['-DADVANCED_GUI_DISABLED']) - if (env['minizip'] == 'yes'): + if env['minizip']: env.Append(CPPFLAGS=['-DMINIZIP_ENABLED']) - if (env['xml'] == 'yes'): + if env['xml']: env.Append(CPPFLAGS=['-DXML_ENABLED']) - if (env['verbose'] == 'no'): + if not env['verbose']: methods.no_verbose(sys, env) if (True): # FIXME: detect GLES3 @@ -423,7 +423,7 @@ if selected_platform in platform_list: SConscript("platform/" + selected_platform + "/SCsub") # build selected platform # Microsoft Visual Studio Project Generation - if (env['vsproj']) == "yes": + if env['vsproj']: methods.generate_vs_project(env, GetOption("num_jobs")) # Check for the existence of headers @@ -470,7 +470,7 @@ def progress_finish(target, source, env): with open(node_count_fname, 'w') as f: f.write('%d\n' % node_count) -if ('env' in locals() and env["progress"] == "yes"): +if 'env' in locals() and env['progress']: try: with open(node_count_fname) as f: node_count_max = int(f.readline()) diff --git a/drivers/SCsub b/drivers/SCsub index b8bba91378f..bdc7dcbb244 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -17,7 +17,7 @@ SConscript('pulseaudio/SCsub') if (env["platform"] == "windows"): SConscript("rtaudio/SCsub") SConscript("wasapi/SCsub") -if (env["xaudio2"] == "yes"): +if env['xaudio2']: SConscript("xaudio2/SCsub") # Graphics drivers @@ -29,10 +29,10 @@ SConscript("png/SCsub") # Tools override # FIXME: Should likely be integrated in the tools/ codebase -if (env["tools"] == "yes"): +if env['tools']: SConscript("convex_decomp/SCsub") -if env['vsproj'] == "yes": +if env['vsproj']: env.AddToVSProject(env.drivers_sources) if env.split_drivers: diff --git a/editor/SCsub b/editor/SCsub index 315865ad32a..bf88ebb1b5a 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -395,8 +395,8 @@ def _make_doc_data_class_path(to_path): g.write("{NULL,NULL}\n") g.write("};\n") -if (env["tools"] == "yes"): +if env['tools']: # Register exporters reg_exporters_inc = '#include "register_exporters.h"\n' reg_exporters = 'void register_exporters() {\n' diff --git a/modules/etc/config.py b/modules/etc/config.py index 4b0b01b78ed..ee719e52b8d 100644 --- a/modules/etc/config.py +++ b/modules/etc/config.py @@ -6,6 +6,6 @@ def can_build(platform): def configure(env): # Tools only, disabled for non-tools # TODO: Find a cleaner way to achieve that - if (env["tools"] == "no"): + if not env['tools']: env["module_etc_enabled"] = "no" env.disabled_modules.append("etc") diff --git a/modules/squish/config.py b/modules/squish/config.py index cc8f0980103..2b296389de0 100644 --- a/modules/squish/config.py +++ b/modules/squish/config.py @@ -6,6 +6,6 @@ def can_build(platform): def configure(env): # Tools only, disabled for non-tools # TODO: Find a cleaner way to achieve that - if (env["tools"] == "no"): + if not env['tools']: env["module_squish_enabled"] = "no" env.disabled_modules.append("squish") diff --git a/modules/tinyexr/config.py b/modules/tinyexr/config.py index 2e4b96a6b09..9cbf22cdc62 100644 --- a/modules/tinyexr/config.py +++ b/modules/tinyexr/config.py @@ -6,6 +6,6 @@ def can_build(platform): def configure(env): # Tools only, disabled for non-tools # TODO: Find a cleaner way to achieve that - if (env["tools"] == "no"): + if not env['tools']: env["module_tinyexr_enabled"] = "no" env.disabled_modules.append("tinyexr") diff --git a/platform/android/detect.py b/platform/android/detect.py index 6640a053fe6..67b31e488bb 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -32,7 +32,7 @@ def get_opts(): def get_flags(): return [ - ('tools', 'no'), + ('tools', False), ] diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index 0b81422fa36..8a44114a519 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -37,7 +37,7 @@ def get_opts(): def get_flags(): return [ - ('tools', 'no'), + ('tools', False), ] diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index bea8f156af5..b48a080ce01 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -27,7 +27,7 @@ def get_opts(): def get_flags(): return [ - ('tools', 'no'), + ('tools', False), ('module_theora_enabled', 'no'), ] diff --git a/platform/server/detect.py b/platform/server/detect.py index 5c13297bc60..673245ecff9 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -86,7 +86,7 @@ def configure(env): if (env['builtin_enet'] == 'no'): env.ParseConfig('pkg-config libenet --cflags --libs') - if (env['builtin_squish'] == 'no' and env["tools"] == "yes"): + if env['builtin_squish'] == 'no' and env['tools']: env.ParseConfig('pkg-config libsquish --cflags --libs') if env['builtin_zstd'] == 'no': diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py index 23929dd804b..af53f974462 100644 --- a/platform/uwp/detect.py +++ b/platform/uwp/detect.py @@ -33,8 +33,8 @@ def get_opts(): def get_flags(): return [ - ('tools', 'no'), - ('xaudio2', 'yes'), + ('tools', False), + ('xaudio2', True), ] diff --git a/platform/windows/SCsub b/platform/windows/SCsub index fd041e096e1..d3c160f052e 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -30,7 +30,7 @@ common_win.append(obj) binary = env.Program('#bin/godot', ['godot_win.cpp'] + common_win, PROGSUFFIX=env["PROGSUFFIX"]) # Microsoft Visual Studio Project Generation -if (env['vsproj']) == "yes": +if env['vsproj']: env.vs_srcs = env.vs_srcs + ["platform/windows/godot_win.cpp"] for x in common_win: env.vs_srcs = env.vs_srcs + ["platform/windows/" + str(x)] diff --git a/platform/x11/detect.py b/platform/x11/detect.py index be21aa8f8ec..1787bb46c41 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -159,7 +159,7 @@ def configure(env): if (env['builtin_enet'] == 'no'): env.ParseConfig('pkg-config libenet --cflags --libs') - if (env['builtin_squish'] == 'no' and env["tools"] == "yes"): + if env['builtin_squish'] == 'no' and env['tools']: env.ParseConfig('pkg-config libsquish --cflags --libs') if env['builtin_zstd'] == 'no': diff --git a/scene/3d/SCsub b/scene/3d/SCsub index 90e78ba8d38..72739b527e1 100644 --- a/scene/3d/SCsub +++ b/scene/3d/SCsub @@ -3,7 +3,7 @@ Import('env') -if (env["disable_3d"] == "yes"): +if env['disable_3d']: env.scene_sources.append("3d/spatial.cpp") env.scene_sources.append("3d/skeleton.cpp") From 45a9a680a3cf54d4f43c46c3ec43a108ee62b834 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 25 Sep 2017 00:22:58 -0400 Subject: [PATCH 3/5] Use BoolVariable for third-party options. --- SConstruct | 30 +++++++++++----------- core/SCsub | 2 +- drivers/SCsub | 2 +- drivers/png/SCsub | 2 +- modules/enet/SCsub | 2 +- modules/freetype/SCsub | 4 +-- modules/ogg/SCsub | 2 +- modules/openssl/SCsub | 2 +- modules/opus/SCsub | 4 +-- modules/recast/SCsub | 6 +---- modules/regex/SCsub | 2 +- modules/squish/SCsub | 2 +- modules/theora/SCsub | 6 ++--- modules/vorbis/SCsub | 4 +-- modules/webm/SCsub | 8 +++--- modules/webp/SCsub | 2 +- platform/osx/detect.py | 2 +- platform/server/detect.py | 42 +++++++++++++++--------------- platform/x11/detect.py | 54 +++++++++++++++++++-------------------- 19 files changed, 87 insertions(+), 91 deletions(-) diff --git a/SConstruct b/SConstruct index 8b1770a86ab..1d7b91e907b 100644 --- a/SConstruct +++ b/SConstruct @@ -157,21 +157,21 @@ opts.Add(BoolVariable('progress', "Show a progress indicator during build", True opts.Add(BoolVariable('dev', "If yes, alias for verbose=yes warnings=all", False)) # Thirdparty libraries -opts.Add('builtin_enet', "Use the builtin enet library (yes/no)", 'yes') -opts.Add('builtin_freetype', "Use the builtin freetype library (yes/no)", 'yes') -opts.Add('builtin_libogg', "Use the builtin libogg library (yes/no)", 'yes') -opts.Add('builtin_libpng', "Use the builtin libpng library (yes/no)", 'yes') -opts.Add('builtin_libtheora', "Use the builtin libtheora library (yes/no)", 'yes') -opts.Add('builtin_libvorbis', "Use the builtin libvorbis library (yes/no)", 'yes') -opts.Add('builtin_libvpx', "Use the builtin libvpx library (yes/no)", 'yes') -opts.Add('builtin_libwebp', "Use the builtin libwebp library (yes/no)", 'yes') -opts.Add('builtin_openssl', "Use the builtin openssl library (yes/no)", 'yes') -opts.Add('builtin_opus', "Use the builtin opus library (yes/no)", 'yes') -opts.Add('builtin_pcre2', "Use the builtin pcre2 library (yes/no)", 'yes') -opts.Add('builtin_recast', "Use the builtin recast library (yes/no)", 'yes') -opts.Add('builtin_squish', "Use the builtin squish library (yes/no)", 'yes') -opts.Add('builtin_zlib', "Use the builtin zlib library (yes/no)", 'yes') -opts.Add('builtin_zstd', "Use the builtin zstd library (yes/no)", 'yes') +opts.Add(BoolVariable('builtin_enet', "Use the builtin enet library", True)) +opts.Add(BoolVariable('builtin_freetype', "Use the builtin freetype library", True)) +opts.Add(BoolVariable('builtin_libogg', "Use the builtin libogg library", True)) +opts.Add(BoolVariable('builtin_libpng', "Use the builtin libpng library", True)) +opts.Add(BoolVariable('builtin_libtheora', "Use the builtin libtheora library", True)) +opts.Add(BoolVariable('builtin_libvorbis', "Use the builtin libvorbis library", True)) +opts.Add(BoolVariable('builtin_libvpx', "Use the builtin libvpx library", True)) +opts.Add(BoolVariable('builtin_libwebp', "Use the builtin libwebp library", True)) +opts.Add(BoolVariable('builtin_openssl', "Use the builtin openssl library", True)) +opts.Add(BoolVariable('builtin_opus', "Use the builtin opus library", True)) +opts.Add(BoolVariable('builtin_pcre2', "Use the builtin pcre2 library)", True)) +opts.Add(BoolVariable('builtin_recast', "Use the builtin recast library", True)) +opts.Add(BoolVariable('builtin_squish', "Use the builtin squish library", True)) +opts.Add(BoolVariable('builtin_zlib', "Use the builtin zlib library", True)) +opts.Add(BoolVariable('builtin_zstd', "Use the builtin zstd library", True)) # Environment setup opts.Add("CXX", "C++ compiler") diff --git a/core/SCsub b/core/SCsub index e78fe185a9e..e9b21bc71b7 100644 --- a/core/SCsub +++ b/core/SCsub @@ -83,7 +83,7 @@ thirdparty_minizip_sources = [ thirdparty_minizip_sources = [thirdparty_minizip_dir + file for file in thirdparty_minizip_sources] env.add_source_files(env.core_sources, thirdparty_minizip_sources) -if "builtin_zstd" in env and env["builtin_zstd"] == "yes": +if 'builtin_zstd' in env and env['builtin_zstd']: SConscript("#thirdparty/zstd/SCsub") diff --git a/drivers/SCsub b/drivers/SCsub index bdc7dcbb244..195f7ec4381 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -4,7 +4,7 @@ Import('env') env.drivers_sources = [] -if ("builtin_zlib" in env and env["builtin_zlib"] == "yes"): +if 'builtin_zlib' in env and env['builtin_zlib']: SConscript("zlib/SCsub") # OS drivers diff --git a/drivers/png/SCsub b/drivers/png/SCsub index 6684e36b20c..39480351a64 100644 --- a/drivers/png/SCsub +++ b/drivers/png/SCsub @@ -5,7 +5,7 @@ Import('env') env_png = env.Clone() # Thirdparty source files -if (env['builtin_libpng'] != 'no'): +if env['builtin_libpng']: thirdparty_dir = "#thirdparty/libpng/" thirdparty_sources = [ "png.c", diff --git a/modules/enet/SCsub b/modules/enet/SCsub index 42a933a66da..4790c5099f2 100644 --- a/modules/enet/SCsub +++ b/modules/enet/SCsub @@ -7,7 +7,7 @@ Import('env_modules') env_enet = env_modules.Clone() -if (env['builtin_enet'] != 'no'): +if env['builtin_enet']: thirdparty_dir = "#thirdparty/enet/" thirdparty_sources = [ "godot.cpp", diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub index f22df4407c0..19e384af736 100644 --- a/modules/freetype/SCsub +++ b/modules/freetype/SCsub @@ -6,7 +6,7 @@ from compat import isbasestring # Not building in a separate env as scene needs it # Thirdparty source files -if (env['builtin_freetype'] != 'no'): +if env['builtin_freetype']: thirdparty_dir = "#thirdparty/freetype/" thirdparty_sources = [ "src/autofit/autofit.c", @@ -65,7 +65,7 @@ if (env['builtin_freetype'] != 'no'): env.Append(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include"]) # also requires libpng headers - if (env['builtin_libpng'] != 'no'): + if env['builtin_libpng']: env.Append(CPPPATH=["#thirdparty/libpng"]) lib = env.Library("freetype_builtin", thirdparty_sources) diff --git a/modules/ogg/SCsub b/modules/ogg/SCsub index 5eabaf6f2b5..5e559bd4dbe 100644 --- a/modules/ogg/SCsub +++ b/modules/ogg/SCsub @@ -6,7 +6,7 @@ Import('env_modules') env_ogg = env_modules.Clone() # Thirdparty source files -if (env['builtin_libogg'] != 'no'): +if env['builtin_libogg']: thirdparty_dir = "#thirdparty/libogg/" thirdparty_sources = [ "bitwise.c", diff --git a/modules/openssl/SCsub b/modules/openssl/SCsub index eb3c0e64d81..84c5e684394 100644 --- a/modules/openssl/SCsub +++ b/modules/openssl/SCsub @@ -6,7 +6,7 @@ Import('env_modules') env_openssl = env_modules.Clone() # Thirdparty source files -if (env['builtin_openssl'] != 'no'): +if env['builtin_openssl']: thirdparty_dir = "#thirdparty/openssl/" thirdparty_sources = [ diff --git a/modules/opus/SCsub b/modules/opus/SCsub index 4d3053c7ecf..fee06bd2674 100644 --- a/modules/opus/SCsub +++ b/modules/opus/SCsub @@ -6,7 +6,7 @@ Import('env_modules') env_opus = env_modules.Clone() # Thirdparty source files -if (env['builtin_opus'] != 'no'): +if env['builtin_opus']: thirdparty_dir = "#thirdparty/opus/" thirdparty_sources = [ @@ -209,7 +209,7 @@ if (env['builtin_opus'] != 'no'): env_opus.Append(CPPPATH=[thirdparty_dir + "/" + dir for dir in thirdparty_include_paths]) # also requires libogg - if (env['builtin_libogg'] != 'no'): + if env['builtin_libogg']: env_opus.Append(CPPPATH=["#thirdparty/libogg"]) # Module files diff --git a/modules/recast/SCsub b/modules/recast/SCsub index 349bd22efb7..500c0ec0556 100644 --- a/modules/recast/SCsub +++ b/modules/recast/SCsub @@ -5,7 +5,7 @@ Import('env') # Not building in a separate env as core needs it # Thirdparty source files -if (env['builtin_recast'] != 'no'): +if env['builtin_recast']: thirdparty_dir = "#thirdparty/recastnavigation/Recast/" thirdparty_sources = [ "Source/Recast.cpp", @@ -24,10 +24,6 @@ if (env['builtin_recast'] != 'no'): env.Append(CPPPATH=[thirdparty_dir, thirdparty_dir + "/Include"]) - # also requires recast headers - if (env['builtin_recast'] != 'no'): - env.Append(CPPPATH=["#thirdparty/recastnavigation/Recast"]) - lib = env.Library("recast_builtin", thirdparty_sources) env.Append(LIBS=[lib]) diff --git a/modules/regex/SCsub b/modules/regex/SCsub index 2dfc2739e92..2bab144a282 100644 --- a/modules/regex/SCsub +++ b/modules/regex/SCsub @@ -7,7 +7,7 @@ env_regex = env_modules.Clone() env_regex.Append(CPPFLAGS=["-DPCRE2_CODE_UNIT_WIDTH=0"]) env_regex.add_source_files(env.modules_sources, "*.cpp") -if (env['builtin_pcre2'] != 'no'): +if env['builtin_pcre2']: jit_blacklist = ['javascript'] thirdparty_dir = '#thirdparty/pcre2/src/' thirdparty_flags = ['-DPCRE2_STATIC', '-DHAVE_CONFIG_H'] diff --git a/modules/squish/SCsub b/modules/squish/SCsub index cca7c038f19..127f22d7984 100644 --- a/modules/squish/SCsub +++ b/modules/squish/SCsub @@ -6,7 +6,7 @@ Import('env_modules') env_squish = env_modules.Clone() # Thirdparty source files -if (env['builtin_squish'] != 'no'): +if env['builtin_squish']: thirdparty_dir = "#thirdparty/squish/" thirdparty_sources = [ "alpha.cpp", diff --git a/modules/theora/SCsub b/modules/theora/SCsub index 2de4d296403..9015c2c354a 100644 --- a/modules/theora/SCsub +++ b/modules/theora/SCsub @@ -6,7 +6,7 @@ Import('env_modules') env_theora = env_modules.Clone() # Thirdparty source files -if (env['builtin_libtheora'] != 'no'): +if env['builtin_libtheora']: thirdparty_dir = "#thirdparty/libtheora/" thirdparty_sources = [ #"analyze.c", @@ -74,9 +74,9 @@ if (env['builtin_libtheora'] != 'no'): env_theora.Append(CPPPATH=[thirdparty_dir]) # also requires libogg and libvorbis - if (env['builtin_libogg'] != 'no'): + if env['builtin_libogg']: env_theora.Append(CPPPATH=["#thirdparty/libogg"]) - if (env['builtin_libvorbis'] != 'no'): + if env['builtin_libvorbis']: env_theora.Append(CPPPATH=["#thirdparty/libvorbis"]) # Godot source files diff --git a/modules/vorbis/SCsub b/modules/vorbis/SCsub index d3e4f7e15ae..9d2d0feb92f 100644 --- a/modules/vorbis/SCsub +++ b/modules/vorbis/SCsub @@ -6,7 +6,7 @@ Import('env_modules') env_vorbis = env_modules.Clone() # Thirdparty source files -if (env['builtin_libvorbis'] != 'no'): +if env['builtin_libvorbis']: thirdparty_dir = "#thirdparty/libvorbis/" thirdparty_sources = [ #"analysis.c", @@ -42,7 +42,7 @@ if (env['builtin_libvorbis'] != 'no'): env_vorbis.Append(CPPPATH=[thirdparty_dir]) # also requires libogg - if (env['builtin_libogg'] != 'no'): + if env['builtin_libogg']: env_vorbis.Append(CPPPATH=["#thirdparty/libogg"]) # Godot source files diff --git a/modules/webm/SCsub b/modules/webm/SCsub index 889f5e83aab..2f1a28a54ca 100644 --- a/modules/webm/SCsub +++ b/modules/webm/SCsub @@ -19,14 +19,14 @@ env_webm.add_source_files(env.modules_sources, thirdparty_libsimplewebm_sources) env_webm.Append(CPPPATH=[thirdparty_libsimplewebm_dir, thirdparty_libsimplewebm_dir + "libwebm/"]) # also requires libogg, libvorbis and libopus -if (env['builtin_libogg'] != 'no'): +if env['builtin_libogg']: env_webm.Append(CPPPATH=["#thirdparty/libogg"]) -if (env['builtin_libvorbis'] != 'no'): +if env['builtin_libvorbis']: env_webm.Append(CPPPATH=["#thirdparty/libvorbis"]) -if (env['builtin_opus'] != 'no'): +if env['builtin_opus']: env_webm.Append(CPPPATH=["#thirdparty/opus"]) -if (env['builtin_libvpx'] != 'no'): +if env['builtin_libvpx']: Export('env_webm') SConscript("libvpx/SCsub") diff --git a/modules/webp/SCsub b/modules/webp/SCsub index aa3486a2c57..f9295fed474 100644 --- a/modules/webp/SCsub +++ b/modules/webp/SCsub @@ -6,7 +6,7 @@ Import('env_modules') env_webp = env_modules.Clone() # Thirdparty source files -if (env['builtin_libwebp'] != 'no'): +if env['builtin_libwebp']: thirdparty_dir = "#thirdparty/libwebp/" thirdparty_sources = [ "dec/alpha_dec.c", diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 3ae95f188d8..51da0007121 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -97,7 +97,7 @@ def configure(env): ## Dependencies - if (env['builtin_libtheora'] != 'no'): + if env['builtin_libtheora']: env["x86_libtheora_opt_gcc"] = True ## Flags diff --git a/platform/server/detect.py b/platform/server/detect.py index 673245ecff9..94cdd0da73b 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -64,60 +64,60 @@ def configure(env): # FIXME: Check for existence of the libs before parsing their flags with pkg-config - if (env['builtin_openssl'] == 'no'): + if not env['builtin_openssl']: env.ParseConfig('pkg-config openssl --cflags --libs') - if (env['builtin_libwebp'] == 'no'): + if not env['builtin_libwebp']: env.ParseConfig('pkg-config libwebp --cflags --libs') # freetype depends on libpng and zlib, so bundling one of them while keeping others # as shared libraries leads to weird issues - if (env['builtin_freetype'] == 'yes' or env['builtin_libpng'] == 'yes' or env['builtin_zlib'] == 'yes'): - env['builtin_freetype'] = 'yes' - env['builtin_libpng'] = 'yes' - env['builtin_zlib'] = 'yes' + if env['builtin_freetype'] or env['builtin_libpng'] or env['builtin_zlib']: + env['builtin_freetype'] = True + env['builtin_libpng'] = True + env['builtin_zlib'] = True - if (env['builtin_freetype'] == 'no'): + if not env['builtin_freetype']: env.ParseConfig('pkg-config freetype2 --cflags --libs') - if (env['builtin_libpng'] == 'no'): + if not env['builtin_libpng']: env.ParseConfig('pkg-config libpng --cflags --libs') - if (env['builtin_enet'] == 'no'): + if not env['builtin_enet']: env.ParseConfig('pkg-config libenet --cflags --libs') - if env['builtin_squish'] == 'no' and env['tools']: + if not env['builtin_squish'] and env['tools']: env.ParseConfig('pkg-config libsquish --cflags --libs') - if env['builtin_zstd'] == 'no': + if not env['builtin_zstd']: env.ParseConfig('pkg-config libzstd --cflags --libs') # Sound and video libraries # Keep the order as it triggers chained dependencies (ogg needed by others, etc.) - if (env['builtin_libtheora'] == 'no'): - env['builtin_libogg'] = 'no' # Needed to link against system libtheora - env['builtin_libvorbis'] = 'no' # Needed to link against system libtheora + if not env['builtin_libtheora']: + env['builtin_libogg'] = False # Needed to link against system libtheora + env['builtin_libvorbis'] = False # Needed to link against system libtheora env.ParseConfig('pkg-config theora theoradec --cflags --libs') - if (env['builtin_libvpx'] == 'no'): + if not env['builtin_libvpx']: env.ParseConfig('pkg-config vpx --cflags --libs') - if (env['builtin_libvorbis'] == 'no'): - env['builtin_libogg'] = 'no' # Needed to link against system libvorbis + if not env['builtin_libvorbis']: + env['builtin_libogg'] = False # Needed to link against system libvorbis env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs') - if (env['builtin_opus'] == 'no'): - env['builtin_libogg'] = 'no' # Needed to link against system opus + if not env['builtin_opus']: + env['builtin_libogg'] = False # Needed to link against system opus env.ParseConfig('pkg-config opus opusfile --cflags --libs') - if (env['builtin_libogg'] == 'no'): + if not env['builtin_libogg']: env.ParseConfig('pkg-config ogg --cflags --libs') ## Flags # Linkflags below this line should typically stay the last ones - if (env['builtin_zlib'] == 'no'): + if not env['builtin_zlib']: env.ParseConfig('pkg-config zlib --cflags --libs') env.Append(CPPPATH=['#platform/server']) diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 1787bb46c41..ff7f2c9bd8a 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -62,10 +62,10 @@ def get_opts(): def get_flags(): return [ - ('builtin_freetype', 'no'), - ('builtin_libpng', 'no'), - ('builtin_openssl', 'no'), - ('builtin_zlib', 'no'), + ('builtin_freetype', False), + ('builtin_libpng', False), + ('builtin_openssl', False), + ('builtin_zlib', False), ] @@ -137,64 +137,64 @@ def configure(env): # FIXME: Check for existence of the libs before parsing their flags with pkg-config - if (env['builtin_openssl'] == 'no'): + if not env['builtin_openssl']: env.ParseConfig('pkg-config openssl --cflags --libs') - if (env['builtin_libwebp'] == 'no'): + if not env['builtin_libwebp']: env.ParseConfig('pkg-config libwebp --cflags --libs') # freetype depends on libpng and zlib, so bundling one of them while keeping others # as shared libraries leads to weird issues - if (env['builtin_freetype'] == 'yes' or env['builtin_libpng'] == 'yes' or env['builtin_zlib'] == 'yes'): - env['builtin_freetype'] = 'yes' - env['builtin_libpng'] = 'yes' - env['builtin_zlib'] = 'yes' + if env['builtin_freetype'] or env['builtin_libpng'] or env['builtin_zlib']: + env['builtin_freetype'] = True + env['builtin_libpng'] = True + env['builtin_zlib'] = True - if (env['builtin_freetype'] == 'no'): + if not env['builtin_freetype']: env.ParseConfig('pkg-config freetype2 --cflags --libs') - if (env['builtin_libpng'] == 'no'): + if not env['builtin_libpng']: env.ParseConfig('pkg-config libpng --cflags --libs') - if (env['builtin_enet'] == 'no'): + if not env['builtin_enet']: env.ParseConfig('pkg-config libenet --cflags --libs') - if env['builtin_squish'] == 'no' and env['tools']: + if not env['builtin_squish'] and env['tools']: env.ParseConfig('pkg-config libsquish --cflags --libs') - if env['builtin_zstd'] == 'no': + if not env['builtin_zstd']: env.ParseConfig('pkg-config libzstd --cflags --libs') # Sound and video libraries # Keep the order as it triggers chained dependencies (ogg needed by others, etc.) - if (env['builtin_libtheora'] == 'no'): - env['builtin_libogg'] = 'no' # Needed to link against system libtheora - env['builtin_libvorbis'] = 'no' # Needed to link against system libtheora + if not env['builtin_libtheora']: + env['builtin_libogg'] = False # Needed to link against system libtheora + env['builtin_libvorbis'] = False # Needed to link against system libtheora env.ParseConfig('pkg-config theora theoradec --cflags --libs') - if (env['builtin_libvpx'] == 'no'): + if not env['builtin_libvpx']: env.ParseConfig('pkg-config vpx --cflags --libs') - if (env['builtin_libvorbis'] == 'no'): - env['builtin_libogg'] = 'no' # Needed to link against system libvorbis + if not env['builtin_libvorbis']: + env['builtin_libogg'] = False # Needed to link against system libvorbis env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs') - if (env['builtin_opus'] == 'no'): - env['builtin_libogg'] = 'no' # Needed to link against system opus + if not env['builtin_opus']: + env['builtin_libogg'] = False # Needed to link against system opus env.ParseConfig('pkg-config opus opusfile --cflags --libs') - if (env['builtin_libogg'] == 'no'): + if not env['builtin_libogg']: env.ParseConfig('pkg-config ogg --cflags --libs') - if (env['builtin_libtheora'] != 'no'): + if env['builtin_libtheora']: list_of_x86 = ['x86_64', 'x86', 'i386', 'i586'] if any(platform.machine() in s for s in list_of_x86): env["x86_libtheora_opt_gcc"] = True # On Linux wchar_t should be 32-bits # 16-bit library shouldn't be required due to compiler optimisations - if (env['builtin_pcre2'] == 'no'): + if not env['builtin_pcre2']: env.ParseConfig('pkg-config libpcre2-32 --cflags --libs') ## Flags @@ -226,7 +226,7 @@ def configure(env): print("libudev development libraries not found, disabling udev support") # Linkflags below this line should typically stay the last ones - if (env['builtin_zlib'] == 'no'): + if not env['builtin_zlib']: env.ParseConfig('pkg-config zlib --cflags --libs') env.Append(CPPPATH=['#platform/x11']) From 5be675eb0332ccf660a81df51701146997ef9fcb Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 25 Sep 2017 00:27:32 -0400 Subject: [PATCH 4/5] Use BoolVariable for module options. --- SConstruct | 4 ++-- modules/etc/config.py | 2 +- modules/squish/config.py | 2 +- modules/tinyexr/config.py | 2 +- platform/android/detect.py | 2 +- platform/iphone/detect.py | 2 +- platform/javascript/detect.py | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/SConstruct b/SConstruct index 1d7b91e907b..4fd1b86f54e 100644 --- a/SConstruct +++ b/SConstruct @@ -189,7 +189,7 @@ for k in platform_opts.keys(): opts.Add(o) for x in module_list: - opts.Add('module_' + x + '_enabled', "Enable module '" + x + "' (yes/no)", "yes") + opts.Add(BoolVariable('module_' + x + '_enabled', "Enable module '%s'" % (x, ), True)) opts.Update(env_base) # update environment Help(opts.GenerateHelpText(env_base)) # generate help @@ -359,7 +359,7 @@ if selected_platform in platform_list: env.doc_class_path={} for x in module_list: - if env['module_' + x + '_enabled'] != "yes": + if not env['module_' + x + '_enabled']: continue tmppath = "./modules/" + x sys.path.append(tmppath) diff --git a/modules/etc/config.py b/modules/etc/config.py index ee719e52b8d..7dc2cb59c1c 100644 --- a/modules/etc/config.py +++ b/modules/etc/config.py @@ -7,5 +7,5 @@ def configure(env): # Tools only, disabled for non-tools # TODO: Find a cleaner way to achieve that if not env['tools']: - env["module_etc_enabled"] = "no" + env['module_etc_enabled'] = False env.disabled_modules.append("etc") diff --git a/modules/squish/config.py b/modules/squish/config.py index 2b296389de0..9b7729bda46 100644 --- a/modules/squish/config.py +++ b/modules/squish/config.py @@ -7,5 +7,5 @@ def configure(env): # Tools only, disabled for non-tools # TODO: Find a cleaner way to achieve that if not env['tools']: - env["module_squish_enabled"] = "no" + env['module_squish_enabled'] = False env.disabled_modules.append("squish") diff --git a/modules/tinyexr/config.py b/modules/tinyexr/config.py index 9cbf22cdc62..3e16fd725ef 100644 --- a/modules/tinyexr/config.py +++ b/modules/tinyexr/config.py @@ -7,5 +7,5 @@ def configure(env): # Tools only, disabled for non-tools # TODO: Find a cleaner way to achieve that if not env['tools']: - env["module_tinyexr_enabled"] = "no" + env['module_tinyexr_enabled'] = False env.disabled_modules.append("tinyexr") diff --git a/platform/android/detect.py b/platform/android/detect.py index 67b31e488bb..0a031fe0b1b 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -244,7 +244,7 @@ def configure(env): env.Append(LIBS=['OpenSLES', 'EGL', 'GLESv3', 'android', 'log', 'z', 'dl']) # TODO: Move that to opus module's config - if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"): + if 'module_opus_enabled' in env and env['module_opus_enabled']: if (env["android_arch"] == "armv6" or env["android_arch"] == "armv7"): env.Append(CFLAGS=["-DOPUS_ARM_OPT"]) env.opus_fixed_point = "yes" diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index 8a44114a519..d763b4b6c32 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -151,7 +151,7 @@ def configure(env): env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DMPC_FIXED_POINT']) # TODO: Move that to opus module's config - if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"): + if 'module_opus_enabled' in env and env['module_opus_enabled']: env.opus_fixed_point = "yes" if (env["arch"] == "arm"): env.Append(CFLAGS=["-DOPUS_ARM_OPT"]) diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index b48a080ce01..fdcdc7da6fc 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -28,7 +28,7 @@ def get_flags(): return [ ('tools', False), - ('module_theora_enabled', 'no'), + ('module_theora_enabled', False), ] @@ -116,5 +116,5 @@ def configure(env): env.Append(LINKFLAGS=['--memory-init-file', '1']) # TODO: Move that to opus module's config - if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"): + if 'module_opus_enabled' in env and env['module_opus_enabled']: env.opus_fixed_point = "yes" From 3e69d19116e8d0d64fcbb096d925249e5d3596ed Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 25 Sep 2017 00:37:17 -0400 Subject: [PATCH 5/5] Use BoolVariable in platform-specific options. --- modules/webm/libvpx/SCsub | 2 +- platform/android/detect.py | 14 +++++++------- platform/iphone/detect.py | 22 +++++++++++----------- platform/javascript/SCsub | 2 +- platform/javascript/detect.py | 10 +++++----- platform/server/detect.py | 6 +++--- platform/windows/detect.py | 6 +++--- platform/x11/detect.py | 32 ++++++++++++++++---------------- 8 files changed, 47 insertions(+), 47 deletions(-) diff --git a/modules/webm/libvpx/SCsub b/modules/webm/libvpx/SCsub index 0ee2ed45b80..fd8d762a5e9 100644 --- a/modules/webm/libvpx/SCsub +++ b/modules/webm/libvpx/SCsub @@ -265,7 +265,7 @@ if env["platform"] == 'uwp': else: import platform is_x11_or_server_arm = ((env["platform"] == 'x11' or env["platform"] == 'server') and platform.machine().startswith('arm')) - is_ios_x86 = (env["platform"] == 'iphone' and env["ios_sim"] == "yes") + is_ios_x86 = (env["platform"] == 'iphone' and env["ios_sim"]) is_android_x86 = (env["platform"] == 'android' and env["android_arch"] == 'x86') if is_android_x86: cpu_bits = '32' diff --git a/platform/android/detect.py b/platform/android/detect.py index 0a031fe0b1b..13fc4ee8109 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -18,14 +18,14 @@ def can_build(): def get_opts(): - from SCons.Variables import EnumVariable + from SCons.Variables import BoolVariable, EnumVariable return [ ('ANDROID_NDK_ROOT', 'Path to the Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)), ('ndk_platform', 'Target platform (android-, e.g. "android-18")', "android-18"), EnumVariable('android_arch', 'Target architecture', "armv7", ('armv7', 'armv6', 'arm64v8', 'x86')), - ('android_neon', 'Enable NEON support (armv7 only)', "yes"), - ('android_stl', 'Enable Android STL support (for modules)', "no") + BoolVariable('android_neon', 'Enable NEON support (armv7 only)', True), + BoolVariable('android_stl', 'Enable Android STL support (for modules)', False), ] @@ -94,7 +94,7 @@ def configure(env): env['android_arch'] = 'armv7' neon_text = "" - if env["android_arch"] == "armv7" and env['android_neon'] == 'yes': + if env["android_arch"] == "armv7" and env['android_neon']: neon_text = " (with NEON)" print("Building for Android (" + env['android_arch'] + ")" + neon_text) @@ -118,7 +118,7 @@ def configure(env): target_subpath = "arm-linux-androideabi-4.9" abi_subpath = "arm-linux-androideabi" arch_subpath = "armeabi-v7a" - if env['android_neon'] == 'yes': + if env['android_neon']: env.extra_suffix = ".armv7.neon" + env.extra_suffix else: env.extra_suffix = ".armv7" + env.extra_suffix @@ -200,7 +200,7 @@ def configure(env): elif env["android_arch"] == "armv7": target_opts = ['-target', 'armv7-none-linux-androideabi'] env.Append(CPPFLAGS='-D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -march=armv7-a -mfloat-abi=softfp'.split()) - if env['android_neon'] == 'yes': + if env['android_neon']: env['neon_enabled'] = True env.Append(CPPFLAGS=['-mfpu=neon', '-D__ARM_NEON__']) else: @@ -214,7 +214,7 @@ def configure(env): env.Append(CPPFLAGS=target_opts) env.Append(CPPFLAGS=common_opts) - if (env['android_stl'] == 'yes'): + if env['android_stl']: env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/include"]) env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath + "/include"]) env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath]) diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index d763b4b6c32..dd4db0b1cd7 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -20,17 +20,17 @@ def can_build(): def get_opts(): - + from SCons.Variables import BoolVariable return [ ('IPHONEPLATFORM', 'Name of the iPhone platform', 'iPhoneOS'), ('IPHONEPATH', 'Path to iPhone toolchain', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain'), ('IPHONESDK', 'Path to the iPhone SDK', '/Applications/Xcode.app/Contents/Developer/Platforms/${IPHONEPLATFORM}.platform/Developer/SDKs/${IPHONEPLATFORM}.sdk/'), - ('game_center', 'Support for game center', 'yes'), - ('store_kit', 'Support for in-app store', 'yes'), - ('icloud', 'Support for iCloud', 'yes'), - ('ios_exceptions', 'Enable exceptions', 'no'), + BoolVariable('game_center', 'Support for game center', True), + BoolVariable('store_kit', 'Support for in-app store', True), + BoolVariable('icloud', 'Support for iCloud', True), + BoolVariable('ios_exceptions', 'Enable exceptions', False), ('ios_triple', 'Triple for ios toolchain', ''), - ('ios_sim', 'Build simulator binary', 'no'), + BoolVariable('ios_sim', 'Build simulator binary', False), ] @@ -58,7 +58,7 @@ def configure(env): ## Architecture - if (env["ios_sim"] == "yes" or env["arch"] == "x86"): # i386, simulator + if env["ios_sim"] or env["arch"] == "x86": # i386, simulator env["arch"] = "x86" env["bits"] = "32" elif (env["arch"] == "arm" or env["arch"] == "arm32" or env["arch"] == "armv7" or env["bits"] == "32"): # arm @@ -91,7 +91,7 @@ def configure(env): env.Append(CPPFLAGS=['-DNEED_LONG_INT']) env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON']) - if env['ios_exceptions'] == 'yes': + if env['ios_exceptions']: env.Append(CPPFLAGS=['-fexceptions']) else: env.Append(CPPFLAGS=['-fno-exceptions']) @@ -129,15 +129,15 @@ def configure(env): ]) # Feature options - if env['game_center'] == 'yes': + if env['game_center']: env.Append(CPPFLAGS=['-DGAME_CENTER_ENABLED']) env.Append(LINKFLAGS=['-framework', 'GameKit']) - if env['store_kit'] == 'yes': + if env['store_kit']: env.Append(CPPFLAGS=['-DSTOREKIT_ENABLED']) env.Append(LINKFLAGS=['-framework', 'StoreKit']) - if env['icloud'] == 'yes': + if env['icloud']: env.Append(CPPFLAGS=['-DICLOUD_ENABLED']) env.Append(CPPPATH=['$IPHONESDK/usr/include', diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub index e2820417457..f01d9367d2f 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -29,7 +29,7 @@ zip_dir = target_dir.Dir('.javascript_zip') zip_files = env.InstallAs(zip_dir.File('godot.html'), '#misc/dist/html/default.html') implicit_targets = [] -if env['wasm'] == 'yes': +if env['wasm']: wasm = target_dir.File(basename + '.wasm') implicit_targets.append(wasm) zip_files.append(InstallAs(zip_dir.File('godot.wasm'), wasm)) diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index fdcdc7da6fc..cc29ad89562 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -17,10 +17,10 @@ def can_build(): def get_opts(): - + from SCons.Variables import BoolVariable return [ - ['wasm', 'Compile to WebAssembly', 'no'], - ['javascript_eval', 'Enable JavaScript eval interface', 'yes'], + BoolVariable('wasm', 'Compile to WebAssembly', False), + BoolVariable('javascript_eval', 'Enable JavaScript eval interface', True), ] @@ -95,7 +95,7 @@ def configure(env): # These flags help keep the file size down env.Append(CPPFLAGS=["-fno-exceptions", '-DNO_SAFE_CAST', '-fno-rtti']) - if env['javascript_eval'] == 'yes': + if env['javascript_eval']: env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED']) ## Link flags @@ -103,7 +103,7 @@ def configure(env): env.Append(LINKFLAGS=['-s', 'EXTRA_EXPORTED_RUNTIME_METHODS="[\'FS\']"']) env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1']) - if (env['wasm'] == 'yes'): + if env['wasm']: env.Append(LINKFLAGS=['-s', 'BINARYEN=1']) # In contrast to asm.js, enabling memory growth on WebAssembly has no # major performance impact, and causes only a negligible increase in diff --git a/platform/server/detect.py b/platform/server/detect.py index 94cdd0da73b..04b38f280dd 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -19,9 +19,9 @@ def can_build(): def get_opts(): - + from SCons.Variables import BoolVariable return [ - ('use_llvm', 'Use the LLVM compiler', 'no'), + BoolVariable('use_llvm', 'Use the LLVM compiler', False), ] @@ -52,7 +52,7 @@ def configure(env): ## Compiler configuration - if (env["use_llvm"] == "yes"): + if env['use_llvm']: if ('clang++' not in env['CXX']): env["CC"] = "clang" env["CXX"] = "clang++" diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 1b7a9926685..92f2e078c82 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -49,7 +49,7 @@ def can_build(): def get_opts(): - from SCons.Variables import EnumVariable + from SCons.Variables import BoolVariable, EnumVariable mingw32 = "" mingw64 = "" @@ -65,7 +65,7 @@ def get_opts(): return [ ('mingw_prefix_32', 'MinGW prefix (Win32)', mingw32), ('mingw_prefix_64', 'MinGW prefix (Win64)', mingw64), - ('use_lto', 'Use link time optimization (when using MingW)', 'no'), + BoolVariable('use_lto', 'Use link time optimization (when using MingW)', False), EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')), ] @@ -263,7 +263,7 @@ def configure(env): env['LD'] = mingw_prefix + "g++" env["x86_libtheora_opt_gcc"] = True - if (env["use_lto"] == "yes"): + if env['use_lto']: env.Append(CCFLAGS=['-flto']) env.Append(LINKFLAGS=['-flto']) diff --git a/platform/x11/detect.py b/platform/x11/detect.py index ff7f2c9bd8a..c8d9930af13 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -45,16 +45,16 @@ def can_build(): return True def get_opts(): - from SCons.Variables import EnumVariable + from SCons.Variables import BoolVariable, EnumVariable return [ - ('use_llvm', 'Use the LLVM compiler', 'no'), - ('use_static_cpp', 'Link stdc++ statically', 'no'), - ('use_sanitizer', 'Use LLVM compiler address sanitizer', 'no'), - ('use_leak_sanitizer', 'Use LLVM compiler memory leaks sanitizer (implies use_sanitizer)', 'no'), - ('use_lto', 'Use link time optimization', 'no'), - ('pulseaudio', 'Detect & use pulseaudio', 'yes'), - ('udev', 'Use udev for gamepad connection callbacks', 'no'), + BoolVariable('use_llvm', 'Use the LLVM compiler', False), + BoolVariable('use_static_cpp', 'Link stdc++ statically', False), + BoolVariable('use_sanitizer', 'Use LLVM compiler address sanitizer', False), + BoolVariable('use_leak_sanitizer', 'Use LLVM compiler memory leaks sanitizer (implies use_sanitizer)', False), + BoolVariable('use_lto', 'Use link time optimization', False), + BoolVariable('pulseaudio', 'Detect & use pulseaudio', True), + BoolVariable('udev', 'Use udev for gamepad connection callbacks', False), EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')), ] @@ -101,7 +101,7 @@ def configure(env): ## Compiler configuration - if (env["use_llvm"] == "yes"): + if env['use_llvm']: if ('clang++' not in env['CXX']): env["CC"] = "clang" env["CXX"] = "clang++" @@ -110,18 +110,18 @@ def configure(env): env.extra_suffix = ".llvm" + env.extra_suffix # leak sanitizer requires (address) sanitizer - if (env["use_sanitizer"] == "yes" or env["use_leak_sanitizer"] == "yes"): + if env['use_sanitizer'] or env['use_leak_sanitizer']: env.Append(CCFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer']) env.Append(LINKFLAGS=['-fsanitize=address']) env.extra_suffix += "s" - if (env["use_leak_sanitizer"] == "yes"): + if env['use_leak_sanitizer']: env.Append(CCFLAGS=['-fsanitize=leak']) env.Append(LINKFLAGS=['-fsanitize=leak']) - if (env["use_lto"] == "yes"): + if env['use_lto']: env.Append(CCFLAGS=['-flto']) env.Append(LINKFLAGS=['-flto']) - if (env["use_llvm"] == "no"): + if not env['use_llvm']: env['RANLIB'] = 'gcc-ranlib' env['AR'] = 'gcc-ar' @@ -206,7 +206,7 @@ def configure(env): else: print("ALSA libraries not found, disabling driver") - if (env["pulseaudio"] == "yes"): + if env['pulseaudio']: if (os.system("pkg-config --exists libpulse-simple") == 0): # 0 means found print("Enabling PulseAudio") env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"]) @@ -217,7 +217,7 @@ def configure(env): if (platform.system() == "Linux"): env.Append(CPPFLAGS=["-DJOYDEV_ENABLED"]) - if (env["udev"] == "yes"): + if env['udev']: if (os.system("pkg-config --exists libudev") == 0): # 0 means found print("Enabling udev support") env.Append(CPPFLAGS=["-DUDEV_ENABLED"]) @@ -245,5 +245,5 @@ def configure(env): env.Append(CPPFLAGS=['-m64']) env.Append(LINKFLAGS=['-m64', '-L/usr/lib/i686-linux-gnu']) - if (env["use_static_cpp"] == "yes"): + if env['use_static_cpp']: env.Append(LINKFLAGS=['-static-libstdc++'])