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