diff options
Diffstat (limited to 'platform')
49 files changed, 2134 insertions, 1690 deletions
diff --git a/platform/android/SCsub b/platform/android/SCsub index 4f9a9709cb..146f7c25a3 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -6,127 +6,127 @@ Import('env') android_files = [ - 'os_android.cpp', - 'godot_android.cpp', - 'file_access_android.cpp', - 'dir_access_android.cpp', - 'audio_driver_opensl.cpp', - 'file_access_jandroid.cpp', - 'dir_access_jandroid.cpp', - 'thread_jandroid.cpp', - 'audio_driver_jandroid.cpp', - 'ifaddrs_android.cpp', - 'android_native_app_glue.c', - 'java_glue.cpp', - 'cpu-features.c', - 'java_class_wrapper.cpp' + 'os_android.cpp', + 'godot_android.cpp', + 'file_access_android.cpp', + 'dir_access_android.cpp', + 'audio_driver_opensl.cpp', + 'file_access_jandroid.cpp', + 'dir_access_jandroid.cpp', + 'thread_jandroid.cpp', + 'audio_driver_jandroid.cpp', + 'ifaddrs_android.cpp', + 'android_native_app_glue.c', + 'java_glue.cpp', + 'cpu-features.c', + 'java_class_wrapper.cpp' ] -#env.Depends('#core/math/vector3.h', 'vector3_psp.h') +# env.Depends('#core/math/vector3.h', 'vector3_psp.h') #obj = env.SharedObject('godot_android.cpp') env_android = env.Clone() if env['target'] == "profile": - env_android.Append(CPPFLAGS=['-DPROFILER_ENABLED']) + env_android.Append(CPPFLAGS=['-DPROFILER_ENABLED']) -android_objects=[] +android_objects = [] for x in android_files: - android_objects.append( env_android.SharedObject( x ) ) + android_objects.append(env_android.SharedObject(x)) prog = None -abspath=env.Dir(".").abspath +abspath = env.Dir(".").abspath -gradle_basein = open(abspath+"/build.gradle.template","rb") -gradle_baseout = open(abspath+"/java/build.gradle","wb") +gradle_basein = open(abspath + "/build.gradle.template", "rb") +gradle_baseout = open(abspath + "/java/build.gradle", "wb") gradle_text = gradle_basein.read() -gradle_maven_repos_text="" +gradle_maven_repos_text = "" if len(env.android_maven_repos) > 0: - gradle_maven_repos_text+="maven {\n" - for x in env.android_maven_repos: - gradle_maven_repos_text+="\t\t"+x+"\n" - gradle_maven_repos_text+="\t}\n" + gradle_maven_repos_text += "maven {\n" + for x in env.android_maven_repos: + gradle_maven_repos_text += "\t\t" + x + "\n" + gradle_maven_repos_text += "\t}\n" -gradle_maven_dependencies_text="" +gradle_maven_dependencies_text = "" for x in env.android_dependencies: - gradle_maven_dependencies_text+=x+"\n" + gradle_maven_dependencies_text += x + "\n" -gradle_java_dirs_text="" +gradle_java_dirs_text = "" for x in env.android_java_dirs: - gradle_java_dirs_text+=",'"+x.replace("\\","/")+"'" + gradle_java_dirs_text += ",'" + x.replace("\\", "/") + "'" -gradle_res_dirs_text="" +gradle_res_dirs_text = "" for x in env.android_res_dirs: - gradle_res_dirs_text+=",'"+x.replace("\\","/")+"'" + gradle_res_dirs_text += ",'" + x.replace("\\", "/") + "'" -gradle_aidl_dirs_text="" +gradle_aidl_dirs_text = "" for x in env.android_aidl_dirs: - gradle_aidl_dirs_text+=",'"+x.replace("\\","/")+"'" + gradle_aidl_dirs_text += ",'" + x.replace("\\", "/") + "'" -gradle_jni_dirs_text="" +gradle_jni_dirs_text = "" for x in env.android_jni_dirs: - gradle_jni_dirs_text+=",'"+x.replace("\\","/")+"'" + gradle_jni_dirs_text += ",'" + x.replace("\\", "/") + "'" -gradle_asset_dirs_text="" +gradle_asset_dirs_text = "" -gradle_default_config_text="" +gradle_default_config_text = "" for x in env.android_default_config: - gradle_default_config_text+=x+"\n\t\t" + gradle_default_config_text += x + "\n\t\t" -gradle_text = gradle_text.replace("$$GRADLE_REPOSITORY_URLS$$",gradle_maven_repos_text) -gradle_text = gradle_text.replace("$$GRADLE_DEPENDENCIES$$",gradle_maven_dependencies_text) -gradle_text = gradle_text.replace("$$GRADLE_JAVA_DIRS$$",gradle_java_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_RES_DIRS$$",gradle_res_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_ASSET_DIRS$$",gradle_asset_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_AIDL_DIRS$$",gradle_aidl_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_JNI_DIRS$$",gradle_jni_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_DEFAULT_CONFIG$$",gradle_default_config_text) +gradle_text = gradle_text.replace("$$GRADLE_REPOSITORY_URLS$$", gradle_maven_repos_text) +gradle_text = gradle_text.replace("$$GRADLE_DEPENDENCIES$$", gradle_maven_dependencies_text) +gradle_text = gradle_text.replace("$$GRADLE_JAVA_DIRS$$", gradle_java_dirs_text) +gradle_text = gradle_text.replace("$$GRADLE_RES_DIRS$$", gradle_res_dirs_text) +gradle_text = gradle_text.replace("$$GRADLE_ASSET_DIRS$$", gradle_asset_dirs_text) +gradle_text = gradle_text.replace("$$GRADLE_AIDL_DIRS$$", gradle_aidl_dirs_text) +gradle_text = gradle_text.replace("$$GRADLE_JNI_DIRS$$", gradle_jni_dirs_text) +gradle_text = gradle_text.replace("$$GRADLE_DEFAULT_CONFIG$$", gradle_default_config_text) -gradle_baseout.write( gradle_text ) +gradle_baseout.write(gradle_text) gradle_baseout.close() -pp_basein = open(abspath+"/AndroidManifest.xml.template","rb") -pp_baseout = open(abspath+"/java/AndroidManifest.xml","wb") +pp_basein = open(abspath + "/AndroidManifest.xml.template", "rb") +pp_baseout = open(abspath + "/java/AndroidManifest.xml", "wb") manifest = pp_basein.read() -manifest = manifest.replace("$$ADD_APPLICATION_CHUNKS$$",env.android_manifest_chunk) -manifest = manifest.replace("$$ADD_PERMISSION_CHUNKS$$",env.android_permission_chunk) -manifest = manifest.replace("$$ADD_APPATTRIBUTE_CHUNKS$$",env.android_appattributes_chunk) -pp_baseout.write( manifest ) +manifest = manifest.replace("$$ADD_APPLICATION_CHUNKS$$", env.android_manifest_chunk) +manifest = manifest.replace("$$ADD_PERMISSION_CHUNKS$$", env.android_permission_chunk) +manifest = manifest.replace("$$ADD_APPATTRIBUTE_CHUNKS$$", env.android_appattributes_chunk) +pp_baseout.write(manifest) -env_android.SharedLibrary("#bin/libgodot",[android_objects],SHLIBSUFFIX=env["SHLIBSUFFIX"]) +env_android.SharedLibrary("#bin/libgodot", [android_objects], SHLIBSUFFIX=env["SHLIBSUFFIX"]) lib_arch_dir = '' if env['android_arch'] == 'armv6': - lib_arch_dir = 'armeabi' + lib_arch_dir = 'armeabi' elif env['android_arch'] == 'armv7': - lib_arch_dir = 'armeabi-v7a' + lib_arch_dir = 'armeabi-v7a' elif env['android_arch'] == 'x86': - lib_arch_dir = 'x86' + lib_arch_dir = 'x86' else: - print 'WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin' + print 'WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin' if lib_arch_dir != '': - if env['target'] == 'release': - lib_type_dir = 'release' - else: # release_debug, debug - lib_type_dir = 'debug' - - out_dir = '#platform/android/java/libs/'+lib_type_dir+'/'+lib_arch_dir - env_android.Command(out_dir+'/libgodot_android.so', '#bin/libgodot'+env['SHLIBSUFFIX'], Move("$TARGET", "$SOURCE")) + if env['target'] == 'release': + lib_type_dir = 'release' + else: # release_debug, debug + lib_type_dir = 'debug' + + out_dir = '#platform/android/java/libs/' + lib_type_dir + '/' + lib_arch_dir + env_android.Command(out_dir + '/libgodot_android.so', '#bin/libgodot' + env['SHLIBSUFFIX'], Move("$TARGET", "$SOURCE")) diff --git a/platform/android/detect.py b/platform/android/detect.py index 842036f986..7f197895f1 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -3,248 +3,263 @@ import sys import string import platform + def is_active(): - return True + return True + def get_name(): - return "Android" + return "Android" + def can_build(): - import os - if (not os.environ.has_key("ANDROID_NDK_ROOT")): - return False + import os + if (not os.environ.has_key("ANDROID_NDK_ROOT")): + return False + + return True - return True def get_opts(): - return [ - ('ANDROID_NDK_ROOT', 'the path to Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)), - ('NDK_TARGET', 'toolchain to use for the NDK',os.environ.get("NDK_TARGET", "arm-linux-androideabi-4.9")), - ('NDK_TARGET_X86', 'toolchain to use for the NDK x86',os.environ.get("NDK_TARGET_X86", "x86-4.9")), - ('ndk_platform', 'compile for platform: (android-<api> , example: android-14)',"android-14"), - ('android_arch', 'select compiler architecture: (armv7/armv6/x86)',"armv7"), - ('android_neon','enable neon (armv7 only)',"yes"), - ('android_stl','enable STL support in android port (for modules)',"no") - ] + return [ + ('ANDROID_NDK_ROOT', 'the path to Android NDK', + os.environ.get("ANDROID_NDK_ROOT", 0)), + ('ndk_platform', 'compile for platform: (android-<api> , example: android-14)', "android-14"), + ('android_arch', 'select compiler architecture: (armv7/armv6/x86)', "armv7"), + ('android_neon', 'enable neon (armv7 only)', "yes"), + ('android_stl', 'enable STL support in android port (for modules)', "no") + ] def get_flags(): - return [ - ('tools', 'no'), - ('openssl', 'builtin'), #use builtin openssl - ] + return [ + ('tools', 'no'), + ] def create(env): - tools = env['TOOLS'] - if "mingw" in tools: - tools.remove('mingw') - if "applelink" in tools: - tools.remove("applelink") - env.Tool('gcc') - return env.Clone(tools=tools); + tools = env['TOOLS'] + if "mingw" in tools: + tools.remove('mingw') + if "applelink" in tools: + tools.remove("applelink") + env.Tool('gcc') + return env.Clone(tools=tools) + def configure(env): - # Workaround for MinGW. See: - # http://www.scons.org/wiki/LongCmdLinesOnWin32 - import os - if (os.name=="nt"): - - import subprocess - - def mySubProcess(cmdline,env): - #print "SPAWNED : " + cmdline - startupinfo = subprocess.STARTUPINFO() - startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW - proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, startupinfo=startupinfo, shell = False, env = env) - data, err = proc.communicate() - rv = proc.wait() - if rv: - print "=====" - print err - print "=====" - return rv - - def mySpawn(sh, escape, cmd, args, env): - - newargs = ' '.join(args[1:]) - cmdline = cmd + " " + newargs - - rv=0 - if len(cmdline) > 32000 and cmd.endswith("ar") : - cmdline = cmd + " " + args[1] + " " + args[2] + " " - for i in range(3,len(args)) : - rv = mySubProcess( cmdline + args[i], env ) - if rv : - break - else: - rv = mySubProcess( cmdline, env ) - - return rv - - env['SPAWN'] = mySpawn - - ndk_platform=env['ndk_platform'] - - if env['android_arch'] not in ['armv7','armv6','x86']: - env['android_arch']='armv7' - - if env['android_arch']=='x86': - env['NDK_TARGET']=env['NDK_TARGET_X86'] - env["x86_libtheora_opt_gcc"]=True - - if env['PLATFORM'] == 'win32': - env.Tool('gcc') - env['SHLIBSUFFIX'] = '.so' - - - neon_text="" - if env["android_arch"]=="armv7" and env['android_neon']=='yes': - neon_text=" (with neon)" - print("Godot Android!!!!! ("+env['android_arch']+")"+neon_text) - - env.Append(CPPPATH=['#platform/android']) - - if env['android_arch']=='x86': - env.extra_suffix=".x86"+env.extra_suffix - elif env['android_arch']=='armv6': - env.extra_suffix=".armv6"+env.extra_suffix - elif env["android_arch"]=="armv7": - if env['android_neon']=='yes': - env.extra_suffix=".armv7.neon"+env.extra_suffix - else: - env.extra_suffix=".armv7"+env.extra_suffix - - gcc_path=env["ANDROID_NDK_ROOT"]+"/toolchains/"+env["NDK_TARGET"]+"/prebuilt/"; - - if (sys.platform.startswith("linux")): - if (platform.machine().endswith('64')): - gcc_path=gcc_path+"/linux-x86_64/bin" - else: - gcc_path=gcc_path+"/linux-x86/bin" - elif (sys.platform.startswith("darwin")): - gcc_path=gcc_path+"/darwin-x86_64/bin" - env['SHLINKFLAGS'][1] = '-shared' - env['SHLIBSUFFIX'] = '.so' - elif (sys.platform.startswith('win')): - if (platform.machine().endswith('64')): - gcc_path=gcc_path+"/windows-x86_64/bin" - else: - gcc_path=gcc_path+"/windows-x86/bin" - - env['ENV']['PATH'] = gcc_path+":"+env['ENV']['PATH'] - if env['android_arch']=='x86': - env['CC'] = gcc_path+'/i686-linux-android-gcc' - env['CXX'] = gcc_path+'/i686-linux-android-g++' - env['AR'] = gcc_path+"/i686-linux-android-ar" - env['RANLIB'] = gcc_path+"/i686-linux-android-ranlib" - env['AS'] = gcc_path+"/i686-linux-android-as" - else: - env['CC'] = gcc_path+'/arm-linux-androideabi-gcc' - env['CXX'] = gcc_path+'/arm-linux-androideabi-g++' - env['AR'] = gcc_path+"/arm-linux-androideabi-ar" - env['RANLIB'] = gcc_path+"/arm-linux-androideabi-ranlib" - env['AS'] = gcc_path+"/arm-linux-androideabi-as" - - if env['android_arch']=='x86': - env['ARCH'] = 'arch-x86' - else: - env['ARCH'] = 'arch-arm' - - import string - #include path - gcc_include=env["ANDROID_NDK_ROOT"]+"/platforms/"+ndk_platform+"/"+env['ARCH'] +"/usr/include" - ld_sysroot=env["ANDROID_NDK_ROOT"]+"/platforms/"+ndk_platform+"/"+env['ARCH'] - #glue_include=env["ANDROID_NDK_ROOT"]+"/sources/android/native_app_glue" - ld_path=env["ANDROID_NDK_ROOT"]+"/platforms/"+ndk_platform+"/"+env['ARCH']+"/usr/lib" - env.Append(CPPPATH=[gcc_include]) -# env['CCFLAGS'] = string.split('-DNO_THREADS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -mthumb -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED ') - - env['neon_enabled']=False - if env['android_arch']=='x86': - env.Append(CCFLAGS=string.split('-DNO_STATVFS -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__GLIBC__ -Wno-psabi -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')) - elif env["android_arch"]=="armv6": - env.Append(CCFLAGS=string.split('-DNO_STATVFS -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_6__ -D__GLIBC__ -Wno-psabi -march=armv6 -mfpu=vfp -mfloat-abi=softfp -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')) - elif env["android_arch"]=="armv7": - env.Append(CCFLAGS=string.split('-DNO_STATVFS -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -D__GLIBC__ -Wno-psabi -march=armv7-a -mfloat-abi=softfp -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')) - if env['android_neon']=='yes': - env['neon_enabled']=True - env.Append(CCFLAGS=['-mfpu=neon','-D__ARM_NEON__']) - else: - env.Append(CCFLAGS=['-mfpu=vfpv3-d16']) - - env.Append(LDPATH=[ld_path]) - env.Append(LIBS=['OpenSLES']) -# env.Append(LIBS=['c','m','stdc++','log','EGL','GLESv1_CM','GLESv2','OpenSLES','supc++','android']) - env.Append(LIBS=['EGL','OpenSLES','android']) - env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2', 'z']) - - env["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ") - env.Append(LINKFLAGS=["-Wl,-soname,libgodot_android.so"]) - - if (env["target"]=="release"): - - env.Append(CCFLAGS=['-O2', '-ffast-math','-fomit-frame-pointer']) - - elif (env["target"]=="release_debug"): - - env.Append(CCFLAGS=['-O2', '-ffast-math','-DDEBUG_ENABLED']) - - elif (env["target"]=="debug"): - - env.Append(CCFLAGS=['-D_DEBUG', '-g1', '-Wall', '-O0', '-DDEBUG_ENABLED']) - env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) - - env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL','-DMPC_FIXED_POINT']) -# env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_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 (env["android_arch"]=="armv6" or env["android_arch"]=="armv7"): - env.Append(CFLAGS=["-DOPUS_ARM_OPT"]) - env.opus_fixed_point="yes" - - if (env['android_stl']=='yes'): - #env.Append(CCFLAGS=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/system/include"]) - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/include"]) - if env['android_arch']=='x86': - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include"]) - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86"]) - elif env['android_arch']=='armv6': - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include"]) - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi"]) - elif env["android_arch"]=="armv7": - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include"]) - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a"]) - - env.Append(LIBS=["gnustl_static","supc++"]) - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cpufeatures"]) - - #env.Append(CCFLAGS=["-I"+env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/stlport/stlport"]) - #env.Append(CCFLAGS=["-I"+env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include"]) - #env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/libs/armeabi/libstdc++.a"]) - else: - - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/include"]) - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cpufeatures"]) - if env['android_arch']=='x86': - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86"]) - elif env["android_arch"]=="armv6": - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi"]) - elif env["android_arch"]=="armv7": - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a"]) - env.Append(LIBS=['gnustl_static']) - env.Append(CCFLAGS=["-fno-exceptions",'-DNO_SAFE_CAST']) - - - import methods - env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - - env.use_windows_spawn_fix() + # Workaround for MinGW. See: + # http://www.scons.org/wiki/LongCmdLinesOnWin32 + import os + if (os.name == "nt"): + + import subprocess + + def mySubProcess(cmdline, env): + # print "SPAWNED : " + cmdline + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, startupinfo=startupinfo, shell=False, env=env) + data, err = proc.communicate() + rv = proc.wait() + if rv: + print "=====" + print err + print "=====" + return rv + + def mySpawn(sh, escape, cmd, args, env): + + newargs = ' '.join(args[1:]) + cmdline = cmd + " " + newargs + + rv = 0 + if len(cmdline) > 32000 and cmd.endswith("ar"): + cmdline = cmd + " " + args[1] + " " + args[2] + " " + for i in range(3, len(args)): + rv = mySubProcess(cmdline + args[i], env) + if rv: + break + else: + rv = mySubProcess(cmdline, env) + + return rv + + env['SPAWN'] = mySpawn + + ndk_platform = env['ndk_platform'] + + if env['android_arch'] not in ['armv7', 'armv6', 'x86']: + env['android_arch'] = 'armv7' + + if env['android_arch'] == 'x86': + env["x86_libtheora_opt_gcc"] = True + + if env['PLATFORM'] == 'win32': + env.Tool('gcc') + env['SHLIBSUFFIX'] = '.so' + + neon_text = "" + if env["android_arch"] == "armv7" and env['android_neon'] == 'yes': + neon_text = " (with neon)" + print("Godot Android!!!!! (" + env['android_arch'] + ")" + neon_text) + + env.Append(CPPPATH=['#platform/android']) + + if env['android_arch'] == 'x86': + env.extra_suffix = ".x86" + env.extra_suffix + target_subpath = "x86-4.9" + abi_subpath = "i686-linux-android" + arch_subpath = "x86" + elif env['android_arch'] == 'armv6': + env.extra_suffix = ".armv6" + env.extra_suffix + target_subpath = "arm-linux-androideabi-4.9" + abi_subpath = "arm-linux-androideabi" + arch_subpath = "armeabi" + elif env["android_arch"] == "armv7": + target_subpath = "arm-linux-androideabi-4.9" + abi_subpath = "arm-linux-androideabi" + arch_subpath = "armeabi-v7a" + if env['android_neon'] == 'yes': + env.extra_suffix = ".armv7.neon" + env.extra_suffix + else: + env.extra_suffix = ".armv7" + env.extra_suffix + + if (sys.platform.startswith("linux")): + if (platform.machine().endswith('64')): + host_subpath = "linux-x86_64" + else: + host_subpath = "linux-x86" + elif (sys.platform.startswith("darwin")): + host_subpath = "darwin-x86_64" + elif (sys.platform.startswith('win')): + if (platform.machine().endswith('64')): + host_subpath = "windows-x86_64" + else: + host_subpath = "windows-x86" + + compiler_path = env["ANDROID_NDK_ROOT"] + \ + "/toolchains/llvm/prebuilt/" + host_subpath + "/bin" + gcc_toolchain_path = env["ANDROID_NDK_ROOT"] + \ + "/toolchains/" + target_subpath + "/prebuilt/" + host_subpath + tools_path = gcc_toolchain_path + "/" + abi_subpath + "/bin" + + # For Clang to find NDK tools in preference of those system-wide + env.PrependENVPath('PATH', tools_path) + + env['CC'] = compiler_path + '/clang' + env['CXX'] = compiler_path + '/clang++' + env['AR'] = tools_path + "/ar" + env['RANLIB'] = tools_path + "/ranlib" + env['AS'] = tools_path + "/as" + + if env['android_arch'] == 'x86': + env['ARCH'] = 'arch-x86' + else: + env['ARCH'] = 'arch-arm' + + sysroot = env["ANDROID_NDK_ROOT"] + \ + "/platforms/" + ndk_platform + "/" + env['ARCH'] + common_opts = ['-fno-integrated-as', '-gcc-toolchain', gcc_toolchain_path] + + env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include"]) + env.Append(CPPFLAGS=string.split( + '-Wno-invalid-command-line-argument -Wno-unused-command-line-argument')) + env.Append(CPPFLAGS=string.split( + '-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing -Wa,--noexecstack')) + env.Append(CPPFLAGS=string.split('-DANDROID -DNO_STATVFS -DGLES2_ENABLED')) + + env['neon_enabled'] = False + if env['android_arch'] == 'x86': + can_vectorize = True + target_opts = ['-target', 'i686-none-linux-android'] + elif env["android_arch"] == "armv6": + can_vectorize = False + target_opts = ['-target', 'armv6-none-linux-androideabi'] + env.Append(CPPFLAGS=string.split( + '-D__ARM_ARCH_6__ -march=armv6 -mfpu=vfp -mfloat-abi=softfp')) + elif env["android_arch"] == "armv7": + can_vectorize = True + target_opts = ['-target', 'armv7-none-linux-androideabi'] + env.Append(CPPFLAGS=string.split( + '-D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -march=armv7-a -mfloat-abi=softfp')) + if env['android_neon'] == 'yes': + env['neon_enabled'] = True + env.Append(CPPFLAGS=['-mfpu=neon', '-D__ARM_NEON__']) + else: + env.Append(CPPFLAGS=['-mfpu=vfpv3-d16']) + + env.Append(CPPFLAGS=target_opts) + env.Append(CPPFLAGS=common_opts) + + env.Append(LIBS=['OpenSLES']) + env.Append(LIBS=['EGL', 'OpenSLES', 'android']) + env.Append(LIBS=['log', 'GLESv1_CM', 'GLESv2', 'z']) + + if (sys.platform.startswith("darwin")): + env['SHLIBSUFFIX'] = '.so' + + env['LINKFLAGS'] = ['-shared', '--sysroot=' + + sysroot, '-Wl,--warn-shared-textrel', + '-Wl,--threads'] + env.Append(LINKFLAGS=string.split( + '-Wl,--fix-cortex-a8')) + env.Append(LINKFLAGS=string.split( + '-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now')) + env.Append(LINKFLAGS=string.split( + '-Wl,-soname,libgodot_android.so -Wl,--gc-sections')) + env.Append(LINKFLAGS=target_opts) + env.Append(LINKFLAGS=common_opts) + + env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + '/toolchains/arm-linux-androideabi-4.9/prebuilt/' + + host_subpath + '/lib/gcc/' + abi_subpath + '/4.9.x']) + env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + + '/toolchains/arm-linux-androideabi-4.9/prebuilt/' + host_subpath + '/' + abi_subpath + '/lib']) + + if (env["target"].startswith("release")): + env.Append(LINKFLAGS=['-O2']) + env.Append(CPPFLAGS=['-O2', '-DNDEBUG', '-ffast-math', + '-funsafe-math-optimizations', '-fomit-frame-pointer']) + if (can_vectorize): + env.Append(CPPFLAGS=['-ftree-vectorize']) + if (env["target"] == "release_debug"): + env.Append(CPPFLAGS=['-DDEBUG_ENABLED']) + elif (env["target"] == "debug"): + env.Append(LINKFLAGS=['-O0']) + env.Append(CPPFLAGS=['-O0', '-D_DEBUG', '-UNDEBUG', '-DDEBUG_ENABLED', + '-DDEBUG_MEMORY_ALLOC', '-g', '-fno-limit-debug-info']) + + env.Append(CPPFLAGS=['-DANDROID_ENABLED', + '-DUNIX_ENABLED', '-DNO_FCNTL', '-DMPC_FIXED_POINT']) + + # TODO: Move that to opus module's config + if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"): + if (env["android_arch"] == "armv6" or env["android_arch"] == "armv7"): + env.Append(CFLAGS=["-DOPUS_ARM_OPT"]) + env.opus_fixed_point = "yes" + + if (env['android_stl'] == 'yes'): + 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]) + env.Append(LIBS=["gnustl_static"]) + else: + env.Append(CXXFLAGS=['-fno-rtti', '-fno-exceptions', '-DNO_SAFE_CAST']) + + import methods + env.Append(BUILDERS={'GLSL120': env.Builder( + action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder( + action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL120GLES': env.Builder( + action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')}) + + env.use_windows_spawn_fix() diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index 57376f8103..06be1f747d 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -154,7 +154,7 @@ Error DirAccessJAndroid::change_dir(String p_dir){ String DirAccessJAndroid::get_current_dir(){ - return "/"+current_dir; + return "res://"+current_dir; } bool DirAccessJAndroid::file_exists(String p_file){ @@ -268,6 +268,6 @@ DirAccessJAndroid::DirAccessJAndroid() { DirAccessJAndroid::~DirAccessJAndroid() { - list_dir_end();; + list_dir_end(); } #endif diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 4735a91f43..88a5554eef 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -531,9 +531,9 @@ void EditorExportPlatformAndroid::_fix_resources(Vector<uint8_t>& p_manifest) { Vector<String> string_table; - printf("stirng block len: %i\n",string_block_len); - printf("stirng count: %i\n",string_count); - printf("flags: %x\n",string_flags); + //printf("stirng block len: %i\n",string_block_len); + //printf("stirng count: %i\n",string_count); + //printf("flags: %x\n",string_flags); for(uint32_t i=0;i<string_count;i++) { @@ -617,7 +617,7 @@ void EditorExportPlatformAndroid::_fix_resources(Vector<uint8_t>& p_manifest) { p_manifest=ret; - printf("end\n"); + //printf("end\n"); } String EditorExportPlatformAndroid::get_project_name() const { @@ -778,16 +778,16 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool else nspace=""; - printf("ATTR %i NSPACE: %i\n",i,attr_nspace); - printf("ATTR %i NAME: %i (%s)\n",i,attr_name,attrname.utf8().get_data()); - printf("ATTR %i VALUE: %i (%s)\n",i,attr_value,value.utf8().get_data()); - printf("ATTR %i FLAGS: %x\n",i,attr_flags); - printf("ATTR %i RESID: %x\n",i,attr_resid); + //printf("ATTR %i NSPACE: %i\n",i,attr_nspace); + //printf("ATTR %i NAME: %i (%s)\n",i,attr_name,attrname.utf8().get_data()); + //printf("ATTR %i VALUE: %i (%s)\n",i,attr_value,value.utf8().get_data()); + //printf("ATTR %i FLAGS: %x\n",i,attr_flags); + //printf("ATTR %i RESID: %x\n",i,attr_resid); //replace project information if (tname=="manifest" && attrname=="package") { - print_line("FOUND PACKAGE"); + print_line("FOUND package"); string_table[attr_value]=get_package_name(); } @@ -796,14 +796,14 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool //print_line("attrname: "+attrname); if (tname=="manifest" && /*nspace=="android" &&*/ attrname=="versionCode") { - print_line("FOUND versioncode"); + print_line("FOUND versionCode"); encode_uint32(version_code,&p_manifest[iofs+16]); } if (tname=="manifest" && /*nspace=="android" &&*/ attrname=="versionName") { - print_line("FOUND versionname"); + print_line("FOUND versionName"); if (attr_value==0xFFFFFFFF) { WARN_PRINT("Version name in a resource, should be plaintext") } else @@ -834,10 +834,10 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool } else if (value.begins_with("godot.")) { String perm = value.get_slice(".",1); - print_line("PERM: "+perm+" HAS: "+itos(perms.has(perm))); if (perms.has(perm) || (p_give_internet && perm=="INTERNET")) { + print_line("PERM: "+perm); string_table[attr_value]="android.permission."+perm; } @@ -871,12 +871,12 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool } break; } - printf("chunk %x: size: %d\n",chunk,size); + //printf("chunk %x: size: %d\n",chunk,size); ofs+=size; } - printf("end\n"); + //printf("end\n"); //create new andriodmanifest binary @@ -893,14 +893,14 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool encode_uint32(ofs,&ret[string_table_begins+i*4]); ofs+=string_table[i].length()*2+2+2; - print_line("ofs: "+itos(i)+": "+itos(ofs)); + //print_line("ofs: "+itos(i)+": "+itos(ofs)); } ret.resize(ret.size()+ofs); uint8_t *chars=&ret[ret.size()-ofs]; for(int i=0;i<string_table.size();i++) { String s = string_table[i]; - print_line("savint string :"+s); + //print_line("savint string :"+s); encode_uint16(s.length(),chars); chars+=2; for(int j=0;j<s.length();j++) { //include zero? @@ -934,7 +934,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool encode_uint32(new_stable_end-8,&ret[12]); //update new string table size - print_line("file size: "+itos(ret.size())); + //print_line("file size: "+itos(ret.size())); p_manifest=ret; @@ -949,7 +949,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool header[i]=decode_uint32(&p_manifest[i*4]); } - print_line("STO: "+itos(header[3])); + //print_line("STO: "+itos(header[3])); uint32_t st_offset=9*4; //ERR_FAIL_COND(header[3]!=0x24) uint32_t string_count=header[4]; diff --git a/platform/android/java/src/org/godotengine/godot/GodotIO.java b/platform/android/java/src/org/godotengine/godot/GodotIO.java index 55e330924a..128a9b2f7b 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotIO.java +++ b/platform/android/java/src/org/godotengine/godot/GodotIO.java @@ -288,6 +288,11 @@ public class GodotIO { try { ad.files = am.list(path); + // no way to find path is directory or file exactly. + // but if ad.files.length==0, then it's an empty directory or file. + if (ad.files.length==0) { + return -1; + } } catch (IOException e) { System.out.printf("Exception on dir_open: %s\n",e); diff --git a/platform/bb10/SCsub b/platform/bb10/SCsub index 84fff0828b..c19f46d579 100644 --- a/platform/bb10/SCsub +++ b/platform/bb10/SCsub @@ -4,19 +4,19 @@ Import('env') bb10_lib = [ - 'bbutil.c', - 'os_bb10.cpp', - 'audio_driver_bb10.cpp', - 'godot_bb10.cpp', - 'payment_service.cpp', + 'bbutil.c', + 'os_bb10.cpp', + 'audio_driver_bb10.cpp', + 'godot_bb10.cpp', + 'payment_service.cpp', ] env_bps = env.Clone() if env['bb10_payment_service'] == "yes": - env_bps.Append(CPPFLAGS=['-DPAYMENT_SERVICE_ENABLED']) + env_bps.Append(CPPFLAGS=['-DPAYMENT_SERVICE_ENABLED']) if env['bb10_lgles_override'] == "yes": - env_bps.Append(CPPFLAGS=['-DBB10_LGLES_OVERRIDE']) + env_bps.Append(CPPFLAGS=['-DBB10_LGLES_OVERRIDE']) prog = None diff --git a/platform/bb10/detect.py b/platform/bb10/detect.py index 2b76aa3496..d3ee9f0124 100644 --- a/platform/bb10/detect.py +++ b/platform/bb10/detect.py @@ -5,85 +5,88 @@ import methods def is_active(): - return True + return True + def get_name(): - return "BlackBerry 10" + return "BlackBerry 10" + def can_build(): - import os - if (not os.environ.has_key("QNX_TARGET")): - return False - return True + import os + if (not os.environ.has_key("QNX_TARGET")): + return False + return True + def get_opts(): - return [ - ('QNX_HOST', 'path to qnx host', os.environ.get("QNX_HOST", 0)), - ('QNX_TARGET', 'path to qnx target', os.environ.get("QNX_TARGET", 0)), - ('QNX_CONFIGURATION', 'path to qnx configuration', os.environ.get("QNX_CONFIGURATION", 0)), - ('qnx_target', 'Qnx target (armle or x86', 'armle'), - ('bb10_payment_service', 'Enable Payment Service for BlackBerry10', 'yes'), - ('bb10_lgles_override', 'Force legacy GLES (1.1) on iOS', 'no'), - ('bb10_exceptions', 'Use exceptions when compiling on bb10', 'no'), - ] + return [ + ('QNX_HOST', 'path to qnx host', os.environ.get("QNX_HOST", 0)), + ('QNX_TARGET', 'path to qnx target', os.environ.get("QNX_TARGET", 0)), + ('QNX_CONFIGURATION', 'path to qnx configuration', os.environ.get("QNX_CONFIGURATION", 0)), + ('qnx_target', 'Qnx target (armle or x86', 'armle'), + ('bb10_payment_service', 'Enable Payment Service for BlackBerry10', 'yes'), + ('bb10_lgles_override', 'Force legacy GLES (1.1) on iOS', 'no'), + ('bb10_exceptions', 'Use exceptions when compiling on bb10', 'no'), + ] + def get_flags(): - return [ - ('tools', 'no'), - ('builtin_zlib', 'yes'), - ('module_theora_enabled', 'no'), - ] + return [ + ('tools', 'no'), + ('module_theora_enabled', 'no'), + ] -def configure(env): - if env['PLATFORM'] == 'win32': - env.Tool('mingw') - env['SPAWN'] = methods.win32_spawn +def configure(env): - env['qnx_target_ver'] = env['qnx_target'] - if env['qnx_target'] == "armle": - env['qnx_prefix'] = 'ntoarmv7' - env['qnx_target_ver'] = 'armle-v7' - else: - env['qnx_prefix'] = 'ntox86' + if env['PLATFORM'] == 'win32': + env.Tool('mingw') + env['SPAWN'] = methods.win32_spawn - env['OBJSUFFIX'] = ".qnx.${qnx_target}.o" - env['LIBSUFFIX'] = ".qnx.${qnx_target}.a" - env['PROGSUFFIX'] = ".qnx.${qnx_target}" - print("PROGSUFFIX: "+env['PROGSUFFIX']+" target: "+env['qnx_target']) + env['qnx_target_ver'] = env['qnx_target'] + if env['qnx_target'] == "armle": + env['qnx_prefix'] = 'ntoarmv7' + env['qnx_target_ver'] = 'armle-v7' + else: + env['qnx_prefix'] = 'ntox86' - env.PrependENVPath('PATH', env['QNX_CONFIGURATION'] + '/bin') - env.PrependENVPath('PATH', env['QNX_CONFIGURATION'] + '/usr/bin') - env['ENV']['QNX_HOST'] = env['QNX_HOST'] - env['ENV']['QNX_TARGET'] = env['QNX_TARGET'] - env['ENV']['QNX_CONFIGURATION'] = env['QNX_CONFIGURATION'] + env['OBJSUFFIX'] = ".qnx.${qnx_target}.o" + env['LIBSUFFIX'] = ".qnx.${qnx_target}.a" + env['PROGSUFFIX'] = ".qnx.${qnx_target}" + print("PROGSUFFIX: " + env['PROGSUFFIX'] + " target: " + env['qnx_target']) - env['CC'] = '$qnx_prefix-gcc' - env['CXX'] = '$qnx_prefix-g++' - env['AR'] = '$qnx_prefix-ar' - env['RANLIB'] = '$qnx_prefix-ranlib' + env.PrependENVPath('PATH', env['QNX_CONFIGURATION'] + '/bin') + env.PrependENVPath('PATH', env['QNX_CONFIGURATION'] + '/usr/bin') + env['ENV']['QNX_HOST'] = env['QNX_HOST'] + env['ENV']['QNX_TARGET'] = env['QNX_TARGET'] + env['ENV']['QNX_CONFIGURATION'] = env['QNX_CONFIGURATION'] - env.Append(CPPPATH = ['#platform/bb10']) - env.Append(LIBPATH = ['#platform/bb10/lib/$qnx_target', '#platform/bb10/lib/$qnx_target_ver']) - env.Append(CCFLAGS = string.split('-DBB10_ENABLED -DUNIX_ENABLED -DGLES2_ENABLED -DGLES1_ENABLED -D_LITTLE_ENDIAN -DNO_THREADS -DNO_FCNTL')) - if env['bb10_exceptions']=="yes": - env.Append(CCFLAGS = ['-fexceptions']) - else: - env.Append(CCFLAGS = ['-fno-exceptions']) + env['CC'] = '$qnx_prefix-gcc' + env['CXX'] = '$qnx_prefix-g++' + env['AR'] = '$qnx_prefix-ar' + env['RANLIB'] = '$qnx_prefix-ranlib' - #env.Append(LINKFLAGS = string.split() + env.Append(CPPPATH=['#platform/bb10']) + env.Append(LIBPATH=['#platform/bb10/lib/$qnx_target', '#platform/bb10/lib/$qnx_target_ver']) + env.Append(CCFLAGS=string.split('-DBB10_ENABLED -DUNIX_ENABLED -DGLES2_ENABLED -DGLES1_ENABLED -D_LITTLE_ENDIAN -DNO_THREADS -DNO_FCNTL')) + if env['bb10_exceptions'] == "yes": + env.Append(CCFLAGS=['-fexceptions']) + else: + env.Append(CCFLAGS=['-fno-exceptions']) - if (env["target"]=="release"): + # env.Append(LINKFLAGS = string.split() - env.Append(CCFLAGS=['-O3','-DRELEASE_BUILD']) + if (env["target"] == "release"): - elif (env["target"]=="debug"): + env.Append(CCFLAGS=['-O3', '-DRELEASE_BUILD']) - env.Append(CCFLAGS=['-g', '-O0','-DDEBUG_ENABLED', '-D_DEBUG']) - env.Append(LINKFLAGS=['-g']) + elif (env["target"] == "debug"): - env.Append(LIBS=['bps', 'pps', 'screen', 'socket', 'EGL', 'GLESv2', 'GLESv1_CM', 'm', 'asound']) + env.Append(CCFLAGS=['-g', '-O0', '-DDEBUG_ENABLED', '-D_DEBUG']) + env.Append(LINKFLAGS=['-g']) + env.Append(LIBS=['bps', 'pps', 'screen', 'socket', 'EGL', 'GLESv2', 'GLESv1_CM', 'm', 'asound']) diff --git a/platform/haiku/SCsub b/platform/haiku/SCsub index b5a584baa4..d0c244a194 100644 --- a/platform/haiku/SCsub +++ b/platform/haiku/SCsub @@ -3,25 +3,26 @@ Import('env') common_haiku = [ - 'os_haiku.cpp', - 'context_gl_haiku.cpp', - 'haiku_application.cpp', - 'haiku_direct_window.cpp', - 'haiku_gl_view.cpp', - 'key_mapping_haiku.cpp', - 'audio_driver_media_kit.cpp' + 'os_haiku.cpp', + 'context_gl_haiku.cpp', + 'haiku_application.cpp', + 'haiku_direct_window.cpp', + 'haiku_gl_view.cpp', + 'key_mapping_haiku.cpp', + 'audio_driver_media_kit.cpp' ] target = env.Program( - '#bin/godot', - ['godot_haiku.cpp'] + common_haiku + '#bin/godot', + ['godot_haiku.cpp'] + common_haiku ) command = env.Command('#bin/godot.rsrc', '#platform/haiku/godot.rdef', - ['rc -o $TARGET $SOURCE']) + ['rc -o $TARGET $SOURCE']) -def addResourcesAction(target = None, source = None, env = None): - return env.Execute('xres -o ' + File(target)[0].path + ' bin/godot.rsrc') + +def addResourcesAction(target=None, source=None, env=None): + return env.Execute('xres -o ' + File(target)[0].path + ' bin/godot.rsrc') env.AddPostAction(target, addResourcesAction) env.Depends(target, command) diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index af997a5737..71202a9a49 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -1,61 +1,67 @@ import os import sys + def is_active(): - return True + return True + def get_name(): - return "Haiku" + return "Haiku" + def can_build(): - if (os.name != "posix"): - return False + if (os.name != "posix"): + return False - if (sys.platform == "darwin"): - return False + if (sys.platform == "darwin"): + return False + + return True - return True def get_opts(): - return [ - ('debug_release', 'Add debug symbols to release version','no') - ] + return [ + ('debug_release', 'Add debug symbols to release version', 'no') + ] + def get_flags(): - return [ - ] + return [ + ] + def configure(env): - is64 = sys.maxsize > 2**32 - - if (env["bits"]=="default"): - if (is64): - env["bits"]="64" - else: - env["bits"]="32" - - env.Append(CPPPATH = ['#platform/haiku']) - - env["CC"] = "gcc-x86" - env["CXX"] = "g++-x86" - - if (env["target"]=="release"): - if (env["debug_release"]=="yes"): - env.Append(CCFLAGS=['-g2']) - else: - env.Append(CCFLAGS=['-O3','-ffast-math']) - elif (env["target"]=="release_debug"): - env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED']) - elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) - - #env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) - env.Append(CPPFLAGS = ['-DPTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np - env.Append(CPPFLAGS = ['-DOPENGL_ENABLED', '-DMEDIA_KIT_ENABLED']) - env.Append(CPPFLAGS = ['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) - env.Append(LIBS = ['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL']) - - import methods - env.Append(BUILDERS = {'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl')}) - env.Append(BUILDERS = {'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl')}) - env.Append(BUILDERS = {'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl')}) + is64 = sys.maxsize > 2**32 + + if (env["bits"] == "default"): + if (is64): + env["bits"] = "64" + else: + env["bits"] = "32" + + env.Append(CPPPATH=['#platform/haiku']) + + env["CC"] = "gcc-x86" + env["CXX"] = "g++-x86" + + if (env["target"] == "release"): + if (env["debug_release"] == "yes"): + env.Append(CCFLAGS=['-g2']) + else: + env.Append(CCFLAGS=['-O3', '-ffast-math']) + elif (env["target"] == "release_debug"): + env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED']) + elif (env["target"] == "debug"): + env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + + # env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) + env.Append(CPPFLAGS=['-DPTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np + env.Append(CPPFLAGS=['-DOPENGL_ENABLED', '-DMEDIA_KIT_ENABLED']) + env.Append(CPPFLAGS=['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) + env.Append(LIBS=['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL']) + + import methods + env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')}) diff --git a/platform/iphone/SCsub b/platform/iphone/SCsub index 236630bef4..38f789259c 100644 --- a/platform/iphone/SCsub +++ b/platform/iphone/SCsub @@ -4,33 +4,33 @@ Import('env') iphone_lib = [ - 'os_iphone.cpp', - #'rasterizer_iphone.cpp', - 'audio_driver_iphone.cpp', - 'sem_iphone.cpp', - 'gl_view.mm', - 'main.m', - 'app_delegate.mm', - 'view_controller.mm', - 'game_center.mm', - 'in_app_store.mm', - 'icloud.mm', - #'Appirater.m', - 'ios.mm', + 'os_iphone.cpp', + #'rasterizer_iphone.cpp', + 'audio_driver_iphone.cpp', + 'sem_iphone.cpp', + 'gl_view.mm', + 'main.m', + 'app_delegate.mm', + 'view_controller.mm', + 'game_center.mm', + 'in_app_store.mm', + 'icloud.mm', + #'Appirater.m', + 'ios.mm', ] -#env.Depends('#core/math/vector3.h', 'vector3_psp.h') +# env.Depends('#core/math/vector3.h', 'vector3_psp.h') #iphone_lib = env.Library('iphone', iphone_lib) -env_ios = env.Clone(); +env_ios = env.Clone() if env['ios_gles22_override'] == "yes": - env_ios.Append(CPPFLAGS=['-DGLES2_OVERRIDE']) + env_ios.Append(CPPFLAGS=['-DGLES2_OVERRIDE']) -#if env['ios_appirater'] == "yes": +# if env['ios_appirater'] == "yes": # env_ios.Append(CPPFLAGS=['-DAPPIRATER_ENABLED']) @@ -38,5 +38,5 @@ obj = env_ios.Object('godot_iphone.cpp') prog = None prog = env_ios.Program('#bin/godot', [obj] + iphone_lib) -action = "$IPHONEPATH/usr/bin/dsymutil "+File(prog)[0].path+" -o " + File(prog)[0].path + ".dSYM" +action = "$IPHONEPATH/usr/bin/dsymutil " + File(prog)[0].path + " -o " + File(prog)[0].path + ".dSYM" env.AddPostAction(prog, action) diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index 1be63891b1..b92b64e9f1 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -3,187 +3,187 @@ import sys def is_active(): - return True + return True + def get_name(): - return "iOS" + return "iOS" + def can_build(): - import sys - import os - if sys.platform == 'darwin' or os.environ.has_key("OSXCROSS_IOS"): - return True + import sys + import os + if sys.platform == 'darwin' or os.environ.has_key("OSXCROSS_IOS"): + return True + + return False - return False def get_opts(): - return [ - ('IPHONEPLATFORM', 'name of the iphone platform', 'iPhoneOS'), - ('IPHONEPATH', 'the 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_gles22_override', 'Force GLES2.0 on iOS', 'yes'), - ('ios_appirater', 'Enable Appirater', 'no'), - ('ios_exceptions', 'Use exceptions when compiling on playbook', 'yes'), - ('ios_triple', 'Triple for ios toolchain', ''), - ('ios_sim', 'Build simulator binary', 'no'), - ] + return [ + ('IPHONEPLATFORM', 'name of the iphone platform', 'iPhoneOS'), + ('IPHONEPATH', 'the 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_gles22_override', 'Force GLES2.0 on iOS', 'yes'), + ('ios_appirater', 'Enable Appirater', 'no'), + ('ios_exceptions', 'Use exceptions when compiling on playbook', 'yes'), + ('ios_triple', 'Triple for ios toolchain', ''), + ('ios_sim', 'Build simulator binary', 'no'), + ] -def get_flags(): - return [ - ('tools', 'no'), - ('webp', 'yes'), - ('builtin_zlib', 'yes'), - ('openssl','builtin'), #use builtin openssl - ] +def get_flags(): + return [ + ('tools', 'no'), + ] def configure(env): - env.Append(CPPPATH=['#platform/iphone']) - - env['ENV']['PATH'] = env['IPHONEPATH']+"/Developer/usr/bin/:"+env['ENV']['PATH'] - - env['CC'] = '$IPHONEPATH/usr/bin/${ios_triple}clang' - env['CXX'] = '$IPHONEPATH/usr/bin/${ios_triple}clang++' - env['AR'] = '$IPHONEPATH/usr/bin/${ios_triple}ar' - env['RANLIB'] = '$IPHONEPATH/usr/bin/${ios_triple}ranlib' - - import string - if (env["ios_sim"]=="yes" or env["arch"] == "x86"): # i386, simulator - env["arch"]="x86" - env["bits"]="32" - env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -Wall -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $IPHONESDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"') - elif (env["arch"]=="arm64"): # arm64 - env["bits"] = "64" - env['CCFLAGS'] = string.split('-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -fvisibility=hidden -Wno-sign-conversion -MMD -MT dependencies -miphoneos-version-min=5.1.1 -isysroot $IPHONESDK') - env.Append(CPPFLAGS=['-DNEED_LONG_INT']) - env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON']) - else: # armv7 - env["arch"] = "arm" - env["bits"] = "32" - env['CCFLAGS'] = string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=5.1.1 -MMD -MT dependencies -isysroot $IPHONESDK') - - if (env["arch"]=="x86"): - env['IPHONEPLATFORM'] = 'iPhoneSimulator' - env.Append(LINKFLAGS=['-arch', 'i386', '-mios-simulator-version-min=4.3', - '-isysroot', '$IPHONESDK', - #'-mmacosx-version-min=10.6', - '-Xlinker', - '-objc_abi_version', - '-Xlinker', '2', - '-framework', 'AudioToolbox', - '-framework', 'AVFoundation', - '-framework', 'CoreAudio', - '-framework', 'CoreGraphics', - '-framework', 'CoreMedia', - '-framework', 'Foundation', - '-framework', 'Security', - '-framework', 'UIKit', - '-framework', 'MediaPlayer', - '-framework', 'OpenGLES', - '-framework', 'QuartzCore', - '-framework', 'SystemConfiguration', - '-F$IPHONESDK', - ]) - elif (env["arch"]=="arm64"): - env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1', - '-isysroot', '$IPHONESDK', - #'-stdlib=libc++', - '-framework', 'Foundation', - '-framework', 'UIKit', - '-framework', 'CoreGraphics', - '-framework', 'OpenGLES', - '-framework', 'QuartzCore', - '-framework', 'CoreAudio', - '-framework', 'AudioToolbox', - '-framework', 'SystemConfiguration', - '-framework', 'Security', - #'-framework', 'AdSupport', - '-framework', 'MediaPlayer', - '-framework', 'AVFoundation', - '-framework', 'CoreMedia', - ]) - else: - env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1', - '-isysroot', '$IPHONESDK', - '-framework', 'Foundation', - '-framework', 'UIKit', - '-framework', 'CoreGraphics', - '-framework', 'OpenGLES', - '-framework', 'QuartzCore', - '-framework', 'CoreAudio', - '-framework', 'AudioToolbox', - '-framework', 'SystemConfiguration', - '-framework', 'Security', - #'-framework', 'AdSupport', - '-framework', 'MediaPlayer', - '-framework', 'AVFoundation', - '-framework', 'CoreMedia', - ]) - - if env['game_center'] == 'yes': - env.Append(CPPFLAGS=['-fblocks', '-DGAME_CENTER_ENABLED']) - env.Append(LINKFLAGS=['-framework', 'GameKit']) - - if env['store_kit'] == 'yes': - env.Append(CPPFLAGS=['-DSTOREKIT_ENABLED']) - env.Append(LINKFLAGS=['-framework', 'StoreKit']) - - if env['icloud'] == 'yes': - env.Append(CPPFLAGS=['-DICLOUD_ENABLED']) - - env.Append(CPPPATH = ['$IPHONESDK/usr/include', '$IPHONESDK/System/Library/Frameworks/OpenGLES.framework/Headers', '$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers']) - - if (env["target"]=="release"): - - env.Append(CCFLAGS=['-O3', '-DNS_BLOCK_ASSERTIONS=1','-Wall', '-gdwarf-2']) # removed -ffast-math - env.Append(LINKFLAGS=['-O3']) # - - elif env["target"] == "release_debug": - env.Append(CCFLAGS=['-Os', '-DNS_BLOCK_ASSERTIONS=1','-Wall','-DDEBUG_ENABLED']) - env.Append(LINKFLAGS=['-Os']) - env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED']) - - elif (env["target"]=="debug"): - - env.Append(CCFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-Wall', '-O0', '-DDEBUG_ENABLED']) - env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED']) - - elif (env["target"]=="profile"): - - env.Append(CCFLAGS=['-g','-pg', '-Os']) - env.Append(LINKFLAGS=['-pg']) - - if (env["ios_sim"]=="yes"): #TODO: Check if needed? - env['ENV']['MACOSX_DEPLOYMENT_TARGET'] = '10.6' - env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate' - 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"): - env.opus_fixed_point="yes" - if env["arch"]=="x86": - pass - elif(env["arch"]=="arm64"): - env.Append(CFLAGS=["-DOPUS_ARM64_OPT"]) - else: - env.Append(CFLAGS=["-DOPUS_ARM_OPT"]) - - if env['ios_exceptions'] == 'yes': - env.Append(CPPFLAGS=['-fexceptions']) - else: - env.Append(CPPFLAGS=['-fno-exceptions']) - #env['neon_enabled']=True - env['S_compiler'] = '$IPHONEPATH/Developer/usr/bin/gcc' - - import methods - env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) + env.Append(CPPPATH=['#platform/iphone']) + + env['ENV']['PATH'] = env['IPHONEPATH'] + "/Developer/usr/bin/:" + env['ENV']['PATH'] + + env['CC'] = '$IPHONEPATH/usr/bin/${ios_triple}clang' + env['CXX'] = '$IPHONEPATH/usr/bin/${ios_triple}clang++' + env['AR'] = '$IPHONEPATH/usr/bin/${ios_triple}ar' + env['RANLIB'] = '$IPHONEPATH/usr/bin/${ios_triple}ranlib' + + import string + if (env["ios_sim"] == "yes" or env["arch"] == "x86"): # i386, simulator + env["arch"] = "x86" + env["bits"] = "32" + env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -Wall -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $IPHONESDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"') + elif (env["arch"] == "arm64"): # arm64 + env["bits"] = "64" + env['CCFLAGS'] = string.split('-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -fvisibility=hidden -Wno-sign-conversion -MMD -MT dependencies -miphoneos-version-min=5.1.1 -isysroot $IPHONESDK') + env.Append(CPPFLAGS=['-DNEED_LONG_INT']) + env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON']) + else: # armv7 + env["arch"] = "arm" + env["bits"] = "32" + env['CCFLAGS'] = string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=5.1.1 -MMD -MT dependencies -isysroot $IPHONESDK') + + if (env["arch"] == "x86"): + env['IPHONEPLATFORM'] = 'iPhoneSimulator' + env.Append(LINKFLAGS=['-arch', 'i386', '-mios-simulator-version-min=4.3', + '-isysroot', '$IPHONESDK', + #'-mmacosx-version-min=10.6', + '-Xlinker', + '-objc_abi_version', + '-Xlinker', '2', + '-framework', 'AudioToolbox', + '-framework', 'AVFoundation', + '-framework', 'CoreAudio', + '-framework', 'CoreGraphics', + '-framework', 'CoreMedia', + '-framework', 'Foundation', + '-framework', 'Security', + '-framework', 'UIKit', + '-framework', 'MediaPlayer', + '-framework', 'OpenGLES', + '-framework', 'QuartzCore', + '-framework', 'SystemConfiguration', + '-F$IPHONESDK', + ]) + elif (env["arch"] == "arm64"): + env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1', + '-isysroot', '$IPHONESDK', + #'-stdlib=libc++', + '-framework', 'Foundation', + '-framework', 'UIKit', + '-framework', 'CoreGraphics', + '-framework', 'OpenGLES', + '-framework', 'QuartzCore', + '-framework', 'CoreAudio', + '-framework', 'AudioToolbox', + '-framework', 'SystemConfiguration', + '-framework', 'Security', + #'-framework', 'AdSupport', + '-framework', 'MediaPlayer', + '-framework', 'AVFoundation', + '-framework', 'CoreMedia', + ]) + else: + env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1', + '-isysroot', '$IPHONESDK', + '-framework', 'Foundation', + '-framework', 'UIKit', + '-framework', 'CoreGraphics', + '-framework', 'OpenGLES', + '-framework', 'QuartzCore', + '-framework', 'CoreAudio', + '-framework', 'AudioToolbox', + '-framework', 'SystemConfiguration', + '-framework', 'Security', + #'-framework', 'AdSupport', + '-framework', 'MediaPlayer', + '-framework', 'AVFoundation', + '-framework', 'CoreMedia', + ]) + + if env['game_center'] == 'yes': + env.Append(CPPFLAGS=['-fblocks', '-DGAME_CENTER_ENABLED']) + env.Append(LINKFLAGS=['-framework', 'GameKit']) + + if env['store_kit'] == 'yes': + env.Append(CPPFLAGS=['-DSTOREKIT_ENABLED']) + env.Append(LINKFLAGS=['-framework', 'StoreKit']) + + if env['icloud'] == 'yes': + env.Append(CPPFLAGS=['-DICLOUD_ENABLED']) + + env.Append(CPPPATH=['$IPHONESDK/usr/include', '$IPHONESDK/System/Library/Frameworks/OpenGLES.framework/Headers', '$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers']) + + if (env["target"] == "release"): + + env.Append(CCFLAGS=['-O3', '-DNS_BLOCK_ASSERTIONS=1', '-Wall', '-gdwarf-2']) # removed -ffast-math + env.Append(LINKFLAGS=['-O3']) + + elif env["target"] == "release_debug": + env.Append(CCFLAGS=['-Os', '-DNS_BLOCK_ASSERTIONS=1', '-Wall', '-DDEBUG_ENABLED']) + env.Append(LINKFLAGS=['-Os']) + env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED']) + + elif (env["target"] == "debug"): + + env.Append(CCFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-Wall', '-O0', '-DDEBUG_ENABLED']) + env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED']) + + elif (env["target"] == "profile"): + + env.Append(CCFLAGS=['-g', '-pg', '-Os']) + env.Append(LINKFLAGS=['-pg']) + + if (env["ios_sim"] == "yes"): # TODO: Check if needed? + env['ENV']['MACOSX_DEPLOYMENT_TARGET'] = '10.6' + env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate' + 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"): + env.opus_fixed_point = "yes" + if env["arch"] == "x86": + pass + elif(env["arch"] == "arm64"): + env.Append(CFLAGS=["-DOPUS_ARM64_OPT"]) + else: + env.Append(CFLAGS=["-DOPUS_ARM_OPT"]) + + if env['ios_exceptions'] == 'yes': + env.Append(CPPFLAGS=['-fexceptions']) + else: + env.Append(CPPFLAGS=['-fno-exceptions']) + # env['neon_enabled']=True + env['S_compiler'] = '$IPHONEPATH/Developer/usr/bin/gcc' + + import methods + env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')}) diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub index 22af436470..5d5cd1590a 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -3,27 +3,35 @@ Import('env') javascript_files = [ - "os_javascript.cpp", - "audio_driver_javascript.cpp", - "javascript_main.cpp", - "audio_server_javascript.cpp", - "javascript_eval.cpp" + "os_javascript.cpp", + "audio_driver_javascript.cpp", + "javascript_main.cpp", + "audio_server_javascript.cpp", + "javascript_eval.cpp" ] -#obj = env.SharedObject('godot_javascript.cpp') - env_javascript = env.Clone() if env['target'] == "profile": - env_javascript.Append(CPPFLAGS=['-DPROFILER_ENABLED']) + env_javascript.Append(CPPFLAGS=['-DPROFILER_ENABLED']) -javascript_objects=[] +javascript_objects = [] for x in javascript_files: - javascript_objects.append( env_javascript.Object( x ) ) + javascript_objects.append(env_javascript.Object(x)) -env.Append(LINKFLAGS=["-s","EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync']\""]) +env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync']\""]) +env.Append(LINKFLAGS=["--shell-file", '"platform/javascript/godot_shell.html"']) -prog = None +build = env.Program('#bin/godot', javascript_objects, PROGSUFFIX=env["PROGSUFFIX"] + ".html") -#env_javascript.SharedLibrary("#platform/javascript/libgodot_javascript.so",[javascript_objects]) +def make_html_shell(target, source, env): + html_path = target[0].rstr() + assert html_path[:4] == 'bin/' + assert html_path[-5:] == '.html' + basename = html_path[4:-5] + with open(html_path, 'r+') as html_file: + fixed_html = html_file.read().replace('.html.mem', '.mem').replace(basename, '$GODOT_BASE') + html_file.seek(0) + html_file.truncate() + html_file.write(fixed_html) -env.Program('#bin/godot',javascript_objects,PROGSUFFIX=env["PROGSUFFIX"]+".html") +env.AddPostAction(build, Action(make_html_shell, "Creating HTML shell file")) diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index e1f91cf948..9bc204a94a 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -2,105 +2,107 @@ import os import sys import string + def is_active(): - return True + return True + def get_name(): - return "JavaScript" + return "JavaScript" + def can_build(): - import os - if (not os.environ.has_key("EMSCRIPTEN_ROOT")): - return False - return True + import os + if (not os.environ.has_key("EMSCRIPTEN_ROOT")): + return False + return True + def get_opts(): - return [ - ['compress','Compress JS Executable','no'], - ['javascript_eval','Enable JavaScript eval interface','yes'] - ] + return [ + ['wasm', 'Compile to WebAssembly', 'no'], + ['javascript_eval', 'Enable JavaScript eval interface', 'yes'], + ] -def get_flags(): - return [ - ('tools', 'no'), - ('builtin_zlib', 'yes'), - ('module_etc1_enabled', 'no'), - ('module_mpc_enabled', 'no'), - ('module_theora_enabled', 'no'), - ] +def get_flags(): + return [ + ('tools', 'no'), + ('module_etc1_enabled', 'no'), + ('module_mpc_enabled', 'no'), + ('module_theora_enabled', 'no'), + ] def configure(env): - env['ENV'] = os.environ; - env.use_windows_spawn_fix('javascript') - - env.Append(CPPPATH=['#platform/javascript']) + env['ENV'] = os.environ + env.use_windows_spawn_fix('javascript') - em_path=os.environ["EMSCRIPTEN_ROOT"] + env.Append(CPPPATH=['#platform/javascript']) - env['ENV']['PATH'] = em_path+":"+env['ENV']['PATH'] + em_path = os.environ["EMSCRIPTEN_ROOT"] - env['CC'] = em_path+'/emcc' - env['CXX'] = em_path+'/emcc' - #env['AR'] = em_path+"/emar" - env['AR'] = em_path+"/emcc" - env['ARFLAGS'] = "-o" + env['ENV']['PATH'] = em_path + ":" + env['ENV']['PATH'] + env['CC'] = em_path + '/emcc' + env['CXX'] = em_path + '/emcc' + #env['AR'] = em_path+"/emar" + env['AR'] = em_path + "/emcc" + env['ARFLAGS'] = "-o" # env['RANLIB'] = em_path+"/emranlib" - env['RANLIB'] = em_path + "/emcc" - env['OBJSUFFIX'] = '.bc' - env['LIBSUFFIX'] = '.bc' - env['CCCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" - env['CXXCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" + env['RANLIB'] = em_path + "/emcc" + env['OBJSUFFIX'] = '.bc' + env['LIBSUFFIX'] = '.bc' + env['CCCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" + env['CXXCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" # env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2']) # env["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ") - if (env["target"]=="release"): - env.Append(CCFLAGS=['-O2']) - elif (env["target"]=="release_debug"): - env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED']) - elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-O2', '-DDEBUG_ENABLED']) - #env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-g4', '-DDEBUG_ENABLED']) - env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) - - # TODO: Move that to opus module's config - if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"): - env.opus_fixed_point = "yes" - - env.Append(CPPFLAGS=["-fno-exceptions",'-DNO_SAFE_CAST','-fno-rtti']) - env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DNO_FCNTL','-DMPC_FIXED_POINT','-DTYPED_METHOD_BIND','-DNO_THREADS']) - env.Append(CPPFLAGS=['-DGLES2_ENABLED']) - env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS']) - env.Append(CPPFLAGS=['-s','ASM_JS=1']) - env.Append(CPPFLAGS=['-s','FULL_ES2=1']) + if (env["target"] == "release"): + env.Append(CCFLAGS=['-O2']) + elif (env["target"] == "release_debug"): + env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) + elif (env["target"] == "debug"): + env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-O2', '-DDEBUG_ENABLED']) + #env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-g4', '-DDEBUG_ENABLED']) + env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) + + # TODO: Move that to opus module's config + if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"): + env.opus_fixed_point = "yes" + + env.Append(CPPFLAGS=["-fno-exceptions", '-DNO_SAFE_CAST', '-fno-rtti']) + env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DNO_FCNTL', '-DMPC_FIXED_POINT', '-DTYPED_METHOD_BIND', '-DNO_THREADS']) + env.Append(CPPFLAGS=['-DGLES2_ENABLED']) + env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS']) + env.Append(CPPFLAGS=['-s', 'FULL_ES2=1']) # env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT']) - if env['javascript_eval'] == 'yes': - env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED']) + if env['wasm'] == 'yes': + env.Append(LINKFLAGS=['-s', 'BINARYEN=1']) + env.Append(LINKFLAGS=['-s', '\'BINARYEN_METHOD="native-wasm"\'']) + env["PROGSUFFIX"] += ".webassembly" + else: + env.Append(CPPFLAGS=['-s', 'ASM_JS=1']) + env.Append(LINKFLAGS=['-s', 'ASM_JS=1']) - if (env["compress"]=="yes"): - lzma_binpath = em_path+"/third_party/lzma.js/lzma-native" - lzma_decoder = em_path+"/third_party/lzma.js/lzma-decoder.js" - lzma_dec = "LZMA.decompress" - env.Append(LINKFLAGS=['--compression',lzma_binpath+","+lzma_decoder+","+lzma_dec]) + if env['javascript_eval'] == 'yes': + env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED']) - env.Append(LINKFLAGS=['-s','ASM_JS=1']) - env.Append(LINKFLAGS=['-O2']) - #env.Append(LINKFLAGS=['-g4']) + env.Append(LINKFLAGS=['-O2']) + # env.Append(LINKFLAGS=['-g4']) - #print "CCCOM is:", env.subst('$CCCOM') - #print "P: ", env['p'], " Platofrm: ", env['platform'] + # print "CCCOM is:", env.subst('$CCCOM') + # print "P: ", env['p'], " Platofrm: ", env['platform'] - import methods + import methods - env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } ) + env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')}) + #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } ) diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index f934916aa2..721aef3e50 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -180,9 +180,7 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t>& p_html, const St String current_line = lines[i]; current_line = current_line.replace("$GODOT_TMEM",itos((1<<(max_memory+5))*1024*1024)); - current_line = current_line.replace("$GODOT_FS",p_name+"fs.js"); - current_line = current_line.replace("$GODOT_MEM",p_name+".mem"); - current_line = current_line.replace("$GODOT_JS",p_name+".js"); + current_line = current_line.replace("$GODOT_BASE",p_name); current_line = current_line.replace("$GODOT_CANVAS_WIDTH",Globals::get_singleton()->get("display/width")); current_line = current_line.replace("$GODOT_CANVAS_HEIGHT",Globals::get_singleton()->get("display/height")); current_line = current_line.replace("$GODOT_HEAD_TITLE",!html_title.empty()?html_title:(String) Globals::get_singleton()->get("application/name")); @@ -319,16 +317,19 @@ Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool } if (file=="godot.js") { - //_fix_godot(data); file=p_path.get_file().basename()+".js"; } if (file=="godot.mem") { - //_fix_godot(data); file=p_path.get_file().basename()+".mem"; } + if (file=="godot.wasm") { + + file=p_path.get_file().basename()+".wasm"; + } + String dst = p_path.get_base_dir().plus_file(file); FileAccess *f=FileAccess::open(dst,FileAccess::WRITE); if (!f) { diff --git a/platform/javascript/godot_shell.html b/platform/javascript/godot_shell.html new file mode 100644 index 0000000000..3170d2bb9e --- /dev/null +++ b/platform/javascript/godot_shell.html @@ -0,0 +1,357 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> +<head> + <meta charset="utf-8" /> + <title>$GODOT_HEAD_TITLE</title> + $GODOT_HEAD_INCLUDE + <style type="text/css"> + body { + margin: 0; + border: 0 none; + padding: 0; + text-align: center; + background-color: black; + font-family: $GODOT_STYLE_FONT_FAMILY; + } + + + /* Godot Engine default theme style + * ================================ */ + + .godot { + color: #e0e0e0; + background-color: #3b3943; + background-image: linear-gradient(to bottom, #403e48, #35333c); + border: 1px solid #45434e; + box-shadow: 0 0 1px 1px #2f2d35; + } + + button.godot { + font-family: $GODOT_STYLE_FONT_FAMILY; /* override user agent style */ + padding: 1px 5px; + background-color: #37353f; + background-image: linear-gradient(to bottom, #413e49, #3a3842); + border: 1px solid #514f5d; + border-radius: 1px; + box-shadow: 0 0 1px 1px #2a2930; + } + + button.godot:hover { + color: #f0f0f0; + background-color: #44414e; + background-image: linear-gradient(to bottom, #494652, #423f4c); + border: 1px solid #5a5667; + box-shadow: 0 0 1px 1px #26252b; + } + + button.godot:active { + color: #fff; + background-color: #3e3b46; + background-image: linear-gradient(to bottom, #36343d, #413e49); + border: 1px solid #4f4c59; + box-shadow: 0 0 1px 1px #26252b; + } + + button.godot:disabled { + color: rgba(230, 230, 230, 0.2); + background-color: #3d3d3d; + background-image: linear-gradient(to bottom, #434343, #393939); + border: 1px solid #474747; + box-shadow: 0 0 1px 1px #2d2b33; + } + + + /* Canvas / wrapper + * ================ */ + + #container { + display: inline-block; /* scale with canvas */ + vertical-align: top; /* prevent extra height */ + position: relative; /* root for absolutely positioned overlay */ + margin: 0; + border: 0 none; + padding: 0; + background-color: #111; + } + + #canvas { + display: block; + margin: 0 auto; + /* canvas must have border and padding set to zero to + * calculate cursor coordinates correctly */ + border: 0 none; + padding: 0; + } + + + /* Status display + * ============== */ + + #status-container { + position: absolute; + left: 0; + top: 0; + right: 0; + bottom: 0; + display: flex; + justify-content: center; + align-items: center; + /* don't consume click events - make children visible explicitly */ + visibility: hidden; + } + + #status { + visibility: visible; + padding: 4px 6px; + } + + + /* On-hover controls + * ================= */ + + #controls { + visibility: hidden; + opacity: 0.0; + transition: opacity 500ms ease-in-out 200ms; + position: absolute; + right: 16px; + top: 16px; + padding: 3px 5px; + font-size: small; + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + } + + #container:hover > #controls { + opacity: 1.0; + transition: opacity 60ms ease-in-out; + } + + #controls > button, + #controls > label { + vertical-align: middle; + margin-left: 2px; + margin-right: 2px; + } + + #controls > label > input[type="checkbox"] { + /* override user agent style */ + margin-left: 0; + } + + label > input { + vertical-align: middle; + } + + #display-output { display: none; } + + + /* Debug output + * ============ */ + + #output { + display: none; + margin: 6px auto; + border: 2px groove grey; + padding: 4px; + outline: none; + text-align: left; + white-space: pre-wrap; + font-size: small; + color: #eee; + background-color: black; + font-family: "Lucida Console", Monaco, monospace; + } + + + /* Export style include + * ==================== */ + + $GODOT_STYLE_INCLUDE + </style> +</head> +<body> + <div id="container"> + <canvas id="canvas" width="$GODOT_CANVAS_WIDTH" height="$GODOT_CANVAS_HEIGHT" onclick="canvas.ownerDocument.defaultView.focus();" oncontextmenu="event.preventDefault();"> + HTML5 canvas appears to be unsupported in the current browser.<br />Please try updating or use a different browser. + </canvas> + <div id="status-container"> + <span id="status" class="godot" onclick="this.style.visibility='hidden';">Loading page...</span> + </div> + <div id="controls" class="godot"> + <label id="display-output"><input id="output-toggle" type="checkbox" autocomplete="off" onchange="Presentation.setOutputVisible(this.checked);" />display output</label> + <!-- hidden until implemented + <label><input id="lock-cursor" type="checkbox" autocomplete="off" />lock cursor</label> + <label><input id="resize-canvas" type="checkbox" autocomplete="off" />resize canvas</label> + --> + <button id="fullscreen" class="godot" type="button" disabled="disabled" autocomplete="off" onclick="Presentation.goFullscreen();">fullscreen</button> + </div> + </div> + <!-- Firefox adds extra space to textarea, but shouldn't matter too much https://bugzilla.mozilla.org/show_bug.cgi?id=33654 --> + <textarea id="output" rows="10" cols="100" readonly="readonly" style="resize:none"></textarea> + + <script type="text/javascript">//<![CDATA[ + var Presentation = (function() { + var statusElement = document.getElementById("status"); + var outputElement = document.getElementById("output"); + var doneLoading = false; + + function onLoaded() { + doneLoading = true; + var fullscreenButtonElement = document.getElementById("fullscreen"); + fullscreenButtonElement.disabled = false; + } + + var presentation = { + statusElement: statusElement, + outputElement: outputElement, + setOutputVisible: function setOutputVisible(visible) { + outputElement.style.display = (visible?"block":"none"); + }, + setStatusVisible: function setStatusVisible(visible) { + statusElement.style.visibility = (visible?"visible":"hidden"); + }, + setStatus: function setStatus(text) { + if (!text || text.length === 0) { + Presentation.setStatusVisible(false); + onLoaded(); + } else { + Presentation.setStatusVisible(true); + statusElement.innerHTML = text; + } + }, + goFullscreen: function goFullscreen() { + if (doneLoading) Module.requestFullScreen(false, false); + } + }; + + if ($GODOT_CONTROLS_ENABLED) { // controls enabled + (function() { + var controlsElement = document.getElementById("controls"); + controlsElement.style.visibility="visible"; + })(); + } + + if ($GODOT_DEBUG_ENABLED) { // debugging enabled + (function() { + var outputToggleLabel = document.getElementById("display-output"); + var outputToggle = document.getElementById("output-toggle"); + + outputElement.value = ""; // clear browser cache + outputElement.style.display = "block"; + outputToggle.checked = true; + outputToggleLabel.style.display = "inline"; + + presentation.print = function print(text) { + if (outputElement.value.length !== 0) + outputElement.value += "\n"; + outputElement.value += text; + outputElement.scrollTop = outputElement.scrollHeight; // focus on bottom + }; + })(); + } + + return presentation; + })(); + + // Emscripten interface + var Module = (function() { + var print = (function() { + if (typeof Presentation.print === "function") { + return function print(text) { + if (arguments.length > 1) + text = Array.prototype.slice.call(arguments).join(" "); + console.log(text); + Presentation.print(text); + }; + } else { + return function print(text) { + if (arguments.length > 1) + text = Array.prototype.slice.call(arguments).join(" "); + console.log(text); + }; + } + })(); + + var canvas = (function() { + var canvasElement = document.getElementById("canvas"); + + // As a default initial behavior, pop up an alert when WebGL context is lost. To make your + // application robust, you may want to override this behavior before shipping! + // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2 + canvasElement.addEventListener("webglcontextlost", function(e) { alert("WebGL context lost. Plase reload the page."); e.preventDefault(); }, false); + + return canvasElement; + })(); + + var setStatus = (function() { + if (typeof Presentation.setStatus === "function") + return function setStatus(text) { + if (!Module.setStatus.last) + Module.setStatus.last = { time: Date.now(), text: "" }; + if (text === Module.setStatus.text) + return; + var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); + var now = Date.now(); + if (m) { + if (now - Date.now() < 30) // if this is a progress update, skip it if too soon + return; + text = m[1]; + } + Presentation.setStatus(text); + }; + else + return function setStatus(text) { + if (!Module.setStatus.last) + Module.setStatus.last = { time: Date.now(), text: "" }; + if (text === Module.setStatus.text) + return; + var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); + var now = Date.now(); + if (m) { + if (now - Date.now() < 30) // if this is a progress update, skip it if too soon + return; + text = m[1]; + } + }; + })(); + + return { + TOTAL_MEMORY: 268435456, + preRun: [], + postRun: [], + print: print, + printErr: function printErr(text) { + if (arguments.length > 1) + text = Array.prototype.slice.call(arguments).join(" "); + if (0) { // XXX disabled for safety `if (typeof dump == "function")` + dump(text + "\n"); // fast, straight to the real console + } else { + console.error(text); + } + }, + canvas: canvas, + setStatus: setStatus, + totalDependencies: 0, + monitorRunDependencies: function monitorRunDependencies(left) { + this.totalDependencies = Math.max(this.totalDependencies, left); + Module.setStatus(left ? "Preparing... (" + (this.totalDependencies-left) + "/" + this.totalDependencies + ")" : "All downloads complete."); + } + }; + })(); + + Presentation.setStatus("Downloading..."); + + window.onerror = function(event) { + // TODO: do not warn on ok events like simulating an infinite loop or exitStatus + Module.setStatus("Exception thrown, see JavaScript console"); + Module.setStatus = function(text) { + if (text) Module.printErr("[post-exception status] " + text); + }; + }; + //]]></script> + <script type="text/javascript" src="$GODOT_BASEfs.js"></script> + {{{ SCRIPT }}} +</body> +</html> diff --git a/platform/osx/SCsub b/platform/osx/SCsub index 217dee81eb..c8e0e17612 100644 --- a/platform/osx/SCsub +++ b/platform/osx/SCsub @@ -3,13 +3,13 @@ Import('env') files = [ - 'os_osx.mm', - 'godot_main_osx.mm', - 'audio_driver_osx.cpp', - 'sem_osx.cpp', -# 'context_gl_osx.cpp', - 'dir_access_osx.mm', - 'joystick_osx.cpp', - ] + 'os_osx.mm', + 'godot_main_osx.mm', + 'audio_driver_osx.cpp', + 'sem_osx.cpp', + # 'context_gl_osx.cpp', + 'dir_access_osx.mm', + 'joystick_osx.cpp', +] -env.Program('#bin/godot',files) +env.Program('#bin/godot', files) diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 4e772e37eb..9191f1aabc 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -4,99 +4,97 @@ import sys def is_active(): - return True + return True + def get_name(): - return "OSX" + return "OSX" + def can_build(): - if (sys.platform == "darwin" or os.environ.has_key("OSXCROSS_ROOT")): - return True + if (sys.platform == "darwin" or os.environ.has_key("OSXCROSS_ROOT")): + return True + return False - return False def get_opts(): - return [ - ('force_64_bits','Force 64 bits binary','no'), - ('osxcross_sdk','OSXCross SDK version','darwin14'), + return [ + ('force_64_bits', 'Force 64 bits binary', 'no'), + ('osxcross_sdk', 'OSXCross SDK version', 'darwin14'), - ] + ] -def get_flags(): - return [ - ] +def get_flags(): + return [ + ] def configure(env): - env.Append(CPPPATH=['#platform/osx']) - - if (env["bits"]=="default"): - env["bits"]="32" - - if (env["target"]=="release"): - - env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer','-ftree-vectorize','-msse2']) - - elif (env["target"]=="release_debug"): + env.Append(CPPPATH=['#platform/osx']) - env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED']) + if (env["bits"] == "default"): + env["bits"] = "32" - elif (env["target"]=="debug"): + if (env["target"] == "release"): - env.Append(CCFLAGS=['-g3', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-O2', '-ffast-math', '-fomit-frame-pointer', '-ftree-vectorize', '-msse2']) + elif (env["target"] == "release_debug"): + env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) - if (not os.environ.has_key("OSXCROSS_ROOT")): - #regular native build - if (env["bits"]=="64"): - env.Append(CCFLAGS=['-arch', 'x86_64']) - env.Append(LINKFLAGS=['-arch', 'x86_64']) - elif (env["bits"]=="32"): - env.Append(CCFLAGS=['-arch', 'i386']) - env.Append(LINKFLAGS=['-arch', 'i386']) - else: - env.Append(CCFLAGS=['-arch', 'i386', '-arch', 'x86_64']) - env.Append(LINKFLAGS=['-arch', 'i386', '-arch', 'x86_64']) - else: - #osxcross build - root=os.environ.get("OSXCROSS_ROOT",0) - if env["bits"]=="64": - basecmd=root+"/target/bin/x86_64-apple-"+env["osxcross_sdk"]+"-" - else: - basecmd=root+"/target/bin/i386-apple-"+env["osxcross_sdk"]+"-" + elif (env["target"] == "debug"): + env.Append(CCFLAGS=['-g3', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) - env['CC'] = basecmd+"cc" - env['CXX'] = basecmd+"c++" - env['AR'] = basecmd+"ar" - env['RANLIB'] = basecmd+"ranlib" - env['AS'] = basecmd+"as" + if (not os.environ.has_key("OSXCROSS_ROOT")): + # regular native build + if (env["bits"] == "64"): + env.Append(CCFLAGS=['-arch', 'x86_64']) + env.Append(LINKFLAGS=['-arch', 'x86_64']) + elif (env["bits"] == "32"): + env.Append(CCFLAGS=['-arch', 'i386']) + env.Append(LINKFLAGS=['-arch', 'i386']) + else: + env.Append(CCFLAGS=['-arch', 'i386', '-arch', 'x86_64']) + env.Append(LINKFLAGS=['-arch', 'i386', '-arch', 'x86_64']) + else: + # osxcross build + root = os.environ.get("OSXCROSS_ROOT", 0) + if env["bits"] == "64": + basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-" + else: + basecmd = root + "/target/bin/i386-apple-" + env["osxcross_sdk"] + "-" + env['CC'] = basecmd + "cc" + env['CXX'] = basecmd + "c++" + env['AR'] = basecmd + "ar" + env['RANLIB'] = basecmd + "ranlib" + env['AS'] = basecmd + "as" - env.Append(CPPFLAGS=["-DAPPLE_STYLE_KEYS"]) - env.Append(CPPFLAGS=['-DUNIX_ENABLED','-DGLES2_ENABLED','-DOSX_ENABLED']) - env.Append(LIBS=['pthread']) - #env.Append(CPPFLAGS=['-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-mmacosx-version-min=10.4']) - #env.Append(LINKFLAGS=['-mmacosx-version-min=10.4', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk']) - env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit','-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback']) + env.Append(CPPFLAGS=["-DAPPLE_STYLE_KEYS"]) + env.Append(CPPFLAGS=['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DOSX_ENABLED']) + env.Append(LIBS=['pthread']) + #env.Append(CPPFLAGS=['-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-mmacosx-version-min=10.4']) + #env.Append(LINKFLAGS=['-mmacosx-version-min=10.4', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk']) + env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback']) - if (env["CXX"]=="clang++"): - env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) - env["CC"]="clang" - env["LD"]="clang++" + if (env["CXX"] == "clang++"): + env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) + env["CC"] = "clang" + env["LD"] = "clang++" - import methods + import methods - env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } ) + env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')}) + #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } ) - env["x86_libtheora_opt_gcc"]=True + env["x86_libtheora_opt_gcc"] = True diff --git a/platform/server/SCsub b/platform/server/SCsub index 12758c5db0..30195bb908 100644 --- a/platform/server/SCsub +++ b/platform/server/SCsub @@ -3,8 +3,8 @@ Import('env') -common_server=[\ - "os_server.cpp",\ +common_server = [\ + "os_server.cpp",\ ] -env.Program('#bin/godot_server',['godot_server.cpp']+common_server) +env.Program('#bin/godot_server', ['godot_server.cpp'] + common_server) diff --git a/platform/server/detect.py b/platform/server/detect.py index ce14100fd0..4d86ffd376 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -4,73 +4,117 @@ import sys def is_active(): - return True + return True + def get_name(): - return "Server" + return "Server" def can_build(): - if (os.name!="posix"): - return False + if (os.name != "posix"): + return False + + return True # enabled - return True # enabled def get_opts(): - return [ - ('use_llvm','Use llvm compiler','no'), - ('force_32_bits','Force 32 bits binary','no') - ] + return [ + ('use_llvm', 'Use llvm compiler', 'no'), + ('force_32_bits', 'Force 32 bits binary', 'no') + ] -def get_flags(): - return [ - ] +def get_flags(): + return [ + ] def configure(env): - env.Append(CPPPATH=['#platform/server']) - if (env["use_llvm"]=="yes"): - env["CC"]="clang" - env["CXX"]="clang++" - env["LD"]="clang++" + env.Append(CPPPATH=['#platform/server']) + if (env["use_llvm"] == "yes"): + env["CC"] = "clang" + env["CXX"] = "clang++" + env["LD"] = "clang++" + + is64 = sys.maxsize > 2**32 + + if (env["bits"] == "default"): + if (is64): + env["bits"] = "64" + else: + env["bits"] = "32" + + # if (env["tools"]=="no"): + # #no tools suffix + # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX'] + # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX'] + + if (env["target"] == "release"): + + env.Append(CCFLAGS=['-O2', '-ffast-math', '-fomit-frame-pointer']) + + elif (env["target"] == "release_debug"): + + env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED']) + + elif (env["target"] == "debug"): + + env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + + + # Shared libraries, when requested + + if (env['builtin_openssl'] == 'no'): + env.ParseConfig('pkg-config openssl --cflags --libs') - is64=sys.maxsize > 2**32 + if (env['builtin_libwebp'] == 'no'): + env.ParseConfig('pkg-config libwebp --cflags --libs') - if (env["bits"]=="default"): - if (is64): - env["bits"]="64" - else: - env["bits"]="32" + if (env['builtin_freetype'] == 'no'): + env['builtin_libpng'] = 'no' # Freetype links against libpng + env.ParseConfig('pkg-config freetype2 --cflags --libs') + if (env['builtin_libpng'] == 'no'): + env.ParseConfig('pkg-config libpng --cflags --libs') - #if (env["tools"]=="no"): - # #no tools suffix - # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX'] - # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX'] + if (env['builtin_enet'] == 'no'): + env.ParseConfig('pkg-config libenet --cflags --libs') + if (env['builtin_squish'] == 'no' and env["tools"] == "yes"): + env.ParseConfig('pkg-config libsquish --cflags --libs') - if (env["target"]=="release"): + # Sound and video libraries + # Keep the order as it triggers chained dependencies (ogg needed by others, etc.) - env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer']) + 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 + env.ParseConfig('pkg-config theora theoradec --cflags --libs') - elif (env["target"]=="release_debug"): + if (env['builtin_libvpx'] == 'no'): + env.ParseConfig('pkg-config vpx --cflags --libs') - env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED']) + if (env['builtin_libvorbis'] == 'no'): + env['builtin_libogg'] = 'no' # Needed to link against system libvorbis + env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs') - elif (env["target"]=="debug"): + if (env['builtin_opus'] == 'no'): + env['builtin_libogg'] = 'no' # Needed to link against system opus + env.ParseConfig('pkg-config opus opusfile --cflags --libs') - env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + if (env['builtin_libogg'] == 'no'): + env.ParseConfig('pkg-config ogg --cflags --libs') - env.Append(CPPFLAGS=['-DSERVER_ENABLED','-DUNIX_ENABLED']) - env.Append(LIBS=['pthread','z']) #TODO detect linux/BSD! - if (env["CXX"]=="clang++"): - env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) - env["CC"]="clang" - env["LD"]="clang++" + env.Append(CPPFLAGS=['-DSERVER_ENABLED', '-DUNIX_ENABLED']) + env.Append(LIBS=['pthread', 'z']) # TODO detect linux/BSD! + if (env["CXX"] == "clang++"): + env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) + env["CC"] = "clang" + env["LD"] = "clang++" diff --git a/platform/uwp/SCsub b/platform/uwp/SCsub new file mode 100644 index 0000000000..430d4ef9e7 --- /dev/null +++ b/platform/uwp/SCsub @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +Import('env') + +files = [ + 'thread_uwp.cpp', + '#platform/windows/tcp_server_winsock.cpp', + '#platform/windows/packet_peer_udp_winsock.cpp', + '#platform/windows/stream_peer_winsock.cpp', + '#platform/windows/key_mapping_win.cpp', + 'joystick_uwp.cpp', + 'gl_context_egl.cpp', + 'app.cpp', + 'os_uwp.cpp', +] + +if "build_angle" in env and env["build_angle"]: + cmd = env.AlwaysBuild(env.ANGLE('libANGLE.lib', None)) + +prog = env.Program('#bin/godot', files) + +if "build_angle" in env and env["build_angle"]: + env.Depends(prog, [cmd]) diff --git a/platform/winrt/app.cpp b/platform/uwp/app.cpp index c2b7ba0641..539c1815f6 100644 --- a/platform/winrt/app.cpp +++ b/platform/uwp/app.cpp @@ -53,7 +53,7 @@ using namespace Windows::System; using namespace Windows::System::Threading::Core; using namespace Microsoft::WRL; -using namespace GodotWinRT; +using namespace GodotUWP; // Helper to convert a length in device-independent pixels (DIPs) to a length in physical pixels. inline float ConvertDipsToPixels(float dips, float dpi) @@ -63,7 +63,7 @@ inline float ConvertDipsToPixels(float dips, float dpi) } // Implementation of the IFrameworkViewSource interface, necessary to run our app. -ref class GodotWinrtViewSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource +ref class GodotUWPViewSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource { public: virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView() @@ -76,7 +76,7 @@ public: [Platform::MTAThread] int main(Platform::Array<Platform::String^>^) { - auto godotApplicationSource = ref new GodotWinrtViewSource(); + auto godotApplicationSource = ref new GodotUWPViewSource(); CoreApplication::Run(godotApplicationSource); return 0; } @@ -105,7 +105,7 @@ void App::Initialize(CoreApplicationView^ applicationView) // Information about the Suspending and Resuming event handlers can be found here: // http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh994930.aspx - os = new OSWinrt; + os = new OSUWP; } @@ -157,7 +157,7 @@ void App::SetWindow(CoreWindow^ p_window) unsigned int argc; char** argv = get_command_line(&argc); - Main::setup("winrt", argc, argv, false); + Main::setup("uwp", argc, argv, false); // The CoreWindow has been created, so EGL can be initialized. ContextEGL* context = memnew(ContextEGL(window)); @@ -431,7 +431,7 @@ void App::OnMouseMoved(MouseDevice ^ mouse_device, MouseEventArgs ^ args) { void App::key_event(Windows::UI::Core::CoreWindow^ sender, bool p_pressed, Windows::UI::Core::KeyEventArgs^ key_args, Windows::UI::Core::CharacterReceivedEventArgs^ char_args) { - OSWinrt::KeyEvent ke; + OSUWP::KeyEvent ke; InputModifierState mod; mod.meta = false; @@ -445,14 +445,14 @@ void App::key_event(Windows::UI::Core::CoreWindow^ sender, bool p_pressed, Windo if (key_args != nullptr) { - ke.type = OSWinrt::KeyEvent::MessageType::KEY_EVENT_MESSAGE; + ke.type = OSUWP::KeyEvent::MessageType::KEY_EVENT_MESSAGE; ke.unicode = 0; ke.scancode = KeyMappingWindows::get_keysym((unsigned int)key_args->VirtualKey); ke.echo = (!p_pressed && !key_args->KeyStatus.IsKeyReleased) || (p_pressed && key_args->KeyStatus.WasKeyDown); } else { - ke.type = OSWinrt::KeyEvent::MessageType::CHAR_EVENT_MESSAGE; + ke.type = OSUWP::KeyEvent::MessageType::CHAR_EVENT_MESSAGE; ke.unicode = char_args->KeyCode; ke.scancode = 0; ke.echo = (!p_pressed && !char_args->KeyStatus.IsKeyReleased) || (p_pressed && char_args->KeyStatus.WasKeyDown); diff --git a/platform/winrt/app.h b/platform/uwp/app.h index 652ec86e1f..f82de4d240 100644 --- a/platform/winrt/app.h +++ b/platform/uwp/app.h @@ -32,10 +32,10 @@ #include <wrl.h> -#include "os_winrt.h" +#include "os_uwp.h" #include "GLES2/gl2.h" -namespace GodotWinRT +namespace GodotUWP { ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView { @@ -97,7 +97,7 @@ namespace GodotWinRT EGLSurface mEglSurface; CoreWindow^ window; - OSWinrt* os; + OSUWP* os; int last_touch_x[32]; // 20 fingers, index 31 reserved for the mouse int last_touch_y[32]; diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py new file mode 100644 index 0000000000..6eb4ca9caa --- /dev/null +++ b/platform/uwp/detect.py @@ -0,0 +1,166 @@ +import os + +import sys +import string +import methods + + +def is_active(): + return True + + +def get_name(): + return "UWP" + + +def can_build(): + if (os.name == "nt"): + # building natively on windows! + if (os.getenv("VSINSTALLDIR")): + + if (os.getenv("ANGLE_SRC_PATH") == None): + return False + + return True + return False + + +def get_opts(): + return [] + + +def get_flags(): + + return [ + ('tools', 'no'), + ('xaudio2', 'yes'), + ] + + +def configure(env): + + if(env["bits"] != "default"): + print "Error: bits argument is disabled for MSVC" + print ("Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings)" + + " that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=uwp) and SCons will attempt to detect what MSVC compiler" + + " will be executed and inform you.") + sys.exit() + + arch = "" + env['ENV'] = os.environ + + # ANGLE + angle_root = os.getenv("ANGLE_SRC_PATH") + env.Append(CPPPATH=[angle_root + '/include']) + jobs = str(env.GetOption("num_jobs")) + angle_build_cmd = "msbuild.exe " + angle_root + "/winrt/10/src/angle.sln /nologo /v:m /m:" + jobs + " /p:Configuration=Release /p:Platform=" + + if os.path.isfile(str(os.getenv("ANGLE_SRC_PATH")) + "/winrt/10/src/angle.sln"): + env["build_angle"] = True + + if os.getenv('Platform') == "ARM": + + print "Compiled program architecture will be an ARM executable. (forcing bits=32)." + + arch = "arm" + env["bits"] = "32" + env.Append(LINKFLAGS=['/MACHINE:ARM']) + env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/arm']) + + angle_build_cmd += "ARM" + + env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_ARM/lib']) + + else: + + compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV']) + + if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"): + env["bits"] = "64" + print "Compiled program architecture will be a x64 executable (forcing bits=64)." + elif (compiler_version_str == "x86" or compiler_version_str == "amd64_x86"): + env["bits"] = "32" + print "Compiled program architecture will be a x86 executable. (forcing bits=32)." + else: + print "Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup." + env["bits"] = "32" + + if (env["bits"] == "32"): + arch = "x86" + + angle_build_cmd += "Win32" + + env.Append(CPPFLAGS=['/DPNG_ABORT=abort']) + env.Append(LINKFLAGS=['/MACHINE:X86']) + env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store']) + env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_Win32/lib']) + + else: + arch = "x64" + + angle_build_cmd += "x64" + + env.Append(LINKFLAGS=['/MACHINE:X64']) + env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/amd64']) + env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_x64/lib']) + + env.Append(CPPPATH=['#platform/uwp', '#drivers/windows']) + env.Append(LINKFLAGS=['/MANIFEST:NO', '/NXCOMPAT', '/DYNAMICBASE', '/WINMD', '/APPCONTAINER', '/ERRORREPORT:PROMPT', '/NOLOGO', '/TLBID:1', '/NODEFAULTLIB:"kernel32.lib"', '/NODEFAULTLIB:"ole32.lib"']) + env.Append(CPPFLAGS=['/D', '__WRL_NO_DEFAULT_LIB__', '/D', 'WIN32']) + env.Append(CPPFLAGS=['/FU', os.environ['VCINSTALLDIR'] + 'lib/store/references/platform.winmd']) + env.Append(CPPFLAGS=['/AI', os.environ['VCINSTALLDIR'] + 'lib/store/references']) + + env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/references']) + + if (env["target"] == "release"): + + env.Append(CPPFLAGS=['/O2', '/GL']) + env.Append(CPPFLAGS=['/MD']) + env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS', '/LTCG']) + + elif (env["target"] == "release_debug"): + + env.Append(CCFLAGS=['/O2', '/Zi', '/DDEBUG_ENABLED']) + env.Append(CPPFLAGS=['/MD']) + env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) + + elif (env["target"] == "debug"): + + env.Append(CCFLAGS=['/Zi', '/DDEBUG_ENABLED', '/DDEBUG_MEMORY_ENABLED']) + env.Append(CPPFLAGS=['/MDd']) + env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) + env.Append(LINKFLAGS=['/DEBUG']) + + env.Append(CCFLAGS=string.split('/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /D "_UNICODE" /D "UNICODE" /D "WINAPI_FAMILY=WINAPI_FAMILY_APP" /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo')) + env.Append(CXXFLAGS=string.split('/ZW /FS')) + env.Append(CCFLAGS=['/AI', os.environ['VCINSTALLDIR'] + '\\vcpackages', '/AI', os.environ['WINDOWSSDKDIR'] + '\\References\\CommonConfiguration\\Neutral']) + + env["PROGSUFFIX"] = "." + arch + env["PROGSUFFIX"] + env["OBJSUFFIX"] = "." + arch + env["OBJSUFFIX"] + env["LIBSUFFIX"] = "." + arch + env["LIBSUFFIX"] + + env.Append(CCFLAGS=['/DUWP_ENABLED']) + env.Append(CCFLAGS=['/DWINDOWS_ENABLED']) + env.Append(CCFLAGS=['/DTYPED_METHOD_BIND']) + + env.Append(CCFLAGS=['/DGLES2_ENABLED', '/DGL_GLEXT_PROTOTYPES', '/DEGL_EGLEXT_PROTOTYPES', '/DANGLE_ENABLED']) + + LIBS = [ + 'WindowsApp', + 'mincore', + 'libANGLE', + 'libEGL', + 'libGLESv2', + ] + env.Append(LINKFLAGS=[p + ".lib" for p in LIBS]) + + # Incremental linking fix + env['BUILDERS']['ProgramOriginal'] = env['BUILDERS']['Program'] + env['BUILDERS']['Program'] = methods.precious_program + + env.Append(BUILDERS={'ANGLE': env.Builder(action=angle_build_cmd)}) + + env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'HLSL9': env.Builder(action=methods.build_hlsl_dx9_headers, suffix='hlsl.h', src_suffix='.hlsl')}) + env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')}) diff --git a/platform/winrt/export/export.cpp b/platform/uwp/export/export.cpp index eca9f09de6..aab9ae8e39 100644 --- a/platform/winrt/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -71,7 +71,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "object.h" #include "tools/editor/editor_import_export.h" #include "tools/editor/editor_node.h" -#include "platform/winrt/logo.h" +#include "platform/uwp/logo.h" #include "os/file_access.h" #include "io/zip.h" #include "io/unzip.h" @@ -432,9 +432,9 @@ public: ~AppxPackager(); }; -class EditorExportPlatformWinrt : public EditorExportPlatform { +class EditorExportPlatformUWP : public EditorExportPlatform { - OBJ_TYPE(EditorExportPlatformWinrt, EditorExportPlatform); + OBJ_TYPE(EditorExportPlatformUWP, EditorExportPlatform); Ref<ImageTexture> logo; @@ -528,8 +528,8 @@ public: virtual Error export_project(const String& p_path, bool p_debug, int p_flags = 0); - EditorExportPlatformWinrt(); - ~EditorExportPlatformWinrt(); + EditorExportPlatformUWP(); + ~EditorExportPlatformUWP(); }; @@ -1452,7 +1452,7 @@ Error AppxPackager::sign(const CertFile & p_cert, const AppxDigests & digests, P //////////////////////////////////////////////////////////////////// -bool EditorExportPlatformWinrt::_valid_resource_name(const String &p_name) const { +bool EditorExportPlatformUWP::_valid_resource_name(const String &p_name) const { if (p_name.empty()) return false; if (p_name.ends_with(".")) return false; @@ -1472,7 +1472,7 @@ bool EditorExportPlatformWinrt::_valid_resource_name(const String &p_name) const return true; } -bool EditorExportPlatformWinrt::_valid_guid(const String & p_guid) const { +bool EditorExportPlatformUWP::_valid_guid(const String & p_guid) const { Vector<String> parts = p_guid.split("-"); @@ -1485,7 +1485,7 @@ bool EditorExportPlatformWinrt::_valid_guid(const String & p_guid) const { return true; } -bool EditorExportPlatformWinrt::_valid_bgcolor(const String & p_color) const { +bool EditorExportPlatformUWP::_valid_bgcolor(const String & p_color) const { if (p_color.empty()) return true; if (p_color.begins_with("#") && p_color.is_valid_html_color()) return true; @@ -1529,7 +1529,7 @@ bool EditorExportPlatformWinrt::_valid_bgcolor(const String & p_color) const { return false; } -bool EditorExportPlatformWinrt::_valid_image(const Ref<ImageTexture> p_image, int p_width, int p_height) const { +bool EditorExportPlatformUWP::_valid_image(const Ref<ImageTexture> p_image, int p_width, int p_height) const { if (!p_image.is_valid()) return false; @@ -1553,7 +1553,7 @@ bool EditorExportPlatformWinrt::_valid_image(const Ref<ImageTexture> p_image, in return valid_w && valid_h; } -Vector<uint8_t> EditorExportPlatformWinrt::_fix_manifest(const Vector<uint8_t> &p_template, bool p_give_internet) const { +Vector<uint8_t> EditorExportPlatformUWP::_fix_manifest(const Vector<uint8_t> &p_template, bool p_give_internet) const { String result = String::utf8((const char*)p_template.ptr(), p_template.size()); @@ -1659,7 +1659,7 @@ Vector<uint8_t> EditorExportPlatformWinrt::_fix_manifest(const Vector<uint8_t> & return r_ret; } -Vector<uint8_t> EditorExportPlatformWinrt::_get_image_data(const String & p_path) { +Vector<uint8_t> EditorExportPlatformUWP::_get_image_data(const String & p_path) { Vector<uint8_t> data; Ref<ImageTexture> ref; @@ -1741,7 +1741,7 @@ Vector<uint8_t> EditorExportPlatformWinrt::_get_image_data(const String & p_path return data; } -Error EditorExportPlatformWinrt::save_appx_file(void * p_userdata, const String & p_path, const Vector<uint8_t>& p_data, int p_file, int p_total) { +Error EditorExportPlatformUWP::save_appx_file(void * p_userdata, const String & p_path, const Vector<uint8_t>& p_data, int p_file, int p_total) { AppxPackager *packager = (AppxPackager*)p_userdata; String dst_path = p_path.replace_first("res://", "game/"); @@ -1751,7 +1751,7 @@ Error EditorExportPlatformWinrt::save_appx_file(void * p_userdata, const String return OK; } -bool EditorExportPlatformWinrt::_should_compress_asset(const String & p_path, const Vector<uint8_t>& p_data) { +bool EditorExportPlatformUWP::_should_compress_asset(const String & p_path, const Vector<uint8_t>& p_data) { /* TODO: This was copied verbatim from Android export. It should be * refactored to the parent class and also be used for .zip export. @@ -1800,7 +1800,7 @@ bool EditorExportPlatformWinrt::_should_compress_asset(const String & p_path, co return true; } -bool EditorExportPlatformWinrt::_set(const StringName& p_name, const Variant& p_value) { +bool EditorExportPlatformUWP::_set(const StringName& p_name, const Variant& p_value) { String n = p_name; @@ -1906,7 +1906,7 @@ bool EditorExportPlatformWinrt::_set(const StringName& p_name, const Variant& p_ return true; } -bool EditorExportPlatformWinrt::_get(const StringName& p_name, Variant &r_ret) const { +bool EditorExportPlatformUWP::_get(const StringName& p_name, Variant &r_ret) const { String n = p_name; @@ -2002,7 +2002,7 @@ bool EditorExportPlatformWinrt::_get(const StringName& p_name, Variant &r_ret) c return true; } -void EditorExportPlatformWinrt::_get_property_list(List<PropertyInfo>* p_list) const { +void EditorExportPlatformUWP::_get_property_list(List<PropertyInfo>* p_list) const { p_list->push_back(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "appx")); p_list->push_back(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "appx")); @@ -2071,14 +2071,14 @@ void EditorExportPlatformWinrt::_get_property_list(List<PropertyInfo>* p_list) c } -bool EditorExportPlatformWinrt::can_export(String * r_error) const { +bool EditorExportPlatformUWP::can_export(String * r_error) const { String err; bool valid = true; - if (!exists_export_template("winrt_x86_debug.zip") || !exists_export_template("winrt_x86_release.zip") - || !exists_export_template("winrt_arm_debug.zip") || !exists_export_template("winrt_arm_release.zip") - || !exists_export_template("winrt_x64_debug.zip") || !exists_export_template("winrt_x64_release.zip")) { + if (!exists_export_template("uwp_x86_debug.zip") || !exists_export_template("uwp_x86_release.zip") + || !exists_export_template("uwp_arm_debug.zip") || !exists_export_template("uwp_arm_release.zip") + || !exists_export_template("uwp_x64_debug.zip") || !exists_export_template("uwp_x64_release.zip")) { valid = false; err += TTR("No export templates found.\nDownload and install export templates.") + "\n"; } @@ -2154,7 +2154,7 @@ bool EditorExportPlatformWinrt::can_export(String * r_error) const { return valid; } -Error EditorExportPlatformWinrt::export_project(const String & p_path, bool p_debug, int p_flags) { +Error EditorExportPlatformUWP::export_project(const String & p_path, bool p_debug, int p_flags) { String src_appx; @@ -2170,30 +2170,30 @@ Error EditorExportPlatformWinrt::export_project(const String & p_path, bool p_de if (p_debug) { switch (arch) { case X86: { - src_appx = find_export_template("winrt_x86_debug.zip", &err); + src_appx = find_export_template("uwp_x86_debug.zip", &err); break; } case X64: { - src_appx = find_export_template("winrt_x64_debug.zip", &err); + src_appx = find_export_template("uwp_x64_debug.zip", &err); break; } case ARM: { - src_appx = find_export_template("winrt_arm_debug.zip", &err); + src_appx = find_export_template("uwp_arm_debug.zip", &err); break; } } } else { switch (arch) { case X86: { - src_appx = find_export_template("winrt_x86_release.zip", &err); + src_appx = find_export_template("uwp_x86_release.zip", &err); break; } case X64: { - src_appx = find_export_template("winrt_x64_release.zip", &err); + src_appx = find_export_template("uwp_x64_release.zip", &err); break; } case ARM: { - src_appx = find_export_template("winrt_arm_release.zip", &err); + src_appx = find_export_template("uwp_arm_release.zip", &err); break; } } @@ -2337,9 +2337,9 @@ Error EditorExportPlatformWinrt::export_project(const String & p_path, bool p_de return OK; } -EditorExportPlatformWinrt::EditorExportPlatformWinrt() { +EditorExportPlatformUWP::EditorExportPlatformUWP() { - Image img(_winrt_logo); + Image img(_uwp_logo); logo = Ref<ImageTexture>(memnew(ImageTexture)); logo->create_from_image(img); @@ -2381,11 +2381,11 @@ EditorExportPlatformWinrt::EditorExportPlatformWinrt() { certificate_pass = ""; } -EditorExportPlatformWinrt::~EditorExportPlatformWinrt() {} +EditorExportPlatformUWP::~EditorExportPlatformUWP() {} -void register_winrt_exporter() { +void register_uwp_exporter() { - Ref<EditorExportPlatformWinrt> exporter = Ref<EditorExportPlatformWinrt>(memnew(EditorExportPlatformWinrt)); + Ref<EditorExportPlatformUWP> exporter = Ref<EditorExportPlatformUWP>(memnew(EditorExportPlatformUWP)); EditorImportExport::get_singleton()->add_export_platform(exporter); } diff --git a/platform/winrt/export/export.h b/platform/uwp/export/export.h index 278d6d23cd..f25065341d 100644 --- a/platform/winrt/export/export.h +++ b/platform/uwp/export/export.h @@ -26,4 +26,4 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -void register_winrt_exporter(); +void register_uwp_exporter(); diff --git a/platform/winrt/gl_context_egl.cpp b/platform/uwp/gl_context_egl.cpp index f7b514b3c0..f7b514b3c0 100644 --- a/platform/winrt/gl_context_egl.cpp +++ b/platform/uwp/gl_context_egl.cpp diff --git a/platform/winrt/gl_context_egl.h b/platform/uwp/gl_context_egl.h index 8124c2903d..8124c2903d 100644 --- a/platform/winrt/gl_context_egl.h +++ b/platform/uwp/gl_context_egl.h diff --git a/platform/winrt/joystick_winrt.cpp b/platform/uwp/joystick_uwp.cpp index 9f93c5a26b..ad0516992b 100644 --- a/platform/winrt/joystick_winrt.cpp +++ b/platform/uwp/joystick_uwp.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joystick.cpp */ +/* joystick_uwp.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,20 +27,20 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "joystick_winrt.h" +#include "joystick_uwp.h" using namespace Windows::Gaming::Input; using namespace Windows::Foundation; -void JoystickWinrt::register_events() { +void JoystickUWP::register_events() { Gamepad::GamepadAdded += - ref new EventHandler<Gamepad^>(this, &JoystickWinrt::OnGamepadAdded); + ref new EventHandler<Gamepad^>(this, &JoystickUWP::OnGamepadAdded); Gamepad::GamepadRemoved += - ref new EventHandler<Gamepad^>(this, &JoystickWinrt::OnGamepadRemoved); + ref new EventHandler<Gamepad^>(this, &JoystickUWP::OnGamepadRemoved); } -uint32_t JoystickWinrt::process_controllers(uint32_t p_last_id) { +uint32_t JoystickUWP::process_controllers(uint32_t p_last_id) { for (int i = 0; i < MAX_CONTROLLERS; i++) { @@ -74,20 +74,20 @@ uint32_t JoystickWinrt::process_controllers(uint32_t p_last_id) { return p_last_id; } -JoystickWinrt::JoystickWinrt() { +JoystickUWP::JoystickUWP() { for (int i = 0; i < MAX_CONTROLLERS; i++) controllers[i].id = i; } -JoystickWinrt::JoystickWinrt(InputDefault * p_input) { +JoystickUWP::JoystickUWP(InputDefault * p_input) { input = p_input; - JoystickWinrt(); + JoystickUWP(); } -void JoystickWinrt::OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) { +void JoystickUWP::OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) { short idx = -1; @@ -106,10 +106,10 @@ void JoystickWinrt::OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::I controllers[idx].id = idx; controllers[idx].type = ControllerType::GAMEPAD_CONTROLLER; - input->joy_connection_changed(controllers[idx].id, true, "Xbox Controller", "__WINRT_GAMEPAD__"); + input->joy_connection_changed(controllers[idx].id, true, "Xbox Controller", "__UWP_GAMEPAD__"); } -void JoystickWinrt::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) { +void JoystickUWP::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) { short idx = -1; @@ -136,7 +136,7 @@ void JoystickWinrt::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming: input->joy_connection_changed(idx, false, "Xbox Controller"); } -InputDefault::JoyAxis JoystickWinrt::axis_correct(double p_val, bool p_negate, bool p_trigger) const { +InputDefault::JoyAxis JoystickUWP::axis_correct(double p_val, bool p_negate, bool p_trigger) const { InputDefault::JoyAxis jx; diff --git a/platform/winrt/joystick_winrt.h b/platform/uwp/joystick_uwp.h index 17f9565708..47ec738a18 100644 --- a/platform/winrt/joystick_winrt.h +++ b/platform/uwp/joystick_uwp.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joystick.h */ +/* joystick_uwp.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,20 +26,20 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef JOYSTICK_WINRT_H -#define JOYSTICK_WINRT_H +#ifndef JOYSTICK_UWP_H +#define JOYSTICK_UWP_H #include "main/input_default.h" -ref class JoystickWinrt sealed { +ref class JoystickUWP sealed { internal: void register_events(); uint32_t process_controllers(uint32_t p_last_id); - JoystickWinrt(); - JoystickWinrt(InputDefault* p_input); + JoystickUWP(); + JoystickUWP(InputDefault* p_input); private: diff --git a/platform/winrt/logo.png b/platform/uwp/logo.png Binary files differindex 4376abd563..4376abd563 100644 --- a/platform/winrt/logo.png +++ b/platform/uwp/logo.png diff --git a/platform/winrt/os_winrt.cpp b/platform/uwp/os_uwp.cpp index 4b23f3960e..fb1dc3be19 100644 --- a/platform/winrt/os_winrt.cpp +++ b/platform/uwp/os_uwp.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* os_winrt.cpp */ +/* os_uwp.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,10 +27,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "drivers/gles2/rasterizer_gles2.h" -#include "os_winrt.h" +#include "os_uwp.h" #include "drivers/unix/memory_pool_static_malloc.h" #include "os/memory_pool_dynamic_static.h" -#include "thread_winrt.h" +#include "thread_uwp.h" #include "drivers/windows/semaphore_windows.h" #include "drivers/windows/mutex_windows.h" #include "main/main.h" @@ -69,28 +69,28 @@ using namespace Windows::ApplicationModel::DataTransfer; using namespace concurrency; -int OSWinrt::get_video_driver_count() const { +int OSUWP::get_video_driver_count() const { return 1; } -const char * OSWinrt::get_video_driver_name(int p_driver) const { +const char * OSUWP::get_video_driver_name(int p_driver) const { return "GLES2"; } -OS::VideoMode OSWinrt::get_default_video_mode() const { +OS::VideoMode OSUWP::get_default_video_mode() const { return video_mode; } -Size2 OSWinrt::get_window_size() const { +Size2 OSUWP::get_window_size() const { Size2 size; size.width = video_mode.width; size.height = video_mode.height; return size; } -void OSWinrt::set_window_size(const Size2 p_size) { +void OSUWP::set_window_size(const Size2 p_size) { Windows::Foundation::Size new_size; new_size.Width = p_size.width; @@ -105,7 +105,7 @@ void OSWinrt::set_window_size(const Size2 p_size) { } } -void OSWinrt::set_window_fullscreen(bool p_enabled) { +void OSUWP::set_window_fullscreen(bool p_enabled) { ApplicationView^ view = ApplicationView::GetForCurrentView(); @@ -126,12 +126,12 @@ void OSWinrt::set_window_fullscreen(bool p_enabled) { } } -bool OSWinrt::is_window_fullscreen() const { +bool OSUWP::is_window_fullscreen() const { return ApplicationView::GetForCurrentView()->IsFullScreenMode; } -void OSWinrt::set_keep_screen_on(bool p_enabled) { +void OSUWP::set_keep_screen_on(bool p_enabled) { if (is_keep_screen_on() == p_enabled) return; @@ -143,11 +143,11 @@ void OSWinrt::set_keep_screen_on(bool p_enabled) { OS::set_keep_screen_on(p_enabled); } -int OSWinrt::get_audio_driver_count() const { +int OSUWP::get_audio_driver_count() const { return AudioDriverManagerSW::get_driver_count(); } -const char * OSWinrt::get_audio_driver_name(int p_driver) const { +const char * OSUWP::get_audio_driver_name(int p_driver) const { AudioDriverSW* driver = AudioDriverManagerSW::get_driver(p_driver); ERR_FAIL_COND_V( !driver, "" ); @@ -157,14 +157,14 @@ const char * OSWinrt::get_audio_driver_name(int p_driver) const { static MemoryPoolStatic *mempool_static=NULL; static MemoryPoolDynamic *mempool_dynamic=NULL; -void OSWinrt::initialize_core() { +void OSUWP::initialize_core() { last_button_state=0; //RedirectIOToConsole(); - ThreadWinrt::make_default(); + ThreadUWP::make_default(); SemaphoreWindows::make_default(); MutexWindows::make_default(); @@ -206,23 +206,23 @@ void OSWinrt::initialize_core() { cursor_shape=CURSOR_ARROW; } -bool OSWinrt::can_draw() const { +bool OSUWP::can_draw() const { return !minimized; }; -void OSWinrt::set_gl_context(ContextEGL* p_context) { +void OSUWP::set_gl_context(ContextEGL* p_context) { gl_context = p_context; }; -void OSWinrt::screen_size_changed() { +void OSUWP::screen_size_changed() { gl_context->reset(); }; -void OSWinrt::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) { +void OSUWP::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) { main_loop=NULL; outside=true; @@ -285,7 +285,7 @@ void OSWinrt::initialize(const VideoMode& p_desired,int p_video_driver,int p_aud input = memnew( InputDefault ); - joystick = ref new JoystickWinrt(input); + joystick = ref new JoystickUWP(input); joystick->register_events(); AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); @@ -345,7 +345,7 @@ void OSWinrt::initialize(const VideoMode& p_desired,int p_video_driver,int p_aud } -void OSWinrt::set_clipboard(const String& p_text) { +void OSUWP::set_clipboard(const String& p_text) { DataPackage^ clip = ref new DataPackage(); clip->RequestedOperation = DataPackageOperation::Copy; @@ -354,7 +354,7 @@ void OSWinrt::set_clipboard(const String& p_text) { Clipboard::SetContent(clip); }; -String OSWinrt::get_clipboard() const { +String OSUWP::get_clipboard() const { if (managed_object->clipboard != nullptr) return managed_object->clipboard->Data(); @@ -363,7 +363,7 @@ String OSWinrt::get_clipboard() const { }; -void OSWinrt::input_event(InputEvent &p_event) { +void OSUWP::input_event(InputEvent &p_event) { p_event.ID = ++last_id; @@ -378,20 +378,20 @@ void OSWinrt::input_event(InputEvent &p_event) { } }; -void OSWinrt::delete_main_loop() { +void OSUWP::delete_main_loop() { if (main_loop) memdelete(main_loop); main_loop=NULL; } -void OSWinrt::set_main_loop( MainLoop * p_main_loop ) { +void OSUWP::set_main_loop( MainLoop * p_main_loop ) { input->set_main_loop(p_main_loop); main_loop=p_main_loop; } -void OSWinrt::finalize() { +void OSUWP::finalize() { if(main_loop) memdelete(main_loop); @@ -432,7 +432,7 @@ void OSWinrt::finalize() { joystick = nullptr; } -void OSWinrt::finalize_core() { +void OSUWP::finalize_core() { if (mempool_dynamic) memdelete( mempool_dynamic ); @@ -440,7 +440,7 @@ void OSWinrt::finalize_core() { } -void OSWinrt::vprint(const char* p_format, va_list p_list, bool p_stderr) { +void OSUWP::vprint(const char* p_format, va_list p_list, bool p_stderr) { char buf[16384+1]; int len = vsnprintf(buf,16384,p_format,p_list); @@ -467,14 +467,14 @@ void OSWinrt::vprint(const char* p_format, va_list p_list, bool p_stderr) { fflush(stdout); }; -void OSWinrt::alert(const String& p_alert,const String& p_title) { +void OSUWP::alert(const String& p_alert,const String& p_title) { Platform::String^ alert = ref new Platform::String(p_alert.c_str()); Platform::String^ title = ref new Platform::String(p_title.c_str()); MessageDialog^ msg = ref new MessageDialog(alert, title); - UICommand^ close = ref new UICommand("Close", ref new UICommandInvokedHandler(managed_object, &OSWinrt::ManagedType::alert_close)); + UICommand^ close = ref new UICommand("Close", ref new UICommandInvokedHandler(managed_object, &OSUWP::ManagedType::alert_close)); msg->Commands->Append(close); msg->DefaultCommandIndex = 0; @@ -483,17 +483,17 @@ void OSWinrt::alert(const String& p_alert,const String& p_title) { msg->ShowAsync(); } -void OSWinrt::ManagedType::alert_close(IUICommand^ command) { +void OSUWP::ManagedType::alert_close(IUICommand^ command) { alert_close_handle = false; } -void OSWinrt::ManagedType::on_clipboard_changed(Platform::Object ^ sender, Platform::Object ^ ev) { +void OSUWP::ManagedType::on_clipboard_changed(Platform::Object ^ sender, Platform::Object ^ ev) { update_clipboard(); } -void OSWinrt::ManagedType::update_clipboard() { +void OSUWP::ManagedType::update_clipboard() { DataPackageView^ data = Clipboard::GetContent(); @@ -507,7 +507,7 @@ void OSWinrt::ManagedType::update_clipboard() { } } -void OSWinrt::ManagedType::on_accelerometer_reading_changed(Accelerometer ^ sender, AccelerometerReadingChangedEventArgs ^ args) { +void OSUWP::ManagedType::on_accelerometer_reading_changed(Accelerometer ^ sender, AccelerometerReadingChangedEventArgs ^ args) { AccelerometerReading^ reading = args->Reading; @@ -518,7 +518,7 @@ void OSWinrt::ManagedType::on_accelerometer_reading_changed(Accelerometer ^ send )); } -void OSWinrt::ManagedType::on_magnetometer_reading_changed(Magnetometer ^ sender, MagnetometerReadingChangedEventArgs ^ args) { +void OSUWP::ManagedType::on_magnetometer_reading_changed(Magnetometer ^ sender, MagnetometerReadingChangedEventArgs ^ args) { MagnetometerReading^ reading = args->Reading; @@ -529,7 +529,7 @@ void OSWinrt::ManagedType::on_magnetometer_reading_changed(Magnetometer ^ sender )); } -void OSWinrt::ManagedType::on_gyroscope_reading_changed(Gyrometer ^ sender, GyrometerReadingChangedEventArgs ^ args) { +void OSUWP::ManagedType::on_gyroscope_reading_changed(Gyrometer ^ sender, GyrometerReadingChangedEventArgs ^ args) { GyrometerReading^ reading = args->Reading; @@ -540,7 +540,7 @@ void OSWinrt::ManagedType::on_gyroscope_reading_changed(Gyrometer ^ sender, Gyro )); } -void OSWinrt::set_mouse_mode(MouseMode p_mode) { +void OSUWP::set_mouse_mode(MouseMode p_mode) { if (p_mode == MouseMode::MOUSE_MODE_CAPTURED) { @@ -566,41 +566,41 @@ void OSWinrt::set_mouse_mode(MouseMode p_mode) { SetEvent(mouse_mode_changed); } -OSWinrt::MouseMode OSWinrt::get_mouse_mode() const{ +OSUWP::MouseMode OSUWP::get_mouse_mode() const{ return mouse_mode; } -Point2 OSWinrt::get_mouse_pos() const { +Point2 OSUWP::get_mouse_pos() const { return Point2(old_x, old_y); } -int OSWinrt::get_mouse_button_state() const { +int OSUWP::get_mouse_button_state() const { return last_button_state; } -void OSWinrt::set_window_title(const String& p_title) { +void OSUWP::set_window_title(const String& p_title) { } -void OSWinrt::set_video_mode(const VideoMode& p_video_mode,int p_screen) { +void OSUWP::set_video_mode(const VideoMode& p_video_mode,int p_screen) { video_mode = p_video_mode; } -OS::VideoMode OSWinrt::get_video_mode(int p_screen) const { +OS::VideoMode OSUWP::get_video_mode(int p_screen) const { return video_mode; } -void OSWinrt::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const { +void OSUWP::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const { } -void OSWinrt::print_error(const char* p_function, const char* p_file, int p_line, const char* p_code, const char* p_rationale, ErrorType p_type) { +void OSUWP::print_error(const char* p_function, const char* p_file, int p_line, const char* p_code, const char* p_rationale, ErrorType p_type) { const char* err_details; if (p_rationale && p_rationale[0]) @@ -625,12 +625,12 @@ void OSWinrt::print_error(const char* p_function, const char* p_file, int p_line } -String OSWinrt::get_name() { +String OSUWP::get_name() { - return "WinRT"; + return "UWP"; } -OS::Date OSWinrt::get_date(bool utc) const { +OS::Date OSUWP::get_date(bool utc) const { SYSTEMTIME systemtime; if (utc) @@ -646,7 +646,7 @@ OS::Date OSWinrt::get_date(bool utc) const { date.dst=false; return date; } -OS::Time OSWinrt::get_time(bool utc) const { +OS::Time OSUWP::get_time(bool utc) const { SYSTEMTIME systemtime; if (utc) @@ -661,7 +661,7 @@ OS::Time OSWinrt::get_time(bool utc) const { return time; } -OS::TimeZoneInfo OSWinrt::get_time_zone_info() const { +OS::TimeZoneInfo OSUWP::get_time_zone_info() const { TIME_ZONE_INFORMATION info; bool daylight = false; if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) @@ -678,7 +678,7 @@ OS::TimeZoneInfo OSWinrt::get_time_zone_info() const { return ret; } -uint64_t OSWinrt::get_unix_time() const { +uint64_t OSUWP::get_unix_time() const { FILETIME ft; SYSTEMTIME st; @@ -700,7 +700,7 @@ uint64_t OSWinrt::get_unix_time() const { return (*(uint64_t*)&ft - *(uint64_t*)&fep) / 10000000; }; -void OSWinrt::delay_usec(uint32_t p_usec) const { +void OSUWP::delay_usec(uint32_t p_usec) const { int msec = p_usec < 1000 ? 1 : p_usec / 1000; @@ -708,7 +708,7 @@ void OSWinrt::delay_usec(uint32_t p_usec) const { WaitForSingleObjectEx(GetCurrentThread(), msec, false); } -uint64_t OSWinrt::get_ticks_usec() const { +uint64_t OSUWP::get_ticks_usec() const { uint64_t ticks; uint64_t time; @@ -723,13 +723,13 @@ uint64_t OSWinrt::get_ticks_usec() const { } -void OSWinrt::process_events() { +void OSUWP::process_events() { last_id = joystick->process_controllers(last_id); process_key_events(); } -void OSWinrt::process_key_events() +void OSUWP::process_key_events() { for (int i = 0; i < key_event_pos; i++) { @@ -750,7 +750,7 @@ void OSWinrt::process_key_events() key_event_pos = 0; } -void OSWinrt::queue_key_event(KeyEvent & p_event) +void OSUWP::queue_key_event(KeyEvent & p_event) { // This merges Char events with the previous Key event, so // the unicode can be retrieved without sending duplicate events. @@ -768,7 +768,7 @@ void OSWinrt::queue_key_event(KeyEvent & p_event) key_event_buffer[key_event_pos++] = p_event; } -void OSWinrt::set_cursor_shape(CursorShape p_shape) { +void OSUWP::set_cursor_shape(CursorShape p_shape) { ERR_FAIL_INDEX(p_shape, CURSOR_MAX); @@ -800,58 +800,58 @@ void OSWinrt::set_cursor_shape(CursorShape p_shape) { cursor_shape = p_shape; } -Error OSWinrt::execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id,String* r_pipe,int *r_exitcode) { +Error OSUWP::execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id,String* r_pipe,int *r_exitcode) { return FAILED; }; -Error OSWinrt::kill(const ProcessID& p_pid) { +Error OSUWP::kill(const ProcessID& p_pid) { return FAILED; }; -Error OSWinrt::set_cwd(const String& p_cwd) { +Error OSUWP::set_cwd(const String& p_cwd) { return FAILED; } -String OSWinrt::get_executable_path() const { +String OSUWP::get_executable_path() const { return ""; } -void OSWinrt::set_icon(const Image& p_icon) { +void OSUWP::set_icon(const Image& p_icon) { } -bool OSWinrt::has_environment(const String& p_var) const { +bool OSUWP::has_environment(const String& p_var) const { return false; }; -String OSWinrt::get_environment(const String& p_var) const { +String OSUWP::get_environment(const String& p_var) const { return ""; }; -String OSWinrt::get_stdin_string(bool p_block) { +String OSUWP::get_stdin_string(bool p_block) { return String(); } -void OSWinrt::move_window_to_foreground() { +void OSUWP::move_window_to_foreground() { } -Error OSWinrt::shell_open(String p_uri) { +Error OSUWP::shell_open(String p_uri) { return FAILED; } -String OSWinrt::get_locale() const { +String OSUWP::get_locale() const { #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP // this should work on phone 8.1, but it doesn't return "en"; @@ -861,46 +861,46 @@ String OSWinrt::get_locale() const { #endif } -void OSWinrt::release_rendering_thread() { +void OSUWP::release_rendering_thread() { gl_context->release_current(); } -void OSWinrt::make_rendering_thread() { +void OSUWP::make_rendering_thread() { gl_context->make_current(); } -void OSWinrt::swap_buffers() { +void OSUWP::swap_buffers() { gl_context->swap_buffers(); } -bool OSWinrt::has_touchscreen_ui_hint() const { +bool OSUWP::has_touchscreen_ui_hint() const { TouchCapabilities^ tc = ref new TouchCapabilities(); return tc->TouchPresent != 0 || UIViewSettings::GetForCurrentView()->UserInteractionMode == UserInteractionMode::Touch; } -bool OSWinrt::has_virtual_keyboard() const { +bool OSUWP::has_virtual_keyboard() const { return UIViewSettings::GetForCurrentView()->UserInteractionMode == UserInteractionMode::Touch; } -void OSWinrt::show_virtual_keyboard(const String & p_existing_text, const Rect2 & p_screen_rect) { +void OSUWP::show_virtual_keyboard(const String & p_existing_text, const Rect2 & p_screen_rect) { InputPane^ pane = InputPane::GetForCurrentView(); pane->TryShow(); } -void OSWinrt::hide_virtual_keyboard() { +void OSUWP::hide_virtual_keyboard() { InputPane^ pane = InputPane::GetForCurrentView(); pane->TryHide(); } -void OSWinrt::run() { +void OSUWP::run() { if (!main_loop) return; @@ -927,13 +927,13 @@ void OSWinrt::run() { -MainLoop *OSWinrt::get_main_loop() const { +MainLoop *OSUWP::get_main_loop() const { return main_loop; } -String OSWinrt::get_data_dir() const { +String OSUWP::get_data_dir() const { Windows::Storage::StorageFolder ^data_folder = Windows::Storage::ApplicationData::Current->LocalFolder; @@ -941,7 +941,7 @@ String OSWinrt::get_data_dir() const { } -OSWinrt::OSWinrt() { +OSUWP::OSUWP() { key_event_pos=0; force_quit=false; @@ -973,7 +973,7 @@ OSWinrt::OSWinrt() { } -OSWinrt::~OSWinrt() +OSUWP::~OSUWP() { #ifdef STDOUT_FILE fclose(stdo); diff --git a/platform/winrt/os_winrt.h b/platform/uwp/os_uwp.h index a4667f213d..47eb095e11 100644 --- a/platform/winrt/os_winrt.h +++ b/platform/uwp/os_uwp.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* os_winrt.h */ +/* os_uwp.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef OSWinrt_H -#define OSWinrt_H +#ifndef OSUWP_H +#define OSUWP_H #include "os/input.h" #include "os/os.h" @@ -55,12 +55,12 @@ #include <stdio.h> #include "main/input_default.h" -#include "joystick_winrt.h" +#include "joystick_uwp.h" /** @author Juan Linietsky <reduzio@gmail.com> */ -class OSWinrt : public OS { +class OSUWP : public OS { public: @@ -137,7 +137,7 @@ private: InputDefault *input; - JoystickWinrt^ joystick; + JoystickUWP^ joystick; Windows::System::Display::DisplayRequest^ display_request; @@ -159,7 +159,7 @@ private: internal: ManagedType() { alert_close_handle = false; } - property OSWinrt* os; + property OSUWP* os; }; ManagedType^ managed_object; Windows::Devices::Sensors::Accelerometer^ accelerometer; @@ -273,8 +273,8 @@ public: void queue_key_event(KeyEvent &p_event); - OSWinrt(); - ~OSWinrt(); + OSUWP(); + ~OSUWP(); }; diff --git a/platform/winrt/platform_config.h b/platform/uwp/platform_config.h index 88b1fefed8..88b1fefed8 100644 --- a/platform/winrt/platform_config.h +++ b/platform/uwp/platform_config.h diff --git a/platform/winrt/thread_winrt.cpp b/platform/uwp/thread_uwp.cpp index 8e3e0d5bef..a5a0920df6 100644 --- a/platform/winrt/thread_winrt.cpp +++ b/platform/uwp/thread_uwp.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* thread_winrt.cpp */ +/* thread_uwp.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,13 +26,13 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "thread_winrt.h" +#include "thread_uwp.h" #include "os/memory.h" -Thread* ThreadWinrt::create_func_winrt(ThreadCreateCallback p_callback,void *p_user,const Settings&) { +Thread* ThreadUWP::create_func_uwp(ThreadCreateCallback p_callback,void *p_user,const Settings&) { - ThreadWinrt* thread = memnew(ThreadWinrt); + ThreadUWP* thread = memnew(ThreadUWP); std::thread new_thread(p_callback, p_user); @@ -41,34 +41,34 @@ Thread* ThreadWinrt::create_func_winrt(ThreadCreateCallback p_callback,void *p_u return thread; }; -Thread::ID ThreadWinrt::get_thread_ID_func_winrt() { +Thread::ID ThreadUWP::get_thread_ID_func_uwp() { return std::hash<std::thread::id>()(std::this_thread::get_id()); }; -void ThreadWinrt::wait_to_finish_func_winrt(Thread* p_thread) { +void ThreadUWP::wait_to_finish_func_uwp(Thread* p_thread) { - ThreadWinrt *tp=static_cast<ThreadWinrt*>(p_thread); + ThreadUWP *tp=static_cast<ThreadUWP*>(p_thread); tp->thread.join(); }; -Thread::ID ThreadWinrt::get_ID() const { +Thread::ID ThreadUWP::get_ID() const { return std::hash<std::thread::id>()(thread.get_id()); }; -void ThreadWinrt::make_default() { - create_func = create_func_winrt; - get_thread_ID_func = get_thread_ID_func_winrt; - wait_to_finish_func = wait_to_finish_func_winrt; +void ThreadUWP::make_default() { + create_func = create_func_uwp; + get_thread_ID_func = get_thread_ID_func_uwp; + wait_to_finish_func = wait_to_finish_func_uwp; }; -ThreadWinrt::ThreadWinrt() { +ThreadUWP::ThreadUWP() { }; -ThreadWinrt::~ThreadWinrt() { +ThreadUWP::~ThreadUWP() { }; diff --git a/platform/winrt/thread_winrt.h b/platform/uwp/thread_uwp.h index df275d560a..95b9aeb62b 100644 --- a/platform/winrt/thread_winrt.h +++ b/platform/uwp/thread_uwp.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* thread_winrt.h */ +/* thread_uwp.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,24 +26,24 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef THREAD_WINRT_H -#define THREAD_WINRT_H +#ifndef THREAD_UWP_H +#define THREAD_UWP_H -#ifdef WINRT_ENABLED +#ifdef UWP_ENABLED #include "os/thread.h" #include <thread> -class ThreadWinrt : public Thread { +class ThreadUWP : public Thread { std::thread thread; - static Thread* create_func_winrt(ThreadCreateCallback p_callback,void *,const Settings&); - static ID get_thread_ID_func_winrt(); - static void wait_to_finish_func_winrt(Thread* p_thread); + static Thread* create_func_uwp(ThreadCreateCallback p_callback,void *,const Settings&); + static ID get_thread_ID_func_uwp(); + static void wait_to_finish_func_uwp(Thread* p_thread); - ThreadWinrt(); + ThreadUWP(); public: @@ -52,7 +52,7 @@ public: static void make_default(); - ~ThreadWinrt(); + ~ThreadUWP(); }; diff --git a/platform/windows/SCsub b/platform/windows/SCsub index e53eb7af34..32c23b906a 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -3,27 +3,27 @@ Import('env') -common_win=[ - "context_gl_win.cpp", - "os_windows.cpp", - "ctxgl_procaddr.cpp", - "key_mapping_win.cpp", - "tcp_server_winsock.cpp", - "packet_peer_udp_winsock.cpp", - "stream_peer_winsock.cpp", - "joystick.cpp", +common_win = [ + "context_gl_win.cpp", + "os_windows.cpp", + "ctxgl_procaddr.cpp", + "key_mapping_win.cpp", + "tcp_server_winsock.cpp", + "packet_peer_udp_winsock.cpp", + "stream_peer_winsock.cpp", + "joystick.cpp", ] -restarget="godot_res"+env["OBJSUFFIX"] +restarget = "godot_res" + env["OBJSUFFIX"] -obj = env.RES(restarget,'godot_res.rc') +obj = env.RES(restarget, 'godot_res.rc') common_win.append(obj) -env.Program('#bin/godot',['godot_win.cpp']+common_win,PROGSUFFIX=env["PROGSUFFIX"]) +env.Program('#bin/godot', ['godot_win.cpp'] + common_win, PROGSUFFIX=env["PROGSUFFIX"]) # Microsoft Visual Studio Project Generation -if (env['vsproj'])=="yes": - 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)] +if (env['vsproj']) == "yes": + 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/windows/detect.py b/platform/windows/detect.py index 7ae0100762..df5bc49aa4 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -85,7 +85,7 @@ ##### # TODO : -# +# # - finish to cleanup this script to remove all the remains of previous hacks and workarounds # - make it work with the Windows7 SDK that is supposed to enable 64bits compilation for MSVC2010-Express # - confirm it works well with other Visual Studio versions. @@ -99,300 +99,295 @@ import sys import methods -def is_active(): - return True - -def get_name(): - return "Windows" - -def can_build(): - - if (os.name=="nt"): - #building natively on windows! - if ( os.getenv("VCINSTALLDIR") ): - return True - else: - print("\nMSVC not detected, attempting Mingw.") - mingw32 = "" - mingw64 = "" - if ( os.getenv("MINGW32_PREFIX") ) : - mingw32 = os.getenv("MINGW32_PREFIX") - if ( os.getenv("MINGW64_PREFIX") ) : - mingw64 = os.getenv("MINGW64_PREFIX") - - test = "gcc --version > NUL 2>&1" - if os.system(test)!= 0 and os.system(mingw32+test)!=0 and os.system(mingw64+test)!=0 : - print("- could not detect gcc.") - print("Please, make sure a path to a Mingw /bin directory is accessible into the environment PATH.\n") - return False - else: - print("- gcc detected.") - - return True - - if (os.name=="posix"): - - mingw = "i586-mingw32msvc-" - mingw64 = "x86_64-w64-mingw32-" - mingw32 = "i686-w64-mingw32-" - - if (os.getenv("MINGW32_PREFIX")): - mingw32=os.getenv("MINGW32_PREFIX") - mingw = mingw32 - if (os.getenv("MINGW64_PREFIX")): - mingw64=os.getenv("MINGW64_PREFIX") - - test = "gcc --version &>/dev/null" - if (os.system(mingw+test) == 0 or os.system(mingw64+test) == 0 or os.system(mingw32+test) == 0): - return True - - return False - -def get_opts(): - - mingw="" - mingw32="" - mingw64="" - if ( os.name == "posix" ): - mingw = "i586-mingw32msvc-" - mingw32 = "i686-w64-mingw32-" - mingw64 = "x86_64-w64-mingw32-" - - if os.system(mingw32+"gcc --version &>/dev/null") != 0 : - mingw32 = mingw - - if (os.getenv("MINGW32_PREFIX")): - mingw32=os.getenv("MINGW32_PREFIX") - mingw = mingw32 - if (os.getenv("MINGW64_PREFIX")): - mingw64=os.getenv("MINGW64_PREFIX") - - - return [ - ('mingw_prefix','Mingw Prefix',mingw32), - ('mingw_prefix_64','Mingw Prefix 64 bits',mingw64), - ] - -def get_flags(): - - return [ - ('builtin_zlib', 'yes'), - ('openssl','builtin'), #use builtin openssl - ] - -def build_res_file( target, source, env ): - - cmdbase = "" - if (env["bits"] == "32"): - cmdbase = env['mingw_prefix'] - else: - cmdbase = env['mingw_prefix_64'] - CPPPATH = env['CPPPATH'] - cmdbase = cmdbase + 'windres --include-dir . ' - import subprocess - for x in range(len(source)): - cmd = cmdbase + '-i ' + str(source[x]) + ' -o ' + str(target[x]) - try: - out = subprocess.Popen(cmd,shell = True,stderr = subprocess.PIPE).communicate() - if len(out[1]): - return 1 - except: - return 1 - return 0 - -def configure(env): - - env.Append(CPPPATH=['#platform/windows']) - env['is_mingw']=False - if (os.name=="nt" and os.getenv("VCINSTALLDIR") ): - #build using visual studio - env['ENV']['TMP'] = os.environ['TMP'] - env.Append(CPPPATH=['#platform/windows/include']) - env.Append(LIBPATH=['#platform/windows/lib']) - - - if (env["target"]=="release"): - - env.Append(CCFLAGS=['/O2']) - env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS']) - env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup']) - - elif (env["target"]=="release_debug"): - - env.Append(CCFLAGS=['/O2','/DDEBUG_ENABLED']) - env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) - elif (env["target"]=="debug_release"): - - env.Append(CCFLAGS=['/Z7','/Od']) - env.Append(LINKFLAGS=['/DEBUG']) - env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS']) - env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup']) - - elif (env["target"]=="debug"): - - env.Append(CCFLAGS=['/Z7','/DDEBUG_ENABLED','/DDEBUG_MEMORY_ENABLED','/DD3D_DEBUG_INFO','/Od']) - env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) - env.Append(LINKFLAGS=['/DEBUG']) - - - env.Append(CCFLAGS=['/MT','/Gd','/GR','/nologo']) - env.Append(CXXFLAGS=['/TP']) - env.Append(CPPFLAGS=['/DMSVC', '/GR', ]) - env.Append(CCFLAGS=['/I'+os.getenv("WindowsSdkDir")+"/Include"]) - env.Append(CCFLAGS=['/DWINDOWS_ENABLED']) - env.Append(CCFLAGS=['/DRTAUDIO_ENABLED']) - env.Append(CCFLAGS=['/DWIN32']) - env.Append(CCFLAGS=['/DTYPED_METHOD_BIND']) - - env.Append(CCFLAGS=['/DGLES2_ENABLED']) - LIBS=['winmm','opengl32','dsound','kernel32','ole32','oleaut32','user32','gdi32', 'IPHLPAPI','Shlwapi', 'wsock32','Ws2_32', 'shell32','advapi32','dinput8','dxguid'] - env.Append(LINKFLAGS=[p+env["LIBSUFFIX"] for p in LIBS]) - - env.Append(LIBPATH=[os.getenv("WindowsSdkDir")+"/Lib"]) - if (os.getenv("DXSDK_DIR")): - DIRECTX_PATH=os.getenv("DXSDK_DIR") - else: - DIRECTX_PATH="C:/Program Files/Microsoft DirectX SDK (March 2009)" - - if (os.getenv("VCINSTALLDIR")): - VC_PATH=os.getenv("VCINSTALLDIR") - else: - VC_PATH="" - - env.Append(CCFLAGS=["/I" + p for p in os.getenv("INCLUDE").split(";")]) - env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")]) - env.Append(CCFLAGS=["/I"+DIRECTX_PATH+"/Include"]) - env.Append(LIBPATH=[DIRECTX_PATH+"/Lib/x86"]) - env['ENV'] = os.environ; - - # This detection function needs the tools env (that is env['ENV'], not SCons's env), and that is why it's this far bellow in the code - compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV']) - - # Note: this detection/override code from here onward should be here instead of in SConstruct because it's platform and compiler specific (MSVC/Windows) - if(env["bits"] != "default"): - print "Error: bits argument is disabled for MSVC" - print ("Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings)" - +" that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=windows) and SCons will attempt to detect what MSVC compiler" - +" will be executed and inform you.") - sys.exit() - - # Forcing bits argument because MSVC does not have a flag to set this through SCons... it's different compilers (cl.exe's) called from the propper command prompt - # that decide the architecture that is build for. Scons can only detect the os.getenviron (because vsvarsall.bat sets a lot of stuff for cl.exe to work with) - env["bits"]="32" - env["x86_libtheora_opt_vc"]=True - - print "Detected MSVC compiler: "+compiler_version_str - # If building for 64bit architecture, disable assembly optimisations for 32 bit builds (theora as of writting)... vc compiler for 64bit can not compile _asm - if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"): - env["bits"]="64" - env["x86_libtheora_opt_vc"]=False - print "Compiled program architecture will be a 64 bit executable (forcing bits=64)." - elif (compiler_version_str=="x86" or compiler_version_str == "amd64_x86"): - print "Compiled program architecture will be a 32 bit executable. (forcing bits=32)." - else: - print "Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup." - if env["bits"]=="64": - env.Append(CCFLAGS=['/D_WIN64']) - - # Incremental linking fix - env['BUILDERS']['ProgramOriginal'] = env['BUILDERS']['Program'] - env['BUILDERS']['Program'] = methods.precious_program - else: - - # Workaround for MinGW. See: - # http://www.scons.org/wiki/LongCmdLinesOnWin32 - env.use_windows_spawn_fix() - - #build using mingw - if (os.name=="nt"): - env['ENV']['TMP'] = os.environ['TMP'] #way to go scons, you can be so stupid sometimes - else: - env["PROGSUFFIX"]=env["PROGSUFFIX"]+".exe" # for linux cross-compilation - - mingw_prefix="" +def is_active(): + return True - if (env["bits"]=="default"): - env["bits"]="32" - if (env["bits"]=="32"): - env.Append(LINKFLAGS=['-static']) - env.Append(LINKFLAGS=['-static-libgcc']) - env.Append(LINKFLAGS=['-static-libstdc++']) - mingw_prefix=env["mingw_prefix"]; - else: - env.Append(LINKFLAGS=['-static']) - mingw_prefix=env["mingw_prefix_64"]; +def get_name(): + return "Windows" - nulstr="" - if (os.name=="posix"): - nulstr=">/dev/null" - else: - nulstr=">nul" +def can_build(): + if (os.name == "nt"): + # building natively on windows! + if (os.getenv("VCINSTALLDIR")): + return True + else: + print("\nMSVC not detected, attempting Mingw.") + mingw32 = "" + mingw64 = "" + if (os.getenv("MINGW32_PREFIX")): + mingw32 = os.getenv("MINGW32_PREFIX") + if (os.getenv("MINGW64_PREFIX")): + mingw64 = os.getenv("MINGW64_PREFIX") + test = "gcc --version > NUL 2>&1" + if os.system(test) != 0 and os.system(mingw32 + test) != 0 and os.system(mingw64 + test) != 0: + print("- could not detect gcc.") + print("Please, make sure a path to a Mingw /bin directory is accessible into the environment PATH.\n") + return False + else: + print("- gcc detected.") - # if os.system(mingw_prefix+"gcc --version"+nulstr)!=0: - # #not really super consistent but.. - # print("Can't find Windows compiler: "+mingw_prefix) - # sys.exit(255) + return True - if (env["target"]=="release"): + if (os.name == "posix"): - env.Append(CCFLAGS=['-msse2']) + mingw = "i586-mingw32msvc-" + mingw64 = "x86_64-w64-mingw32-" + mingw32 = "i686-w64-mingw32-" - if (env["bits"]=="64"): - env.Append(CCFLAGS=['-O3']) - else: - env.Append(CCFLAGS=['-O2']) + if (os.getenv("MINGW32_PREFIX")): + mingw32 = os.getenv("MINGW32_PREFIX") + mingw = mingw32 + if (os.getenv("MINGW64_PREFIX")): + mingw64 = os.getenv("MINGW64_PREFIX") - env.Append(LINKFLAGS=['-Wl,--subsystem,windows']) + test = "gcc --version &>/dev/null" + if (os.system(mingw + test) == 0 or os.system(mingw64 + test) == 0 or os.system(mingw32 + test) == 0): + return True - elif (env["target"]=="release_debug"): + return False - env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED']) - elif (env["target"]=="debug"): +def get_opts(): - env.Append(CCFLAGS=['-g', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + mingw = "" + mingw32 = "" + mingw64 = "" + if (os.name == "posix"): + mingw = "i586-mingw32msvc-" + mingw32 = "i686-w64-mingw32-" + mingw64 = "x86_64-w64-mingw32-" + if os.system(mingw32 + "gcc --version &>/dev/null") != 0: + mingw32 = mingw + if (os.getenv("MINGW32_PREFIX")): + mingw32 = os.getenv("MINGW32_PREFIX") + mingw = mingw32 + if (os.getenv("MINGW64_PREFIX")): + mingw64 = os.getenv("MINGW64_PREFIX") - env["CC"]=mingw_prefix+"gcc" - env['AS']=mingw_prefix+"as" - env['CXX'] = mingw_prefix+"g++" - env['AR'] = mingw_prefix+"ar" - env['RANLIB'] = mingw_prefix+"ranlib" - env['LD'] = mingw_prefix+"g++" - env["x86_libtheora_opt_gcc"]=True + return [ + ('mingw_prefix', 'Mingw Prefix', mingw32), + ('mingw_prefix_64', 'Mingw Prefix 64 bits', mingw64), + ] - #env['CC'] = "winegcc" - #env['CXX'] = "wineg++" - env.Append(CCFLAGS=['-DWINDOWS_ENABLED','-mwindows']) - env.Append(CPPFLAGS=['-DRTAUDIO_ENABLED']) - env.Append(CCFLAGS=['-DGLES2_ENABLED']) - env.Append(LIBS=['mingw32','opengl32', 'dsound', 'ole32', 'd3d9','winmm','gdi32','iphlpapi','shlwapi','wsock32','ws2_32','kernel32', 'oleaut32', 'dinput8', 'dxguid']) +def get_flags(): - # if (env["bits"]=="32"): - # env.Append(LIBS=['gcc_s']) - # #--with-arch=i686 - # env.Append(CPPFLAGS=['-march=i686']) - # env.Append(LINKFLAGS=['-march=i686']) + return [ + ] +def build_res_file(target, source, env): + cmdbase = "" + if (env["bits"] == "32"): + cmdbase = env['mingw_prefix'] + else: + cmdbase = env['mingw_prefix_64'] + CPPPATH = env['CPPPATH'] + cmdbase = cmdbase + 'windres --include-dir . ' + import subprocess + for x in range(len(source)): + cmd = cmdbase + '-i ' + str(source[x]) + ' -o ' + str(target[x]) + try: + out = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE).communicate() + if len(out[1]): + return 1 + except: + return 1 + return 0 - #'d3dx9d' - env.Append(CPPFLAGS=['-DMINGW_ENABLED']) - #env.Append(LINKFLAGS=['-g']) - # resrc - env['is_mingw']=True - env.Append( BUILDERS = { 'RES' : env.Builder(action = build_res_file, suffix = '.o',src_suffix = '.rc') } ) +def configure(env): - env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } ) - env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) + env.Append(CPPPATH=['#platform/windows']) + env['is_mingw'] = False + if (os.name == "nt" and os.getenv("VCINSTALLDIR")): + # build using visual studio + env['ENV']['TMP'] = os.environ['TMP'] + env.Append(CPPPATH=['#platform/windows/include']) + env.Append(LIBPATH=['#platform/windows/lib']) + + if (env["target"] == "release"): + + env.Append(CCFLAGS=['/O2']) + env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS']) + env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup']) + + elif (env["target"] == "release_debug"): + + env.Append(CCFLAGS=['/O2', '/DDEBUG_ENABLED']) + env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) + elif (env["target"] == "debug_release"): + + env.Append(CCFLAGS=['/Z7', '/Od']) + env.Append(LINKFLAGS=['/DEBUG']) + env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS']) + env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup']) + + elif (env["target"] == "debug"): + + env.Append(CCFLAGS=['/Z7', '/DDEBUG_ENABLED', '/DDEBUG_MEMORY_ENABLED', '/DD3D_DEBUG_INFO', '/Od']) + env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) + env.Append(LINKFLAGS=['/DEBUG']) + + env.Append(CCFLAGS=['/MT', '/Gd', '/GR', '/nologo']) + env.Append(CXXFLAGS=['/TP']) + env.Append(CPPFLAGS=['/DMSVC', '/GR', ]) + env.Append(CCFLAGS=['/I' + os.getenv("WindowsSdkDir") + "/Include"]) + env.Append(CCFLAGS=['/DWINDOWS_ENABLED']) + env.Append(CCFLAGS=['/DRTAUDIO_ENABLED']) + env.Append(CCFLAGS=['/DWIN32']) + env.Append(CCFLAGS=['/DTYPED_METHOD_BIND']) + + env.Append(CCFLAGS=['/DGLES2_ENABLED']) + LIBS = ['winmm', 'opengl32', 'dsound', 'kernel32', 'ole32', 'oleaut32', 'user32', 'gdi32', 'IPHLPAPI', 'Shlwapi', 'wsock32', 'Ws2_32', 'shell32', 'advapi32', 'dinput8', 'dxguid'] + env.Append(LINKFLAGS=[p + env["LIBSUFFIX"] for p in LIBS]) + + env.Append(LIBPATH=[os.getenv("WindowsSdkDir") + "/Lib"]) + if (os.getenv("DXSDK_DIR")): + DIRECTX_PATH = os.getenv("DXSDK_DIR") + else: + DIRECTX_PATH = "C:/Program Files/Microsoft DirectX SDK (March 2009)" + + if (os.getenv("VCINSTALLDIR")): + VC_PATH = os.getenv("VCINSTALLDIR") + else: + VC_PATH = "" + + env.Append(CCFLAGS=["/I" + p for p in os.getenv("INCLUDE").split(";")]) + env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")]) + env.Append(CCFLAGS=["/I" + DIRECTX_PATH + "/Include"]) + env.Append(LIBPATH=[DIRECTX_PATH + "/Lib/x86"]) + env['ENV'] = os.environ + + # This detection function needs the tools env (that is env['ENV'], not SCons's env), and that is why it's this far bellow in the code + compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV']) + + # Note: this detection/override code from here onward should be here instead of in SConstruct because it's platform and compiler specific (MSVC/Windows) + if(env["bits"] != "default"): + print "Error: bits argument is disabled for MSVC" + print ("Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings)" + + " that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=windows) and SCons will attempt to detect what MSVC compiler" + + " will be executed and inform you.") + sys.exit() + + # Forcing bits argument because MSVC does not have a flag to set this through SCons... it's different compilers (cl.exe's) called from the propper command prompt + # that decide the architecture that is build for. Scons can only detect the os.getenviron (because vsvarsall.bat sets a lot of stuff for cl.exe to work with) + env["bits"] = "32" + env["x86_libtheora_opt_vc"] = True + + print "Detected MSVC compiler: " + compiler_version_str + # If building for 64bit architecture, disable assembly optimisations for 32 bit builds (theora as of writting)... vc compiler for 64bit can not compile _asm + if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"): + env["bits"] = "64" + env["x86_libtheora_opt_vc"] = False + print "Compiled program architecture will be a 64 bit executable (forcing bits=64)." + elif (compiler_version_str == "x86" or compiler_version_str == "amd64_x86"): + print "Compiled program architecture will be a 32 bit executable. (forcing bits=32)." + else: + print "Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup." + if env["bits"] == "64": + env.Append(CCFLAGS=['/D_WIN64']) + + # Incremental linking fix + env['BUILDERS']['ProgramOriginal'] = env['BUILDERS']['Program'] + env['BUILDERS']['Program'] = methods.precious_program + + else: + + # Workaround for MinGW. See: + # http://www.scons.org/wiki/LongCmdLinesOnWin32 + env.use_windows_spawn_fix() + + # build using mingw + if (os.name == "nt"): + env['ENV']['TMP'] = os.environ['TMP'] # way to go scons, you can be so stupid sometimes + else: + env["PROGSUFFIX"] = env["PROGSUFFIX"] + ".exe" # for linux cross-compilation + + mingw_prefix = "" + + if (env["bits"] == "default"): + env["bits"] = "32" + + if (env["bits"] == "32"): + env.Append(LINKFLAGS=['-static']) + env.Append(LINKFLAGS=['-static-libgcc']) + env.Append(LINKFLAGS=['-static-libstdc++']) + mingw_prefix = env["mingw_prefix"] + else: + env.Append(LINKFLAGS=['-static']) + mingw_prefix = env["mingw_prefix_64"] + + nulstr = "" + + if (os.name == "posix"): + nulstr = ">/dev/null" + else: + nulstr = ">nul" + + # if os.system(mingw_prefix+"gcc --version"+nulstr)!=0: + # #not really super consistent but.. + # print("Can't find Windows compiler: "+mingw_prefix) + # sys.exit(255) + + if (env["target"] == "release"): + + env.Append(CCFLAGS=['-msse2']) + + if (env["bits"] == "64"): + env.Append(CCFLAGS=['-O3']) + else: + env.Append(CCFLAGS=['-O2']) + + env.Append(LINKFLAGS=['-Wl,--subsystem,windows']) + + elif (env["target"] == "release_debug"): + + env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) + + elif (env["target"] == "debug"): + + env.Append(CCFLAGS=['-g', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + + env["CC"] = mingw_prefix + "gcc" + env['AS'] = mingw_prefix + "as" + env['CXX'] = mingw_prefix + "g++" + env['AR'] = mingw_prefix + "ar" + env['RANLIB'] = mingw_prefix + "ranlib" + env['LD'] = mingw_prefix + "g++" + env["x86_libtheora_opt_gcc"] = True + + #env['CC'] = "winegcc" + #env['CXX'] = "wineg++" + + env.Append(CCFLAGS=['-DWINDOWS_ENABLED', '-mwindows']) + env.Append(CPPFLAGS=['-DRTAUDIO_ENABLED']) + env.Append(CCFLAGS=['-DGLES2_ENABLED']) + env.Append(LIBS=['mingw32', 'opengl32', 'dsound', 'ole32', 'd3d9', 'winmm', 'gdi32', 'iphlpapi', 'shlwapi', 'wsock32', 'ws2_32', 'kernel32', 'oleaut32', 'dinput8', 'dxguid']) + + # if (env["bits"]=="32"): + # env.Append(LIBS=['gcc_s']) + # #--with-arch=i686 + # env.Append(CPPFLAGS=['-march=i686']) + # env.Append(LINKFLAGS=['-march=i686']) + + #'d3dx9d' + env.Append(CPPFLAGS=['-DMINGW_ENABLED']) + # env.Append(LINKFLAGS=['-g']) + + # resrc + env['is_mingw'] = True + env.Append(BUILDERS={'RES': env.Builder(action=build_res_file, suffix='.o', src_suffix='.rc')}) + + env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'HLSL9': env.Builder(action=methods.build_hlsl_dx9_headers, suffix='hlsl.h', src_suffix='.hlsl')}) + env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')}) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 286f5fb0b7..3987044d80 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2388,7 +2388,7 @@ void OS_Windows::set_use_vsync(bool p_enable) { gl_context->set_use_vsync(p_enable); } -bool OS_Windows::is_vsnc_enabled() const{ +bool OS_Windows::is_vsync_enabled() const{ if (gl_context) return gl_context->is_using_vsync(); diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 903dd10c70..11fa094b88 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -295,7 +295,7 @@ public: virtual String get_joy_guid(int p_device) const; virtual void set_use_vsync(bool p_enable); - virtual bool is_vsnc_enabled() const; + virtual bool is_vsync_enabled() const; OS_Windows(HINSTANCE _hInstance); ~OS_Windows(); diff --git a/platform/windows/packet_peer_udp_winsock.cpp b/platform/windows/packet_peer_udp_winsock.cpp index b4cd60979c..73c6116aa3 100644 --- a/platform/windows/packet_peer_udp_winsock.cpp +++ b/platform/windows/packet_peer_udp_winsock.cpp @@ -112,15 +112,23 @@ void PacketPeerUDPWinsock::_set_blocking(bool p_blocking) { }; } -Error PacketPeerUDPWinsock::listen(int p_port, IP_Address::AddrType p_address_type, int p_recv_buffer_size) { +Error PacketPeerUDPWinsock::listen(int p_port, IP_Address::AddrType p_type, int p_recv_buffer_size) { close(); - int sock = _get_socket(p_address_type); + int sock = _get_socket(p_type); if (sock == -1 ) return ERR_CANT_CREATE; + if(p_type == IP_Address::TYPE_IPV6) { + // Use IPv6 only socket + int yes = 1; + if(setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&yes, sizeof(yes)) != 0) { + WARN_PRINT("Unable to unset IPv4 address mapping over IPv6"); + } + } + struct sockaddr_storage addr = {0}; - size_t addr_size = _set_listen_sockaddr(&addr, p_port, p_address_type, NULL); + size_t addr_size = _set_listen_sockaddr(&addr, p_port, p_type, NULL); if (bind(sock, (struct sockaddr*)&addr, addr_size) == -1 ) { close(); @@ -239,11 +247,7 @@ int PacketPeerUDPWinsock::_get_socket(IP_Address::AddrType p_type) { if (sockfd != -1) return sockfd; - int family = p_type == IP_Address::TYPE_IPV6 ? AF_INET6 : AF_INET; - - sockfd = socket(family, SOCK_DGRAM, IPPROTO_UDP); - ERR_FAIL_COND_V( sockfd == -1, -1 ); - //fcntl(sockfd, F_SETFL, O_NONBLOCK); + sockfd = _socket_create(p_type, SOCK_DGRAM, IPPROTO_UDP); return sockfd; } diff --git a/platform/windows/stream_peer_winsock.cpp b/platform/windows/stream_peer_winsock.cpp index b511e38ecb..44c17c73e5 100644 --- a/platform/windows/stream_peer_winsock.cpp +++ b/platform/windows/stream_peer_winsock.cpp @@ -296,8 +296,8 @@ Error StreamPeerWinsock::connect(const IP_Address& p_host, uint16_t p_port) { ERR_FAIL_COND_V( p_host.type == IP_Address::TYPE_NONE, ERR_INVALID_PARAMETER); - int family = p_host.type == IP_Address::TYPE_IPV6 ? AF_INET6 : AF_INET; - if ((sockfd = socket(family, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) { + sockfd = _socket_create(p_host.type, SOCK_STREAM, IPPROTO_TCP); + if (sockfd == INVALID_SOCKET) { ERR_PRINT("Socket creation failed!"); disconnect(); //perror("socket"); diff --git a/platform/windows/tcp_server_winsock.cpp b/platform/windows/tcp_server_winsock.cpp index 1aedc52bb9..38a6b04100 100644 --- a/platform/windows/tcp_server_winsock.cpp +++ b/platform/windows/tcp_server_winsock.cpp @@ -66,9 +66,17 @@ void TCPServerWinsock::cleanup() { Error TCPServerWinsock::listen(uint16_t p_port, IP_Address::AddrType p_type,const List<String> *p_accepted_hosts) { int sockfd; - sockfd = socket(AF_INET, SOCK_STREAM, 0); + sockfd = _socket_create(p_type, SOCK_STREAM, IPPROTO_TCP); ERR_FAIL_COND_V(sockfd == INVALID_SOCKET, FAILED); + if(p_type == IP_Address::TYPE_IPV6) { + // Use IPv6 only socket + int yes = 1; + if(setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&yes, sizeof(yes)) != 0) { + WARN_PRINT("Unable to unset IPv4 address mapping over IPv6"); + } + } + unsigned long par = 1; if (ioctlsocket(sockfd, FIONBIO, &par)) { perror("setting non-block mode"); diff --git a/platform/windows/tcp_server_winsock.h b/platform/windows/tcp_server_winsock.h index 94601a2e12..115fdb4234 100644 --- a/platform/windows/tcp_server_winsock.h +++ b/platform/windows/tcp_server_winsock.h @@ -39,7 +39,7 @@ class TCPServerWinsock : public TCP_Server { public: - virtual Error listen(uint16_t p_port, IP_Address::AddrType p_type = IP_Address::TYPE_IPV4,const List<String> *p_accepted_hosts=NULL); + virtual Error listen(uint16_t p_port, IP_Address::AddrType p_type,const List<String> *p_accepted_hosts=NULL); virtual bool is_connection_available() const; virtual Ref<StreamPeerTCP> take_connection(); diff --git a/platform/winrt/SCsub b/platform/winrt/SCsub deleted file mode 100644 index 91a179084d..0000000000 --- a/platform/winrt/SCsub +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -files = [ - 'thread_winrt.cpp', - '#platform/windows/tcp_server_winsock.cpp', - '#platform/windows/packet_peer_udp_winsock.cpp', - '#platform/windows/stream_peer_winsock.cpp', - '#platform/windows/key_mapping_win.cpp', - 'joystick_winrt.cpp', - 'gl_context_egl.cpp', - 'app.cpp', - 'os_winrt.cpp', -] - -if "build_angle" in env and env["build_angle"]: - cmd = env.AlwaysBuild(env.ANGLE('libANGLE.lib', None)) - -prog = env.Program('#bin/godot', files) - -if "build_angle" in env and env["build_angle"]: - env.Depends(prog, [cmd]) diff --git a/platform/winrt/detect.py b/platform/winrt/detect.py deleted file mode 100644 index a7bc62f685..0000000000 --- a/platform/winrt/detect.py +++ /dev/null @@ -1,166 +0,0 @@ -import os - -import sys -import string -import methods - - -def is_active(): - return True - -def get_name(): - return "WinRT" - -def can_build(): - if (os.name=="nt"): - #building natively on windows! - if (os.getenv("VSINSTALLDIR")): - - if (os.getenv("ANGLE_SRC_PATH") == None): - return False - - return True - return False - -def get_opts(): - return [] - -def get_flags(): - - return [ - ('tools', 'no'), - ('builtin_zlib', 'yes'), - ('openssl', 'builtin'), - ('xaudio2', 'yes'), - ] - - -def configure(env): - - if(env["bits"] != "default"): - print "Error: bits argument is disabled for MSVC" - print ("Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings)" - +" that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=winrt) and SCons will attempt to detect what MSVC compiler" - +" will be executed and inform you.") - sys.exit() - - arch = "" - env['ENV'] = os.environ; - - # ANGLE - angle_root = os.getenv("ANGLE_SRC_PATH") - env.Append(CPPPATH=[angle_root + '/include']) - jobs = str(env.GetOption("num_jobs")) - angle_build_cmd = "msbuild.exe " + angle_root + "/winrt/10/src/angle.sln /nologo /v:m /m:" + jobs + " /p:Configuration=Release /p:Platform=" - - if os.path.isfile(str(os.getenv("ANGLE_SRC_PATH")) + "/winrt/10/src/angle.sln"): - env["build_angle"] = True - - if os.getenv('Platform') == "ARM": - - print "Compiled program architecture will be an ARM executable. (forcing bits=32)." - - arch="arm" - env["bits"]="32" - env.Append(LINKFLAGS=['/MACHINE:ARM']) - env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/arm']) - - angle_build_cmd += "ARM" - - env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_ARM/lib']) - - else: - - compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV']) - - if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"): - env["bits"]="64" - print "Compiled program architecture will be a x64 executable (forcing bits=64)." - elif (compiler_version_str=="x86" or compiler_version_str == "amd64_x86"): - env["bits"]="32" - print "Compiled program architecture will be a x86 executable. (forcing bits=32)." - else: - print "Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup." - env["bits"]="32" - - if (env["bits"] == "32"): - arch = "x86" - - angle_build_cmd += "Win32" - - env.Append(CPPFLAGS=['/DPNG_ABORT=abort']) - env.Append(LINKFLAGS=['/MACHINE:X86']) - env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store']) - env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_Win32/lib']) - - else: - arch = "x64" - - angle_build_cmd += "x64" - - env.Append(LINKFLAGS=['/MACHINE:X64']) - env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/amd64']) - env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_x64/lib']) - - env.Append(CPPPATH=['#platform/winrt','#drivers/windows']) - env.Append(LINKFLAGS=['/MANIFEST:NO', '/NXCOMPAT', '/DYNAMICBASE', '/WINMD', '/APPCONTAINER', '/ERRORREPORT:PROMPT', '/NOLOGO', '/TLBID:1', '/NODEFAULTLIB:"kernel32.lib"', '/NODEFAULTLIB:"ole32.lib"']) - env.Append(CPPFLAGS=['/D','__WRL_NO_DEFAULT_LIB__','/D','WIN32']) - env.Append(CPPFLAGS=['/FU', os.environ['VCINSTALLDIR'] + 'lib/store/references/platform.winmd']) - env.Append(CPPFLAGS=['/AI', os.environ['VCINSTALLDIR'] + 'lib/store/references']) - - env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/references']) - - if (env["target"]=="release"): - - env.Append(CPPFLAGS=['/O2', '/GL']) - env.Append(CPPFLAGS=['/MD']) - env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS', '/LTCG']) - - elif (env["target"]=="release_debug"): - - env.Append(CCFLAGS=['/O2','/Zi','/DDEBUG_ENABLED']) - env.Append(CPPFLAGS=['/MD']) - env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) - - elif (env["target"]=="debug"): - - env.Append(CCFLAGS=['/Zi','/DDEBUG_ENABLED','/DDEBUG_MEMORY_ENABLED']) - env.Append(CPPFLAGS=['/MDd']) - env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) - env.Append(LINKFLAGS=['/DEBUG']) - - - env.Append(CCFLAGS=string.split('/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /D "_UNICODE" /D "UNICODE" /D "WINAPI_FAMILY=WINAPI_FAMILY_APP" /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo')) - env.Append(CXXFLAGS=string.split('/ZW /FS')) - env.Append(CCFLAGS=['/AI', os.environ['VCINSTALLDIR']+'\\vcpackages', '/AI', os.environ['WINDOWSSDKDIR']+'\\References\\CommonConfiguration\\Neutral']) - - - env["PROGSUFFIX"]="."+arch+env["PROGSUFFIX"] - env["OBJSUFFIX"]="."+arch+env["OBJSUFFIX"] - env["LIBSUFFIX"]="."+arch+env["LIBSUFFIX"] - - env.Append(CCFLAGS=['/DWINRT_ENABLED']) - env.Append(CCFLAGS=['/DWINDOWS_ENABLED']) - env.Append(CCFLAGS=['/DTYPED_METHOD_BIND']) - - env.Append(CCFLAGS=['/DGLES2_ENABLED','/DGL_GLEXT_PROTOTYPES','/DEGL_EGLEXT_PROTOTYPES','/DANGLE_ENABLED']) - - LIBS = [ - 'WindowsApp', - 'mincore', - 'libANGLE', - 'libEGL', - 'libGLESv2', - ] - env.Append(LINKFLAGS=[p+".lib" for p in LIBS]) - - # Incremental linking fix - env['BUILDERS']['ProgramOriginal'] = env['BUILDERS']['Program'] - env['BUILDERS']['Program'] = methods.precious_program - - env.Append( BUILDERS = { 'ANGLE' : env.Builder(action = angle_build_cmd) } ) - - env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } ) - env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) diff --git a/platform/x11/SCsub b/platform/x11/SCsub index e20bd44f8d..0defd4f025 100644 --- a/platform/x11/SCsub +++ b/platform/x11/SCsub @@ -3,11 +3,11 @@ Import('env') -common_x11=[\ - "context_gl_x11.cpp",\ - "os_x11.cpp",\ - "key_mapping_x11.cpp",\ - "joystick_linux.cpp",\ +common_x11 = [\ + "context_gl_x11.cpp",\ + "os_x11.cpp",\ + "key_mapping_x11.cpp",\ + "joystick_linux.cpp",\ ] -env.Program('#bin/godot',['godot_x11.cpp']+common_x11) +env.Program('#bin/godot', ['godot_x11.cpp'] + common_x11) diff --git a/platform/x11/detect.py b/platform/x11/detect.py index e90af2c697..d8cd79297e 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -5,236 +5,233 @@ import platform def is_active(): - return True + return True + def get_name(): - return "X11" + return "X11" def can_build(): - if (os.name!="posix"): - return False + if (os.name != "posix"): + return False - if sys.platform == "darwin": - return False # no x11 on mac for now + if sys.platform == "darwin": + return False # no x11 on mac for now - errorval=os.system("pkg-config --version > /dev/null") + errorval = os.system("pkg-config --version > /dev/null") - if (errorval): - print("pkg-config not found.. x11 disabled.") - return False + if (errorval): + print("pkg-config not found.. x11 disabled.") + return False - x11_error=os.system("pkg-config x11 --modversion > /dev/null ") - if (x11_error): - print("X11 not found.. x11 disabled.") - return False + x11_error = os.system("pkg-config x11 --modversion > /dev/null ") + if (x11_error): + print("X11 not found.. x11 disabled.") + return False - ssl_error=os.system("pkg-config openssl --modversion > /dev/null ") - if (ssl_error): - print("OpenSSL not found.. x11 disabled.") - return False + ssl_error = os.system("pkg-config openssl --modversion > /dev/null ") + if (ssl_error): + print("OpenSSL not found.. x11 disabled.") + return False - x11_error=os.system("pkg-config xcursor --modversion > /dev/null ") - if (x11_error): - print("xcursor not found.. x11 disabled.") - return False + x11_error = os.system("pkg-config xcursor --modversion > /dev/null ") + if (x11_error): + print("xcursor not found.. x11 disabled.") + return False - x11_error=os.system("pkg-config xinerama --modversion > /dev/null ") - if (x11_error): - print("xinerama not found.. x11 disabled.") - return False + x11_error = os.system("pkg-config xinerama --modversion > /dev/null ") + if (x11_error): + print("xinerama not found.. x11 disabled.") + return False - x11_error=os.system("pkg-config xrandr --modversion > /dev/null ") - if (x11_error): - print("xrandr not found.. x11 disabled.") - return False + x11_error = os.system("pkg-config xrandr --modversion > /dev/null ") + if (x11_error): + print("xrandr not found.. x11 disabled.") + return False + return True # X11 enabled - return True # X11 enabled def get_opts(): - return [ - ('use_llvm','Use llvm compiler','no'), - ('use_static_cpp','link stdc++ statically','no'), - ('use_sanitizer','Use llvm compiler sanitize address','no'), - ('use_leak_sanitizer','Use llvm compiler sanitize memory leaks','no'), - ('pulseaudio','Detect & Use pulseaudio','yes'), - ('udev','Use udev for gamepad connection callbacks','no'), - ('debug_release', 'Add debug symbols to release version','no'), - ] + return [ + ('use_llvm', 'Use llvm compiler', 'no'), + ('use_static_cpp', 'link stdc++ statically', 'no'), + ('use_sanitizer', 'Use llvm compiler sanitize address', 'no'), + ('use_leak_sanitizer', 'Use llvm compiler sanitize memory leaks', 'no'), + ('pulseaudio', 'Detect & Use pulseaudio', 'yes'), + ('udev', 'Use udev for gamepad connection callbacks', 'no'), + ('debug_release', 'Add debug symbols to release version', 'no'), + ] -def get_flags(): - return [ - ("openssl", "system"), - ('freetype', 'system'), - ('libpng', 'system'), - ] +def get_flags(): + return [ + ('builtin_freetype', 'no'), + ('builtin_libpng', 'no'), + ('builtin_openssl', 'no'), + ('builtin_zlib', 'no'), + ] def configure(env): - is64=sys.maxsize > 2**32 - - if (env["bits"]=="default"): - if (is64): - env["bits"]="64" - else: - env["bits"]="32" - - env.Append(CPPPATH=['#platform/x11']) - if (env["use_llvm"]=="yes"): - if 'clang++' not in env['CXX']: - env["CC"]="clang" - env["CXX"]="clang++" - env["LD"]="clang++" - env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) - env.extra_suffix=".llvm" - - if (env["use_sanitizer"]=="yes"): - env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer']) - env.Append(LINKFLAGS=['-fsanitize=address']) - env.extra_suffix+="s" - - if (env["use_leak_sanitizer"]=="yes"): - env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer']) - env.Append(LINKFLAGS=['-fsanitize=address']) - env.extra_suffix+="s" - - - #if (env["tools"]=="no"): - # #no tools suffix - # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX'] - # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX'] - - - if (env["target"]=="release"): - - if (env["debug_release"]=="yes"): - env.Append(CCFLAGS=['-g2']) - else: - env.Append(CCFLAGS=['-O3','-ffast-math']) - - elif (env["target"]=="release_debug"): - - env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED']) - if (env["debug_release"]=="yes"): - env.Append(CCFLAGS=['-g2']) - - elif (env["target"]=="debug"): - - env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) - - env.ParseConfig('pkg-config x11 --cflags --libs') - env.ParseConfig('pkg-config xinerama --cflags --libs') - env.ParseConfig('pkg-config xcursor --cflags --libs') - env.ParseConfig('pkg-config xrandr --cflags --libs') - - if (env["openssl"] == "system"): - env.ParseConfig('pkg-config openssl --cflags --libs') - - if (env["libwebp"] == "system"): - env.ParseConfig('pkg-config libwebp --cflags --libs') - - if (env["freetype"] == "system"): - env["libpng"] = "system" # Freetype links against libpng - env.ParseConfig('pkg-config freetype2 --cflags --libs') - - if (env["libpng"] == "system"): - env.ParseConfig('pkg-config libpng --cflags --libs') - - if (env["enet"] == "system"): - env.ParseConfig('pkg-config libenet --cflags --libs') - - if (env["squish"] == "system" and env["tools"] == "yes"): - env.ParseConfig('pkg-config libsquish --cflags --libs') - - # Sound and video libraries - # Keep the order as it triggers chained dependencies (ogg needed by others, etc.) - - if (env["libtheora"] == "system"): - env["libogg"] = "system" # Needed to link against system libtheora - env["libvorbis"] = "system" # Needed to link against system libtheora - env.ParseConfig('pkg-config theora theoradec --cflags --libs') - - if (env["libvpx"] == "system"): - env.ParseConfig('pkg-config vpx --cflags --libs') - - if (env["libvorbis"] == "system"): - env["libogg"] = "system" # Needed to link against system libvorbis - env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs') - - if (env["opus"] == "system"): - env["libogg"] = "system" # Needed to link against system opus - env.ParseConfig('pkg-config opus opusfile --cflags --libs') - - if (env["libogg"] == "system"): - env.ParseConfig('pkg-config ogg --cflags --libs') - - - env.Append(CPPFLAGS=['-DOPENGL_ENABLED']) - - if (env["glew"] == "system"): - env.ParseConfig('pkg-config glew --cflags --libs') + is64 = sys.maxsize > 2**32 - if os.system("pkg-config --exists alsa")==0: - print("Enabling ALSA") - env.Append(CPPFLAGS=["-DALSA_ENABLED"]) - env.ParseConfig('pkg-config alsa --cflags --libs') - else: - print("ALSA libraries not found, disabling driver") + if (env["bits"] == "default"): + if (is64): + env["bits"] = "64" + else: + env["bits"] = "32" - if (platform.system() == "Linux"): - env.Append(CPPFLAGS=["-DJOYDEV_ENABLED"]) - if (env["udev"]=="yes"): - # pkg-config returns 0 when the lib exists... - found_udev = not os.system("pkg-config --exists libudev") + env.Append(CPPPATH=['#platform/x11']) + if (env["use_llvm"] == "yes"): + if 'clang++' not in env['CXX']: + env["CC"] = "clang" + env["CXX"] = "clang++" + env["LD"] = "clang++" + env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) + env.extra_suffix = ".llvm" - if (found_udev): - print("Enabling udev support") - env.Append(CPPFLAGS=["-DUDEV_ENABLED"]) - env.ParseConfig('pkg-config libudev --cflags --libs') - else: - print("libudev development libraries not found, disabling udev support") + if (env["use_sanitizer"] == "yes"): + env.Append(CXXFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer']) + env.Append(LINKFLAGS=['-fsanitize=address']) + env.extra_suffix += "s" - if (env["pulseaudio"]=="yes"): - if not os.system("pkg-config --exists libpulse-simple"): - print("Enabling PulseAudio") - env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"]) - env.ParseConfig('pkg-config --cflags --libs libpulse-simple') - else: - print("PulseAudio development libraries not found, disabling driver") + if (env["use_leak_sanitizer"] == "yes"): + env.Append(CXXFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer']) + env.Append(LINKFLAGS=['-fsanitize=address']) + env.extra_suffix += "s" + + # if (env["tools"]=="no"): + # #no tools suffix + # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX'] + # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX'] + + if (env["target"] == "release"): - env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES_OVER_GL']) - env.Append(LIBS=['GL', 'pthread', 'z']) - if (platform.system() == "Linux"): - env.Append(LIBS='dl') - #env.Append(CPPFLAGS=['-DMPC_FIXED_POINT']) + if (env["debug_release"] == "yes"): + env.Append(CCFLAGS=['-g2']) + else: + env.Append(CCFLAGS=['-O3', '-ffast-math']) + + elif (env["target"] == "release_debug"): + + env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED']) + if (env["debug_release"] == "yes"): + env.Append(CCFLAGS=['-g2']) -#host compiler is default.. + elif (env["target"] == "debug"): + + env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + + env.ParseConfig('pkg-config x11 --cflags --libs') + env.ParseConfig('pkg-config xinerama --cflags --libs') + env.ParseConfig('pkg-config xcursor --cflags --libs') + env.ParseConfig('pkg-config xrandr --cflags --libs') - if (is64 and env["bits"]=="32"): - env.Append(CPPFLAGS=['-m32']) - env.Append(LINKFLAGS=['-m32','-L/usr/lib/i386-linux-gnu']) - elif (not is64 and env["bits"]=="64"): - env.Append(CPPFLAGS=['-m64']) - env.Append(LINKFLAGS=['-m64','-L/usr/lib/i686-linux-gnu']) + if (env['builtin_openssl'] == 'no'): + env.ParseConfig('pkg-config openssl --cflags --libs') + + if (env['builtin_libwebp'] == 'no'): + env.ParseConfig('pkg-config libwebp --cflags --libs') + + if (env['builtin_freetype'] == 'no'): + env['builtin_libpng'] = 'no' # Freetype links against libpng + env.ParseConfig('pkg-config freetype2 --cflags --libs') + + if (env['builtin_libpng'] == 'no'): + env.ParseConfig('pkg-config libpng --cflags --libs') + + if (env['builtin_enet'] == 'no'): + env.ParseConfig('pkg-config libenet --cflags --libs') + + if (env['builtin_squish'] == 'no' and env["tools"] == "yes"): + env.ParseConfig('pkg-config libsquish --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 + env.ParseConfig('pkg-config theora theoradec --cflags --libs') + + if (env['builtin_libvpx'] == 'no'): + env.ParseConfig('pkg-config vpx --cflags --libs') + + if (env['builtin_libvorbis'] == 'no'): + env['builtin_libogg'] = 'no' # 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 + env.ParseConfig('pkg-config opus opusfile --cflags --libs') + + if (env['builtin_libogg'] == 'no'): + env.ParseConfig('pkg-config ogg --cflags --libs') + + env.Append(CPPFLAGS=['-DOPENGL_ENABLED']) + + if (env['builtin_glew'] == 'no'): + env.ParseConfig('pkg-config glew --cflags --libs') + + if os.system("pkg-config --exists alsa") == 0: + print("Enabling ALSA") + env.Append(CPPFLAGS=["-DALSA_ENABLED"]) + env.ParseConfig('pkg-config alsa --cflags --libs') + else: + print("ALSA libraries not found, disabling driver") + + if (platform.system() == "Linux"): + env.Append(CPPFLAGS=["-DJOYDEV_ENABLED"]) + if (env["udev"] == "yes"): + # pkg-config returns 0 when the lib exists... + found_udev = not os.system("pkg-config --exists libudev") + + if (found_udev): + print("Enabling udev support") + env.Append(CPPFLAGS=["-DUDEV_ENABLED"]) + env.ParseConfig('pkg-config libudev --cflags --libs') + else: + print("libudev development libraries not found, disabling udev support") + if (env["pulseaudio"] == "yes"): + if not os.system("pkg-config --exists libpulse-simple"): + print("Enabling PulseAudio") + env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"]) + env.ParseConfig('pkg-config --cflags --libs libpulse-simple') + else: + print("PulseAudio development libraries not found, disabling driver") - import methods + env.Append(CPPFLAGS=['-DX11_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) + env.Append(LIBS=['GL', 'pthread', 'z']) + if (platform.system() == "Linux"): + env.Append(LIBS='dl') + # env.Append(CPPFLAGS=['-DMPC_FIXED_POINT']) - env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } ) +# host compiler is default.. - if (env["use_static_cpp"]=="yes"): - env.Append(LINKFLAGS=['-static-libstdc++']) + if (is64 and env["bits"] == "32"): + env.Append(CPPFLAGS=['-m32']) + env.Append(LINKFLAGS=['-m32', '-L/usr/lib/i386-linux-gnu']) + elif (not is64 and env["bits"] == "64"): + env.Append(CPPFLAGS=['-m64']) + env.Append(LINKFLAGS=['-m64', '-L/usr/lib/i686-linux-gnu']) - 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 + import methods + env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')}) + #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } ) + + if (env["use_static_cpp"] == "yes"): + env.Append(LINKFLAGS=['-static-libstdc++']) + + 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 diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 5f1ab5b4aa..0172dca4c4 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -1951,7 +1951,7 @@ void OS_X11::set_use_vsync(bool p_enable) { return context_gl->set_use_vsync(p_enable); } -bool OS_X11::is_vsnc_enabled() const { +bool OS_X11::is_vsync_enabled() const { if (context_gl) return context_gl->is_using_vsync(); diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index b27f71406a..efa7e44afe 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -264,7 +264,7 @@ public: virtual void set_context(int p_context); virtual void set_use_vsync(bool p_enable); - virtual bool is_vsnc_enabled() const; + virtual bool is_vsync_enabled() const; void run(); |