Use BoolVariable in platform-specific options.

This commit is contained in:
Elliott Sales de Andrade 2017-09-25 00:37:17 -04:00
parent 5be675eb03
commit 3e69d19116
8 changed files with 47 additions and 47 deletions

View File

@ -265,7 +265,7 @@ if env["platform"] == 'uwp':
else: else:
import platform import platform
is_x11_or_server_arm = ((env["platform"] == 'x11' or env["platform"] == 'server') and platform.machine().startswith('arm')) 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') is_android_x86 = (env["platform"] == 'android' and env["android_arch"] == 'x86')
if is_android_x86: if is_android_x86:
cpu_bits = '32' cpu_bits = '32'

View File

@ -18,14 +18,14 @@ def can_build():
def get_opts(): def get_opts():
from SCons.Variables import EnumVariable from SCons.Variables import BoolVariable, EnumVariable
return [ return [
('ANDROID_NDK_ROOT', 'Path to the Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)), ('ANDROID_NDK_ROOT', 'Path to the Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)),
('ndk_platform', 'Target platform (android-<api>, e.g. "android-18")', "android-18"), ('ndk_platform', 'Target platform (android-<api>, e.g. "android-18")', "android-18"),
EnumVariable('android_arch', 'Target architecture', "armv7", ('armv7', 'armv6', 'arm64v8', 'x86')), EnumVariable('android_arch', 'Target architecture', "armv7", ('armv7', 'armv6', 'arm64v8', 'x86')),
('android_neon', 'Enable NEON support (armv7 only)', "yes"), BoolVariable('android_neon', 'Enable NEON support (armv7 only)', True),
('android_stl', 'Enable Android STL support (for modules)', "no") BoolVariable('android_stl', 'Enable Android STL support (for modules)', False),
] ]
@ -94,7 +94,7 @@ def configure(env):
env['android_arch'] = 'armv7' env['android_arch'] = 'armv7'
neon_text = "" 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)" neon_text = " (with NEON)"
print("Building for Android (" + env['android_arch'] + ")" + neon_text) print("Building for Android (" + env['android_arch'] + ")" + neon_text)
@ -118,7 +118,7 @@ def configure(env):
target_subpath = "arm-linux-androideabi-4.9" target_subpath = "arm-linux-androideabi-4.9"
abi_subpath = "arm-linux-androideabi" abi_subpath = "arm-linux-androideabi"
arch_subpath = "armeabi-v7a" arch_subpath = "armeabi-v7a"
if env['android_neon'] == 'yes': if env['android_neon']:
env.extra_suffix = ".armv7.neon" + env.extra_suffix env.extra_suffix = ".armv7.neon" + env.extra_suffix
else: else:
env.extra_suffix = ".armv7" + env.extra_suffix env.extra_suffix = ".armv7" + env.extra_suffix
@ -200,7 +200,7 @@ def configure(env):
elif env["android_arch"] == "armv7": elif env["android_arch"] == "armv7":
target_opts = ['-target', 'armv7-none-linux-androideabi'] 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()) 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['neon_enabled'] = True
env.Append(CPPFLAGS=['-mfpu=neon', '-D__ARM_NEON__']) env.Append(CPPFLAGS=['-mfpu=neon', '-D__ARM_NEON__'])
else: else:
@ -214,7 +214,7 @@ def configure(env):
env.Append(CPPFLAGS=target_opts) env.Append(CPPFLAGS=target_opts)
env.Append(CPPFLAGS=common_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/include"])
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath + "/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]) env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath])

View File

@ -20,17 +20,17 @@ def can_build():
def get_opts(): def get_opts():
from SCons.Variables import BoolVariable
return [ return [
('IPHONEPLATFORM', 'Name of the iPhone platform', 'iPhoneOS'), ('IPHONEPLATFORM', 'Name of the iPhone platform', 'iPhoneOS'),
('IPHONEPATH', 'Path to iPhone toolchain', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain'), ('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/'), ('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'), BoolVariable('game_center', 'Support for game center', True),
('store_kit', 'Support for in-app store', 'yes'), BoolVariable('store_kit', 'Support for in-app store', True),
('icloud', 'Support for iCloud', 'yes'), BoolVariable('icloud', 'Support for iCloud', True),
('ios_exceptions', 'Enable exceptions', 'no'), BoolVariable('ios_exceptions', 'Enable exceptions', False),
('ios_triple', 'Triple for ios toolchain', ''), ('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 ## 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["arch"] = "x86"
env["bits"] = "32" env["bits"] = "32"
elif (env["arch"] == "arm" or env["arch"] == "arm32" or env["arch"] == "armv7" or env["bits"] == "32"): # arm 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=['-DNEED_LONG_INT'])
env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON']) env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON'])
if env['ios_exceptions'] == 'yes': if env['ios_exceptions']:
env.Append(CPPFLAGS=['-fexceptions']) env.Append(CPPFLAGS=['-fexceptions'])
else: else:
env.Append(CPPFLAGS=['-fno-exceptions']) env.Append(CPPFLAGS=['-fno-exceptions'])
@ -129,15 +129,15 @@ def configure(env):
]) ])
# Feature options # Feature options
if env['game_center'] == 'yes': if env['game_center']:
env.Append(CPPFLAGS=['-DGAME_CENTER_ENABLED']) env.Append(CPPFLAGS=['-DGAME_CENTER_ENABLED'])
env.Append(LINKFLAGS=['-framework', 'GameKit']) env.Append(LINKFLAGS=['-framework', 'GameKit'])
if env['store_kit'] == 'yes': if env['store_kit']:
env.Append(CPPFLAGS=['-DSTOREKIT_ENABLED']) env.Append(CPPFLAGS=['-DSTOREKIT_ENABLED'])
env.Append(LINKFLAGS=['-framework', 'StoreKit']) env.Append(LINKFLAGS=['-framework', 'StoreKit'])
if env['icloud'] == 'yes': if env['icloud']:
env.Append(CPPFLAGS=['-DICLOUD_ENABLED']) env.Append(CPPFLAGS=['-DICLOUD_ENABLED'])
env.Append(CPPPATH=['$IPHONESDK/usr/include', env.Append(CPPPATH=['$IPHONESDK/usr/include',

View File

@ -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') zip_files = env.InstallAs(zip_dir.File('godot.html'), '#misc/dist/html/default.html')
implicit_targets = [] implicit_targets = []
if env['wasm'] == 'yes': if env['wasm']:
wasm = target_dir.File(basename + '.wasm') wasm = target_dir.File(basename + '.wasm')
implicit_targets.append(wasm) implicit_targets.append(wasm)
zip_files.append(InstallAs(zip_dir.File('godot.wasm'), wasm)) zip_files.append(InstallAs(zip_dir.File('godot.wasm'), wasm))

View File

@ -17,10 +17,10 @@ def can_build():
def get_opts(): def get_opts():
from SCons.Variables import BoolVariable
return [ return [
['wasm', 'Compile to WebAssembly', 'no'], BoolVariable('wasm', 'Compile to WebAssembly', False),
['javascript_eval', 'Enable JavaScript eval interface', 'yes'], BoolVariable('javascript_eval', 'Enable JavaScript eval interface', True),
] ]
@ -95,7 +95,7 @@ def configure(env):
# These flags help keep the file size down # These flags help keep the file size down
env.Append(CPPFLAGS=["-fno-exceptions", '-DNO_SAFE_CAST', '-fno-rtti']) 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']) env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED'])
## Link flags ## Link flags
@ -103,7 +103,7 @@ def configure(env):
env.Append(LINKFLAGS=['-s', 'EXTRA_EXPORTED_RUNTIME_METHODS="[\'FS\']"']) env.Append(LINKFLAGS=['-s', 'EXTRA_EXPORTED_RUNTIME_METHODS="[\'FS\']"'])
env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1']) env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1'])
if (env['wasm'] == 'yes'): if env['wasm']:
env.Append(LINKFLAGS=['-s', 'BINARYEN=1']) env.Append(LINKFLAGS=['-s', 'BINARYEN=1'])
# In contrast to asm.js, enabling memory growth on WebAssembly has no # In contrast to asm.js, enabling memory growth on WebAssembly has no
# major performance impact, and causes only a negligible increase in # major performance impact, and causes only a negligible increase in

View File

@ -19,9 +19,9 @@ def can_build():
def get_opts(): def get_opts():
from SCons.Variables import BoolVariable
return [ 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 ## Compiler configuration
if (env["use_llvm"] == "yes"): if env['use_llvm']:
if ('clang++' not in env['CXX']): if ('clang++' not in env['CXX']):
env["CC"] = "clang" env["CC"] = "clang"
env["CXX"] = "clang++" env["CXX"] = "clang++"

View File

@ -49,7 +49,7 @@ def can_build():
def get_opts(): def get_opts():
from SCons.Variables import EnumVariable from SCons.Variables import BoolVariable, EnumVariable
mingw32 = "" mingw32 = ""
mingw64 = "" mingw64 = ""
@ -65,7 +65,7 @@ def get_opts():
return [ return [
('mingw_prefix_32', 'MinGW prefix (Win32)', mingw32), ('mingw_prefix_32', 'MinGW prefix (Win32)', mingw32),
('mingw_prefix_64', 'MinGW prefix (Win64)', mingw64), ('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')), 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['LD'] = mingw_prefix + "g++"
env["x86_libtheora_opt_gcc"] = True env["x86_libtheora_opt_gcc"] = True
if (env["use_lto"] == "yes"): if env['use_lto']:
env.Append(CCFLAGS=['-flto']) env.Append(CCFLAGS=['-flto'])
env.Append(LINKFLAGS=['-flto']) env.Append(LINKFLAGS=['-flto'])

View File

@ -45,16 +45,16 @@ def can_build():
return True return True
def get_opts(): def get_opts():
from SCons.Variables import EnumVariable from SCons.Variables import BoolVariable, EnumVariable
return [ return [
('use_llvm', 'Use the LLVM compiler', 'no'), BoolVariable('use_llvm', 'Use the LLVM compiler', False),
('use_static_cpp', 'Link stdc++ statically', 'no'), BoolVariable('use_static_cpp', 'Link stdc++ statically', False),
('use_sanitizer', 'Use LLVM compiler address sanitizer', 'no'), BoolVariable('use_sanitizer', 'Use LLVM compiler address sanitizer', False),
('use_leak_sanitizer', 'Use LLVM compiler memory leaks sanitizer (implies use_sanitizer)', 'no'), BoolVariable('use_leak_sanitizer', 'Use LLVM compiler memory leaks sanitizer (implies use_sanitizer)', False),
('use_lto', 'Use link time optimization', 'no'), BoolVariable('use_lto', 'Use link time optimization', False),
('pulseaudio', 'Detect & use pulseaudio', 'yes'), BoolVariable('pulseaudio', 'Detect & use pulseaudio', True),
('udev', 'Use udev for gamepad connection callbacks', 'no'), BoolVariable('udev', 'Use udev for gamepad connection callbacks', False),
EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')), EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')),
] ]
@ -101,7 +101,7 @@ def configure(env):
## Compiler configuration ## Compiler configuration
if (env["use_llvm"] == "yes"): if env['use_llvm']:
if ('clang++' not in env['CXX']): if ('clang++' not in env['CXX']):
env["CC"] = "clang" env["CC"] = "clang"
env["CXX"] = "clang++" env["CXX"] = "clang++"
@ -110,18 +110,18 @@ def configure(env):
env.extra_suffix = ".llvm" + env.extra_suffix env.extra_suffix = ".llvm" + env.extra_suffix
# leak sanitizer requires (address) sanitizer # 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(CCFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
env.Append(LINKFLAGS=['-fsanitize=address']) env.Append(LINKFLAGS=['-fsanitize=address'])
env.extra_suffix += "s" env.extra_suffix += "s"
if (env["use_leak_sanitizer"] == "yes"): if env['use_leak_sanitizer']:
env.Append(CCFLAGS=['-fsanitize=leak']) env.Append(CCFLAGS=['-fsanitize=leak'])
env.Append(LINKFLAGS=['-fsanitize=leak']) env.Append(LINKFLAGS=['-fsanitize=leak'])
if (env["use_lto"] == "yes"): if env['use_lto']:
env.Append(CCFLAGS=['-flto']) env.Append(CCFLAGS=['-flto'])
env.Append(LINKFLAGS=['-flto']) env.Append(LINKFLAGS=['-flto'])
if (env["use_llvm"] == "no"): if not env['use_llvm']:
env['RANLIB'] = 'gcc-ranlib' env['RANLIB'] = 'gcc-ranlib'
env['AR'] = 'gcc-ar' env['AR'] = 'gcc-ar'
@ -206,7 +206,7 @@ def configure(env):
else: else:
print("ALSA libraries not found, disabling driver") 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 if (os.system("pkg-config --exists libpulse-simple") == 0): # 0 means found
print("Enabling PulseAudio") print("Enabling PulseAudio")
env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"]) env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"])
@ -217,7 +217,7 @@ def configure(env):
if (platform.system() == "Linux"): if (platform.system() == "Linux"):
env.Append(CPPFLAGS=["-DJOYDEV_ENABLED"]) env.Append(CPPFLAGS=["-DJOYDEV_ENABLED"])
if (env["udev"] == "yes"): if env['udev']:
if (os.system("pkg-config --exists libudev") == 0): # 0 means found if (os.system("pkg-config --exists libudev") == 0): # 0 means found
print("Enabling udev support") print("Enabling udev support")
env.Append(CPPFLAGS=["-DUDEV_ENABLED"]) env.Append(CPPFLAGS=["-DUDEV_ENABLED"])
@ -245,5 +245,5 @@ def configure(env):
env.Append(CPPFLAGS=['-m64']) env.Append(CPPFLAGS=['-m64'])
env.Append(LINKFLAGS=['-m64', '-L/usr/lib/i686-linux-gnu']) 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++']) env.Append(LINKFLAGS=['-static-libstdc++'])