diff options
164 files changed, 9077 insertions, 8633 deletions
diff --git a/SConstruct b/SConstruct index 70816d82b8..04c648c283 100644 --- a/SConstruct +++ b/SConstruct @@ -1,6 +1,6 @@ #!/usr/bin/env python -EnsureSConsVersion(0,14); +EnsureSConsVersion(0, 14) import string @@ -14,85 +14,84 @@ methods.update_version() # scan possible build platforms -platform_list = [] # list of platforms -platform_opts = {} # options for each platform -platform_flags = {} # flags for each platform +platform_list = [] # list of platforms +platform_opts = {} # options for each platform +platform_flags = {} # flags for each platform -active_platforms=[] -active_platform_ids=[] -platform_exporters=[] -global_defaults=[] +active_platforms = [] +active_platform_ids = [] +platform_exporters = [] +global_defaults = [] for x in glob.glob("platform/*"): - if (not os.path.isdir(x) or not os.path.exists(x+"/detect.py")): - continue - tmppath="./"+x + if (not os.path.isdir(x) or not os.path.exists(x + "/detect.py")): + continue + tmppath = "./" + x - sys.path.append(tmppath) - import detect + sys.path.append(tmppath) + import detect - if (os.path.exists(x+"/export/export.cpp")): - platform_exporters.append(x[9:]) - if (os.path.exists(x+"/globals/global_defaults.cpp")): - global_defaults.append(x[9:]) - if (detect.is_active()): - active_platforms.append( detect.get_name() ) - active_platform_ids.append(x); - if (detect.can_build()): - x=x.replace("platform/","") # rest of world - x=x.replace("platform\\","") # win32 - platform_list+=[x] - platform_opts[x]=detect.get_opts() - platform_flags[x]=detect.get_flags() - sys.path.remove(tmppath) - sys.modules.pop('detect') + if (os.path.exists(x + "/export/export.cpp")): + platform_exporters.append(x[9:]) + if (os.path.exists(x + "/globals/global_defaults.cpp")): + global_defaults.append(x[9:]) + if (detect.is_active()): + active_platforms.append(detect.get_name()) + active_platform_ids.append(x) + if (detect.can_build()): + x = x.replace("platform/", "") # rest of world + x = x.replace("platform\\", "") # win32 + platform_list += [x] + platform_opts[x] = detect.get_opts() + platform_flags[x] = detect.get_flags() + sys.path.remove(tmppath) + sys.modules.pop('detect') -module_list=methods.detect_modules() +module_list = methods.detect_modules() -#print "Detected Platforms: "+str(platform_list) +# print "Detected Platforms: "+str(platform_list) -methods.save_active_platforms(active_platforms,active_platform_ids) +methods.save_active_platforms(active_platforms, active_platform_ids) -custom_tools=['default'] +custom_tools = ['default'] platform_arg = ARGUMENTS.get("platform", ARGUMENTS.get("p", False)) -if (os.name=="posix"): - pass -elif (os.name=="nt"): - if ( os.getenv("VCINSTALLDIR")==None or platform_arg=="android"): - custom_tools=['mingw'] +if (os.name == "posix"): + pass +elif (os.name == "nt"): + if (os.getenv("VCINSTALLDIR") == None or platform_arg == "android"): + custom_tools = ['mingw'] -env_base=Environment(tools=custom_tools); +env_base = Environment(tools=custom_tools) if 'TERM' in os.environ: - env_base['ENV']['TERM'] = os.environ['TERM'] + env_base['ENV']['TERM'] = os.environ['TERM'] env_base.AppendENVPath('PATH', os.getenv('PATH')) env_base.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH')) -env_base.global_defaults=global_defaults -env_base.android_maven_repos=[] -env_base.android_dependencies=[] -env_base.android_java_dirs=[] -env_base.android_res_dirs=[] -env_base.android_aidl_dirs=[] -env_base.android_jni_dirs=[] -env_base.android_default_config=[] -env_base.android_manifest_chunk="" -env_base.android_permission_chunk="" -env_base.android_appattributes_chunk="" -env_base.disabled_modules=[] -env_base.use_ptrcall=False -env_base.split_drivers=False - - - -env_base.__class__.android_add_maven_repository=methods.android_add_maven_repository -env_base.__class__.android_add_dependency=methods.android_add_dependency -env_base.__class__.android_add_java_dir=methods.android_add_java_dir -env_base.__class__.android_add_res_dir=methods.android_add_res_dir -env_base.__class__.android_add_aidl_dir=methods.android_add_aidl_dir -env_base.__class__.android_add_jni_dir=methods.android_add_jni_dir -env_base.__class__.android_add_default_config=methods.android_add_default_config +env_base.global_defaults = global_defaults +env_base.android_maven_repos = [] +env_base.android_dependencies = [] +env_base.android_java_dirs = [] +env_base.android_res_dirs = [] +env_base.android_aidl_dirs = [] +env_base.android_jni_dirs = [] +env_base.android_default_config = [] +env_base.android_manifest_chunk = "" +env_base.android_permission_chunk = "" +env_base.android_appattributes_chunk = "" +env_base.disabled_modules = [] +env_base.use_ptrcall = False +env_base.split_drivers = False + + +env_base.__class__.android_add_maven_repository = methods.android_add_maven_repository +env_base.__class__.android_add_dependency = methods.android_add_dependency +env_base.__class__.android_add_java_dir = methods.android_add_java_dir +env_base.__class__.android_add_res_dir = methods.android_add_res_dir +env_base.__class__.android_add_aidl_dir = methods.android_add_aidl_dir +env_base.__class__.android_add_jni_dir = methods.android_add_jni_dir +env_base.__class__.android_add_default_config = methods.android_add_default_config env_base.__class__.android_add_to_manifest = methods.android_add_to_manifest env_base.__class__.android_add_to_permissions = methods.android_add_to_permissions env_base.__class__.android_add_to_attributes = methods.android_add_to_attributes @@ -102,75 +101,89 @@ env_base.__class__.add_source_files = methods.add_source_files env_base.__class__.use_windows_spawn_fix = methods.use_windows_spawn_fix env_base.__class__.split_lib = methods.split_lib -env_base["x86_libtheora_opt_gcc"]=False -env_base["x86_libtheora_opt_vc"]=False +env_base["x86_libtheora_opt_gcc"] = False +env_base["x86_libtheora_opt_vc"] = False + +# Build options customs = ['custom.py'] profile = ARGUMENTS.get("profile", False) if profile: - import os.path - if os.path.isfile(profile): - customs.append(profile) - elif os.path.isfile(profile+".py"): - customs.append(profile+".py") - -opts=Variables(customs, ARGUMENTS) -opts.Add('target', 'Compile Target (debug/release_debug/release).', "debug") -opts.Add('arch', 'Platform dependent architecture (arm/arm64/x86/x64/mips/etc)', "") -opts.Add('bits', 'Compile Target Bits (default/32/64/fat).', "default") -opts.Add('platform','Platform: '+str(platform_list)+'.',"") -opts.Add('p','Platform (same as platform=).',"") -opts.Add('tools','Build Tools (Including Editor): (yes/no)','yes') -opts.Add('gdscript','Build GDSCript support: (yes/no)','yes') -opts.Add('libogg','Ogg library for ogg container support (system/builtin)','builtin') -opts.Add('libvorbis','Ogg Vorbis library for vorbis support (system/builtin)','builtin') -opts.Add('libtheora','Theora library for theora module (system/builtin)','builtin') -opts.Add('libvpx','VPX library for webm module (system/builtin)','builtin') -opts.Add('opus','Opus and opusfile library for Opus format support: (system/builtin)','builtin') -opts.Add('minizip','Build Minizip Archive Support: (yes/no)','yes') -opts.Add('squish','Squish library for BC Texture Compression in editor (system/builtin)','builtin') -opts.Add('freetype','Freetype library for TTF support via freetype module (system/builtin)','builtin') -opts.Add('xml','XML Save/Load support (yes/no)','yes') -opts.Add('libpng','libpng library for image loader support (system/builtin)','builtin') -opts.Add('libwebp','libwebp library for webp module (system/builtin)','builtin') -opts.Add('openssl','OpenSSL library for openssl module (system/builtin)','builtin') -opts.Add('libmpcdec','libmpcdec library for mpc module (system/builtin)','builtin') -opts.Add('enet','ENet library (system/builtin)','builtin') -opts.Add('glew','GLEW library for the gl_context (system/builtin)','builtin') -opts.Add('xaudio2','XAudio2 audio driver (yes/no)','no') -opts.Add("CXX", "C++ Compiler") -opts.Add("CC", "C Compiler") -opts.Add("CCFLAGS", "Custom flags for the C/C++ compiler"); -opts.Add("CFLAGS", "Custom flags for the C compiler"); -opts.Add("LINKFLAGS", "Custom flags for the linker"); -opts.Add('unix_global_settings_path', 'unix-specific path to system-wide settings. Currently only used by templates.','') -opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no") -opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no") -opts.Add('verbose', 'Enable verbose output for the compilation (yes/no)', 'yes') -opts.Add('deprecated','Enable deprecated features (yes/no)','yes') -opts.Add('extra_suffix', 'Custom extra suffix added to the base filename of all generated binary files.', '') -opts.Add('vsproj', 'Generate Visual Studio Project. (yes/no)', 'no') + import os.path + if os.path.isfile(profile): + customs.append(profile) + elif os.path.isfile(profile + ".py"): + customs.append(profile + ".py") + +opts = Variables(customs, ARGUMENTS) + +# Target build options +opts.Add('arch', "Platform-dependent architecture (arm/arm64/x86/x64/mips/etc)", '') +opts.Add('bits', "Target platform bits (default/32/64/fat)", 'default') +opts.Add('p', "Platform (alias for 'platform')", '') +opts.Add('platform', "Target platform: any in " + str(platform_list), '') +opts.Add('target', "Compilation target (debug/release_debug/release)", 'debug') +opts.Add('tools', "Build the tools a.k.a. the Godot editor (yes/no)", 'yes') + +# Components +opts.Add('deprecated', "Enable deprecated features (yes/no)", 'yes') +opts.Add('gdscript', "Build GDSCript support (yes/no)", 'yes') +opts.Add('minizip', "Build minizip archive support (yes/no)", 'yes') +opts.Add('xaudio2', "XAudio2 audio driver (yes/no)", 'no') +opts.Add('xml', "XML format support for resources (yes/no)", 'yes') + +# Advanced options +opts.Add('disable_3d', "Disable 3D nodes for smaller executable (yes/no)", 'no') +opts.Add('disable_advanced_gui', "Disable advance 3D gui nodes and behaviors (yes/no)", 'no') +opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all generated binary files", '') +opts.Add('unix_global_settings_path', "UNIX-specific path to system-wide settings. Currently only used for templates", '') +opts.Add('verbose', "Enable verbose output for the compilation (yes/no)", 'yes') +opts.Add('vsproj', "Generate Visual Studio Project. (yes/no)", 'no') + +# Thirdparty libraries +opts.Add('builtin_enet', "Use the builtin enet library (yes/no)", 'yes') +opts.Add('builtin_freetype', "Use the builtin freetype library (yes/no)", 'yes') +opts.Add('builtin_glew', "Use the builtin glew library (yes/no)", 'yes') +opts.Add('builtin_libmpcdec', "Use the builtin libmpcdec library (yes/no)", 'yes') +opts.Add('builtin_libogg', "Use the builtin libogg library (yes/no)", 'yes') +opts.Add('builtin_libpng', "Use the builtin libpng library (yes/no)", 'yes') +opts.Add('builtin_libtheora', "Use the builtin libtheora library (yes/no)", 'yes') +opts.Add('builtin_libvorbis', "Use the builtin libvorbis library (yes/no)", 'yes') +opts.Add('builtin_libvpx', "Use the builtin libvpx library (yes/no)", 'yes') +opts.Add('builtin_libwebp', "Use the builtin libwebp library (yes/no)", 'yes') +opts.Add('builtin_openssl', "Use the builtin openssl library (yes/no)", 'yes') +opts.Add('builtin_opus', "Use the builtin opus library (yes/no)", 'yes') +opts.Add('builtin_squish', "Use the builtin squish library (yes/no)", 'yes') +opts.Add('builtin_zlib', "Use the builtin zlib library (yes/no)", 'yes') + +# Environment setup +opts.Add("CXX", "C++ compiler") +opts.Add("CC", "C compiler") +opts.Add("CCFLAGS", "Custom flags for the C and C++ compilers") +opts.Add("CFLAGS", "Custom flags for the C compiler") +opts.Add("LINKFLAGS", "Custom flags for the linker") + # add platform specific options for k in platform_opts.keys(): - opt_list = platform_opts[k] - for o in opt_list: - opts.Add(o[0],o[1],o[2]) + opt_list = platform_opts[k] + for o in opt_list: + opts.Add(o[0], o[1], o[2]) for x in module_list: - opts.Add('module_'+x+'_enabled', "Enable module '"+x+"' (yes/no)", "yes") + opts.Add('module_' + x + '_enabled', "Enable module '" + x + "' (yes/no)", "yes") -opts.Update(env_base) # update environment -Help(opts.GenerateHelpText(env_base)) # generate help +opts.Update(env_base) # update environment +Help(opts.GenerateHelpText(env_base)) # generate help # add default include paths -env_base.Append(CPPPATH=['#core','#core/math','#tools','#drivers','#']) +env_base.Append(CPPPATH=['#core', '#core/math', '#tools', '#drivers', '#']) # configure ENV for platform -env_base.platform_exporters=platform_exporters +env_base.platform_exporters = platform_exporters """ sys.path.append("./platform/"+env_base["platform"]) @@ -180,227 +193,223 @@ sys.path.remove("./platform/"+env_base["platform"]) sys.modules.pop('detect') """ -if (env_base['target']=='debug'): - env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']); - env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE']) +if (env_base['target'] == 'debug'): + env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) + env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE']) -if (env_base['deprecated']!='no'): - env_base.Append(CPPFLAGS=['-DENABLE_DEPRECATED']); +if (env_base['deprecated'] != 'no'): + env_base.Append(CPPFLAGS=['-DENABLE_DEPRECATED']) env_base.platforms = {} -selected_platform ="" +selected_platform = "" if env_base['platform'] != "": - selected_platform=env_base['platform'] + selected_platform = env_base['platform'] elif env_base['p'] != "": - selected_platform=env_base['p'] - env_base["platform"]=selected_platform - + selected_platform = env_base['p'] + env_base["platform"] = selected_platform if selected_platform in platform_list: - sys.path.append("./platform/"+selected_platform) - import detect - if "create" in dir(detect): - env = detect.create(env_base) - else: - env = env_base.Clone() - - if env['vsproj']=="yes": - env.vs_incs = [] - env.vs_srcs = [] - - def AddToVSProject( sources ): - for x in sources: - if type(x) == type(""): - fname = env.File(x).path - else: - fname = env.File(x)[0].path - pieces = fname.split(".") - if len(pieces)>0: - basename = pieces[0] - basename = basename.replace('\\\\','/') - env.vs_srcs = env.vs_srcs + [basename + ".cpp"] - env.vs_incs = env.vs_incs + [basename + ".h"] - #print basename - env.AddToVSProject = AddToVSProject - - env.extra_suffix="" - - if env["extra_suffix"] != '' : - env.extra_suffix += '.'+env["extra_suffix"] - - CCFLAGS = env.get('CCFLAGS', '') - env['CCFLAGS'] = '' - - env.Append(CCFLAGS=string.split(str(CCFLAGS))) - - CFLAGS = env.get('CFLAGS', '') - env['CFLAGS'] = '' - - env.Append(CFLAGS=string.split(str(CFLAGS))) - - LINKFLAGS = env.get('LINKFLAGS', '') - env['LINKFLAGS'] = '' - - env.Append(LINKFLAGS=string.split(str(LINKFLAGS))) - - flag_list = platform_flags[selected_platform] - for f in flag_list: - if not (f[0] in ARGUMENTS): # allow command line to override platform flags - env[f[0]] = f[1] - - #must happen after the flags, so when flags are used by configure, stuff happens (ie, ssl on x11) - detect.configure(env) - - #env['platform_libsuffix'] = env['LIBSUFFIX'] - - suffix="."+selected_platform - - if (env["target"]=="release"): - if (env["tools"]=="yes"): - print("Tools can only be built with targets 'debug' and 'release_debug'.") - sys.exit(255) - suffix+=".opt" - - env.Append(CCFLAGS=['-DNDEBUG']); - - elif (env["target"]=="release_debug"): - if (env["tools"]=="yes"): - suffix+=".opt.tools" - else: - suffix+=".opt.debug" - else: - if (env["tools"]=="yes"): - suffix+=".tools" - else: - suffix+=".debug" - - if env["arch"] != "": - suffix += "."+env["arch"] - elif (env["bits"]=="32"): - suffix+=".32" - elif (env["bits"]=="64"): - suffix+=".64" - elif (env["bits"]=="fat"): - suffix+=".fat" - - suffix+=env.extra_suffix - - env["PROGSUFFIX"]=suffix+env["PROGSUFFIX"] - env["OBJSUFFIX"]=suffix+env["OBJSUFFIX"] - env["LIBSUFFIX"]=suffix+env["LIBSUFFIX"] - env["SHLIBSUFFIX"]=suffix+env["SHLIBSUFFIX"] - - sys.path.remove("./platform/"+selected_platform) - sys.modules.pop('detect') - - - env.module_list=[] - - for x in module_list: - if env['module_'+x+'_enabled'] != "yes": - continue - tmppath="./modules/"+x - sys.path.append(tmppath) - env.current_module=x - import config - if (config.can_build(selected_platform)): - config.configure(env) - env.module_list.append(x) - sys.path.remove(tmppath) - sys.modules.pop('config') - - - if (env.use_ptrcall): - env.Append(CPPFLAGS=['-DPTRCALL_ENABLED']); - - # to test 64 bits compiltion - # env.Append(CPPFLAGS=['-m64']) - - if (env['tools']=='yes'): - env.Append(CPPFLAGS=['-DTOOLS_ENABLED']) - if (env['disable_3d']=='yes'): - env.Append(CPPFLAGS=['-D_3D_DISABLED']) - if (env['gdscript']=='yes'): - env.Append(CPPFLAGS=['-DGDSCRIPT_ENABLED']) - if (env['disable_advanced_gui']=='yes'): - env.Append(CPPFLAGS=['-DADVANCED_GUI_DISABLED']) - - if (env['minizip'] == 'yes'): - env.Append(CPPFLAGS=['-DMINIZIP_ENABLED']) - - if (env['xml']=='yes'): - env.Append(CPPFLAGS=['-DXML_ENABLED']) - - if (env['verbose']=='no'): - methods.no_verbose(sys,env) - - Export('env') - - #build subdirs, the build order is dependent on link order. - - SConscript("core/SCsub") - SConscript("servers/SCsub") - SConscript("scene/SCsub") - SConscript("tools/SCsub") - SConscript("drivers/SCsub") - SConscript("bin/SCsub") - - SConscript("modules/SCsub") - SConscript("main/SCsub") - - SConscript("platform/"+selected_platform+"/SCsub"); # build selected platform - - # Microsoft Visual Studio Project Generation - if (env['vsproj'])=="yes": - - AddToVSProject(env.core_sources) - AddToVSProject(env.main_sources) - AddToVSProject(env.modules_sources) - AddToVSProject(env.scene_sources) - AddToVSProject(env.servers_sources) - AddToVSProject(env.tool_sources) - - # this env flag won't work, it needs to be set in env_base=Environment(MSVC_VERSION='9.0') - # Even then, SCons still seems to ignore it and builds with the latest MSVC... - # That said, it's not needed to be set so far but I'm leaving it here so that this comment - # has a purpose. - #env['MSVS_VERSION']='9.0' - - - # Calls a CMD with /C(lose) and /V(delayed environment variable expansion) options. - # And runs vcvarsall bat for the propper arhitecture and scons for propper configuration - env['MSVSBUILDCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) ^& call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons platform=windows target=$(Configuration) tools=!tools! -j2' - env['MSVSREBUILDCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) & call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons platform=windows target=$(Configuration) tools=!tools! vsproj=yes -j2' - env['MSVSCLEANCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) ^& call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons --clean platform=windows target=$(Configuration) tools=!tools! -j2' - - # This version information (Win32, x64, Debug, Release, Release_Debug seems to be - # required for Visual Studio to understand that it needs to generate an NMAKE - # project. Do not modify without knowing what you are doing. - debug_variants = ['debug|Win32']+['debug|x64'] - release_variants = ['release|Win32']+['release|x64'] - release_debug_variants = ['release_debug|Win32']+['release_debug|x64'] - variants = debug_variants + release_variants + release_debug_variants - debug_targets = ['bin\\godot.windows.tools.32.exe']+['bin\\godot.windows.tools.64.exe'] - release_targets = ['bin\\godot.windows.opt.32.exe']+['bin\\godot.windows.opt.64.exe'] - release_debug_targets = ['bin\\godot.windows.opt.tools.32.exe']+['bin\\godot.windows.opt.tools.64.exe'] - targets = debug_targets + release_targets + release_debug_targets - msvproj = env.MSVSProject(target = ['#godot' + env['MSVSPROJECTSUFFIX'] ], - incs = env.vs_incs, - srcs = env.vs_srcs, - runfile = targets, - buildtarget = targets, - auto_build_solution=1, - variant = variants) + sys.path.append("./platform/" + selected_platform) + import detect + if "create" in dir(detect): + env = detect.create(env_base) + else: + env = env_base.Clone() + + if env['vsproj'] == "yes": + env.vs_incs = [] + env.vs_srcs = [] + + def AddToVSProject(sources): + for x in sources: + if type(x) == type(""): + fname = env.File(x).path + else: + fname = env.File(x)[0].path + pieces = fname.split(".") + if len(pieces) > 0: + basename = pieces[0] + basename = basename.replace('\\\\', '/') + env.vs_srcs = env.vs_srcs + [basename + ".cpp"] + env.vs_incs = env.vs_incs + [basename + ".h"] + # print basename + env.AddToVSProject = AddToVSProject + + env.extra_suffix = "" + + if env["extra_suffix"] != '': + env.extra_suffix += '.' + env["extra_suffix"] + + CCFLAGS = env.get('CCFLAGS', '') + env['CCFLAGS'] = '' + + env.Append(CCFLAGS=string.split(str(CCFLAGS))) + + CFLAGS = env.get('CFLAGS', '') + env['CFLAGS'] = '' + + env.Append(CFLAGS=string.split(str(CFLAGS))) + + LINKFLAGS = env.get('LINKFLAGS', '') + env['LINKFLAGS'] = '' + + env.Append(LINKFLAGS=string.split(str(LINKFLAGS))) + + flag_list = platform_flags[selected_platform] + for f in flag_list: + if not (f[0] in ARGUMENTS): # allow command line to override platform flags + env[f[0]] = f[1] + + # must happen after the flags, so when flags are used by configure, stuff happens (ie, ssl on x11) + detect.configure(env) + + #env['platform_libsuffix'] = env['LIBSUFFIX'] + + suffix = "." + selected_platform + + if (env["target"] == "release"): + if (env["tools"] == "yes"): + print("Tools can only be built with targets 'debug' and 'release_debug'.") + sys.exit(255) + suffix += ".opt" + + env.Append(CCFLAGS=['-DNDEBUG']) + + elif (env["target"] == "release_debug"): + if (env["tools"] == "yes"): + suffix += ".opt.tools" + else: + suffix += ".opt.debug" + else: + if (env["tools"] == "yes"): + suffix += ".tools" + else: + suffix += ".debug" + + if env["arch"] != "": + suffix += "." + env["arch"] + elif (env["bits"] == "32"): + suffix += ".32" + elif (env["bits"] == "64"): + suffix += ".64" + elif (env["bits"] == "fat"): + suffix += ".fat" + + suffix += env.extra_suffix + + env["PROGSUFFIX"] = suffix + env["PROGSUFFIX"] + env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"] + env["LIBSUFFIX"] = suffix + env["LIBSUFFIX"] + env["SHLIBSUFFIX"] = suffix + env["SHLIBSUFFIX"] + + sys.path.remove("./platform/" + selected_platform) + sys.modules.pop('detect') + + env.module_list = [] + + for x in module_list: + if env['module_' + x + '_enabled'] != "yes": + continue + tmppath = "./modules/" + x + sys.path.append(tmppath) + env.current_module = x + import config + if (config.can_build(selected_platform)): + config.configure(env) + env.module_list.append(x) + sys.path.remove(tmppath) + sys.modules.pop('config') + + if (env.use_ptrcall): + env.Append(CPPFLAGS=['-DPTRCALL_ENABLED']) + + # to test 64 bits compiltion + # env.Append(CPPFLAGS=['-m64']) + + if (env['tools'] == 'yes'): + env.Append(CPPFLAGS=['-DTOOLS_ENABLED']) + if (env['disable_3d'] == 'yes'): + env.Append(CPPFLAGS=['-D_3D_DISABLED']) + if (env['gdscript'] == 'yes'): + env.Append(CPPFLAGS=['-DGDSCRIPT_ENABLED']) + if (env['disable_advanced_gui'] == 'yes'): + env.Append(CPPFLAGS=['-DADVANCED_GUI_DISABLED']) + + if (env['minizip'] == 'yes'): + env.Append(CPPFLAGS=['-DMINIZIP_ENABLED']) + + if (env['xml'] == 'yes'): + env.Append(CPPFLAGS=['-DXML_ENABLED']) + + if (env['verbose'] == 'no'): + methods.no_verbose(sys, env) + + Export('env') + + # build subdirs, the build order is dependent on link order. + + SConscript("core/SCsub") + SConscript("servers/SCsub") + SConscript("scene/SCsub") + SConscript("tools/SCsub") + SConscript("drivers/SCsub") + SConscript("bin/SCsub") + + SConscript("modules/SCsub") + SConscript("main/SCsub") + + SConscript("platform/" + selected_platform + "/SCsub") # build selected platform + + # Microsoft Visual Studio Project Generation + if (env['vsproj']) == "yes": + + AddToVSProject(env.core_sources) + AddToVSProject(env.main_sources) + AddToVSProject(env.modules_sources) + AddToVSProject(env.scene_sources) + AddToVSProject(env.servers_sources) + AddToVSProject(env.tool_sources) + + # this env flag won't work, it needs to be set in env_base=Environment(MSVC_VERSION='9.0') + # Even then, SCons still seems to ignore it and builds with the latest MSVC... + # That said, it's not needed to be set so far but I'm leaving it here so that this comment + # has a purpose. + # env['MSVS_VERSION']='9.0' + + # Calls a CMD with /C(lose) and /V(delayed environment variable expansion) options. + # And runs vcvarsall bat for the propper arhitecture and scons for propper configuration + env['MSVSBUILDCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) ^& call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons platform=windows target=$(Configuration) tools=!tools! -j2' + env['MSVSREBUILDCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) & call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons platform=windows target=$(Configuration) tools=!tools! vsproj=yes -j2' + env['MSVSCLEANCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) ^& call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons --clean platform=windows target=$(Configuration) tools=!tools! -j2' + + # This version information (Win32, x64, Debug, Release, Release_Debug seems to be + # required for Visual Studio to understand that it needs to generate an NMAKE + # project. Do not modify without knowing what you are doing. + debug_variants = ['debug|Win32'] + ['debug|x64'] + release_variants = ['release|Win32'] + ['release|x64'] + release_debug_variants = ['release_debug|Win32'] + ['release_debug|x64'] + variants = debug_variants + release_variants + release_debug_variants + debug_targets = ['bin\\godot.windows.tools.32.exe'] + ['bin\\godot.windows.tools.64.exe'] + release_targets = ['bin\\godot.windows.opt.32.exe'] + ['bin\\godot.windows.opt.64.exe'] + release_debug_targets = ['bin\\godot.windows.opt.tools.32.exe'] + ['bin\\godot.windows.opt.tools.64.exe'] + targets = debug_targets + release_targets + release_debug_targets + msvproj = env.MSVSProject(target=['#godot' + env['MSVSPROJECTSUFFIX']], + incs=env.vs_incs, + srcs=env.vs_srcs, + runfile=targets, + buildtarget=targets, + auto_build_solution=1, + variant=variants) else: - print("No valid target platform selected.") - print("The following were detected:") - for x in platform_list: - print("\t"+x) - print("\nPlease run scons again with argument: platform=<string>") + print("No valid target platform selected.") + print("The following were detected:") + for x in platform_list: + print("\t" + x) + print("\nPlease run scons again with argument: platform=<string>") @@ -3,4 +3,4 @@ Import('env') Export('env') -SConscript('tests/SCsub'); +SConscript('tests/SCsub') diff --git a/bin/tests/SCsub b/bin/tests/SCsub index 26687599e1..03495c0649 100644 --- a/bin/tests/SCsub +++ b/bin/tests/SCsub @@ -2,13 +2,13 @@ Import('env') -env.tests_sources=[] -env.add_source_files(env.tests_sources,"*.cpp") +env.tests_sources = [] +env.add_source_files(env.tests_sources, "*.cpp") Export('env') -#SConscript('math/SCsub'); +# SConscript('math/SCsub'); -lib = env.Library("tests",env.tests_sources) +lib = env.Library("tests", env.tests_sources) env.Prepend(LIBS=[lib]) diff --git a/core/SCsub b/core/SCsub index cbed2e4f35..caae3a1c9b 100644 --- a/core/SCsub +++ b/core/SCsub @@ -2,66 +2,66 @@ Import('env') -env.core_sources=[] +env.core_sources = [] -gd_call="" -gd_inc="" +gd_call = "" +gd_inc = "" for x in env.global_defaults: - env.core_sources.append("#platform/"+x+"/globals/global_defaults.cpp") - gd_inc+='#include "platform/'+x+'/globals/global_defaults.h"\n' - gd_call+="\tregister_"+x+"_global_defaults();\n" + env.core_sources.append("#platform/" + x + "/globals/global_defaults.cpp") + gd_inc += '#include "platform/' + x + '/globals/global_defaults.h"\n' + gd_call += "\tregister_" + x + "_global_defaults();\n" -gd_cpp='#include "globals.h"\n' -gd_cpp+=gd_inc -gd_cpp+="void Globals::register_global_defaults() {\n"+gd_call+"\n}\n" +gd_cpp = '#include "globals.h"\n' +gd_cpp += gd_inc +gd_cpp += "void Globals::register_global_defaults() {\n" + gd_call + "\n}\n" -f = open("global_defaults.cpp","wb") +f = open("global_defaults.cpp", "wb") f.write(gd_cpp) f.close() import os txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0" if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ): - e=os.environ["SCRIPT_AES256_ENCRYPTION_KEY"] - txt = "" - ec_valid=True - if (len(e)!=64): - ec_valid=False - else: - - for i in range(len(e)>>1): - if (i>0): - txt+="," - txts="0x"+e[i*2:i*2+2] - try: - int(txts,16) - except: - ec_valid=False - txt+=txts - if (not ec_valid): - txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0" - print("Invalid AES256 encryption key, not 64 bits hex: "+e) + e = os.environ["SCRIPT_AES256_ENCRYPTION_KEY"] + txt = "" + ec_valid = True + if (len(e) != 64): + ec_valid = False + else: + + for i in range(len(e) >> 1): + if (i > 0): + txt += "," + txts = "0x" + e[i * 2:i * 2 + 2] + try: + int(txts, 16) + except: + ec_valid = False + txt += txts + if (not ec_valid): + txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0" + print("Invalid AES256 encryption key, not 64 bits hex: " + e) f = open("script_encryption_key.cpp", "wb") f.write("#include \"globals.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n") f.close() -env.add_source_files(env.core_sources,"*.cpp") +env.add_source_files(env.core_sources, "*.cpp") Export('env') import make_binders -env.Command(['method_bind.inc','method_bind_ext.inc'], 'make_binders.py', make_binders.run) +env.Command(['method_bind.inc', 'method_bind_ext.inc'], 'make_binders.py', make_binders.run) -SConscript('os/SCsub'); -SConscript('math/SCsub'); -SConscript('io/SCsub'); -SConscript('bind/SCsub'); +SConscript('os/SCsub') +SConscript('math/SCsub') +SConscript('io/SCsub') +SConscript('bind/SCsub') -lib = env.Library("core",env.core_sources) +lib = env.Library("core", env.core_sources) env.Prepend(LIBS=[lib]) diff --git a/core/bind/SCsub b/core/bind/SCsub index c2731d60e6..4efc902717 100644 --- a/core/bind/SCsub +++ b/core/bind/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.core_sources,"*.cpp") +env.add_source_files(env.core_sources, "*.cpp") Export('env') diff --git a/core/error_list.h b/core/error_list.h index cb531f527f..154af679fc 100644 --- a/core/error_list.h +++ b/core/error_list.h @@ -57,33 +57,33 @@ enum Error { ERR_FILE_MISSING_DEPENDENCIES, ERR_FILE_EOF, ERR_CANT_OPEN, ///< Can't open a resource/socket/file - ERR_CANT_CREATE, - ERROR_QUERY_FAILED, // (20) + ERR_CANT_CREATE, // (20) + ERROR_QUERY_FAILED, ERR_ALREADY_IN_USE, ERR_LOCKED, ///< resource is locked ERR_TIMEOUT, - ERR_CANT_CONNECT, - ERR_CANT_RESOLVE, // (25) + ERR_CANT_CONNECT, // (25) + ERR_CANT_RESOLVE, ERR_CONNECTION_ERROR, ERR_CANT_AQUIRE_RESOURCE, ERR_CANT_FORK, - ERR_INVALID_DATA, ///< Data passed is invalid - ERR_INVALID_PARAMETER, ///< Parameter passed is invalid (30) + ERR_INVALID_DATA, ///< Data passed is invalid (30) + ERR_INVALID_PARAMETER, ///< Parameter passed is invalid ERR_ALREADY_EXISTS, ///< When adding, item already exists ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, it item does not exist ERR_DATABASE_CANT_READ, ///< database is full - ERR_DATABASE_CANT_WRITE, ///< database is full - ERR_COMPILATION_FAILED, // (35) + ERR_DATABASE_CANT_WRITE, ///< database is full (35) + ERR_COMPILATION_FAILED, ERR_METHOD_NOT_FOUND, ERR_LINK_FAILED, ERR_SCRIPT_FAILED, - ERR_CYCLIC_LINK, - ERR_INVALID_DECLARATION, // (40) + ERR_CYCLIC_LINK, // (40) + ERR_INVALID_DECLARATION, ERR_DUPLICATE_SYMBOL, ERR_PARSE_ERROR, ERR_BUSY, - ERR_SKIP, - ERR_HELP, ///< user requested help!! (45) + ERR_SKIP, // (45) + ERR_HELP, ///< user requested help!! ERR_BUG, ///< a bug in the software certainly happened, due to a double check failing or unexpected behavior. ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames ERR_OMFG_THIS_IS_VERY_VERY_BAD, ///< shit happens, has never been used, though diff --git a/core/io/SCsub b/core/io/SCsub index 48cc9a5275..6789aa8bc6 100644 --- a/core/io/SCsub +++ b/core/io/SCsub @@ -2,8 +2,8 @@ Import('env') -env.add_source_files(env.core_sources,"*.cpp") -env.add_source_files(env.core_sources,"*.c") -#env.core_sources.append("io/fastlz.c") +env.add_source_files(env.core_sources, "*.cpp") +env.add_source_files(env.core_sources, "*.c") +# env.core_sources.append("io/fastlz.c") Export('env') diff --git a/core/make_binders.py b/core/make_binders.py index 7584722965..ef71c4264b 100644 --- a/core/make_binders.py +++ b/core/make_binders.py @@ -1,7 +1,7 @@ # -*- coding: ibm850 -*- -template_typed=""" +template_typed = """ #ifdef TYPED_METHOD_BIND template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$> class MethodBind$argc$$ifret R$$ifconst C$ : public MethodBind { @@ -77,7 +77,7 @@ MethodBind* create_method_bind($ifret R$ $ifnoret void$ (T::*p_method)($arg, P@$ #endif """ -template=""" +template = """ #ifndef TYPED_METHOD_BIND $iftempl template<$ $ifret class R$ $ifretargs ,$ $arg, class P@$ $iftempl >$ class MethodBind$argc$$ifret R$$ifconst C$ : public MethodBind { @@ -166,96 +166,95 @@ MethodBind* create_method_bind($ifret R$ $ifnoret void$ (T::*p_method)($arg, P@$ """ -def make_version(template,nargs,argmax,const,ret): - - intext=template - from_pos=0 - outtext="" - - while(True): - to_pos=intext.find("$",from_pos) - if (to_pos==-1): - outtext+=intext[from_pos:] - break - else: - outtext+=intext[from_pos:to_pos] - end=intext.find("$",to_pos+1) - if (end==-1): - break # ignore - macro=intext[to_pos+1:end] - cmd="" - data="" - - if (macro.find(" ")!=-1): - cmd=macro[0:macro.find(" ")] - data=macro[macro.find(" ")+1:] - else: - cmd=macro - - if (cmd=="argc"): - outtext+=str(nargs) - if (cmd=="ifret" and ret): - outtext+=data - if (cmd=="ifargs" and nargs): - outtext+=data - if (cmd=="ifretargs" and nargs and ret): - outtext+=data - if (cmd=="ifconst" and const): - outtext+=data - elif (cmd=="ifnoconst" and not const): - outtext+=data - elif (cmd=="ifnoret" and not ret): - outtext+=data - elif (cmd=="iftempl" and (nargs>0 or ret)): - outtext+=data - elif (cmd=="arg,"): - for i in range(1,nargs+1): - if (i>1): - outtext+=", " - outtext+=data.replace("@",str(i)) - elif (cmd=="arg"): - for i in range(1,nargs+1): - outtext+=data.replace("@",str(i)) - elif (cmd=="noarg"): - for i in range(nargs+1,argmax+1): - outtext+=data.replace("@",str(i)) - elif (cmd=="noarg"): - for i in range(nargs+1,argmax+1): - outtext+=data.replace("@",str(i)) - - from_pos=end+1 - - return outtext +def make_version(template, nargs, argmax, const, ret): + + intext = template + from_pos = 0 + outtext = "" + + while(True): + to_pos = intext.find("$", from_pos) + if (to_pos == -1): + outtext += intext[from_pos:] + break + else: + outtext += intext[from_pos:to_pos] + end = intext.find("$", to_pos + 1) + if (end == -1): + break # ignore + macro = intext[to_pos + 1:end] + cmd = "" + data = "" + + if (macro.find(" ") != -1): + cmd = macro[0:macro.find(" ")] + data = macro[macro.find(" ") + 1:] + else: + cmd = macro + + if (cmd == "argc"): + outtext += str(nargs) + if (cmd == "ifret" and ret): + outtext += data + if (cmd == "ifargs" and nargs): + outtext += data + if (cmd == "ifretargs" and nargs and ret): + outtext += data + if (cmd == "ifconst" and const): + outtext += data + elif (cmd == "ifnoconst" and not const): + outtext += data + elif (cmd == "ifnoret" and not ret): + outtext += data + elif (cmd == "iftempl" and (nargs > 0 or ret)): + outtext += data + elif (cmd == "arg,"): + for i in range(1, nargs + 1): + if (i > 1): + outtext += ", " + outtext += data.replace("@", str(i)) + elif (cmd == "arg"): + for i in range(1, nargs + 1): + outtext += data.replace("@", str(i)) + elif (cmd == "noarg"): + for i in range(nargs + 1, argmax + 1): + outtext += data.replace("@", str(i)) + elif (cmd == "noarg"): + for i in range(nargs + 1, argmax + 1): + outtext += data.replace("@", str(i)) + + from_pos = end + 1 + + return outtext def run(target, source, env): - versions=10 - versions_ext=6 - text="" - text_ext="" - - for i in range(0,versions+1): - - t="" - t+=make_version(template,i,versions,False,False) - t+=make_version(template_typed,i,versions,False,False) - t+=make_version(template,i,versions,False,True) - t+=make_version(template_typed,i,versions,False,True) - t+=make_version(template,i,versions,True,False) - t+=make_version(template_typed,i,versions,True,False) - t+=make_version(template,i,versions,True,True) - t+=make_version(template_typed,i,versions,True,True) - if (i>=versions_ext): - text_ext+=t - else: - text+=t - - - f=open(target[0].path,"w") - f.write(text) - f.close() - - f=open(target[1].path,"w") - f.write(text_ext) - f.close() + versions = 10 + versions_ext = 6 + text = "" + text_ext = "" + + for i in range(0, versions + 1): + + t = "" + t += make_version(template, i, versions, False, False) + t += make_version(template_typed, i, versions, False, False) + t += make_version(template, i, versions, False, True) + t += make_version(template_typed, i, versions, False, True) + t += make_version(template, i, versions, True, False) + t += make_version(template_typed, i, versions, True, False) + t += make_version(template, i, versions, True, True) + t += make_version(template_typed, i, versions, True, True) + if (i >= versions_ext): + text_ext += t + else: + text += t + + f = open(target[0].path, "w") + f.write(text) + f.close() + + f = open(target[1].path, "w") + f.write(text_ext) + f.close() diff --git a/core/math/SCsub b/core/math/SCsub index c2731d60e6..4efc902717 100644 --- a/core/math/SCsub +++ b/core/math/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.core_sources,"*.cpp") +env.add_source_files(env.core_sources, "*.cpp") Export('env') diff --git a/core/os/SCsub b/core/os/SCsub index c2731d60e6..4efc902717 100644 --- a/core/os/SCsub +++ b/core/os/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.core_sources,"*.cpp") +env.add_source_files(env.core_sources, "*.cpp") Export('env') diff --git a/doc/tools/doc_merge.py b/doc/tools/doc_merge.py index 536770bee4..57ac4bdcdd 100644 --- a/doc/tools/doc_merge.py +++ b/doc/tools/doc_merge.py @@ -6,206 +6,210 @@ import xml.etree.ElementTree as ET tree = ET.parse(sys.argv[1]) -old_doc=tree.getroot() +old_doc = tree.getroot() tree = ET.parse(sys.argv[2]) -new_doc=tree.getroot() +new_doc = tree.getroot() -f = file(sys.argv[3],"wb") -tab=0 +f = file(sys.argv[3], "wb") +tab = 0 -old_classes={} +old_classes = {} + + +def write_string(_f, text, newline=True): + for t in range(tab): + _f.write("\t") + _f.write(text) + if (newline): + _f.write("\n") -def write_string(_f, text,newline=True): - for t in range(tab): - _f.write("\t") - _f.write(text) - if (newline): - _f.write("\n") def escape(ret): - ret=ret.replace("&","&"); - ret=ret.replace("<",">"); - ret=ret.replace(">","<"); - ret=ret.replace("'","'"); - ret=ret.replace("\"","""); - return ret + ret = ret.replace("&", "&") + ret = ret.replace("<", ">") + ret = ret.replace(">", "<") + ret = ret.replace("'", "'") + ret = ret.replace("\"", """) + return ret def inc_tab(): - global tab - tab+=1 + global tab + tab += 1 + def dec_tab(): - global tab - tab-=1 - -write_string(f,'<?xml version="1.0" encoding="UTF-8" ?>') -write_string(f,'<doc version="'+new_doc.attrib["version"]+'">') - -def get_tag(node,name): - tag="" - if (name in node.attrib): - tag=' '+name+'="'+escape(node.attrib[name])+'" ' - return tag - -def find_method_descr(old_class,name): - - methods = old_class.find("methods") - if(methods!=None and len(list(methods))>0): - for m in list(methods): - if (m.attrib["name"]==name): - description=m.find("description") - if (description!=None and description.text.strip()!=""): - return description.text - - return None - -def find_signal_descr(old_class,name): - - signals = old_class.find("signals") - if(signals!=None and len(list(signals))>0): - for m in list(signals): - if (m.attrib["name"]==name): - description=m.find("description") - if (description!=None and description.text.strip()!=""): - return description.text - - return None - -def find_constant_descr(old_class,name): - - if (old_class==None): - return None - constants = old_class.find("constants") - if(constants!=None and len(list(constants))>0): - for m in list(constants): - if (m.attrib["name"]==name): - if (m.text.strip()!=""): - return m.text - return None + global tab + tab -= 1 + +write_string(f, '<?xml version="1.0" encoding="UTF-8" ?>') +write_string(f, '<doc version="' + new_doc.attrib["version"] + '">') -def write_class(c): - class_name = c.attrib["name"] - print("Parsing Class: "+class_name) - if (class_name in old_classes): - old_class=old_classes[class_name] - else: - old_class=None +def get_tag(node, name): + tag = "" + if (name in node.attrib): + tag = ' ' + name + '="' + escape(node.attrib[name]) + '" ' + return tag - category=get_tag(c,"category") - inherits=get_tag(c,"inherits") - write_string(f,'<class name="'+class_name+'" '+category+inherits+'>') - inc_tab() - write_string(f,"<brief_description>") +def find_method_descr(old_class, name): - if (old_class!=None): - old_brief_descr=old_class.find("brief_description") - if (old_brief_descr!=None): - write_string(f,escape(old_brief_descr.text.strip())) + methods = old_class.find("methods") + if(methods != None and len(list(methods)) > 0): + for m in list(methods): + if (m.attrib["name"] == name): + description = m.find("description") + if (description != None and description.text.strip() != ""): + return description.text + return None - write_string(f,"</brief_description>") - write_string(f,"<description>") - if (old_class!=None): - old_descr=old_class.find("description") - if (old_descr!=None): - write_string(f,escape(old_descr.text.strip())) +def find_signal_descr(old_class, name): - write_string(f,"</description>") + signals = old_class.find("signals") + if(signals != None and len(list(signals)) > 0): + for m in list(signals): + if (m.attrib["name"] == name): + description = m.find("description") + if (description != None and description.text.strip() != ""): + return description.text - methods = c.find("methods") - if(methods!=None and len(list(methods))>0): + return None - write_string(f,"<methods>") - inc_tab() - for m in list(methods): - qualifiers=get_tag(m,"qualifiers") +def find_constant_descr(old_class, name): - write_string(f,'<method name="'+escape(m.attrib["name"])+'" ' +qualifiers+'>') - inc_tab() + if (old_class == None): + return None + constants = old_class.find("constants") + if(constants != None and len(list(constants)) > 0): + for m in list(constants): + if (m.attrib["name"] == name): + if (m.text.strip() != ""): + return m.text + return None - for a in list(m): - if (a.tag=="return"): - typ=get_tag(a,"type") - write_string(f,'<return'+typ+'>'); - write_string(f,'</return>'); - elif (a.tag=="argument"): - default=get_tag(a,"default") +def write_class(c): + class_name = c.attrib["name"] + print("Parsing Class: " + class_name) + if (class_name in old_classes): + old_class = old_classes[class_name] + else: + old_class = None - write_string(f,'<argument index="'+a.attrib["index"]+'" name="'+escape(a.attrib["name"])+'" type="'+a.attrib["type"]+'"' +default+'>'); - write_string(f,'</argument>'); + category = get_tag(c, "category") + inherits = get_tag(c, "inherits") + write_string(f, '<class name="' + class_name + '" ' + category + inherits + '>') + inc_tab() - write_string(f,'<description>'); - if (old_class!=None): - old_method_descr=find_method_descr(old_class,m.attrib["name"]) - if (old_method_descr): - write_string(f,escape(escape(old_method_descr.strip()))) + write_string(f, "<brief_description>") - write_string(f,'</description>'); - dec_tab() - write_string(f,"</method>") - dec_tab() - write_string(f,"</methods>") + if (old_class != None): + old_brief_descr = old_class.find("brief_description") + if (old_brief_descr != None): + write_string(f, escape(old_brief_descr.text.strip())) - signals = c.find("signals") - if(signals!=None and len(list(signals))>0): + write_string(f, "</brief_description>") - write_string(f,"<signals>") - inc_tab() + write_string(f, "<description>") + if (old_class != None): + old_descr = old_class.find("description") + if (old_descr != None): + write_string(f, escape(old_descr.text.strip())) - for m in list(signals): + write_string(f, "</description>") - write_string(f,'<signal name="'+escape(m.attrib["name"])+'">') - inc_tab() + methods = c.find("methods") + if(methods != None and len(list(methods)) > 0): - for a in list(m): - if (a.tag=="argument"): + write_string(f, "<methods>") + inc_tab() - write_string(f,'<argument index="'+a.attrib["index"]+'" name="'+escape(a.attrib["name"])+'" type="'+a.attrib["type"]+'">'); - write_string(f,'</argument>'); + for m in list(methods): + qualifiers = get_tag(m, "qualifiers") - write_string(f,'<description>'); - if (old_class!=None): - old_signal_descr=find_signal_descr(old_class,m.attrib["name"]) - if (old_signal_descr): - write_string(f,escape(old_signal_descr.strip())) - write_string(f,'</description>'); - dec_tab() - write_string(f,"</signal>") - dec_tab() - write_string(f,"</signals>") + write_string(f, '<method name="' + escape(m.attrib["name"]) + '" ' + qualifiers + '>') + inc_tab() - constants = c.find("constants") - if(constants!=None and len(list(constants))>0): + for a in list(m): + if (a.tag == "return"): + typ = get_tag(a, "type") + write_string(f, '<return' + typ + '>') + write_string(f, '</return>') + elif (a.tag == "argument"): - write_string(f,"<constants>") - inc_tab() + default = get_tag(a, "default") - for m in list(constants): + write_string(f, '<argument index="' + a.attrib["index"] + '" name="' + escape(a.attrib["name"]) + '" type="' + a.attrib["type"] + '"' + default + '>') + write_string(f, '</argument>') - write_string(f,'<constant name="'+escape(m.attrib["name"])+'" value="'+m.attrib["value"]+'">') - old_constant_descr=find_constant_descr(old_class,m.attrib["name"]) - if (old_constant_descr): - write_string(f,escape(old_constant_descr.strip())) - write_string(f,"</constant>") + write_string(f, '<description>') + if (old_class != None): + old_method_descr = find_method_descr(old_class, m.attrib["name"]) + if (old_method_descr): + write_string(f, escape(escape(old_method_descr.strip()))) - dec_tab() - write_string(f,"</constants>") + write_string(f, '</description>') + dec_tab() + write_string(f, "</method>") + dec_tab() + write_string(f, "</methods>") - dec_tab() - write_string(f,"</class>") + signals = c.find("signals") + if(signals != None and len(list(signals)) > 0): -for c in list(old_doc): - old_classes[c.attrib["name"]]=c + write_string(f, "<signals>") + inc_tab() -for c in list(new_doc): - write_class(c) -write_string(f,'</doc>\n') + for m in list(signals): + + write_string(f, '<signal name="' + escape(m.attrib["name"]) + '">') + inc_tab() + + for a in list(m): + if (a.tag == "argument"): + write_string(f, '<argument index="' + a.attrib["index"] + '" name="' + escape(a.attrib["name"]) + '" type="' + a.attrib["type"] + '">') + write_string(f, '</argument>') + write_string(f, '<description>') + if (old_class != None): + old_signal_descr = find_signal_descr(old_class, m.attrib["name"]) + if (old_signal_descr): + write_string(f, escape(old_signal_descr.strip())) + write_string(f, '</description>') + dec_tab() + write_string(f, "</signal>") + dec_tab() + write_string(f, "</signals>") + + constants = c.find("constants") + if(constants != None and len(list(constants)) > 0): + + write_string(f, "<constants>") + inc_tab() + + for m in list(constants): + + write_string(f, '<constant name="' + escape(m.attrib["name"]) + '" value="' + m.attrib["value"] + '">') + old_constant_descr = find_constant_descr(old_class, m.attrib["name"]) + if (old_constant_descr): + write_string(f, escape(old_constant_descr.strip())) + write_string(f, "</constant>") + + dec_tab() + write_string(f, "</constants>") + + dec_tab() + write_string(f, "</class>") + +for c in list(old_doc): + old_classes[c.attrib["name"]] = c + +for c in list(new_doc): + write_class(c) +write_string(f, '</doc>\n') diff --git a/doc/tools/doc_status.py b/doc/tools/doc_status.py index f0ede405ce..e05bcd63e7 100755 --- a/doc/tools/doc_status.py +++ b/doc/tools/doc_status.py @@ -11,233 +11,235 @@ import xml.etree.ElementTree as ET ################################################################################ flags = { - 'c': platform.platform() != 'Windows', # Disable by default on windows, since we use ANSI escape codes - 'b': False, - 'g': False, - 's': False, - 'u': False, - 'h': False, - 'p': False, - 'o': True, - 'i': False, + 'c': platform.platform() != 'Windows', # Disable by default on windows, since we use ANSI escape codes + 'b': False, + 'g': False, + 's': False, + 'u': False, + 'h': False, + 'p': False, + 'o': True, + 'i': False, } flag_descriptions = { - 'c': 'Toggle colors when outputting.', - 'b': 'Toggle showing only not fully described classes.', - 'g': 'Toggle showing only completed classes.', - 's': 'Toggle showing comments about the status.', - 'u': 'Toggle URLs to docs.', - 'h': 'Show help and exit.', - 'p': 'Toggle showing percentage as well as counts.', - 'o': 'Toggle overall column.', - 'i': 'Toggle collapse of class items columns.', + 'c': 'Toggle colors when outputting.', + 'b': 'Toggle showing only not fully described classes.', + 'g': 'Toggle showing only completed classes.', + 's': 'Toggle showing comments about the status.', + 'u': 'Toggle URLs to docs.', + 'h': 'Show help and exit.', + 'p': 'Toggle showing percentage as well as counts.', + 'o': 'Toggle overall column.', + 'i': 'Toggle collapse of class items columns.', } long_flags = { - 'colors': 'c', - 'use-colors': 'c', + 'colors': 'c', + 'use-colors': 'c', - 'bad': 'b', - 'only-bad': 'b', + 'bad': 'b', + 'only-bad': 'b', - 'good': 'g', - 'only-good': 'g', + 'good': 'g', + 'only-good': 'g', - 'comments': 's', - 'status': 's', + 'comments': 's', + 'status': 's', - 'urls': 'u', - 'gen-url': 'u', + 'urls': 'u', + 'gen-url': 'u', - 'help': 'h', + 'help': 'h', - 'percent': 'p', - 'use-percentages': 'p', + 'percent': 'p', + 'use-percentages': 'p', - 'overall': 'o', - 'use-overall': 'o', + 'overall': 'o', + 'use-overall': 'o', - 'items': 'i', - 'collapse': 'i', + 'items': 'i', + 'collapse': 'i', } table_columns = ['name', 'brief_description', 'description', 'methods', 'constants', 'members', 'signals'] table_column_names = ['Name', 'Brief Desc.', 'Desc.', 'Methods', 'Constants', 'Members', 'Signals'] colors = { - 'name': [36], # cyan - 'part_big_problem': [4, 31], # underline, red - 'part_problem': [31], # red - 'part_mostly_good': [33], # yellow - 'part_good': [32], # green - 'url': [4, 34], # underline, blue - 'section': [1, 4], # bold, underline - 'state_off': [36], # cyan - 'state_on': [1, 35], # bold, magenta/plum + 'name': [36], # cyan + 'part_big_problem': [4, 31], # underline, red + 'part_problem': [31], # red + 'part_mostly_good': [33], # yellow + 'part_good': [32], # green + 'url': [4, 34], # underline, blue + 'section': [1, 4], # bold, underline + 'state_off': [36], # cyan + 'state_on': [1, 35], # bold, magenta/plum } overall_progress_description_weigth = 10 - ################################################################################ # Utils # ################################################################################ def validate_tag(elem, tag): - if elem.tag != tag: - print('Tag mismatch, expected "' + tag + '", got ' + elem.tag) - sys.exit(255) + if elem.tag != tag: + print('Tag mismatch, expected "' + tag + '", got ' + elem.tag) + sys.exit(255) + def color(color, string): - if flags['c']: - color_format = '' - for code in colors[color]: - color_format += '\033[' + str(code) + 'm' - return color_format + string + '\033[0m' - else: - return string + if flags['c']: + color_format = '' + for code in colors[color]: + color_format += '\033[' + str(code) + 'm' + return color_format + string + '\033[0m' + else: + return string ansi_escape = re.compile(r'\x1b[^m]*m') -def nonescape_len(s): - return len(ansi_escape.sub('', s)) +def nonescape_len(s): + return len(ansi_escape.sub('', s)) + ################################################################################ # Classes # ################################################################################ class ClassStatusProgress: - def __init__(self, described = 0, total = 0): - self.described = described - self.total = total - - def __add__(self, other): - return ClassStatusProgress(self.described + other.described, self.total + other.total) - - def increment(self, described): - if described: - self.described += 1 - self.total += 1 - - def is_ok(self): - return self.described >= self.total - - def to_configured_colored_string(self): - if flags['p']: - return self.to_colored_string('{percent}% ({has}/{total})', '{pad_percent}{pad_described}{s}{pad_total}') - else: - return self.to_colored_string() - - def to_colored_string(self, format='{has}/{total}', pad_format='{pad_described}{s}{pad_total}'): - ratio = self.described/self.total if self.total != 0 else 1 - percent = round(100*ratio) - s = format.format(has = str(self.described), total = str(self.total), percent = str(percent)) - if self.described >= self.total: - s = color('part_good', s) - elif self.described >= self.total/4*3: - s = color('part_mostly_good', s) - elif self.described > 0: - s = color('part_problem', s) - else: - s = color('part_big_problem', s) - pad_size = max(len(str(self.described)), len(str(self.total))) - pad_described = ''.ljust(pad_size - len(str(self.described))) - pad_percent = ''.ljust(3 - len(str(percent))) - pad_total = ''.ljust(pad_size - len(str(self.total))) - return pad_format.format(pad_described = pad_described, pad_total = pad_total, pad_percent = pad_percent, s = s) + + def __init__(self, described=0, total=0): + self.described = described + self.total = total + + def __add__(self, other): + return ClassStatusProgress(self.described + other.described, self.total + other.total) + + def increment(self, described): + if described: + self.described += 1 + self.total += 1 + + def is_ok(self): + return self.described >= self.total + + def to_configured_colored_string(self): + if flags['p']: + return self.to_colored_string('{percent}% ({has}/{total})', '{pad_percent}{pad_described}{s}{pad_total}') + else: + return self.to_colored_string() + + def to_colored_string(self, format='{has}/{total}', pad_format='{pad_described}{s}{pad_total}'): + ratio = self.described / self.total if self.total != 0 else 1 + percent = round(100 * ratio) + s = format.format(has=str(self.described), total=str(self.total), percent=str(percent)) + if self.described >= self.total: + s = color('part_good', s) + elif self.described >= self.total / 4 * 3: + s = color('part_mostly_good', s) + elif self.described > 0: + s = color('part_problem', s) + else: + s = color('part_big_problem', s) + pad_size = max(len(str(self.described)), len(str(self.total))) + pad_described = ''.ljust(pad_size - len(str(self.described))) + pad_percent = ''.ljust(3 - len(str(percent))) + pad_total = ''.ljust(pad_size - len(str(self.total))) + return pad_format.format(pad_described=pad_described, pad_total=pad_total, pad_percent=pad_percent, s=s) class ClassStatus: - def __init__(self, name=''): - self.name = name - self.has_brief_description = True - self.has_description = True - self.progresses = { - 'methods': ClassStatusProgress(), - 'constants': ClassStatusProgress(), - 'members': ClassStatusProgress(), - 'signals': ClassStatusProgress() - } - def __add__(self, other): - new_status = ClassStatus() - new_status.name = self.name - new_status.has_brief_description = self.has_brief_description and other.has_brief_description - new_status.has_description = self.has_description and other.has_description - for k in self.progresses: - new_status.progresses[k] = self.progresses[k] + other.progresses[k] - return new_status + def __init__(self, name=''): + self.name = name + self.has_brief_description = True + self.has_description = True + self.progresses = { + 'methods': ClassStatusProgress(), + 'constants': ClassStatusProgress(), + 'members': ClassStatusProgress(), + 'signals': ClassStatusProgress() + } - def is_ok(self): - ok = True - ok = ok and self.has_brief_description - ok = ok and self.has_description - for k in self.progresses: - ok = ok and self.progresses[k].is_ok() - return ok + def __add__(self, other): + new_status = ClassStatus() + new_status.name = self.name + new_status.has_brief_description = self.has_brief_description and other.has_brief_description + new_status.has_description = self.has_description and other.has_description + for k in self.progresses: + new_status.progresses[k] = self.progresses[k] + other.progresses[k] + return new_status - def make_output(self): - output = {} - output['name'] = color('name', self.name) + def is_ok(self): + ok = True + ok = ok and self.has_brief_description + ok = ok and self.has_description + for k in self.progresses: + ok = ok and self.progresses[k].is_ok() + return ok - ok_string = color('part_good', 'OK') - missing_string = color('part_big_problem', 'MISSING') + def make_output(self): + output = {} + output['name'] = color('name', self.name) - output['brief_description'] = ok_string if self.has_brief_description else missing_string - output['description'] = ok_string if self.has_description else missing_string + ok_string = color('part_good', 'OK') + missing_string = color('part_big_problem', 'MISSING') - description_progress = ClassStatusProgress( - (self.has_brief_description + self.has_description) * overall_progress_description_weigth, - 2 * overall_progress_description_weigth - ) - items_progress = ClassStatusProgress() + output['brief_description'] = ok_string if self.has_brief_description else missing_string + output['description'] = ok_string if self.has_description else missing_string - for k in ['methods', 'constants', 'members', 'signals']: - items_progress += self.progresses[k] - output[k] = self.progresses[k].to_configured_colored_string() + description_progress = ClassStatusProgress( + (self.has_brief_description + self.has_description) * overall_progress_description_weigth, + 2 * overall_progress_description_weigth + ) + items_progress = ClassStatusProgress() - output['items'] = items_progress.to_configured_colored_string() + for k in ['methods', 'constants', 'members', 'signals']: + items_progress += self.progresses[k] + output[k] = self.progresses[k].to_configured_colored_string() - output['overall'] = (description_progress + items_progress).to_colored_string('{percent}%', '{pad_percent}{s}') + output['items'] = items_progress.to_configured_colored_string() - if self.name.startswith('Total'): - output['url'] = color('url', 'http://docs.godotengine.org/en/latest/classes/_classes.html') - if flags['s']: - output['comment'] = color('part_good', 'ALL OK') - else: - output['url'] = color('url', 'http://docs.godotengine.org/en/latest/classes/class_{name}.html'.format(name=self.name.lower())) + output['overall'] = (description_progress + items_progress).to_colored_string('{percent}%', '{pad_percent}{s}') - if flags['s'] and not flags['g'] and self.is_ok(): - output['comment'] = color('part_good', 'ALL OK') + if self.name.startswith('Total'): + output['url'] = color('url', 'http://docs.godotengine.org/en/latest/classes/_classes.html') + if flags['s']: + output['comment'] = color('part_good', 'ALL OK') + else: + output['url'] = color('url', 'http://docs.godotengine.org/en/latest/classes/class_{name}.html'.format(name=self.name.lower())) - return output + if flags['s'] and not flags['g'] and self.is_ok(): + output['comment'] = color('part_good', 'ALL OK') - def generate_for_class(c): - status = ClassStatus() - status.name = c.attrib['name'] - for tag in list(c): + return output - if tag.tag == 'brief_description': - status.has_brief_description = len(tag.text.strip()) > 0 + def generate_for_class(c): + status = ClassStatus() + status.name = c.attrib['name'] + for tag in list(c): - elif tag.tag == 'description': - status.has_description = len(tag.text.strip()) > 0 + if tag.tag == 'brief_description': + status.has_brief_description = len(tag.text.strip()) > 0 - elif tag.tag in ['methods', 'signals']: - for sub_tag in list(tag): - descr = sub_tag.find('description') - status.progresses[tag.tag].increment(len(descr.text.strip()) > 0) + elif tag.tag == 'description': + status.has_description = len(tag.text.strip()) > 0 - elif tag.tag in ['constants', 'members']: - for sub_tag in list(tag): - status.progresses[tag.tag].increment(len(sub_tag.text.strip()) > 0) + elif tag.tag in ['methods', 'signals']: + for sub_tag in list(tag): + descr = sub_tag.find('description') + status.progresses[tag.tag].increment(len(descr.text.strip()) > 0) - elif tag.tag in ['theme_items']: - pass #Ignore those tags, since they seem to lack description at all + elif tag.tag in ['constants', 'members']: + for sub_tag in list(tag): + status.progresses[tag.tag].increment(len(sub_tag.text.strip()) > 0) - else: - print(tag.tag, tag.attrib) + elif tag.tag in ['theme_items']: + pass # Ignore those tags, since they seem to lack description at all - return status + else: + print(tag.tag, tag.attrib) + return status ################################################################################ @@ -248,31 +250,31 @@ input_file_list = [] input_class_list = [] for arg in sys.argv[1:]: - if arg.startswith('--'): - flags[long_flags[arg[2:]]] = not flags[long_flags[arg[2:]]] - elif arg.startswith('-'): - for f in arg[1:]: - flags[f] = not flags[f] - elif arg.endswith('.xml'): - input_file_list.append(arg) - else: - input_class_list.append(arg) + if arg.startswith('--'): + flags[long_flags[arg[2:]]] = not flags[long_flags[arg[2:]]] + elif arg.startswith('-'): + for f in arg[1:]: + flags[f] = not flags[f] + elif arg.endswith('.xml'): + input_file_list.append(arg) + else: + input_class_list.append(arg) if flags['i']: - for r in ['methods', 'constants', 'members', 'signals']: - index = table_columns.index(r) - del table_column_names[index] - del table_columns[index] - table_column_names.append('Items') - table_columns.append('items') + for r in ['methods', 'constants', 'members', 'signals']: + index = table_columns.index(r) + del table_column_names[index] + del table_columns[index] + table_column_names.append('Items') + table_columns.append('items') if flags['o'] == (not flags['i']): - table_column_names.append('Overall') - table_columns.append('overall') + table_column_names.append('Overall') + table_columns.append('overall') if flags['u']: - table_column_names.append('Docs URL') - table_columns.append('url') + table_column_names.append('Docs URL') + table_columns.append('url') ################################################################################ @@ -280,29 +282,28 @@ if flags['u']: ################################################################################ if len(input_file_list) < 1 or flags['h']: - if not flags['h']: - print(color('section', 'Invalid usage') + ': At least one classes.xml file is required') - print(color('section', 'Usage') + ': doc_status.py [flags] <classes.xml> [class names]') - print('\t< and > signify required parameters, while [ and ] signify optional parameters.') - print('\tNote that you can give more than one classes file, in which case they will be merged on-the-fly.') - print(color('section', 'Available flags') + ':') - possible_synonym_list = list(long_flags) - possible_synonym_list.sort() - flag_list = list(flags) - flag_list.sort() - for flag in flag_list: - synonyms = [color('name', '-' + flag)] - for synonym in possible_synonym_list: - if long_flags[synonym] == flag: - synonyms.append(color('name', '--' + synonym)) - - print(('{synonyms} (Currently '+color('state_'+('on' if flags[flag] else 'off'), '{value}')+')\n\t{description}').format( - synonyms = ', '.join(synonyms), - value = ('on' if flags[flag] else 'off'), - description = flag_descriptions[flag] - )) - sys.exit(0) - + if not flags['h']: + print(color('section', 'Invalid usage') + ': At least one classes.xml file is required') + print(color('section', 'Usage') + ': doc_status.py [flags] <classes.xml> [class names]') + print('\t< and > signify required parameters, while [ and ] signify optional parameters.') + print('\tNote that you can give more than one classes file, in which case they will be merged on-the-fly.') + print(color('section', 'Available flags') + ':') + possible_synonym_list = list(long_flags) + possible_synonym_list.sort() + flag_list = list(flags) + flag_list.sort() + for flag in flag_list: + synonyms = [color('name', '-' + flag)] + for synonym in possible_synonym_list: + if long_flags[synonym] == flag: + synonyms.append(color('name', '--' + synonym)) + + print(('{synonyms} (Currently ' + color('state_' + ('on' if flags[flag] else 'off'), '{value}') + ')\n\t{description}').format( + synonyms=', '.join(synonyms), + value=('on' if flags[flag] else 'off'), + description=flag_descriptions[flag] + )) + sys.exit(0) ################################################################################ @@ -313,26 +314,25 @@ class_names = [] classes = {} for file in input_file_list: - tree = ET.parse(file) - doc = tree.getroot() + tree = ET.parse(file) + doc = tree.getroot() - if 'version' not in doc.attrib: - print('Version missing from "doc"') - sys.exit(255) + if 'version' not in doc.attrib: + print('Version missing from "doc"') + sys.exit(255) - version = doc.attrib['version'] + version = doc.attrib['version'] - for c in list(doc): - if c.attrib['name'] in class_names: - continue - class_names.append(c.attrib['name']) - classes[c.attrib['name']] = c + for c in list(doc): + if c.attrib['name'] in class_names: + continue + class_names.append(c.attrib['name']) + classes[c.attrib['name']] = c class_names.sort() if len(input_class_list) < 1: - input_class_list = class_names - + input_class_list = class_names ################################################################################ @@ -346,34 +346,32 @@ table_column_chars = '|' total_status = ClassStatus('Total') for cn in input_class_list: - if not cn in classes: - print('Cannot find class ' + cn + '!') - sys.exit(255) - - c = classes[cn] - validate_tag(c, 'class') - status = ClassStatus.generate_for_class(c) + if not cn in classes: + print('Cannot find class ' + cn + '!') + sys.exit(255) - if flags['b'] and status.is_ok(): - continue - if flags['g'] and not status.is_ok(): - continue + c = classes[cn] + validate_tag(c, 'class') + status = ClassStatus.generate_for_class(c) - total_status = total_status + status - out = status.make_output() - row = [] - for column in table_columns: - if column in out: - row.append(out[column]) - else: - row.append('') + if flags['b'] and status.is_ok(): + continue + if flags['g'] and not status.is_ok(): + continue - if 'comment' in out and out['comment'] != '': - row.append(out['comment']) - - table.append(row) + total_status = total_status + status + out = status.make_output() + row = [] + for column in table_columns: + if column in out: + row.append(out[column]) + else: + row.append('') + if 'comment' in out and out['comment'] != '': + row.append(out['comment']) + table.append(row) ################################################################################ @@ -381,50 +379,49 @@ for cn in input_class_list: ################################################################################ if len(table) == 1: - print(color('part_big_problem', 'No classes suitable for printing!')) - sys.exit(0) + print(color('part_big_problem', 'No classes suitable for printing!')) + sys.exit(0) if len(table) > 2: - total_status.name = 'Total = {0}'.format(len(table) - 1) - out = total_status.make_output() - row = [] - for column in table_columns: - if column in out: - row.append(out[column]) - else: - row.append('') - table.append(row) + total_status.name = 'Total = {0}'.format(len(table) - 1) + out = total_status.make_output() + row = [] + for column in table_columns: + if column in out: + row.append(out[column]) + else: + row.append('') + table.append(row) table_column_sizes = [] for row in table: - for cell_i, cell in enumerate(row): - if cell_i >= len(table_column_sizes): - table_column_sizes.append(0) + for cell_i, cell in enumerate(row): + if cell_i >= len(table_column_sizes): + table_column_sizes.append(0) - table_column_sizes[cell_i] = max(nonescape_len(cell), table_column_sizes[cell_i]) + table_column_sizes[cell_i] = max(nonescape_len(cell), table_column_sizes[cell_i]) divider_string = table_row_chars[0] for cell_i in range(len(table[0])): - divider_string += table_row_chars[1] * (table_column_sizes[cell_i] + 2) + table_row_chars[0] + divider_string += table_row_chars[1] * (table_column_sizes[cell_i] + 2) + table_row_chars[0] print(divider_string) for row_i, row in enumerate(table): - row_string = table_column_chars - for cell_i, cell in enumerate(row): - padding_needed = table_column_sizes[cell_i] - nonescape_len(cell) + 2 - if cell_i == 0: - row_string += table_row_chars[2] + cell + table_row_chars[2]*(padding_needed-1) - else: - row_string += table_row_chars[2]*math.floor(padding_needed/2) + cell + table_row_chars[2]*math.ceil((padding_needed/2)) - row_string += table_column_chars + row_string = table_column_chars + for cell_i, cell in enumerate(row): + padding_needed = table_column_sizes[cell_i] - nonescape_len(cell) + 2 + if cell_i == 0: + row_string += table_row_chars[2] + cell + table_row_chars[2] * (padding_needed - 1) + else: + row_string += table_row_chars[2] * math.floor(padding_needed / 2) + cell + table_row_chars[2] * math.ceil((padding_needed / 2)) + row_string += table_column_chars - print(row_string) + print(row_string) - if row_i == 0 or row_i == len(table) - 2: - print(divider_string) + if row_i == 0 or row_i == len(table) - 2: + print(divider_string) print(divider_string) if total_status.is_ok() and not flags['g']: - print('All listed classes are ' + color('part_good', 'OK') + '!') - + print('All listed classes are ' + color('part_good', 'OK') + '!') diff --git a/doc/tools/makedoku.py b/doc/tools/makedoku.py index 7c3ca29af8..ad3bfd791d 100644 --- a/doc/tools/makedoku.py +++ b/doc/tools/makedoku.py @@ -8,308 +8,295 @@ input_list = [] for arg in sys.argv[1:]: - input_list.append(arg) + input_list.append(arg) if len(input_list) < 1: - print("usage: makedoku.py <classes.xml>") - sys.exit(0) + print("usage: makedoku.py <classes.xml>") + sys.exit(0) -def validate_tag(elem,tag): - if (elem.tag != tag): - print("Tag mismatch, expected '"+tag+"', got "+elem.tag); - sys.exit(255) +def validate_tag(elem, tag): + if (elem.tag != tag): + print("Tag mismatch, expected '" + tag + "', got " + elem.tag) + sys.exit(255) -class_names=[] -classes={} +class_names = [] +classes = {} -def make_class_list(class_list,columns): +def make_class_list(class_list, columns): - f=open("class_list.txt","wb") - prev=0 - col_max = len(class_list) / columns + 1 - print("col max is ", col_max) - col_count = 0 - row_count = 0 - last_initial = "" - fit_columns=[] + f = open("class_list.txt", "wb") + prev = 0 + col_max = len(class_list) / columns + 1 + print("col max is ", col_max) + col_count = 0 + row_count = 0 + last_initial = "" + fit_columns = [] - for n in range(0,columns): - fit_columns+=[[]] + for n in range(0, columns): + fit_columns += [[]] - indexers=[] - last_initial="" + indexers = [] + last_initial = "" - idx=0 - for n in class_list: - col = idx/col_max - if (col>=columns): - col=columns-1 - fit_columns[col]+=[n] - idx+=1 - if (n[:1]!=last_initial): - indexers+=[n] - last_initial=n[:1] + idx = 0 + for n in class_list: + col = idx / col_max + if (col >= columns): + col = columns - 1 + fit_columns[col] += [n] + idx += 1 + if (n[:1] != last_initial): + indexers += [n] + last_initial = n[:1] + row_max = 0 - row_max=0 + for n in range(0, columns): + if (len(fit_columns[n]) > row_max): + row_max = len(fit_columns[n]) - for n in range(0,columns): - if (len(fit_columns[n])>row_max): - row_max=len(fit_columns[n]) + for r in range(0, row_max): + s = "|" + for c in range(0, columns): + if (r >= len(fit_columns[c])): + continue + classname = fit_columns[c][r] + initial = classname[0] + if (classname in indexers): + s += "**" + initial + "**|" + else: + s += " |" - for r in range(0,row_max): - s="|" - for c in range(0,columns): - if (r>=len(fit_columns[c])): - continue + s += "[[" + classname.lower() + "|" + classname + "]]|" - classname = fit_columns[c][r] - initial=classname[0] - if (classname in indexers): - s+="**"+initial+"**|" - else: - s+=" |" - - s+="[["+classname.lower()+"|"+classname+"]]|" - - s+="\n" - f.write(s) + s += "\n" + f.write(s) def dokuize_text(txt): - return txt + return txt def dokuize_text(text): - pos=0 - while(True): - pos = text.find("[",pos) - if (pos==-1): - break - - endq_pos=text.find("]",pos+1) - if (endq_pos==-1): - break - - pre_text=text[:pos] - post_text=text[endq_pos+1:] - tag_text=text[pos+1:endq_pos] - - if (tag_text in class_names): - tag_text="[["+tag_text.lower()+"|"+tag_text+"]]" - else: #command - cmd=tag_text - space_pos=tag_text.find(" ") - if (cmd.find("html")==0): - cmd=tag_text[:space_pos] - param=tag_text[space_pos+1:] - tag_text="<"+param+">" - elif(cmd.find("method")==0): - cmd=tag_text[:space_pos] - param=tag_text[space_pos+1:] - - if (param.find(".")!=-1): - class_param,method_param=param.split(".") - tag_text="[["+class_param.lower()+"#"+method_param+"|"+class_param+'.'+method_param+"]]" - else: - tag_text="[[#"+param+"|"+param+"]]" - elif (cmd.find("image=")==0): - tag_text="{{"+cmd[6:]+"}}" - elif (cmd.find("url=")==0): - tag_text="[["+cmd[4:]+"|" - elif (cmd=="/url"): - tag_text="]]>" - elif (cmd=="center"): - tag_text="" - elif (cmd=="/center"): - tag_text="" - elif (cmd=="br"): - tag_text="\\\\\n" - elif (cmd=="i" or cmd=="/i"): - tag_text="//" - elif (cmd=="b" or cmd=="/b"): - tag_text="**" - elif (cmd=="u" or cmd=="/u"): - tag_text="__" - else: - tag_text="["+tag_text+"]" - - - text=pre_text+tag_text+post_text - pos=len(pre_text)+len(tag_text) - - #tnode = ET.SubElement(parent,"div") - #tnode.text=text - return text + pos = 0 + while(True): + pos = text.find("[", pos) + if (pos == -1): + break + + endq_pos = text.find("]", pos + 1) + if (endq_pos == -1): + break + + pre_text = text[:pos] + post_text = text[endq_pos + 1:] + tag_text = text[pos + 1:endq_pos] + + if (tag_text in class_names): + tag_text = "[[" + tag_text.lower() + "|" + tag_text + "]]" + else: # command + cmd = tag_text + space_pos = tag_text.find(" ") + if (cmd.find("html") == 0): + cmd = tag_text[:space_pos] + param = tag_text[space_pos + 1:] + tag_text = "<" + param + ">" + elif(cmd.find("method") == 0): + cmd = tag_text[:space_pos] + param = tag_text[space_pos + 1:] + + if (param.find(".") != -1): + class_param, method_param = param.split(".") + tag_text = "[[" + class_param.lower() + "#" + method_param + "|" + class_param + '.' + method_param + "]]" + else: + tag_text = "[[#" + param + "|" + param + "]]" + elif (cmd.find("image=") == 0): + tag_text = "{{" + cmd[6:] + "}}" + elif (cmd.find("url=") == 0): + tag_text = "[[" + cmd[4:] + "|" + elif (cmd == "/url"): + tag_text = "]]>" + elif (cmd == "center"): + tag_text = "" + elif (cmd == "/center"): + tag_text = "" + elif (cmd == "br"): + tag_text = "\\\\\n" + elif (cmd == "i" or cmd == "/i"): + tag_text = "//" + elif (cmd == "b" or cmd == "/b"): + tag_text = "**" + elif (cmd == "u" or cmd == "/u"): + tag_text = "__" + else: + tag_text = "[" + tag_text + "]" + + text = pre_text + tag_text + post_text + pos = len(pre_text) + len(tag_text) + + #tnode = ET.SubElement(parent,"div") + # tnode.text=text + return text def make_type(t): - global class_names - if (t in class_names): - return "[["+t.lower()+"|"+t+"]]" - return t - - -def make_method(f,name,m,declare,event=False): - - s=" * " - ret_type="void" - args=list(m) - mdata={} - mdata["argidx"]=[] - for a in args: - if (a.tag=="return"): - idx=-1 - elif (a.tag=="argument"): - idx=int(a.attrib["index"]) - else: - continue - - mdata["argidx"].append(idx) - mdata[idx]=a - - - - if (not event): - if (-1 in mdata["argidx"]): - s+=make_type(mdata[-1].attrib["type"]) - else: - s+="void" - s+=" " - - if (declare): - - #span.attrib["class"]="funcdecl" - #a=ET.SubElement(span,"a") - #a.attrib["name"]=name+"_"+m.attrib["name"] - #a.text=name+"::"+m.attrib["name"] - s+="**"+m.attrib["name"]+"**" - else: - s+="[[#"+m.attrib["name"]+"|"+m.attrib["name"]+"]]" - - s+="**(**" - argfound=False - for a in mdata["argidx"]: - arg=mdata[a] - if (a<0): - continue - if (a>0): - s+=", " - else: - s+=" " + global class_names + if (t in class_names): + return "[[" + t.lower() + "|" + t + "]]" + return t + + +def make_method(f, name, m, declare, event=False): + + s = " * " + ret_type = "void" + args = list(m) + mdata = {} + mdata["argidx"] = [] + for a in args: + if (a.tag == "return"): + idx = -1 + elif (a.tag == "argument"): + idx = int(a.attrib["index"]) + else: + continue + + mdata["argidx"].append(idx) + mdata[idx] = a + + if (not event): + if (-1 in mdata["argidx"]): + s += make_type(mdata[-1].attrib["type"]) + else: + s += "void" + s += " " + + if (declare): + + # span.attrib["class"]="funcdecl" + # a=ET.SubElement(span,"a") + # a.attrib["name"]=name+"_"+m.attrib["name"] + # a.text=name+"::"+m.attrib["name"] + s += "**" + m.attrib["name"] + "**" + else: + s += "[[#" + m.attrib["name"] + "|" + m.attrib["name"] + "]]" - s+=make_type(arg.attrib["type"]) - if ("name" in arg.attrib): - s+=" "+arg.attrib["name"] - else: - s+=" arg"+str(a) + s += "**(**" + argfound = False + for a in mdata["argidx"]: + arg = mdata[a] + if (a < 0): + continue + if (a > 0): + s += ", " + else: + s += " " - if ("default" in arg.attrib): - s+="="+arg.attrib["default"] + s += make_type(arg.attrib["type"]) + if ("name" in arg.attrib): + s += " " + arg.attrib["name"] + else: + s += " arg" + str(a) + if ("default" in arg.attrib): + s += "=" + arg.attrib["default"] - argfound=True + argfound = True - if (argfound): - s+=" " - s+="**)**" + if (argfound): + s += " " + s += "**)**" - if ("qualifiers" in m.attrib): - s+=" "+m.attrib["qualifiers"] + if ("qualifiers" in m.attrib): + s += " " + m.attrib["qualifiers"] - f.write(s+"\n") + f.write(s + "\n") def make_doku_class(node): - name = node.attrib["name"] - - f=open(name.lower()+".txt","wb") - - f.write("====== "+name+" ======\n") - - if ("inherits" in node.attrib): - inh=node.attrib["inherits"].strip() - f.write("**Inherits:** [["+inh.lower()+"|"+inh+"]]\\\\\n") - if ("category" in node.attrib): - f.write("**Category:** "+node.attrib["category"].strip()+"\\\\\n") - - briefd = node.find("brief_description") - if (briefd!=None): - f.write("===== Brief Description ======\n") - f.write( dokuize_text(briefd.text.strip())+"\n" ) - - methods = node.find("methods") - - if(methods!=None and len(list(methods))>0): - f.write("===== Member Functions ======\n") - for m in list(methods): - make_method(f,node.attrib["name"],m,False) - - events = node.find("signals") - if(events!=None and len(list(events))>0): - f.write("===== Signals ======\n") - for m in list(events): - make_method(f,node.attrib["name"],m,True,True) - - members = node.find("members") - - if(members!=None and len(list(members))>0): - f.write("===== Member Variables ======\n") - - for c in list(members): - s = " * " - s+=make_type(c.attrib["type"])+" " - s+="**"+c.attrib["name"]+"**" - if (c.text.strip()!=""): - s+=" - "+c.text.strip() - f.write(s+"\n") - - - - constants = node.find("constants") - if(constants!=None and len(list(constants))>0): - f.write("===== Numeric Constants ======\n") - for c in list(constants): - s = " * " - s+="**"+c.attrib["name"]+"**" - if ("value" in c.attrib): - s+=" = **"+c.attrib["value"]+"**" - if (c.text.strip()!=""): - s+=" - "+c.text.strip() - f.write(s+"\n") - - - descr=node.find("description") - if (descr!=None and descr.text.strip()!=""): - f.write("===== Description ======\n") - f.write(dokuize_text(descr.text.strip())+"\n") - - methods = node.find("methods") - - if(methods!=None and len(list(methods))>0): - f.write("===== Member Function Description ======\n") - for m in list(methods): - - d=m.find("description") - if (d==None or d.text.strip()==""): - continue - f.write("== "+m.attrib["name"]+" ==\n") - make_method(f,node.attrib["name"],m,False) - f.write("\\\\\n") - f.write(dokuize_text(d.text.strip())) - f.write("\n") - - - - - - """ + name = node.attrib["name"] + + f = open(name.lower() + ".txt", "wb") + + f.write("====== " + name + " ======\n") + + if ("inherits" in node.attrib): + inh = node.attrib["inherits"].strip() + f.write("**Inherits:** [[" + inh.lower() + "|" + inh + "]]\\\\\n") + if ("category" in node.attrib): + f.write("**Category:** " + node.attrib["category"].strip() + "\\\\\n") + + briefd = node.find("brief_description") + if (briefd != None): + f.write("===== Brief Description ======\n") + f.write(dokuize_text(briefd.text.strip()) + "\n") + + methods = node.find("methods") + + if(methods != None and len(list(methods)) > 0): + f.write("===== Member Functions ======\n") + for m in list(methods): + make_method(f, node.attrib["name"], m, False) + + events = node.find("signals") + if(events != None and len(list(events)) > 0): + f.write("===== Signals ======\n") + for m in list(events): + make_method(f, node.attrib["name"], m, True, True) + + members = node.find("members") + + if(members != None and len(list(members)) > 0): + f.write("===== Member Variables ======\n") + + for c in list(members): + s = " * " + s += make_type(c.attrib["type"]) + " " + s += "**" + c.attrib["name"] + "**" + if (c.text.strip() != ""): + s += " - " + c.text.strip() + f.write(s + "\n") + + constants = node.find("constants") + if(constants != None and len(list(constants)) > 0): + f.write("===== Numeric Constants ======\n") + for c in list(constants): + s = " * " + s += "**" + c.attrib["name"] + "**" + if ("value" in c.attrib): + s += " = **" + c.attrib["value"] + "**" + if (c.text.strip() != ""): + s += " - " + c.text.strip() + f.write(s + "\n") + + descr = node.find("description") + if (descr != None and descr.text.strip() != ""): + f.write("===== Description ======\n") + f.write(dokuize_text(descr.text.strip()) + "\n") + + methods = node.find("methods") + + if(methods != None and len(list(methods)) > 0): + f.write("===== Member Function Description ======\n") + for m in list(methods): + + d = m.find("description") + if (d == None or d.text.strip() == ""): + continue + f.write("== " + m.attrib["name"] + " ==\n") + make_method(f, node.attrib["name"], m, False) + f.write("\\\\\n") + f.write(dokuize_text(d.text.strip())) + f.write("\n") + + """ div=ET.Element("div") div.attrib["class"]="class"; @@ -487,28 +474,26 @@ def make_doku_class(node): return div """ for file in input_list: - tree = ET.parse(file) - doc=tree.getroot() + tree = ET.parse(file) + doc = tree.getroot() - if ("version" not in doc.attrib): - print("Version missing from 'doc'") - sys.exit(255) + if ("version" not in doc.attrib): + print("Version missing from 'doc'") + sys.exit(255) - version=doc.attrib["version"] + version = doc.attrib["version"] - for c in list(doc): - if (c.attrib["name"] in class_names): - continue - class_names.append(c.attrib["name"]) - classes[c.attrib["name"]]=c + for c in list(doc): + if (c.attrib["name"] in class_names): + continue + class_names.append(c.attrib["name"]) + classes[c.attrib["name"]] = c class_names.sort() -make_class_list(class_names,4) +make_class_list(class_names, 4) for cn in class_names: - c=classes[cn] - make_doku_class(c) - - + c = classes[cn] + make_doku_class(c) diff --git a/doc/tools/makehtml.py b/doc/tools/makehtml.py index b0a8cbda88..3ecb8220cb 100644 --- a/doc/tools/makehtml.py +++ b/doc/tools/makehtml.py @@ -6,676 +6,647 @@ import xml.etree.ElementTree as ET from xml.sax.saxutils import escape, unescape html_escape_table = { - '"': """, - "'": "'" + '"': """, + "'": "'" } -html_unescape_table = {v:k for k, v in html_escape_table.items()} +html_unescape_table = {v: k for k, v in html_escape_table.items()} + def html_escape(text): - return escape(text, html_escape_table) + return escape(text, html_escape_table) + def html_unescape(text): - return unescape(text, html_unescape_table) + return unescape(text, html_unescape_table) input_list = [] -single_page=True +single_page = True for arg in sys.argv[1:]: - if arg[:1] == "-": - if arg[1:] == "multipage": - single_page = False - if arg[1:] == "singlepage": - single_page = True - else: - input_list.append(arg) + if arg[:1] == "-": + if arg[1:] == "multipage": + single_page = False + if arg[1:] == "singlepage": + single_page = True + else: + input_list.append(arg) if len(input_list) < 1: - print("usage: makehtml.py <classes.xml>") - sys.exit(0) + print("usage: makehtml.py <classes.xml>") + sys.exit(0) -def validate_tag(elem,tag): - if (elem.tag != tag): - print("Tag mismatch, expected '"+tag+"', got "+elem.tag); - sys.exit(255) +def validate_tag(elem, tag): + if (elem.tag != tag): + print("Tag mismatch, expected '" + tag + "', got " + elem.tag) + sys.exit(255) -def make_html_bottom(body): - #make_html_top(body,True) - ET.SubElement(body,"hr") - copyright = ET.SubElement(body,"span") - copyright.text = "Copyright 2008-2010 Codenix SRL" - -def make_html_top(body,bottom=False): - - if (bottom): - ET.SubElement(body,"hr") - - table = ET.SubElement(body,"table") - table.attrib["class"]="top_table" - tr = ET.SubElement(table,"tr") - td = ET.SubElement(tr,"td") - td.attrib["class"]="top_table" - - img = ET.SubElement(td,"image") - img.attrib["src"]="images/logo.png" - td = ET.SubElement(tr,"td") - td.attrib["class"]="top_table" - a = ET.SubElement(td,"a") - a.attrib["href"]="index.html" - a.text="Index" - td = ET.SubElement(tr,"td") - td.attrib["class"]="top_table" - a = ET.SubElement(td,"a") - a.attrib["href"]="alphabetical.html" - a.text="Classes" - td = ET.SubElement(tr,"td") - td.attrib["class"]="top_table" - a = ET.SubElement(td,"a") - a.attrib["href"]="category.html" - a.text="Categories" - td = ET.SubElement(tr,"td") - a = ET.SubElement(td,"a") - a.attrib["href"]="inheritance.html" - a.text="Inheritance" - if (not bottom): - ET.SubElement(body,"hr") - - - - -def make_html_class_list(class_list,columns): - - div=ET.Element("div") - div.attrib["class"]="ClassList"; - - h1=ET.SubElement(div,"h2") - h1.text="Alphabetical Class List" - - table=ET.SubElement(div,"table") - table.attrib["class"]="class_table" - table.attrib["width"]="100%" - prev=0 - - col_max = len(class_list) / columns + 1 - print("col max is ", col_max) - col_count = 0 - row_count = 0 - last_initial = "" - fit_columns=[] - - for n in range(0,columns): - fit_columns+=[[]] - - indexers=[] - last_initial="" - - idx=0 - for n in class_list: - col = int(idx/col_max) - if (col>=columns): - col=columns-1 - fit_columns[col]+=[n] - idx+=1 - if (n[:1]!=last_initial): - indexers+=[n] - last_initial=n[:1] - - row_max=0 - - for n in range(0,columns): - if (len(fit_columns[n])>row_max): - row_max=len(fit_columns[n]) - - - for r in range(0,row_max): - tr = ET.SubElement(table,"tr") - for c in range(0,columns): - tdi = ET.SubElement(tr,"td") - tdi.attrib["align"]="right" - td = ET.SubElement(tr,"td") - if (r>=len(fit_columns[c])): - continue - - classname = fit_columns[c][r] - print(classname) - if (classname in indexers): - - span = ET.SubElement(tdi, "span") - span.attrib["class"] = "class_index_letter" - span.text = classname[:1].upper() - if (single_page): - link="#"+classname +def make_html_bottom(body): + # make_html_top(body,True) + ET.SubElement(body, "hr") + copyright = ET.SubElement(body, "span") + copyright.text = "Copyright 2008-2010 Codenix SRL" + + +def make_html_top(body, bottom=False): + + if (bottom): + ET.SubElement(body, "hr") + + table = ET.SubElement(body, "table") + table.attrib["class"] = "top_table" + tr = ET.SubElement(table, "tr") + td = ET.SubElement(tr, "td") + td.attrib["class"] = "top_table" + + img = ET.SubElement(td, "image") + img.attrib["src"] = "images/logo.png" + td = ET.SubElement(tr, "td") + td.attrib["class"] = "top_table" + a = ET.SubElement(td, "a") + a.attrib["href"] = "index.html" + a.text = "Index" + td = ET.SubElement(tr, "td") + td.attrib["class"] = "top_table" + a = ET.SubElement(td, "a") + a.attrib["href"] = "alphabetical.html" + a.text = "Classes" + td = ET.SubElement(tr, "td") + td.attrib["class"] = "top_table" + a = ET.SubElement(td, "a") + a.attrib["href"] = "category.html" + a.text = "Categories" + td = ET.SubElement(tr, "td") + a = ET.SubElement(td, "a") + a.attrib["href"] = "inheritance.html" + a.text = "Inheritance" + if (not bottom): + ET.SubElement(body, "hr") + + +def make_html_class_list(class_list, columns): + + div = ET.Element("div") + div.attrib["class"] = "ClassList" + + h1 = ET.SubElement(div, "h2") + h1.text = "Alphabetical Class List" + + table = ET.SubElement(div, "table") + table.attrib["class"] = "class_table" + table.attrib["width"] = "100%" + prev = 0 + + col_max = len(class_list) / columns + 1 + print("col max is ", col_max) + col_count = 0 + row_count = 0 + last_initial = "" + fit_columns = [] + + for n in range(0, columns): + fit_columns += [[]] + + indexers = [] + last_initial = "" + + idx = 0 + for n in class_list: + col = int(idx / col_max) + if (col >= columns): + col = columns - 1 + fit_columns[col] += [n] + idx += 1 + if (n[:1] != last_initial): + indexers += [n] + last_initial = n[:1] + + row_max = 0 + + for n in range(0, columns): + if (len(fit_columns[n]) > row_max): + row_max = len(fit_columns[n]) + + for r in range(0, row_max): + tr = ET.SubElement(table, "tr") + for c in range(0, columns): + tdi = ET.SubElement(tr, "td") + tdi.attrib["align"] = "right" + td = ET.SubElement(tr, "td") + if (r >= len(fit_columns[c])): + continue + + classname = fit_columns[c][r] + print(classname) + if (classname in indexers): + + span = ET.SubElement(tdi, "span") + span.attrib["class"] = "class_index_letter" + span.text = classname[:1].upper() + + if (single_page): + link = "#" + classname + else: + link = classname + ".html" + + a = ET.SubElement(td, "a") + a.attrib["href"] = link + a.text = classname + + if (not single_page): + cat_class_list = ET.Element("html") + csscc = ET.SubElement(cat_class_list, "link") + csscc.attrib["href"] = "main.css" + csscc.attrib["rel"] = "stylesheet" + csscc.attrib["type"] = "text/css" + bodycc = ET.SubElement(cat_class_list, "body") + make_html_top(bodycc) + + cat_class_parent = bodycc else: - link=classname+".html" - - a=ET.SubElement(td,"a") - a.attrib["href"]=link - a.text=classname - - - if (not single_page): - cat_class_list=ET.Element("html") - csscc = ET.SubElement(cat_class_list, "link") - csscc.attrib["href"] = "main.css" - csscc.attrib["rel"] = "stylesheet" - csscc.attrib["type"] = "text/css" - bodycc = ET.SubElement(cat_class_list, "body") - make_html_top(bodycc) - - cat_class_parent=bodycc - else: - cat_class_parent=div - - - - - h1=ET.SubElement(cat_class_parent,"h2") - h1.text="Class List By Category" - - class_cat_table={} - class_cat_list=[] - - for c in class_list: - clss = classes[c] - if ("category" in clss.attrib): - class_cat=clss.attrib["category"] - else: - class_cat="Core" - if (class_cat.find("/")!=-1): - class_cat=class_cat[class_cat.rfind("/")+1:] - if (not class_cat in class_cat_list): - class_cat_list.append(class_cat) - class_cat_table[class_cat]=[] - class_cat_table[class_cat].append(c) - - class_cat_list.sort() - - ct = ET.SubElement(cat_class_parent,"table") - for cl in class_cat_list: - l = class_cat_table[cl] - l.sort() - tr = ET.SubElement(ct,"tr") - tr.attrib["class"]="category_title" - td = ET.SubElement(ct,"td") - td.attrib["class"]="category_title" - - a = ET.SubElement(td,"a") - a.attrib["class"]="category_title" - a.text=cl - a.attrib["name"]="CATEGORY_"+cl - - td = ET.SubElement(ct,"td") - td.attrib["class"]="category_title" - - for clt in l: - tr = ET.SubElement(ct,"tr") - td = ET.SubElement(ct,"td") - make_type(clt,td) - clss=classes[clt] - bd = clss.find("brief_description") - bdtext="" - if (bd!=None): - bdtext=bd.text - td = ET.SubElement(ct,"td") - td.text=bdtext - - if (not single_page): - make_html_bottom(bodycc) - catet_out = ET.ElementTree(cat_class_list) - catet_out.write("category.html") - - - if (not single_page): - inh_class_list=ET.Element("html") - cssic = ET.SubElement(inh_class_list, "link") - cssic.attrib["href"] = "main.css" - cssic.attrib["rel"] = "stylesheet" - cssic.attrib["type"] = "text/css" - bodyic = ET.SubElement(inh_class_list, "body") - make_html_top(bodyic) - inh_class_parent=bodyic - else: - inh_class_parent=div - - - - - h1=ET.SubElement(inh_class_parent,"h2") - h1.text="Class List By Inheritance" - - itemlist = ET.SubElement(inh_class_parent,"list") - - class_inh_table={} - - def add_class(clss): - if (clss.attrib["name"] in class_inh_table): - return #already added - parent_list=None - - if ("inherits" in clss.attrib): - inhc = clss.attrib["inherits"] - if (not (inhc in class_inh_table)): - add_class(classes[inhc]) - - parent_list = class_inh_table[inhc].find("div") - if (parent_list == None): - parent_div = ET.SubElement(class_inh_table[inhc],"div") - parent_list = ET.SubElement(parent_div,"list") - parent_div.attrib["class"]="inh_class_list" + cat_class_parent = div + + h1 = ET.SubElement(cat_class_parent, "h2") + h1.text = "Class List By Category" + + class_cat_table = {} + class_cat_list = [] + + for c in class_list: + clss = classes[c] + if ("category" in clss.attrib): + class_cat = clss.attrib["category"] + else: + class_cat = "Core" + if (class_cat.find("/") != -1): + class_cat = class_cat[class_cat.rfind("/") + 1:] + if (not class_cat in class_cat_list): + class_cat_list.append(class_cat) + class_cat_table[class_cat] = [] + class_cat_table[class_cat].append(c) + + class_cat_list.sort() + + ct = ET.SubElement(cat_class_parent, "table") + for cl in class_cat_list: + l = class_cat_table[cl] + l.sort() + tr = ET.SubElement(ct, "tr") + tr.attrib["class"] = "category_title" + td = ET.SubElement(ct, "td") + td.attrib["class"] = "category_title" + + a = ET.SubElement(td, "a") + a.attrib["class"] = "category_title" + a.text = cl + a.attrib["name"] = "CATEGORY_" + cl + + td = ET.SubElement(ct, "td") + td.attrib["class"] = "category_title" + + for clt in l: + tr = ET.SubElement(ct, "tr") + td = ET.SubElement(ct, "td") + make_type(clt, td) + clss = classes[clt] + bd = clss.find("brief_description") + bdtext = "" + if (bd != None): + bdtext = bd.text + td = ET.SubElement(ct, "td") + td.text = bdtext + + if (not single_page): + make_html_bottom(bodycc) + catet_out = ET.ElementTree(cat_class_list) + catet_out.write("category.html") + + if (not single_page): + inh_class_list = ET.Element("html") + cssic = ET.SubElement(inh_class_list, "link") + cssic.attrib["href"] = "main.css" + cssic.attrib["rel"] = "stylesheet" + cssic.attrib["type"] = "text/css" + bodyic = ET.SubElement(inh_class_list, "body") + make_html_top(bodyic) + inh_class_parent = bodyic else: - parent_list = parent_list.find("list") + inh_class_parent = div + h1 = ET.SubElement(inh_class_parent, "h2") + h1.text = "Class List By Inheritance" - else: - parent_list=itemlist - - item = ET.SubElement(parent_list,"li") -# item.attrib["class"]="inh_class_list" - class_inh_table[clss.attrib["name"]]=item - make_type(clss.attrib["name"],item) - - - for c in class_list: - add_class(classes[c]) - - if (not single_page): - make_html_bottom(bodyic) - catet_out = ET.ElementTree(inh_class_list) - catet_out.write("inheritance.html") + itemlist = ET.SubElement(inh_class_parent, "list") + class_inh_table = {} + def add_class(clss): + if (clss.attrib["name"] in class_inh_table): + return # already added + parent_list = None + if ("inherits" in clss.attrib): + inhc = clss.attrib["inherits"] + if (not (inhc in class_inh_table)): + add_class(classes[inhc]) + parent_list = class_inh_table[inhc].find("div") + if (parent_list == None): + parent_div = ET.SubElement(class_inh_table[inhc], "div") + parent_list = ET.SubElement(parent_div, "list") + parent_div.attrib["class"] = "inh_class_list" + else: + parent_list = parent_list.find("list") - #h1=ET.SubElement(div,"h2") - #h1.text="Class List By Inheritance" + else: + parent_list = itemlist - return div - - -def make_type(p_type,p_parent): - if (p_type=="RefPtr"): - p_type="Resource" - - if (p_type in class_names): - a=ET.SubElement(p_parent,"a") - a.attrib["class"]="datatype_existing" - a.text=p_type+" " - if (single_page): - a.attrib["href"]="#"+p_type - else: - a.attrib["href"]=p_type+".html" - else: - span=ET.SubElement(p_parent,"span") - span.attrib["class"]="datatype" - span.text=p_type+" " + item = ET.SubElement(parent_list, "li") +# item.attrib["class"]="inh_class_list" + class_inh_table[clss.attrib["name"]] = item + make_type(clss.attrib["name"], item) + for c in class_list: + add_class(classes[c]) + if (not single_page): + make_html_bottom(bodyic) + catet_out = ET.ElementTree(inh_class_list) + catet_out.write("inheritance.html") -def make_text_def(class_name,parent,text): - text = html_escape(text) - pos=0 - while(True): - pos = text.find("[",pos) - if (pos==-1): - break + # h1=ET.SubElement(div,"h2") + #h1.text="Class List By Inheritance" - endq_pos=text.find("]",pos+1) - if (endq_pos==-1): - break + return div - pre_text=text[:pos] - post_text=text[endq_pos+1:] - tag_text=text[pos+1:endq_pos] - if (tag_text in class_names): - if (single_page): - tag_text='<a href="#'+tag_text+'">'+tag_text+'</a>' - else: - tag_text='<a href="'+tag_text+'.html">'+tag_text+'</a>' - else: #command - cmd=tag_text - space_pos=tag_text.find(" ") - if (cmd.find("html")==0): - cmd=tag_text[:space_pos] - param=tag_text[space_pos+1:] - tag_text="<"+param+">" - elif(cmd.find("method")==0): - cmd=tag_text[:space_pos] - param=tag_text[space_pos+1:] +def make_type(p_type, p_parent): + if (p_type == "RefPtr"): + p_type = "Resource" - if (not single_page and param.find(".")!=-1): - class_param,method_param=param.split(".") - tag_text=tag_text='<a href="'+class_param+'.html#'+class_param+"_"+method_param+'">'+class_param+'.'+method_param+'()</a>' + if (p_type in class_names): + a = ET.SubElement(p_parent, "a") + a.attrib["class"] = "datatype_existing" + a.text = p_type + " " + if (single_page): + a.attrib["href"] = "#" + p_type + else: + a.attrib["href"] = p_type + ".html" else: - tag_text=tag_text='<a href="#'+class_name+"_"+param+'">'+class_name+'.'+param+'()</a>' - elif (cmd.find("image=")==0): - print("found image: "+cmd) - tag_text="<img src="+cmd[6:]+"/>" - elif (cmd.find("url=")==0): - tag_text="<a href="+cmd[4:]+">" - elif (cmd=="/url"): - tag_text="</a>" - elif (cmd=="center"): - tag_text="<div align=\"center\">" - elif (cmd=="/center"): - tag_text="</div>" - elif (cmd=="br"): - tag_text="<br/>" - elif (cmd=="i" or cmd=="/i" or cmd=="b" or cmd=="/b" or cmd=="u" or cmd=="/u"): - tag_text="<"+tag_text+">" #html direct mapping - else: - tag_text="["+tag_text+"]" - - - text=pre_text+tag_text+post_text - pos=len(pre_text)+len(tag_text) - - #tnode = ET.SubElement(parent,"div") - #tnode.text=text - text="<div class=\"description\">"+text+"</div>" - try: - tnode=ET.XML(text) - parent.append(tnode) - except: - print("Error parsing description text: '"+text+"'") - sys.exit(255) - - - return tnode - - - - -def make_method_def(name,m,declare,event=False): - - mdata={} - - - if (not declare): - div=ET.Element("tr") - div.attrib["class"]="method" - ret_parent=ET.SubElement(div,"td") - ret_parent.attrib["align"]="right" - func_parent=ET.SubElement(div,"td") - else: - div=ET.Element("div") - div.attrib["class"]="method" - ret_parent=div - func_parent=div - - mdata["argidx"]=[] - mdata["name"]=m.attrib["name"] - qualifiers="" - if ("qualifiers" in m.attrib): - qualifiers=m.attrib["qualifiers"] - - args=list(m) - for a in args: - if (a.tag=="return"): - idx=-1 - elif (a.tag=="argument"): - idx=int(a.attrib["index"]) - else: - continue - - mdata["argidx"].append(idx) - mdata[idx]=a - - if (not event): - if (-1 in mdata["argidx"]): - make_type(mdata[-1].attrib["type"],ret_parent) - mdata["argidx"].remove(-1) - else: - make_type("void",ret_parent) - - span=ET.SubElement(func_parent,"span") - if (declare): - span.attrib["class"]="funcdecl" - a=ET.SubElement(span,"a") - a.attrib["name"]=name+"_"+m.attrib["name"] - a.text=name+"::"+m.attrib["name"] - else: - span.attrib["class"]="identifier funcdef" - a=ET.SubElement(span,"a") - a.attrib["href"]="#"+name+"_"+m.attrib["name"] - a.text=m.attrib["name"] - - span=ET.SubElement(func_parent,"span") - span.attrib["class"]="symbol" - span.text=" (" - - for a in mdata["argidx"]: - arg=mdata[a] - if (a>0): - span=ET.SubElement(func_parent,"span") - span.text=", " - else: - span=ET.SubElement(func_parent,"span") - span.text=" " - - - make_type(arg.attrib["type"],func_parent) - - span=ET.SubElement(func_parent,"span") - span.text=arg.attrib["name"] - if ("default" in arg.attrib): - span.text=span.text+"="+arg.attrib["default"] - - - span=ET.SubElement(func_parent,"span") - span.attrib["class"]="symbol" - if (len(mdata["argidx"])): - span.text=" )" - else: - span.text=")" - - if (qualifiers): - span=ET.SubElement(func_parent,"span") - span.attrib["class"]="qualifier" - span.text=" "+qualifiers - - return div - - -def make_html_class(node): - - div=ET.Element("div") - div.attrib["class"]="class"; - - a=ET.SubElement(div,"a") - a.attrib["name"]=node.attrib["name"] + span = ET.SubElement(p_parent, "span") + span.attrib["class"] = "datatype" + span.text = p_type + " " + + +def make_text_def(class_name, parent, text): + text = html_escape(text) + pos = 0 + while(True): + pos = text.find("[", pos) + if (pos == -1): + break + + endq_pos = text.find("]", pos + 1) + if (endq_pos == -1): + break + + pre_text = text[:pos] + post_text = text[endq_pos + 1:] + tag_text = text[pos + 1:endq_pos] + + if (tag_text in class_names): + if (single_page): + tag_text = '<a href="#' + tag_text + '">' + tag_text + '</a>' + else: + tag_text = '<a href="' + tag_text + '.html">' + tag_text + '</a>' + else: # command + cmd = tag_text + space_pos = tag_text.find(" ") + if (cmd.find("html") == 0): + cmd = tag_text[:space_pos] + param = tag_text[space_pos + 1:] + tag_text = "<" + param + ">" + elif(cmd.find("method") == 0): + cmd = tag_text[:space_pos] + param = tag_text[space_pos + 1:] + + if (not single_page and param.find(".") != -1): + class_param, method_param = param.split(".") + tag_text = tag_text = '<a href="' + class_param + '.html#' + class_param + "_" + method_param + '">' + class_param + '.' + method_param + '()</a>' + else: + tag_text = tag_text = '<a href="#' + class_name + "_" + param + '">' + class_name + '.' + param + '()</a>' + elif (cmd.find("image=") == 0): + print("found image: " + cmd) + tag_text = "<img src=" + cmd[6:] + "/>" + elif (cmd.find("url=") == 0): + tag_text = "<a href=" + cmd[4:] + ">" + elif (cmd == "/url"): + tag_text = "</a>" + elif (cmd == "center"): + tag_text = "<div align=\"center\">" + elif (cmd == "/center"): + tag_text = "</div>" + elif (cmd == "br"): + tag_text = "<br/>" + elif (cmd == "i" or cmd == "/i" or cmd == "b" or cmd == "/b" or cmd == "u" or cmd == "/u"): + tag_text = "<" + tag_text + ">" # html direct mapping + else: + tag_text = "[" + tag_text + "]" + + text = pre_text + tag_text + post_text + pos = len(pre_text) + len(tag_text) + + #tnode = ET.SubElement(parent,"div") + # tnode.text=text + text = "<div class=\"description\">" + text + "</div>" + try: + tnode = ET.XML(text) + parent.append(tnode) + except: + print("Error parsing description text: '" + text + "'") + sys.exit(255) + + return tnode + + +def make_method_def(name, m, declare, event=False): + + mdata = {} + + if (not declare): + div = ET.Element("tr") + div.attrib["class"] = "method" + ret_parent = ET.SubElement(div, "td") + ret_parent.attrib["align"] = "right" + func_parent = ET.SubElement(div, "td") + else: + div = ET.Element("div") + div.attrib["class"] = "method" + ret_parent = div + func_parent = div + + mdata["argidx"] = [] + mdata["name"] = m.attrib["name"] + qualifiers = "" + if ("qualifiers" in m.attrib): + qualifiers = m.attrib["qualifiers"] + + args = list(m) + for a in args: + if (a.tag == "return"): + idx = -1 + elif (a.tag == "argument"): + idx = int(a.attrib["index"]) + else: + continue + + mdata["argidx"].append(idx) + mdata[idx] = a + + if (not event): + if (-1 in mdata["argidx"]): + make_type(mdata[-1].attrib["type"], ret_parent) + mdata["argidx"].remove(-1) + else: + make_type("void", ret_parent) + + span = ET.SubElement(func_parent, "span") + if (declare): + span.attrib["class"] = "funcdecl" + a = ET.SubElement(span, "a") + a.attrib["name"] = name + "_" + m.attrib["name"] + a.text = name + "::" + m.attrib["name"] + else: + span.attrib["class"] = "identifier funcdef" + a = ET.SubElement(span, "a") + a.attrib["href"] = "#" + name + "_" + m.attrib["name"] + a.text = m.attrib["name"] + + span = ET.SubElement(func_parent, "span") + span.attrib["class"] = "symbol" + span.text = " (" + + for a in mdata["argidx"]: + arg = mdata[a] + if (a > 0): + span = ET.SubElement(func_parent, "span") + span.text = ", " + else: + span = ET.SubElement(func_parent, "span") + span.text = " " + + make_type(arg.attrib["type"], func_parent) + + span = ET.SubElement(func_parent, "span") + span.text = arg.attrib["name"] + if ("default" in arg.attrib): + span.text = span.text + "=" + arg.attrib["default"] + + span = ET.SubElement(func_parent, "span") + span.attrib["class"] = "symbol" + if (len(mdata["argidx"])): + span.text = " )" + else: + span.text = ")" - h3=ET.SubElement(a,"h3") - h3.attrib["class"]="title class_title" - h3.text=node.attrib["name"] + if (qualifiers): + span = ET.SubElement(func_parent, "span") + span.attrib["class"] = "qualifier" + span.text = " " + qualifiers - briefd = node.find("brief_description") - if (briefd!=None): - div2=ET.SubElement(div,"div") - div2.attrib["class"]="description class_description" - div2.text=briefd.text + return div - if ("inherits" in node.attrib): - ET.SubElement(div,"br") - div2=ET.SubElement(div,"div") - div2.attrib["class"]="inheritance"; +def make_html_class(node): - span=ET.SubElement(div2,"span") - span.text="Inherits: " + div = ET.Element("div") + div.attrib["class"] = "class" - make_type(node.attrib["inherits"],div2) + a = ET.SubElement(div, "a") + a.attrib["name"] = node.attrib["name"] - if ("category" in node.attrib): - ET.SubElement(div,"br") + h3 = ET.SubElement(a, "h3") + h3.attrib["class"] = "title class_title" + h3.text = node.attrib["name"] - div3=ET.SubElement(div,"div") - div3.attrib["class"]="category"; + briefd = node.find("brief_description") + if (briefd != None): + div2 = ET.SubElement(div, "div") + div2.attrib["class"] = "description class_description" + div2.text = briefd.text - span=ET.SubElement(div3,"span") - span.attrib["class"]="category" - span.text="Category: " + if ("inherits" in node.attrib): + ET.SubElement(div, "br") - a = ET.SubElement(div3,"a") - a.attrib["class"]="category_ref" - a.text=node.attrib["category"] - catname=a.text - if (catname.rfind("/")!=-1): - catname=catname[catname.rfind("/"):] - catname="CATEGORY_"+catname + div2 = ET.SubElement(div, "div") + div2.attrib["class"] = "inheritance" - if (single_page): - a.attrib["href"]="#"+catname - else: - a.attrib["href"]="category.html#"+catname + span = ET.SubElement(div2, "span") + span.text = "Inherits: " + make_type(node.attrib["inherits"], div2) - methods = node.find("methods") + if ("category" in node.attrib): + ET.SubElement(div, "br") - if(methods!=None and len(list(methods))>0): + div3 = ET.SubElement(div, "div") + div3.attrib["class"] = "category" - h4=ET.SubElement(div,"h4") - h4.text="Public Methods:" + span = ET.SubElement(div3, "span") + span.attrib["class"] = "category" + span.text = "Category: " - method_table=ET.SubElement(div,"table") - method_table.attrib["class"]="method_list"; + a = ET.SubElement(div3, "a") + a.attrib["class"] = "category_ref" + a.text = node.attrib["category"] + catname = a.text + if (catname.rfind("/") != -1): + catname = catname[catname.rfind("/"):] + catname = "CATEGORY_" + catname - for m in list(methods): -# li = ET.SubElement(div2, "li") - method_table.append( make_method_def(node.attrib["name"],m,False) ) + if (single_page): + a.attrib["href"] = "#" + catname + else: + a.attrib["href"] = "category.html#" + catname - events = node.find("signals") + methods = node.find("methods") - if(events!=None and len(list(events))>0): - h4=ET.SubElement(div,"h4") - h4.text="Events:" + if(methods != None and len(list(methods)) > 0): - event_table=ET.SubElement(div,"table") - event_table.attrib["class"]="method_list"; + h4 = ET.SubElement(div, "h4") + h4.text = "Public Methods:" - for m in list(events): -# li = ET.SubElement(div2, "li") - event_table.append( make_method_def(node.attrib["name"],m,False,True) ) + method_table = ET.SubElement(div, "table") + method_table.attrib["class"] = "method_list" + for m in list(methods): + #li = ET.SubElement(div2, "li") + method_table.append(make_method_def(node.attrib["name"], m, False)) - members = node.find("members") - if(members!=None and len(list(members))>0): + events = node.find("signals") - h4=ET.SubElement(div,"h4") - h4.text="Public Variables:" - div2=ET.SubElement(div,"div") - div2.attrib["class"]="member_list"; + if(events != None and len(list(events)) > 0): + h4 = ET.SubElement(div, "h4") + h4.text = "Events:" - for c in list(members): + event_table = ET.SubElement(div, "table") + event_table.attrib["class"] = "method_list" - li = ET.SubElement(div2, "li") - div3=ET.SubElement(li,"div") - div3.attrib["class"]="member"; - make_type(c.attrib["type"],div3) - span=ET.SubElement(div3,"span") - span.attrib["class"]="identifier member_name" - span.text=" "+c.attrib["name"]+" " - span=ET.SubElement(div3,"span") - span.attrib["class"]="member_description" - span.text=c.text + for m in list(events): + #li = ET.SubElement(div2, "li") + event_table.append(make_method_def(node.attrib["name"], m, False, True)) + members = node.find("members") + if(members != None and len(list(members)) > 0): - constants = node.find("constants") - if(constants!=None and len(list(constants))>0): + h4 = ET.SubElement(div, "h4") + h4.text = "Public Variables:" + div2 = ET.SubElement(div, "div") + div2.attrib["class"] = "member_list" - h4=ET.SubElement(div,"h4") - h4.text="Constants:" - div2=ET.SubElement(div,"div") - div2.attrib["class"]="constant_list"; + for c in list(members): - for c in list(constants): - li = ET.SubElement(div2, "li") - div3=ET.SubElement(li,"div") - div3.attrib["class"]="constant"; + li = ET.SubElement(div2, "li") + div3 = ET.SubElement(li, "div") + div3.attrib["class"] = "member" + make_type(c.attrib["type"], div3) + span = ET.SubElement(div3, "span") + span.attrib["class"] = "identifier member_name" + span.text = " " + c.attrib["name"] + " " + span = ET.SubElement(div3, "span") + span.attrib["class"] = "member_description" + span.text = c.text - span=ET.SubElement(div3,"span") - span.attrib["class"]="identifier constant_name" - span.text=c.attrib["name"]+" " - if ("value" in c.attrib): - span=ET.SubElement(div3,"span") - span.attrib["class"]="symbol" - span.text="= " - span=ET.SubElement(div3,"span") - span.attrib["class"]="constant_value" - span.text=c.attrib["value"]+" " - span=ET.SubElement(div3,"span") - span.attrib["class"]="constant_description" - span.text=c.text + constants = node.find("constants") + if(constants != None and len(list(constants)) > 0): + + h4 = ET.SubElement(div, "h4") + h4.text = "Constants:" + div2 = ET.SubElement(div, "div") + div2.attrib["class"] = "constant_list" + + for c in list(constants): + li = ET.SubElement(div2, "li") + div3 = ET.SubElement(li, "div") + div3.attrib["class"] = "constant" + + span = ET.SubElement(div3, "span") + span.attrib["class"] = "identifier constant_name" + span.text = c.attrib["name"] + " " + if ("value" in c.attrib): + span = ET.SubElement(div3, "span") + span.attrib["class"] = "symbol" + span.text = "= " + span = ET.SubElement(div3, "span") + span.attrib["class"] = "constant_value" + span.text = c.attrib["value"] + " " + span = ET.SubElement(div3, "span") + span.attrib["class"] = "constant_description" + span.text = c.text # ET.SubElement(div,"br") + descr = node.find("description") + if (descr != None and descr.text.strip() != ""): + h4 = ET.SubElement(div, "h4") + h4.text = "Description:" - descr=node.find("description") - if (descr!=None and descr.text.strip()!=""): - h4=ET.SubElement(div,"h4") - h4.text="Description:" - - make_text_def(node.attrib["name"],div,descr.text) + make_text_def(node.attrib["name"], div, descr.text) # div2=ET.SubElement(div,"div") # div2.attrib["class"]="description"; # div2.text=descr.text + if(methods != None or events != None): + h4 = ET.SubElement(div, "h4") + h4.text = "Method Documentation:" + iter_list = [] + if (methods != None): + iter_list += list(methods) + if (events != None): + iter_list += list(events) - if(methods!=None or events!=None): - - h4=ET.SubElement(div,"h4") - h4.text="Method Documentation:" - iter_list = [] - if (methods!=None): - iter_list+=list(methods) - if (events!=None): - iter_list+=list(events) - - for m in iter_list: - - descr=m.find("description") - - if (descr==None or descr.text.strip()==""): - continue; + for m in iter_list: - div2=ET.SubElement(div,"div") - div2.attrib["class"]="method_doc"; + descr = m.find("description") + if (descr == None or descr.text.strip() == ""): + continue - div2.append( make_method_def(node.attrib["name"],m,True) ) - #anchor = ET.SubElement(div2, "a") - #anchor.attrib["name"] = - make_text_def(node.attrib["name"],div2,descr.text) - #div3=ET.SubElement(div2,"div") - #div3.attrib["class"]="description"; - #div3.text=descr.text + div2 = ET.SubElement(div, "div") + div2.attrib["class"] = "method_doc" + div2.append(make_method_def(node.attrib["name"], m, True)) + #anchor = ET.SubElement(div2, "a") + # anchor.attrib["name"] = + make_text_def(node.attrib["name"], div2, descr.text) + # div3=ET.SubElement(div2,"div") + # div3.attrib["class"]="description"; + # div3.text=descr.text - return div + return div -class_names=[] -classes={} +class_names = [] +classes = {} for file in input_list: - tree = ET.parse(file) - doc=tree.getroot() + tree = ET.parse(file) + doc = tree.getroot() - if ("version" not in doc.attrib): - print("Version missing from 'doc'") - sys.exit(255) + if ("version" not in doc.attrib): + print("Version missing from 'doc'") + sys.exit(255) - version=doc.attrib["version"] + version = doc.attrib["version"] - for c in list(doc): - if (c.attrib["name"] in class_names): - continue - class_names.append(c.attrib["name"]) - classes[c.attrib["name"]]=c + for c in list(doc): + if (c.attrib["name"] in class_names): + continue + class_names.append(c.attrib["name"]) + classes[c.attrib["name"]] = c html = ET.Element("html") css = ET.SubElement(html, "link") @@ -685,36 +656,34 @@ css.attrib["type"] = "text/css" body = ET.SubElement(html, "body") if (not single_page): - make_html_top(body) - + make_html_top(body) class_names.sort() -body.append( make_html_class_list(class_names,5) ) +body.append(make_html_class_list(class_names, 5)) for cn in class_names: - c=classes[cn] - if (single_page): - body.append( make_html_class(c)) - else: - html2 = ET.Element("html") - css = ET.SubElement(html2, "link") - css.attrib["href"] = "main.css" - css.attrib["rel"] = "stylesheet" - css.attrib["type"] = "text/css" - body2 = ET.SubElement(html2, "body" ) - make_html_top(body2) - body2.append( make_html_class(c) ); - make_html_bottom(body2) - et_out = ET.ElementTree(html2) - et_out.write(c.attrib["name"]+".html") + c = classes[cn] + if (single_page): + body.append(make_html_class(c)) + else: + html2 = ET.Element("html") + css = ET.SubElement(html2, "link") + css.attrib["href"] = "main.css" + css.attrib["rel"] = "stylesheet" + css.attrib["type"] = "text/css" + body2 = ET.SubElement(html2, "body") + make_html_top(body2) + body2.append(make_html_class(c)) + make_html_bottom(body2) + et_out = ET.ElementTree(html2) + et_out.write(c.attrib["name"] + ".html") et_out = ET.ElementTree(html) if (single_page): - et_out.write("singlepage.html") + et_out.write("singlepage.html") else: - make_html_bottom(body) - et_out.write("alphabetical.html") - + make_html_bottom(body) + et_out.write("alphabetical.html") diff --git a/doc/tools/makemd.py b/doc/tools/makemd.py index e0fbe9af03..bd0d4c6819 100644 --- a/doc/tools/makemd.py +++ b/doc/tools/makemd.py @@ -7,17 +7,17 @@ import xml.etree.ElementTree as ET input_list = [] for arg in sys.argv[1:]: - input_list.append(arg) + input_list.append(arg) if len(input_list) < 1: - print 'usage: makemd.py <classes.xml>' - sys.exit(0) + print 'usage: makemd.py <classes.xml>' + sys.exit(0) def validate_tag(elem, tag): - if elem.tag != tag: - print "Tag mismatch, expected '" + tag + "', got " + elem.tag - sys.exit(255) + if elem.tag != tag: + print "Tag mismatch, expected '" + tag + "', got " + elem.tag + sys.exit(255) class_names = [] @@ -26,321 +26,320 @@ classes = {} def make_class_list(class_list, columns): - f = open('class_list.md', 'wb') - prev = 0 - col_max = len(class_list) / columns + 1 - print ('col max is ', col_max) - col_count = 0 - row_count = 0 - last_initial = '' - fit_columns = [] - - for n in range(0, columns): - fit_columns += [[]] - - indexers = [] - last_initial = '' - - idx = 0 - for n in class_list: - col = idx / col_max - if col >= columns: - col = columns - 1 - fit_columns[col] += [n] - idx += 1 - if n[:1] != last_initial: - indexers += [n] - last_initial = n[:1] - - row_max = 0 - f.write("\n") - - for n in range(0, columns): - if len(fit_columns[n]) > row_max: - row_max = len(fit_columns[n]) - - f.write("| ") - for n in range(0, columns): - f.write(" | |") - - f.write("\n") - f.write("| ") - for n in range(0, columns): - f.write(" --- | ------- |") - f.write("\n") - - for r in range(0, row_max): - s = '| ' - for c in range(0, columns): - if r >= len(fit_columns[c]): - continue - - classname = fit_columns[c][r] - initial = classname[0] - if classname in indexers: - s += '**' + initial + '** | ' - else: - s += ' | ' - - s += '[' + classname + '](class_'+ classname.lower()+') | ' - - s += '\n' - f.write(s) + f = open('class_list.md', 'wb') + prev = 0 + col_max = len(class_list) / columns + 1 + print ('col max is ', col_max) + col_count = 0 + row_count = 0 + last_initial = '' + fit_columns = [] + + for n in range(0, columns): + fit_columns += [[]] + + indexers = [] + last_initial = '' + + idx = 0 + for n in class_list: + col = idx / col_max + if col >= columns: + col = columns - 1 + fit_columns[col] += [n] + idx += 1 + if n[:1] != last_initial: + indexers += [n] + last_initial = n[:1] + + row_max = 0 + f.write("\n") + + for n in range(0, columns): + if len(fit_columns[n]) > row_max: + row_max = len(fit_columns[n]) + + f.write("| ") + for n in range(0, columns): + f.write(" | |") + + f.write("\n") + f.write("| ") + for n in range(0, columns): + f.write(" --- | ------- |") + f.write("\n") + + for r in range(0, row_max): + s = '| ' + for c in range(0, columns): + if r >= len(fit_columns[c]): + continue + + classname = fit_columns[c][r] + initial = classname[0] + if classname in indexers: + s += '**' + initial + '** | ' + else: + s += ' | ' + + s += '[' + classname + '](class_' + classname.lower() + ') | ' + + s += '\n' + f.write(s) def dokuize_text(txt): - return txt + return txt def dokuize_text(text): - pos = 0 - while True: - pos = text.find('[', pos) - if pos == -1: - break - - endq_pos = text.find(']', pos + 1) - if endq_pos == -1: - break - - pre_text = text[:pos] - post_text = text[endq_pos + 1:] - tag_text = text[pos + 1:endq_pos] - - if tag_text in class_names: - tag_text = make_type(tag_text) - else: - - # command - - cmd = tag_text - space_pos = tag_text.find(' ') - if cmd.find('html') == 0: - cmd = tag_text[:space_pos] - param = tag_text[space_pos + 1:] - tag_text = '<' + param + '>' - elif cmd.find('method') == 0: - cmd = tag_text[:space_pos] - param = tag_text[space_pos + 1:] - - if param.find('.') != -1: - (class_param, method_param) = param.split('.') - tag_text = '['+class_param+'.'+method_param.replace("_","_")+'](' + class_param.lower() + '#' \ - + method_param + ')' - else: - tag_text = '[' + param.replace("_","_") + '](#' + param + ')' - elif cmd.find('image=') == 0: - tag_text = '![](' + cmd[6:] + ')' - elif cmd.find('url=') == 0: - tag_text = '[' + cmd[4:] + ']('+cmd[4:] - elif cmd == '/url': - tag_text = ')' - elif cmd == 'center': - tag_text = '' - elif cmd == '/center': - tag_text = '' - elif cmd == 'br': - tag_text = '\n' - elif cmd == 'i' or cmd == '/i': - tag_text = '_' - elif cmd == 'b' or cmd == '/b': - tag_text = '**' - elif cmd == 'u' or cmd == '/u': - tag_text = '__' - else: - tag_text = '[' + tag_text + ']' - - text = pre_text + tag_text + post_text - pos = len(pre_text) + len(tag_text) + pos = 0 + while True: + pos = text.find('[', pos) + if pos == -1: + break + + endq_pos = text.find(']', pos + 1) + if endq_pos == -1: + break + + pre_text = text[:pos] + post_text = text[endq_pos + 1:] + tag_text = text[pos + 1:endq_pos] + + if tag_text in class_names: + tag_text = make_type(tag_text) + else: + + # command + + cmd = tag_text + space_pos = tag_text.find(' ') + if cmd.find('html') == 0: + cmd = tag_text[:space_pos] + param = tag_text[space_pos + 1:] + tag_text = '<' + param + '>' + elif cmd.find('method') == 0: + cmd = tag_text[:space_pos] + param = tag_text[space_pos + 1:] + + if param.find('.') != -1: + (class_param, method_param) = param.split('.') + tag_text = '[' + class_param + '.' + method_param.replace("_", "_") + '](' + class_param.lower() + '#' \ + + method_param + ')' + else: + tag_text = '[' + param.replace("_", "_") + '](#' + param + ')' + elif cmd.find('image=') == 0: + tag_text = '![](' + cmd[6:] + ')' + elif cmd.find('url=') == 0: + tag_text = '[' + cmd[4:] + '](' + cmd[4:] + elif cmd == '/url': + tag_text = ')' + elif cmd == 'center': + tag_text = '' + elif cmd == '/center': + tag_text = '' + elif cmd == 'br': + tag_text = '\n' + elif cmd == 'i' or cmd == '/i': + tag_text = '_' + elif cmd == 'b' or cmd == '/b': + tag_text = '**' + elif cmd == 'u' or cmd == '/u': + tag_text = '__' + else: + tag_text = '[' + tag_text + ']' + + text = pre_text + tag_text + post_text + pos = len(pre_text) + len(tag_text) # tnode = ET.SubElement(parent,"div") # tnode.text=text - return text + return text def make_type(t): - global class_names - if t in class_names: - return '[' + t + '](class_' + t.lower() + ')' - return t + global class_names + if t in class_names: + return '[' + t + '](class_' + t.lower() + ')' + return t def make_method( - f, - name, - m, - declare, - event=False, - ): - - s = ' * ' - ret_type = 'void' - args = list(m) - mdata = {} - mdata['argidx'] = [] - for a in args: - if a.tag == 'return': - idx = -1 - elif a.tag == 'argument': - idx = int(a.attrib['index']) - else: - continue - - mdata['argidx'].append(idx) - mdata[idx] = a - - if not event: - if -1 in mdata['argidx']: - s += make_type(mdata[-1].attrib['type']) - else: - s += 'void' - s += ' ' - - if declare: - - # span.attrib["class"]="funcdecl" - # a=ET.SubElement(span,"a") - # a.attrib["name"]=name+"_"+m.attrib["name"] - # a.text=name+"::"+m.attrib["name"] - - s += ' **'+m.attrib['name'].replace("_","_")+'** ' - else: - s += ' **['+ m.attrib['name'].replace("_","_")+'](#' + m.attrib['name'] + ')** ' - - s += ' **(**' - argfound = False - for a in mdata['argidx']: - arg = mdata[a] - if a < 0: - continue - if a > 0: - s += ', ' - else: - s += ' ' - - s += make_type(arg.attrib['type']) - if 'name' in arg.attrib: - s += ' ' + arg.attrib['name'] - else: - s += ' arg' + str(a) - - if 'default' in arg.attrib: - s += '=' + arg.attrib['default'] - - argfound = True - - if argfound: - s += ' ' - s += ' **)**' - - if 'qualifiers' in m.attrib: - s += ' ' + m.attrib['qualifiers'] - - f.write(s + '\n') + f, + name, + m, + declare, + event=False, +): + + s = ' * ' + ret_type = 'void' + args = list(m) + mdata = {} + mdata['argidx'] = [] + for a in args: + if a.tag == 'return': + idx = -1 + elif a.tag == 'argument': + idx = int(a.attrib['index']) + else: + continue + + mdata['argidx'].append(idx) + mdata[idx] = a + + if not event: + if -1 in mdata['argidx']: + s += make_type(mdata[-1].attrib['type']) + else: + s += 'void' + s += ' ' + + if declare: + + # span.attrib["class"]="funcdecl" + # a=ET.SubElement(span,"a") + # a.attrib["name"]=name+"_"+m.attrib["name"] + # a.text=name+"::"+m.attrib["name"] + + s += ' **' + m.attrib['name'].replace("_", "_") + '** ' + else: + s += ' **[' + m.attrib['name'].replace("_", "_") + '](#' + m.attrib['name'] + ')** ' + + s += ' **(**' + argfound = False + for a in mdata['argidx']: + arg = mdata[a] + if a < 0: + continue + if a > 0: + s += ', ' + else: + s += ' ' + + s += make_type(arg.attrib['type']) + if 'name' in arg.attrib: + s += ' ' + arg.attrib['name'] + else: + s += ' arg' + str(a) + + if 'default' in arg.attrib: + s += '=' + arg.attrib['default'] + + argfound = True + + if argfound: + s += ' ' + s += ' **)**' + + if 'qualifiers' in m.attrib: + s += ' ' + m.attrib['qualifiers'] + + f.write(s + '\n') def make_doku_class(node): - name = node.attrib['name'] - - f = open("class_"+name.lower() + '.md', 'wb') - - f.write('# ' + name + ' \n') - - if 'inherits' in node.attrib: - inh = node.attrib['inherits'].strip() - f.write('####**Inherits:** '+make_type(inh)+'\n') - if 'category' in node.attrib: - f.write('####**Category:** ' + node.attrib['category'].strip() - + '\n') - - briefd = node.find('brief_description') - if briefd != None: - f.write('\n### Brief Description \n') - f.write(dokuize_text(briefd.text.strip()) + '\n') - - methods = node.find('methods') - - if methods != None and len(list(methods)) > 0: - f.write('\n### Member Functions \n') - for m in list(methods): - make_method(f, node.attrib['name'], m, False) - - events = node.find('signals') - if events != None and len(list(events)) > 0: - f.write('\n### Signals \n') - for m in list(events): - make_method(f, node.attrib['name'], m, True, True) - - members = node.find('members') - - if members != None and len(list(members)) > 0: - f.write('\n### Member Variables \n') - - for c in list(members): - s = ' * ' - s += make_type(c.attrib['type']) + ' ' - s += '**' + c.attrib['name'] + '**' - if c.text.strip() != '': - s += ' - ' + c.text.strip() - f.write(s + '\n') - - constants = node.find('constants') - if constants != None and len(list(constants)) > 0: - f.write('\n### Numeric Constants \n') - for c in list(constants): - s = ' * ' - s += '**' + c.attrib['name'] + '**' - if 'value' in c.attrib: - s += ' = **' + c.attrib['value'] + '**' - if c.text.strip() != '': - s += ' - ' + c.text.strip() - f.write(s + '\n') - - descr = node.find('description') - if descr != None and descr.text.strip() != '': - f.write('\n### Description \n') - f.write(dokuize_text(descr.text.strip()) + '\n') - - methods = node.find('methods') - - if methods != None and len(list(methods)) > 0: - f.write('\n### Member Function Description \n') - for m in list(methods): - - d = m.find('description') - if d == None or d.text.strip() == '': - continue - f.write('\n#### <a name="'+m.attrib['name']+'">' + m.attrib['name'] + '</a>\n') - make_method(f, node.attrib['name'], m, True) - f.write('\n') - f.write(dokuize_text(d.text.strip())) - f.write('\n') + name = node.attrib['name'] + + f = open("class_" + name.lower() + '.md', 'wb') + + f.write('# ' + name + ' \n') + + if 'inherits' in node.attrib: + inh = node.attrib['inherits'].strip() + f.write('####**Inherits:** ' + make_type(inh) + '\n') + if 'category' in node.attrib: + f.write('####**Category:** ' + node.attrib['category'].strip() + + '\n') + + briefd = node.find('brief_description') + if briefd != None: + f.write('\n### Brief Description \n') + f.write(dokuize_text(briefd.text.strip()) + '\n') + + methods = node.find('methods') + + if methods != None and len(list(methods)) > 0: + f.write('\n### Member Functions \n') + for m in list(methods): + make_method(f, node.attrib['name'], m, False) + + events = node.find('signals') + if events != None and len(list(events)) > 0: + f.write('\n### Signals \n') + for m in list(events): + make_method(f, node.attrib['name'], m, True, True) + + members = node.find('members') + + if members != None and len(list(members)) > 0: + f.write('\n### Member Variables \n') + + for c in list(members): + s = ' * ' + s += make_type(c.attrib['type']) + ' ' + s += '**' + c.attrib['name'] + '**' + if c.text.strip() != '': + s += ' - ' + c.text.strip() + f.write(s + '\n') + + constants = node.find('constants') + if constants != None and len(list(constants)) > 0: + f.write('\n### Numeric Constants \n') + for c in list(constants): + s = ' * ' + s += '**' + c.attrib['name'] + '**' + if 'value' in c.attrib: + s += ' = **' + c.attrib['value'] + '**' + if c.text.strip() != '': + s += ' - ' + c.text.strip() + f.write(s + '\n') + + descr = node.find('description') + if descr != None and descr.text.strip() != '': + f.write('\n### Description \n') + f.write(dokuize_text(descr.text.strip()) + '\n') + + methods = node.find('methods') + + if methods != None and len(list(methods)) > 0: + f.write('\n### Member Function Description \n') + for m in list(methods): + + d = m.find('description') + if d == None or d.text.strip() == '': + continue + f.write('\n#### <a name="' + m.attrib['name'] + '">' + m.attrib['name'] + '</a>\n') + make_method(f, node.attrib['name'], m, True) + f.write('\n') + f.write(dokuize_text(d.text.strip())) + f.write('\n') for file in input_list: - tree = ET.parse(file) - doc = tree.getroot() + tree = ET.parse(file) + doc = tree.getroot() - if 'version' not in doc.attrib: - print "Version missing from 'doc'" - sys.exit(255) + if 'version' not in doc.attrib: + print "Version missing from 'doc'" + sys.exit(255) - version = doc.attrib['version'] + version = doc.attrib['version'] - for c in list(doc): - if c.attrib['name'] in class_names: - continue - class_names.append(c.attrib['name']) - classes[c.attrib['name']] = c + for c in list(doc): + if c.attrib['name'] in class_names: + continue + class_names.append(c.attrib['name']) + classes[c.attrib['name']] = c class_names.sort() make_class_list(class_names, 2) for cn in class_names: - c = classes[cn] - make_doku_class(c) - + c = classes[cn] + make_doku_class(c) diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py index 718cf4a275..6b6780ce1e 100644 --- a/doc/tools/makerst.py +++ b/doc/tools/makerst.py @@ -8,512 +8,510 @@ import xml.etree.ElementTree as ET input_list = [] for arg in sys.argv[1:]: - input_list.append(arg) + input_list.append(arg) if len(input_list) < 1: - print 'usage: makerst.py <classes.xml>' - sys.exit(0) + print 'usage: makerst.py <classes.xml>' + sys.exit(0) def validate_tag(elem, tag): - if elem.tag != tag: - print "Tag mismatch, expected '" + tag + "', got " + elem.tag - sys.exit(255) + if elem.tag != tag: + print "Tag mismatch, expected '" + tag + "', got " + elem.tag + sys.exit(255) class_names = [] classes = {} -def ul_string(str,ul): - str+="\n" - for i in range(len(str)-1): - str+=ul - str+="\n" - return str + +def ul_string(str, ul): + str += "\n" + for i in range(len(str) - 1): + str += ul + str += "\n" + return str + def make_class_list(class_list, columns): - f = codecs.open('class_list.rst', 'wb', 'utf-8') - prev = 0 - col_max = len(class_list) / columns + 1 - print ('col max is ', col_max) - col_count = 0 - row_count = 0 - last_initial = '' - fit_columns = [] - - for n in range(0, columns): - fit_columns += [[]] - - indexers = [] - last_initial = '' - - idx = 0 - for n in class_list: - col = idx / col_max - if col >= columns: - col = columns - 1 - fit_columns[col] += [n] - idx += 1 - if n[:1] != last_initial: - indexers += [n] - last_initial = n[:1] - - row_max = 0 - f.write("\n") - - for n in range(0, columns): - if len(fit_columns[n]) > row_max: - row_max = len(fit_columns[n]) - - f.write("| ") - for n in range(0, columns): - f.write(" | |") - - f.write("\n") - f.write("+") - for n in range(0, columns): - f.write("--+-------+") - f.write("\n") - - for r in range(0, row_max): - s = '+ ' - for c in range(0, columns): - if r >= len(fit_columns[c]): - continue - - classname = fit_columns[c][r] - initial = classname[0] - if classname in indexers: - s += '**' + initial + '** | ' - else: - s += ' | ' - - s += '[' + classname + '](class_'+ classname.lower()+') | ' - - s += '\n' - f.write(s) - - for n in range(0, columns): - f.write("--+-------+") - f.write("\n") - - -def rstize_text(text,cclass): - - # Linebreak + tabs in the XML should become two line breaks unless in a "codeblock" - pos = 0 - while True: - pos = text.find('\n', pos) - if pos == -1: - break - - pre_text = text[:pos] - while text[pos+1] == '\t': - pos += 1 - post_text = text[pos+1:] - - # Handle codeblocks - if post_text.startswith("[codeblock]"): - end_pos = post_text.find("[/codeblock]") - if end_pos == -1: - sys.exit("ERROR! [codeblock] without a closing tag!") - - code_text = post_text[len("[codeblock]"):end_pos] - post_text = post_text[end_pos:] - - # Remove extraneous tabs - code_pos = 0 - while True: - code_pos = code_text.find('\n', code_pos) - if code_pos == -1: - break - - to_skip = 0 - while code_pos+to_skip+1 < len(code_text) and code_text[code_pos+to_skip+1] == '\t': - to_skip += 1 - - if len(code_text[code_pos+to_skip+1:])==0: - code_text = code_text[:code_pos] + "\n" - code_pos += 1 - else: - code_text = code_text[:code_pos] + "\n " + code_text[code_pos+to_skip+1:] - code_pos += 5 - to_skip - - text = pre_text + "\n[codeblock]" + code_text + post_text - pos += len("\n[codeblock]" + code_text) - - # Handle normal text - else: - text = pre_text + "\n\n" + post_text - pos += 2 - - # Escape * character to avoid interpreting it as emphasis - pos = 0 - while True: - pos = text.find('*', pos) - if pos == -1: - break - text = text[:pos] + "\*" + text[pos + 1:] - pos += 2 - - # Escape _ character at the end of a word to avoid interpreting it as an inline hyperlink - pos = 0 - while True: - pos = text.find('_', pos) - if pos == -1: - break - if not text[pos + 1].isalnum(): # don't escape within a snake_case word - text = text[:pos] + "\_" + text[pos + 1:] - pos += 2 - else: - pos += 1 - - # Handle [tags] - pos = 0 - while True: - pos = text.find('[', pos) - if pos == -1: - break - - endq_pos = text.find(']', pos + 1) - if endq_pos == -1: - break - - pre_text = text[:pos] - post_text = text[endq_pos + 1:] - tag_text = text[pos + 1:endq_pos] - - if tag_text in class_names: - tag_text = make_type(tag_text) - else: # command - cmd = tag_text - space_pos = tag_text.find(' ') - if cmd.find('html') == 0: - cmd = tag_text[:space_pos] - param = tag_text[space_pos + 1:] - tag_text = param - elif cmd.find('method') == 0: - cmd = tag_text[:space_pos] - param = tag_text[space_pos + 1:] - - if param.find('.') != -1: - (class_param, method_param) = param.split('.') - tag_text = ':ref:`'+class_param+'.'+method_param+'<class_' + class_param + '_' + method_param + '>`' - else: - tag_text = ':ref:`' + param + '<class_' + cclass +"_"+ param + '>`' - elif cmd.find('image=') == 0: - tag_text = "" #'![](' + cmd[6:] + ')' - elif cmd.find('url=') == 0: - tag_text = ':ref:`' + cmd[4:] + '<'+cmd[4:]+">`" - elif cmd == '/url': - tag_text = ')' - elif cmd == 'center': - tag_text = '' - elif cmd == '/center': - tag_text = '' - elif cmd == 'codeblock': - tag_text = '\n::\n' - elif cmd == '/codeblock': - tag_text = '' - # Strip newline if the tag was alone on one - if pre_text[-1] == '\n': - pre_text = pre_text[:-1] - elif cmd == 'br': - # Make a new paragraph instead of a linebreak, rst is not so linebreak friendly - tag_text = '\n\n' - # Strip potential leading spaces - while post_text[0] == ' ': - post_text = post_text[1:] - elif cmd == 'i' or cmd == '/i': - tag_text = '*' - elif cmd == 'b' or cmd == '/b': - tag_text = '**' - elif cmd == 'u' or cmd == '/u': - tag_text = '' - elif cmd == 'code' or cmd == '/code': - tag_text = '``' - else: - tag_text = ':ref:`' + tag_text + '<class_'+tag_text.lower()+'>`' - - text = pre_text + tag_text + post_text - pos = len(pre_text) + len(tag_text) + f = codecs.open('class_list.rst', 'wb', 'utf-8') + prev = 0 + col_max = len(class_list) / columns + 1 + print ('col max is ', col_max) + col_count = 0 + row_count = 0 + last_initial = '' + fit_columns = [] + + for n in range(0, columns): + fit_columns += [[]] + + indexers = [] + last_initial = '' + + idx = 0 + for n in class_list: + col = idx / col_max + if col >= columns: + col = columns - 1 + fit_columns[col] += [n] + idx += 1 + if n[:1] != last_initial: + indexers += [n] + last_initial = n[:1] + + row_max = 0 + f.write("\n") + + for n in range(0, columns): + if len(fit_columns[n]) > row_max: + row_max = len(fit_columns[n]) + + f.write("| ") + for n in range(0, columns): + f.write(" | |") + + f.write("\n") + f.write("+") + for n in range(0, columns): + f.write("--+-------+") + f.write("\n") + + for r in range(0, row_max): + s = '+ ' + for c in range(0, columns): + if r >= len(fit_columns[c]): + continue + + classname = fit_columns[c][r] + initial = classname[0] + if classname in indexers: + s += '**' + initial + '** | ' + else: + s += ' | ' + + s += '[' + classname + '](class_' + classname.lower() + ') | ' + + s += '\n' + f.write(s) + + for n in range(0, columns): + f.write("--+-------+") + f.write("\n") + + +def rstize_text(text, cclass): + + # Linebreak + tabs in the XML should become two line breaks unless in a "codeblock" + pos = 0 + while True: + pos = text.find('\n', pos) + if pos == -1: + break + + pre_text = text[:pos] + while text[pos + 1] == '\t': + pos += 1 + post_text = text[pos + 1:] + + # Handle codeblocks + if post_text.startswith("[codeblock]"): + end_pos = post_text.find("[/codeblock]") + if end_pos == -1: + sys.exit("ERROR! [codeblock] without a closing tag!") + + code_text = post_text[len("[codeblock]"):end_pos] + post_text = post_text[end_pos:] + + # Remove extraneous tabs + code_pos = 0 + while True: + code_pos = code_text.find('\n', code_pos) + if code_pos == -1: + break + + to_skip = 0 + while code_pos + to_skip + 1 < len(code_text) and code_text[code_pos + to_skip + 1] == '\t': + to_skip += 1 + + if len(code_text[code_pos + to_skip + 1:]) == 0: + code_text = code_text[:code_pos] + "\n" + code_pos += 1 + else: + code_text = code_text[:code_pos] + "\n " + code_text[code_pos + to_skip + 1:] + code_pos += 5 - to_skip + + text = pre_text + "\n[codeblock]" + code_text + post_text + pos += len("\n[codeblock]" + code_text) + + # Handle normal text + else: + text = pre_text + "\n\n" + post_text + pos += 2 + + # Escape * character to avoid interpreting it as emphasis + pos = 0 + while True: + pos = text.find('*', pos) + if pos == -1: + break + text = text[:pos] + "\*" + text[pos + 1:] + pos += 2 + + # Escape _ character at the end of a word to avoid interpreting it as an inline hyperlink + pos = 0 + while True: + pos = text.find('_', pos) + if pos == -1: + break + if not text[pos + 1].isalnum(): # don't escape within a snake_case word + text = text[:pos] + "\_" + text[pos + 1:] + pos += 2 + else: + pos += 1 + + # Handle [tags] + pos = 0 + while True: + pos = text.find('[', pos) + if pos == -1: + break + + endq_pos = text.find(']', pos + 1) + if endq_pos == -1: + break + + pre_text = text[:pos] + post_text = text[endq_pos + 1:] + tag_text = text[pos + 1:endq_pos] + + if tag_text in class_names: + tag_text = make_type(tag_text) + else: # command + cmd = tag_text + space_pos = tag_text.find(' ') + if cmd.find('html') == 0: + cmd = tag_text[:space_pos] + param = tag_text[space_pos + 1:] + tag_text = param + elif cmd.find('method') == 0: + cmd = tag_text[:space_pos] + param = tag_text[space_pos + 1:] + + if param.find('.') != -1: + (class_param, method_param) = param.split('.') + tag_text = ':ref:`' + class_param + '.' + method_param + '<class_' + class_param + '_' + method_param + '>`' + else: + tag_text = ':ref:`' + param + '<class_' + cclass + "_" + param + '>`' + elif cmd.find('image=') == 0: + tag_text = "" # '![](' + cmd[6:] + ')' + elif cmd.find('url=') == 0: + tag_text = ':ref:`' + cmd[4:] + '<' + cmd[4:] + ">`" + elif cmd == '/url': + tag_text = ')' + elif cmd == 'center': + tag_text = '' + elif cmd == '/center': + tag_text = '' + elif cmd == 'codeblock': + tag_text = '\n::\n' + elif cmd == '/codeblock': + tag_text = '' + # Strip newline if the tag was alone on one + if pre_text[-1] == '\n': + pre_text = pre_text[:-1] + elif cmd == 'br': + # Make a new paragraph instead of a linebreak, rst is not so linebreak friendly + tag_text = '\n\n' + # Strip potential leading spaces + while post_text[0] == ' ': + post_text = post_text[1:] + elif cmd == 'i' or cmd == '/i': + tag_text = '*' + elif cmd == 'b' or cmd == '/b': + tag_text = '**' + elif cmd == 'u' or cmd == '/u': + tag_text = '' + elif cmd == 'code' or cmd == '/code': + tag_text = '``' + else: + tag_text = ':ref:`' + tag_text + '<class_' + tag_text.lower() + '>`' + + text = pre_text + tag_text + post_text + pos = len(pre_text) + len(tag_text) # tnode = ET.SubElement(parent,"div") # tnode.text=text - return text + return text def make_type(t): - global class_names - if t in class_names: - return ':ref:`'+t+'<class_' + t.lower()+'>`' - return t + global class_names + if t in class_names: + return ':ref:`' + t + '<class_' + t.lower() + '>`' + return t def make_method( - f, - name, - m, - declare, - cname, - event=False, - pp=None - ): - - if (declare or pp==None): - t = '- ' - else: - t = "" - - ret_type = 'void' - args = list(m) - mdata = {} - mdata['argidx'] = [] - for a in args: - if a.tag == 'return': - idx = -1 - elif a.tag == 'argument': - idx = int(a.attrib['index']) - else: - continue - - mdata['argidx'].append(idx) - mdata[idx] = a - - if not event: - if -1 in mdata['argidx']: - t += make_type(mdata[-1].attrib['type']) - else: - t += 'void' - t += ' ' - - if declare or pp==None: - - # span.attrib["class"]="funcdecl" - # a=ET.SubElement(span,"a") - # a.attrib["name"]=name+"_"+m.attrib["name"] - # a.text=name+"::"+m.attrib["name"] - - s = ' **'+m.attrib['name']+'** ' - else: - s = ':ref:`'+ m.attrib['name']+'<class_' + cname+"_"+m.attrib['name'] + '>` ' - - s += ' **(**' - argfound = False - for a in mdata['argidx']: - arg = mdata[a] - if a < 0: - continue - if a > 0: - s += ', ' - else: - s += ' ' - - s += make_type(arg.attrib['type']) - if 'name' in arg.attrib: - s += ' ' + arg.attrib['name'] - else: - s += ' arg' + str(a) - - if 'default' in arg.attrib: - s += '=' + arg.attrib['default'] - - argfound = True - - if argfound: - s += ' ' - s += ' **)**' - - if 'qualifiers' in m.attrib: - s += ' ' + m.attrib['qualifiers'] + f, + name, + m, + declare, + cname, + event=False, + pp=None +): + + if (declare or pp == None): + t = '- ' + else: + t = "" + + ret_type = 'void' + args = list(m) + mdata = {} + mdata['argidx'] = [] + for a in args: + if a.tag == 'return': + idx = -1 + elif a.tag == 'argument': + idx = int(a.attrib['index']) + else: + continue + + mdata['argidx'].append(idx) + mdata[idx] = a + + if not event: + if -1 in mdata['argidx']: + t += make_type(mdata[-1].attrib['type']) + else: + t += 'void' + t += ' ' + + if declare or pp == None: + + # span.attrib["class"]="funcdecl" + # a=ET.SubElement(span,"a") + # a.attrib["name"]=name+"_"+m.attrib["name"] + # a.text=name+"::"+m.attrib["name"] + + s = ' **' + m.attrib['name'] + '** ' + else: + s = ':ref:`' + m.attrib['name'] + '<class_' + cname + "_" + m.attrib['name'] + '>` ' + + s += ' **(**' + argfound = False + for a in mdata['argidx']: + arg = mdata[a] + if a < 0: + continue + if a > 0: + s += ', ' + else: + s += ' ' + + s += make_type(arg.attrib['type']) + if 'name' in arg.attrib: + s += ' ' + arg.attrib['name'] + else: + s += ' arg' + str(a) + + if 'default' in arg.attrib: + s += '=' + arg.attrib['default'] + + argfound = True + + if argfound: + s += ' ' + s += ' **)**' + + if 'qualifiers' in m.attrib: + s += ' ' + m.attrib['qualifiers'] # f.write(s) - if (not declare): - if (pp!=None): - pp.append( (t,s) ) - else: - f.write("- "+t+" "+s+"\n") - else: - f.write(t+s+"\n") + if (not declare): + if (pp != None): + pp.append((t, s)) + else: + f.write("- " + t + " " + s + "\n") + else: + f.write(t + s + "\n") def make_heading(title, underline): - return title + '\n' + underline*len(title) + "\n\n" - + return title + '\n' + underline * len(title) + "\n\n" def make_rst_class(node): - name = node.attrib['name'] + name = node.attrib['name'] - f = codecs.open("class_"+name.lower() + '.rst', 'wb', 'utf-8') + f = codecs.open("class_" + name.lower() + '.rst', 'wb', 'utf-8') - # Warn contributors not to edit this file directly - f.write(".. Generated automatically by doc/tools/makerst.py in Godot's source tree.\n") - f.write(".. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.\n\n") + # Warn contributors not to edit this file directly + f.write(".. Generated automatically by doc/tools/makerst.py in Godot's source tree.\n") + f.write(".. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.\n\n") - f.write(".. _class_"+name+":\n\n") - f.write(make_heading(name, '=')) + f.write(".. _class_" + name + ":\n\n") + f.write(make_heading(name, '=')) - if 'inherits' in node.attrib: - inh = node.attrib['inherits'].strip() + if 'inherits' in node.attrib: + inh = node.attrib['inherits'].strip() # whle inh in classes[cn] - f.write('**Inherits:** ') - first=True - while(inh in classes): - if (not first): - f.write(" **<** ") - else: - first=False - - f.write(make_type(inh)) - inode = classes[inh] - if ('inherits' in inode.attrib): - inh=inode.attrib['inherits'].strip() - else: - inh=None - - - f.write("\n\n") - - inherited=[] - for cn in classes: - c=classes[cn] - if 'inherits' in c.attrib: - if (c.attrib['inherits'].strip()==name): - inherited.append(c.attrib['name']) - - if (len(inherited)): - f.write('**Inherited By:** ') - for i in range(len(inherited)): - if (i>0): - f.write(", ") - f.write(make_type(inherited[i])) - f.write("\n\n") - if 'category' in node.attrib: - f.write('**Category:** ' + node.attrib['category'].strip() + "\n\n") - - f.write(make_heading('Brief Description', '-')) - briefd = node.find('brief_description') - if briefd != None: - f.write(rstize_text(briefd.text.strip(),name) + "\n\n") - - methods = node.find('methods') - - if methods != None and len(list(methods)) > 0: - f.write(make_heading('Member Functions', '-')) - ml=[] - for m in list(methods): - make_method(f, node.attrib['name'], m, False,name,False,ml) - longest_t = 0 - longest_s = 0 - for s in ml: - sl = len(s[0]) - if (sl>longest_s): - longest_s=sl - tl = len(s[1]) - if (tl>longest_t): - longest_t=tl - - sep="+" - for i in range(longest_s+2): - sep+="-" - sep+="+" - for i in range(longest_t+2): - sep+="-" - sep+="+\n" - f.write(sep) - for s in ml: - rt = s[0] - while( len(rt) < longest_s ): - rt+=" " - st = s[1] - while( len(st) < longest_t ): - st+=" " - f.write("| "+rt+" | "+st+" |\n") - f.write(sep) - f.write('\n') - - - events = node.find('signals') - if events != None and len(list(events)) > 0: - f.write(make_heading('Signals', '-')) - for m in list(events): - make_method(f, node.attrib['name'], m, True,name, True) - f.write('\n') - - members = node.find('members') - if members != None and len(list(members)) > 0: - f.write(make_heading('Member Variables', '-')) - - for c in list(members): - s = '- ' - s += make_type(c.attrib['type']) + ' ' - s += '**' + c.attrib['name'] + '**' - if c.text.strip() != '': - s += ' - ' + c.text.strip() - f.write(s + '\n') - f.write('\n') - - constants = node.find('constants') - if constants != None and len(list(constants)) > 0: - f.write(make_heading('Numeric Constants', '-')) - for c in list(constants): - s = '- ' - s += '**' + c.attrib['name'] + '**' - if 'value' in c.attrib: - s += ' = **' + c.attrib['value'] + '**' - if c.text.strip() != '': - s += ' --- ' + rstize_text(c.text.strip(),name) - f.write(s + '\n') - f.write('\n') - - descr = node.find('description') - if descr != None and descr.text.strip() != '': - f.write(make_heading('Description', '-')) - f.write(rstize_text(descr.text.strip(),name) + "\n\n") - - methods = node.find('methods') - if methods != None and len(list(methods)) > 0: - f.write(make_heading('Member Function Description', '-')) - for m in list(methods): - f.write(".. _class_"+name+"_"+m.attrib['name']+":\n\n") + f.write('**Inherits:** ') + first = True + while(inh in classes): + if (not first): + f.write(" **<** ") + else: + first = False + + f.write(make_type(inh)) + inode = classes[inh] + if ('inherits' in inode.attrib): + inh = inode.attrib['inherits'].strip() + else: + inh = None + + f.write("\n\n") + + inherited = [] + for cn in classes: + c = classes[cn] + if 'inherits' in c.attrib: + if (c.attrib['inherits'].strip() == name): + inherited.append(c.attrib['name']) + + if (len(inherited)): + f.write('**Inherited By:** ') + for i in range(len(inherited)): + if (i > 0): + f.write(", ") + f.write(make_type(inherited[i])) + f.write("\n\n") + if 'category' in node.attrib: + f.write('**Category:** ' + node.attrib['category'].strip() + "\n\n") + + f.write(make_heading('Brief Description', '-')) + briefd = node.find('brief_description') + if briefd != None: + f.write(rstize_text(briefd.text.strip(), name) + "\n\n") + + methods = node.find('methods') + + if methods != None and len(list(methods)) > 0: + f.write(make_heading('Member Functions', '-')) + ml = [] + for m in list(methods): + make_method(f, node.attrib['name'], m, False, name, False, ml) + longest_t = 0 + longest_s = 0 + for s in ml: + sl = len(s[0]) + if (sl > longest_s): + longest_s = sl + tl = len(s[1]) + if (tl > longest_t): + longest_t = tl + + sep = "+" + for i in range(longest_s + 2): + sep += "-" + sep += "+" + for i in range(longest_t + 2): + sep += "-" + sep += "+\n" + f.write(sep) + for s in ml: + rt = s[0] + while(len(rt) < longest_s): + rt += " " + st = s[1] + while(len(st) < longest_t): + st += " " + f.write("| " + rt + " | " + st + " |\n") + f.write(sep) + f.write('\n') + + events = node.find('signals') + if events != None and len(list(events)) > 0: + f.write(make_heading('Signals', '-')) + for m in list(events): + make_method(f, node.attrib['name'], m, True, name, True) + f.write('\n') + + members = node.find('members') + if members != None and len(list(members)) > 0: + f.write(make_heading('Member Variables', '-')) + + for c in list(members): + s = '- ' + s += make_type(c.attrib['type']) + ' ' + s += '**' + c.attrib['name'] + '**' + if c.text.strip() != '': + s += ' - ' + c.text.strip() + f.write(s + '\n') + f.write('\n') + + constants = node.find('constants') + if constants != None and len(list(constants)) > 0: + f.write(make_heading('Numeric Constants', '-')) + for c in list(constants): + s = '- ' + s += '**' + c.attrib['name'] + '**' + if 'value' in c.attrib: + s += ' = **' + c.attrib['value'] + '**' + if c.text.strip() != '': + s += ' --- ' + rstize_text(c.text.strip(), name) + f.write(s + '\n') + f.write('\n') + + descr = node.find('description') + if descr != None and descr.text.strip() != '': + f.write(make_heading('Description', '-')) + f.write(rstize_text(descr.text.strip(), name) + "\n\n") + + methods = node.find('methods') + if methods != None and len(list(methods)) > 0: + f.write(make_heading('Member Function Description', '-')) + for m in list(methods): + f.write(".. _class_" + name + "_" + m.attrib['name'] + ":\n\n") # f.write(ul_string(m.attrib['name'],"^")) - #f.write('\n<a name="'+m.attrib['name']+'">' + m.attrib['name'] + '</a>\n------\n') - make_method(f, node.attrib['name'], m, True,name) - f.write('\n') - d = m.find('description') - if d == None or d.text.strip() == '': - continue - f.write(rstize_text(d.text.strip(),name)) - f.write("\n\n") - f.write('\n') + #f.write('\n<a name="'+m.attrib['name']+'">' + m.attrib['name'] + '</a>\n------\n') + make_method(f, node.attrib['name'], m, True, name) + f.write('\n') + d = m.find('description') + if d == None or d.text.strip() == '': + continue + f.write(rstize_text(d.text.strip(), name)) + f.write("\n\n") + f.write('\n') for file in input_list: - tree = ET.parse(file) - doc = tree.getroot() + tree = ET.parse(file) + doc = tree.getroot() - if 'version' not in doc.attrib: - print "Version missing from 'doc'" - sys.exit(255) + if 'version' not in doc.attrib: + print "Version missing from 'doc'" + sys.exit(255) - version = doc.attrib['version'] + version = doc.attrib['version'] - for c in list(doc): - if c.attrib['name'] in class_names: - continue - class_names.append(c.attrib['name']) - classes[c.attrib['name']] = c + for c in list(doc): + if c.attrib['name'] in class_names: + continue + class_names.append(c.attrib['name']) + classes[c.attrib['name']] = c class_names.sort() -#Don't make class list for Sphinx, :toctree: handles it +# Don't make class list for Sphinx, :toctree: handles it #make_class_list(class_names, 2) for cn in class_names: - c = classes[cn] - make_rst_class(c) - + c = classes[cn] + make_rst_class(c) diff --git a/drivers/SCsub b/drivers/SCsub index 8571b0c4ec..08a189272f 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -2,41 +2,41 @@ Import('env') -env.drivers_sources=[] +env.drivers_sources = [] if ("builtin_zlib" in env and env["builtin_zlib"] == "yes"): - SConscript("zlib/SCsub"); + SConscript("zlib/SCsub") # OS drivers -SConscript('unix/SCsub'); -SConscript('windows/SCsub'); +SConscript('unix/SCsub') +SConscript('windows/SCsub') # Sounds drivers -SConscript('alsa/SCsub'); -SConscript('pulseaudio/SCsub'); +SConscript('alsa/SCsub') +SConscript('pulseaudio/SCsub') if (env["platform"] == "windows"): - SConscript("rtaudio/SCsub"); + SConscript("rtaudio/SCsub") if (env["xaudio2"] == "yes"): - SConscript("xaudio2/SCsub"); + SConscript("xaudio2/SCsub") # Graphics drivers -SConscript('gles2/SCsub'); -SConscript('gl_context/SCsub'); +SConscript('gles2/SCsub') +SConscript('gl_context/SCsub') # Core dependencies -SConscript("png/SCsub"); +SConscript("png/SCsub") # Tools override # FIXME: Should likely be integrated in the tools/ codebase -if (env["tools"]=="yes"): - SConscript("convex_decomp/SCsub"); +if (env["tools"] == "yes"): + SConscript("convex_decomp/SCsub") -if env['vsproj']=="yes": - env.AddToVSProject(env.drivers_sources) +if env['vsproj'] == "yes": + env.AddToVSProject(env.drivers_sources) if env.split_drivers: - env.split_lib("drivers") + env.split_lib("drivers") else: - env.add_source_files(env.drivers_sources,"*.cpp") - lib = env.Library("drivers",env.drivers_sources) - env.Prepend(LIBS=[lib]) + env.add_source_files(env.drivers_sources, "*.cpp") + lib = env.Library("drivers", env.drivers_sources) + env.Prepend(LIBS=[lib]) diff --git a/drivers/gl_context/SCsub b/drivers/gl_context/SCsub index cf37e9fe36..a968c10cfd 100644 --- a/drivers/gl_context/SCsub +++ b/drivers/gl_context/SCsub @@ -2,20 +2,20 @@ Import('env') -if (env["platform"] in ["haiku","osx","windows","x11"]): - # Thirdparty source files - if (env["glew"] != "system"): # builtin - thirdparty_dir = "#thirdparty/glew/" - thirdparty_sources = [ - "glew.c", - ] - thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] +if (env["platform"] in ["haiku", "osx", "windows", "x11"]): + # Thirdparty source files + if (env['builtin_glew'] != 'no'): # builtin + thirdparty_dir = "#thirdparty/glew/" + thirdparty_sources = [ + "glew.c", + ] + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - env.add_source_files(env.drivers_sources, thirdparty_sources) - env.Append(CPPFLAGS = ['-DGLEW_STATIC']) - env.Append(CPPPATH = [thirdparty_dir]) + env.add_source_files(env.drivers_sources, thirdparty_sources) + env.Append(CPPFLAGS=['-DGLEW_STATIC']) + env.Append(CPPPATH=[thirdparty_dir]) - env.Append(CPPFLAGS = ['-DGLEW_ENABLED']) + env.Append(CPPFLAGS=['-DGLEW_ENABLED']) # Godot source files env.add_source_files(env.drivers_sources, "*.cpp") diff --git a/drivers/gles2/shaders/SCsub b/drivers/gles2/shaders/SCsub index 1de5604321..bf4ec9485d 100644 --- a/drivers/gles2/shaders/SCsub +++ b/drivers/gles2/shaders/SCsub @@ -3,10 +3,10 @@ Import('env') if env['BUILDERS'].has_key('GLSL120GLES'): - env.GLSL120GLES('material.glsl'); - env.GLSL120GLES('canvas.glsl'); - env.GLSL120GLES('canvas_shadow.glsl'); - env.GLSL120GLES('blur.glsl'); - env.GLSL120GLES('copy.glsl'); + env.GLSL120GLES('material.glsl') + env.GLSL120GLES('canvas.glsl') + env.GLSL120GLES('canvas_shadow.glsl') + env.GLSL120GLES('blur.glsl') + env.GLSL120GLES('copy.glsl') Export('env') diff --git a/drivers/png/SCsub b/drivers/png/SCsub index 04cb70e1c1..6684e36b20 100644 --- a/drivers/png/SCsub +++ b/drivers/png/SCsub @@ -5,44 +5,44 @@ Import('env') env_png = env.Clone() # Thirdparty source files -if (env["libpng"] == "builtin"): - thirdparty_dir = "#thirdparty/libpng/" - thirdparty_sources = [ - "png.c", - "pngerror.c", - "pngget.c", - "pngmem.c", - "pngpread.c", - "pngread.c", - "pngrio.c", - "pngrtran.c", - "pngrutil.c", - "pngset.c", - "pngtrans.c", - "pngwio.c", - "pngwrite.c", - "pngwtran.c", - "pngwutil.c", - ] - thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] +if (env['builtin_libpng'] != 'no'): + thirdparty_dir = "#thirdparty/libpng/" + thirdparty_sources = [ + "png.c", + "pngerror.c", + "pngget.c", + "pngmem.c", + "pngpread.c", + "pngread.c", + "pngrio.c", + "pngrtran.c", + "pngrutil.c", + "pngset.c", + "pngtrans.c", + "pngwio.c", + "pngwrite.c", + "pngwtran.c", + "pngwutil.c", + ] + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - env_png.add_source_files(env.drivers_sources, thirdparty_sources) - env_png.Append(CPPPATH = [thirdparty_dir]) + env_png.add_source_files(env.drivers_sources, thirdparty_sources) + env_png.Append(CPPPATH=[thirdparty_dir]) - # Currently .ASM filter_neon.S does not compile on NT. - import os - if ("neon_enabled" in env and env["neon_enabled"]) and os.name!="nt": - env_png.Append(CPPFLAGS = ["-DPNG_ARM_NEON_OPT=2"]) - env_neon = env_png.Clone(); - if "S_compiler" in env: - env_neon['CC'] = env['S_compiler'] - neon_sources = [] - neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/arm_init.c")) - neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon_intrinsics.c")) - neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon.S")) - env.drivers_sources += neon_sources - else: - env_png.Append(CPPFLAGS = ["-DPNG_ARM_NEON_OPT=0"]) + # Currently .ASM filter_neon.S does not compile on NT. + import os + if ("neon_enabled" in env and env["neon_enabled"]) and os.name != "nt": + env_png.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=2"]) + env_neon = env_png.Clone() + if "S_compiler" in env: + env_neon['CC'] = env['S_compiler'] + neon_sources = [] + neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/arm_init.c")) + neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon_intrinsics.c")) + neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon.S")) + env.drivers_sources += neon_sources + else: + env_png.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=0"]) # Godot source files env_png.add_source_files(env.drivers_sources, "*.cpp") diff --git a/drivers/rtaudio/SCsub b/drivers/rtaudio/SCsub index f0273dd421..2b0a602965 100644 --- a/drivers/rtaudio/SCsub +++ b/drivers/rtaudio/SCsub @@ -7,12 +7,12 @@ Import('env') # Thirdparty source files thirdparty_dir = "#thirdparty/rtaudio/" thirdparty_sources = [ - "RtAudio.cpp", + "RtAudio.cpp", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] env.add_source_files(env.drivers_sources, thirdparty_sources) -env.Append(CPPPATH = [thirdparty_dir]) +env.Append(CPPPATH=[thirdparty_dir]) # Driver source files env.add_source_files(env.drivers_sources, "*.cpp") diff --git a/drivers/unix/SCsub b/drivers/unix/SCsub index fe427e747f..3766e782e4 100644 --- a/drivers/unix/SCsub +++ b/drivers/unix/SCsub @@ -2,13 +2,13 @@ Import('env') -g_set_p='#ifdef UNIX_ENABLED\n' -g_set_p+='#include "os_unix.h"\n' -g_set_p+='String OS_Unix::get_global_settings_path() const {\n' -g_set_p+='\treturn "' + env["unix_global_settings_path"]+'";\n' -g_set_p+='}\n' -g_set_p+='#endif' -f = open("os_unix_global_settings_path.cpp","wb") +g_set_p = '#ifdef UNIX_ENABLED\n' +g_set_p += '#include "os_unix.h"\n' +g_set_p += 'String OS_Unix::get_global_settings_path() const {\n' +g_set_p += '\treturn "' + env["unix_global_settings_path"] + '";\n' +g_set_p += '}\n' +g_set_p += '#endif' +f = open("os_unix_global_settings_path.cpp", "wb") f.write(g_set_p) f.close() diff --git a/drivers/unix/socket_helpers.h b/drivers/unix/socket_helpers.h index 9693911acd..3aaae82da2 100644 --- a/drivers/unix/socket_helpers.h +++ b/drivers/unix/socket_helpers.h @@ -10,6 +10,10 @@ #endif #endif +#ifdef WINRT_ENABLED +#define in6addr_any IN6ADDR_ANY_INIT +#endif + // helpers for sockaddr -> IP_Address and back, should work for posix and winsock. All implementations should use this static size_t _set_sockaddr(struct sockaddr_storage* p_addr, const IP_Address& p_ip, int p_port) { diff --git a/drivers/zlib/SCsub b/drivers/zlib/SCsub index 6a099aff52..407deb5f6e 100644 --- a/drivers/zlib/SCsub +++ b/drivers/zlib/SCsub @@ -8,19 +8,19 @@ Import('env') # No check here as already done in drivers/SCsub thirdparty_dir = "#thirdparty/zlib/" thirdparty_sources = [ - "adler32.c", - "compress.c", - "crc32.c", - "deflate.c", - "infback.c", - "inffast.c", - "inflate.c", - "inftrees.c", - "trees.c", - "uncompr.c", - "zutil.c", + "adler32.c", + "compress.c", + "crc32.c", + "deflate.c", + "infback.c", + "inffast.c", + "inflate.c", + "inftrees.c", + "trees.c", + "uncompr.c", + "zutil.c", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] env.add_source_files(env.drivers_sources, thirdparty_sources) -env.Append(CPPPATH = [thirdparty_dir]) +env.Append(CPPPATH=[thirdparty_dir]) diff --git a/main/SCsub b/main/SCsub index cd9002de0a..a83563f44d 100644 --- a/main/SCsub +++ b/main/SCsub @@ -2,11 +2,11 @@ Import('env') -env.main_sources=[] -env.add_source_files(env.main_sources,"*.cpp") +env.main_sources = [] +env.add_source_files(env.main_sources, "*.cpp") Export('env') -lib = env.Library("main",env.main_sources) +lib = env.Library("main", env.main_sources) env.Prepend(LIBS=[lib]) diff --git a/main/main.cpp b/main/main.cpp index 912e8adf4f..6c840a6c23 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -159,7 +159,7 @@ void Main::print_help(const char* p_binary) { OS::get_singleton()->print("%s",OS::get_singleton()->get_video_driver_name(i)); } OS::get_singleton()->print(")\n"); - OS::get_singleton()->print("\t-ldpi\t : Force low-dpi mode (OSX Only)"); + OS::get_singleton()->print("\t-ldpi\t : Force low-dpi mode (OSX Only)\n"); OS::get_singleton()->print("\t-ad DRIVER\t : Audio Driver ("); for (int i=0;i<OS::get_singleton()->get_audio_driver_count();i++) { @@ -169,8 +169,7 @@ void Main::print_help(const char* p_binary) { OS::get_singleton()->print("%s",OS::get_singleton()->get_audio_driver_name(i)); } OS::get_singleton()->print(")\n"); - OS::get_singleton()->print("\t-rthread <mode>\t : Render Thread Mode ('unsafe', 'safe', 'separate)."); - OS::get_singleton()->print(")\n"); + OS::get_singleton()->print("\t-rthread <mode>\t : Render Thread Mode ('unsafe', 'safe', 'separate').\n"); OS::get_singleton()->print("\t-s,-script [script] : Run a script.\n"); OS::get_singleton()->print("\t-d,-debug : Debug (local stdout debugger).\n"); OS::get_singleton()->print("\t-rdebug ADDRESS : Remote debug (<ip>:<port> host address).\n"); diff --git a/methods.py b/methods.py index efe2400c1c..91afd9e70b 100755 --- a/methods.py +++ b/methods.py @@ -1,258 +1,253 @@ import os -def add_source_files(self, sources, filetype, lib_env = None, shared = False): - import glob; - import string; - #if not lib_objects: - if not lib_env: - lib_env = self - if type(filetype) == type(""): - - dir = self.Dir('.').abspath - list = glob.glob(dir + "/"+filetype) - for f in list: - sources.append( self.Object(f) ) - else: - for f in filetype: - sources.append(self.Object(f)) - - -def build_shader_header( target, source, env ): - - for x in source: - print x - - name = str(x) - name = name[ name.rfind("/")+1: ] - name = name[ name.rfind("\\")+1: ] - name = name.replace(".","_") - - - fs = open(str(x),"r") - fd = open(str(x)+".h","w") - fd.write("/* this file has been generated by SCons, do not edit! */\n") - fd.write("static const char *"+name+"=\n") - line=fs.readline() - while(line): - line=line.replace("\r","") - line=line.replace("\n","") - line=line.replace("\\","\\\\") - line=line.replace("\"","\\\"") - fd.write("\""+line+"\\n\"\n") - line=fs.readline() - - fd.write(";\n") - - return 0 - - -def build_glsl_header( filename ): - - fs = open(filename,"r") - line=fs.readline() - - vertex_lines=[] - fragment_lines=[] - uniforms=[] - attributes=[] - fbos=[] - conditionals=[] - texunits=[] - texunit_names=[] - ubos=[] - ubo_names=[] - - reading="" - line_offset=0 - vertex_offset=0 - fragment_offset=0 - - while(line): - - if (line.find("[vertex]")!=-1): - reading="vertex" - line=fs.readline() - line_offset+=1 - vertex_offset=line_offset - continue - - if (line.find("[fragment]")!=-1): - reading="fragment" - line=fs.readline() - line_offset+=1 - fragment_offset=line_offset - continue - - if (line.find("#ifdef ")!=-1): - ifdefline = line.replace("#ifdef ","").strip() - if (not ifdefline in conditionals): - conditionals+=[ifdefline] - - if (line.find("#elif defined(")!=-1): - ifdefline = line.replace("#elif defined(","").strip() - ifdefline = ifdefline.replace(")","").strip() - if (not ifdefline in conditionals): - conditionals+=[ifdefline] - - - import re - if re.search(r"^\s*uniform", line): - - if (line.lower().find("texunit:")!=-1): - #texture unit - texunit = str(int( line[line.find(":")+1:].strip() )) - uline=line[:line.lower().find("//")] - uline = uline.replace("uniform",""); - uline = uline.replace(";",""); - lines = uline.split(",") - for x in lines: - - x = x.strip() - x = x[ x.rfind(" ")+1: ] - if (x.find("[")!=-1): - #unfiorm array - x = x[ :x.find("[") ] - - if (not x in texunit_names): - texunits+=[(x,texunit)] - texunit_names+=[x] - - elif (line.lower().find("ubo:")!=-1): - #ubo - uboidx = str(int( line[line.find(":")+1:].strip() )) - uline=line[:line.lower().find("//")] - uline = uline[uline.find("uniform")+len("uniform"):]; - uline = uline.replace(";",""); - uline = uline.replace("{",""); - lines = uline.split(",") - for x in lines: - - x = x.strip() - x = x[ x.rfind(" ")+1: ] - if (x.find("[")!=-1): - #unfiorm array - x = x[ :x.find("[") ] - - if (not x in ubo_names): - ubos+=[(x,uboidx)] - ubo_names+=[x] - - - - else: - uline = line.replace("uniform",""); - uline = uline.replace(";",""); - lines = uline.split(",") - for x in lines: - - x = x.strip() - x = x[ x.rfind(" ")+1: ] - if (x.find("[")!=-1): - #unfiorm array - x = x[ :x.find("[") ] - - if (not x in uniforms): - uniforms+=[x] - - if ((line.strip().find("in ")==0 or line.strip().find("attribute ")==0) and line.find("attrib:")!=-1): - uline = line.replace("in ",""); - uline = uline.replace("attribute ",""); - uline = uline.replace(";",""); - uline = uline[ uline.find(" "): ].strip() - - - if (uline.find("//")!=-1): - name,bind = uline.split("//") - if (bind.find("attrib:")!=-1): - name=name.strip() - bind=bind.replace("attrib:","").strip() - attributes+=[(name,bind)] - - if (line.strip().find("out ")==0): - uline = line.replace("out","").strip(); - uline = uline.replace(";",""); - uline = uline[ uline.find(" "): ].strip() - - - if (uline.find("//")!=-1): - name,bind = uline.split("//") - if (bind.find("drawbuffer:")!=-1): - name=name.strip() - bind=bind.replace("drawbuffer:","").strip() - fbos+=[(name,bind)] - - line=line.replace("\r","") - line=line.replace("\n","") - line=line.replace("\\","\\\\") - line=line.replace("\"","\\\"") - #line=line+"\\n\\" no need to anymore - - if (reading=="vertex"): - vertex_lines+=[line] - if (reading=="fragment"): - fragment_lines+=[line] - - line=fs.readline() - line_offset+=1 - - fs.close(); - - out_file = filename+".h" - fd = open(out_file,"w") - - fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n"); - - out_file_base = out_file - out_file_base = out_file_base[ out_file_base.rfind("/")+1: ] - out_file_base = out_file_base[ out_file_base.rfind("\\")+1: ] + +def add_source_files(self, sources, filetype, lib_env=None, shared=False): + import glob + import string + # if not lib_objects: + if not lib_env: + lib_env = self + if type(filetype) == type(""): + + dir = self.Dir('.').abspath + list = glob.glob(dir + "/" + filetype) + for f in list: + sources.append(self.Object(f)) + else: + for f in filetype: + sources.append(self.Object(f)) + + +def build_shader_header(target, source, env): + + for x in source: + print x + + name = str(x) + name = name[name.rfind("/") + 1:] + name = name[name.rfind("\\") + 1:] + name = name.replace(".", "_") + + fs = open(str(x), "r") + fd = open(str(x) + ".h", "w") + fd.write("/* this file has been generated by SCons, do not edit! */\n") + fd.write("static const char *" + name + "=\n") + line = fs.readline() + while(line): + line = line.replace("\r", "") + line = line.replace("\n", "") + line = line.replace("\\", "\\\\") + line = line.replace("\"", "\\\"") + fd.write("\"" + line + "\\n\"\n") + line = fs.readline() + + fd.write(";\n") + + return 0 + + +def build_glsl_header(filename): + + fs = open(filename, "r") + line = fs.readline() + + vertex_lines = [] + fragment_lines = [] + uniforms = [] + attributes = [] + fbos = [] + conditionals = [] + texunits = [] + texunit_names = [] + ubos = [] + ubo_names = [] + + reading = "" + line_offset = 0 + vertex_offset = 0 + fragment_offset = 0 + + while(line): + + if (line.find("[vertex]") != -1): + reading = "vertex" + line = fs.readline() + line_offset += 1 + vertex_offset = line_offset + continue + + if (line.find("[fragment]") != -1): + reading = "fragment" + line = fs.readline() + line_offset += 1 + fragment_offset = line_offset + continue + + if (line.find("#ifdef ") != -1): + ifdefline = line.replace("#ifdef ", "").strip() + if (not ifdefline in conditionals): + conditionals += [ifdefline] + + if (line.find("#elif defined(") != -1): + ifdefline = line.replace("#elif defined(", "").strip() + ifdefline = ifdefline.replace(")", "").strip() + if (not ifdefline in conditionals): + conditionals += [ifdefline] + + import re + if re.search(r"^\s*uniform", line): + + if (line.lower().find("texunit:") != -1): + # texture unit + texunit = str(int(line[line.find(":") + 1:].strip())) + uline = line[:line.lower().find("//")] + uline = uline.replace("uniform", "") + uline = uline.replace(";", "") + lines = uline.split(",") + for x in lines: + + x = x.strip() + x = x[x.rfind(" ") + 1:] + if (x.find("[") != -1): + # unfiorm array + x = x[:x.find("[")] + + if (not x in texunit_names): + texunits += [(x, texunit)] + texunit_names += [x] + + elif (line.lower().find("ubo:") != -1): + # ubo + uboidx = str(int(line[line.find(":") + 1:].strip())) + uline = line[:line.lower().find("//")] + uline = uline[uline.find("uniform") + len("uniform"):] + uline = uline.replace(";", "") + uline = uline.replace("{", "") + lines = uline.split(",") + for x in lines: + + x = x.strip() + x = x[x.rfind(" ") + 1:] + if (x.find("[") != -1): + # unfiorm array + x = x[:x.find("[")] + + if (not x in ubo_names): + ubos += [(x, uboidx)] + ubo_names += [x] + + else: + uline = line.replace("uniform", "") + uline = uline.replace(";", "") + lines = uline.split(",") + for x in lines: + + x = x.strip() + x = x[x.rfind(" ") + 1:] + if (x.find("[") != -1): + # unfiorm array + x = x[:x.find("[")] + + if (not x in uniforms): + uniforms += [x] + + if ((line.strip().find("in ") == 0 or line.strip().find("attribute ") == 0) and line.find("attrib:") != -1): + uline = line.replace("in ", "") + uline = uline.replace("attribute ", "") + uline = uline.replace(";", "") + uline = uline[uline.find(" "):].strip() + + if (uline.find("//") != -1): + name, bind = uline.split("//") + if (bind.find("attrib:") != -1): + name = name.strip() + bind = bind.replace("attrib:", "").strip() + attributes += [(name, bind)] + + if (line.strip().find("out ") == 0): + uline = line.replace("out", "").strip() + uline = uline.replace(";", "") + uline = uline[uline.find(" "):].strip() + + if (uline.find("//") != -1): + name, bind = uline.split("//") + if (bind.find("drawbuffer:") != -1): + name = name.strip() + bind = bind.replace("drawbuffer:", "").strip() + fbos += [(name, bind)] + + line = line.replace("\r", "") + line = line.replace("\n", "") + line = line.replace("\\", "\\\\") + line = line.replace("\"", "\\\"") + # line=line+"\\n\\" no need to anymore + + if (reading == "vertex"): + vertex_lines += [line] + if (reading == "fragment"): + fragment_lines += [line] + + line = fs.readline() + line_offset += 1 + + fs.close() + + out_file = filename + ".h" + fd = open(out_file, "w") + + fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n") + + out_file_base = out_file + out_file_base = out_file_base[out_file_base.rfind("/") + 1:] + out_file_base = out_file_base[out_file_base.rfind("\\") + 1:] # print("out file "+out_file+" base " +out_file_base) - out_file_ifdef = out_file_base.replace(".","_").upper() - fd.write("#ifndef "+out_file_ifdef+"\n") - fd.write("#define "+out_file_ifdef+"\n") - - out_file_class = out_file_base.replace(".glsl.h","").title().replace("_","").replace(".","")+"ShaderGL"; - fd.write("\n\n"); - fd.write("#include \"drivers/opengl/shader_gl.h\"\n\n\n"); - fd.write("class "+out_file_class+" : public ShaderGL {\n\n"); - fd.write("\t virtual String get_shader_name() const { return \""+out_file_class+"\"; }\n"); - fd.write("public:\n\n"); - - if (len(conditionals)): - fd.write("\tenum Conditionals {\n"); - for x in conditionals: - fd.write("\t\t"+x+",\n"); - fd.write("\t};\n\n"); - if (len(uniforms)): - fd.write("\tenum Uniforms {\n"); - for x in uniforms: - fd.write("\t\t"+x.upper()+",\n"); - fd.write("\t};\n\n"); - - fd.write("\t_FORCE_INLINE_ int get_uniform(Uniforms p_uniform) const { return _get_uniform(p_uniform); }\n\n"); - if (len(conditionals)): - - fd.write("\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n"); - fd.write("\t#define _FU if (get_uniform(p_uniform)<0) return; ERR_FAIL_COND( get_active()!=this );\n\n "); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, unsigned long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU GLfloat col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; glUniform4fv(get_uniform(p_uniform),1,col); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU GLfloat vec2[2]={p_vec2.x,p_vec2.y}; glUniform2fv(get_uniform(p_uniform),1,vec2); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU GLfloat vec3[3]={p_vec3.x,p_vec3.y,p_vec3.z}; glUniform3fv(get_uniform(p_uniform),1,vec3); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU glUniform2f(get_uniform(p_uniform),p_a,p_b); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU glUniform3f(get_uniform(p_uniform),p_a,p_b,p_c); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU glUniform4f(get_uniform(p_uniform),p_a,p_b,p_c,p_d); }\n\n"); - - fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU + out_file_ifdef = out_file_base.replace(".", "_").upper() + fd.write("#ifndef " + out_file_ifdef + "\n") + fd.write("#define " + out_file_ifdef + "\n") + + out_file_class = out_file_base.replace(".glsl.h", "").title().replace("_", "").replace(".", "") + "ShaderGL" + fd.write("\n\n") + fd.write("#include \"drivers/opengl/shader_gl.h\"\n\n\n") + fd.write("class " + out_file_class + " : public ShaderGL {\n\n") + fd.write("\t virtual String get_shader_name() const { return \"" + out_file_class + "\"; }\n") + fd.write("public:\n\n") + + if (len(conditionals)): + fd.write("\tenum Conditionals {\n") + for x in conditionals: + fd.write("\t\t" + x + ",\n") + fd.write("\t};\n\n") + if (len(uniforms)): + fd.write("\tenum Uniforms {\n") + for x in uniforms: + fd.write("\t\t" + x.upper() + ",\n") + fd.write("\t};\n\n") + + fd.write("\t_FORCE_INLINE_ int get_uniform(Uniforms p_uniform) const { return _get_uniform(p_uniform); }\n\n") + if (len(conditionals)): + + fd.write("\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n") + fd.write("\t#define _FU if (get_uniform(p_uniform)<0) return; ERR_FAIL_COND( get_active()!=this );\n\n ") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") + #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); + #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, unsigned long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU GLfloat col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; glUniform4fv(get_uniform(p_uniform),1,col); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU GLfloat vec2[2]={p_vec2.x,p_vec2.y}; glUniform2fv(get_uniform(p_uniform),1,vec2); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU GLfloat vec3[3]={p_vec3.x,p_vec3.y,p_vec3.z}; glUniform3fv(get_uniform(p_uniform),1,vec3); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU glUniform2f(get_uniform(p_uniform),p_a,p_b); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU glUniform3f(get_uniform(p_uniform),p_a,p_b,p_c); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU glUniform4f(get_uniform(p_uniform),p_a,p_b,p_c,p_d); }\n\n") + + fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU const Transform &tr = p_transform; @@ -281,9 +276,9 @@ def build_glsl_header( filename ): } - """); + """) - fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Matrix32& p_transform) { _FU + fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Matrix32& p_transform) { _FU const Matrix32 &tr = p_transform; @@ -312,9 +307,9 @@ def build_glsl_header( filename ): } - """); + """) - fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU + fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU GLfloat matrix[16]; @@ -326,233 +321,226 @@ def build_glsl_header( filename ): } glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix); - }; """); - - fd.write("\n\n#undef _FU\n\n\n"); - - - fd.write("\tvirtual void init() {\n\n"); - if (len(conditionals)): - - fd.write("\t\tstatic const char* _conditional_strings[]={\n") - if (len(conditionals)): - for x in conditionals: - fd.write("\t\t\t\"#define "+x+"\\n\",\n"); - fd.write("\t\t};\n\n"); - else: - fd.write("\t\tstatic const char **_conditional_strings=NULL;\n") - - if (len(uniforms)): - - fd.write("\t\tstatic const char* _uniform_strings[]={\n") - if (len(uniforms)): - for x in uniforms: - fd.write("\t\t\t\""+x+"\",\n"); - fd.write("\t\t};\n\n"); - else: - fd.write("\t\tstatic const char **_uniform_strings=NULL;\n") - - if (len(attributes)): - - fd.write("\t\tstatic AttributePair _attribute_pairs[]={\n") - for x in attributes: - fd.write("\t\t\t{\""+x[0]+"\","+x[1]+"},\n"); - fd.write("\t\t};\n\n"); - else: - fd.write("\t\tstatic AttributePair *_attribute_pairs=NULL;\n") - - - - if (len(fbos)): - fd.write("\t\tstatic FBOPair _fbo_pairs[]={\n") - for x in fbos: - fd.write("\t\t\t{\""+x[0]+"\","+x[1]+"},\n"); - fd.write("\t\t};\n\n"); - else: - fd.write("\t\tstatic FBOPair *_fbo_pairs=NULL;\n") - - if (len(ubos)): - fd.write("\t\tstatic UBOPair _ubo_pairs[]={\n") - for x in ubos: - fd.write("\t\t\t{\""+x[0]+"\","+x[1]+"},\n"); - fd.write("\t\t};\n\n"); - else: - fd.write("\t\tstatic UBOPair *_ubo_pairs=NULL;\n") - - if (len(texunits)): - fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n") - for x in texunits: - fd.write("\t\t\t{\""+x[0]+"\","+x[1]+"},\n"); - fd.write("\t\t};\n\n"); - else: - fd.write("\t\tstatic TexUnitPair *_texunit_pairs=NULL;\n") - - fd.write("\t\tstatic const char* _vertex_code=\"\\\n") - for x in vertex_lines: - fd.write("\t\t\t"+x+"\n"); - fd.write("\t\t\";\n\n"); - - fd.write("\t\tstatic const int _vertex_code_start="+str(vertex_offset)+";\n") + }; """) + fd.write("\n\n#undef _FU\n\n\n") - fd.write("\t\tstatic const char* _fragment_code=\"\\\n") - for x in fragment_lines: - fd.write("\t\t\t"+x+"\n"); - fd.write("\t\t\";\n\n"); + fd.write("\tvirtual void init() {\n\n") + if (len(conditionals)): - fd.write("\t\tstatic const int _fragment_code_start="+str(fragment_offset)+";\n") + fd.write("\t\tstatic const char* _conditional_strings[]={\n") + if (len(conditionals)): + for x in conditionals: + fd.write("\t\t\t\"#define " + x + "\\n\",\n") + fd.write("\t\t};\n\n") + else: + fd.write("\t\tstatic const char **_conditional_strings=NULL;\n") - fd.write("\t\tsetup(_conditional_strings,"+str(len(conditionals))+",_uniform_strings,"+str(len(uniforms))+",_attribute_pairs,"+str(len(attributes))+",_fbo_pairs,"+str(len(fbos))+",_ubo_pairs,"+str(len(ubos))+",_texunit_pairs,"+str(len(texunits))+",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n") - fd.write("\t};\n\n") + if (len(uniforms)): - fd.write("};\n\n"); - fd.write("#endif\n\n"); - fd.close(); + fd.write("\t\tstatic const char* _uniform_strings[]={\n") + if (len(uniforms)): + for x in uniforms: + fd.write("\t\t\t\"" + x + "\",\n") + fd.write("\t\t};\n\n") + else: + fd.write("\t\tstatic const char **_uniform_strings=NULL;\n") + + if (len(attributes)): + + fd.write("\t\tstatic AttributePair _attribute_pairs[]={\n") + for x in attributes: + fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n") + fd.write("\t\t};\n\n") + else: + fd.write("\t\tstatic AttributePair *_attribute_pairs=NULL;\n") + + if (len(fbos)): + fd.write("\t\tstatic FBOPair _fbo_pairs[]={\n") + for x in fbos: + fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n") + fd.write("\t\t};\n\n") + else: + fd.write("\t\tstatic FBOPair *_fbo_pairs=NULL;\n") + + if (len(ubos)): + fd.write("\t\tstatic UBOPair _ubo_pairs[]={\n") + for x in ubos: + fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n") + fd.write("\t\t};\n\n") + else: + fd.write("\t\tstatic UBOPair *_ubo_pairs=NULL;\n") + + if (len(texunits)): + fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n") + for x in texunits: + fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n") + fd.write("\t\t};\n\n") + else: + fd.write("\t\tstatic TexUnitPair *_texunit_pairs=NULL;\n") + + fd.write("\t\tstatic const char* _vertex_code=\"\\\n") + for x in vertex_lines: + fd.write("\t\t\t" + x + "\n") + fd.write("\t\t\";\n\n") + + fd.write("\t\tstatic const int _vertex_code_start=" + str(vertex_offset) + ";\n") + + fd.write("\t\tstatic const char* _fragment_code=\"\\\n") + for x in fragment_lines: + fd.write("\t\t\t" + x + "\n") + fd.write("\t\t\";\n\n") + + fd.write("\t\tstatic const int _fragment_code_start=" + str(fragment_offset) + ";\n") + + fd.write("\t\tsetup(_conditional_strings," + str(len(conditionals)) + ",_uniform_strings," + str(len(uniforms)) + ",_attribute_pairs," + str(len(attributes)) + ",_fbo_pairs," + str(len(fbos)) + ",_ubo_pairs," + str(len(ubos)) + ",_texunit_pairs," + str(len(texunits)) + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n") + fd.write("\t};\n\n") + + fd.write("};\n\n") + fd.write("#endif\n\n") + fd.close() + + +def build_glsl_headers(target, source, env): + + for x in source: + + build_glsl_header(str(x)) + + return 0 + + +def build_hlsl_dx9_header(filename): + + fs = open(filename, "r") + line = fs.readline() + + vertex_lines = [] + fragment_lines = [] + uniforms = [] + fragment_uniforms = [] + attributes = [] + fbos = [] + conditionals = [] + + reading = "" + line_offset = 0 + vertex_offset = 0 + fragment_offset = 0 + + while(line): + + if (line.find("[vertex]") != -1): + reading = "vertex" + line = fs.readline() + line_offset += 1 + vertex_offset = line_offset + continue + + if (line.find("[fragment]") != -1): + reading = "fragment" + line = fs.readline() + line_offset += 1 + fragment_offset = line_offset + continue + + if (line.find("#ifdef ") != -1): + ifdefline = line.replace("#ifdef ", "").strip() + if (not ifdefline in conditionals): + conditionals += [ifdefline] + + if (line.find("#elif defined(") != -1): + ifdefline = line.replace("#elif defined(", "").strip() + ifdefline = ifdefline.replace(")", "").strip() + if (not ifdefline in conditionals): + conditionals += [ifdefline] + if (line.find("uniform") != -1): + uline = line.replace("uniform", "") + uline = uline.replace(";", "") + lines = uline.split(",") + for x in lines: + + x = x.strip() + x = x[x.rfind(" ") + 1:] + if (x.find("[") != -1): + # unfiorm array + x = x[:x.find("[")] + + if (not x in uniforms): + uniforms += [x] + fragment_uniforms += [reading == "fragment"] + line = line.replace("\r", "") + line = line.replace("\n", "") + line = line.replace("\\", "\\\\") + line = line.replace("\"", "\\\"") + line = line + "\\n\\" + if (reading == "vertex"): + vertex_lines += [line] + if (reading == "fragment"): + fragment_lines += [line] -def build_glsl_headers( target, source, env ): + line = fs.readline() + line_offset += 1 - for x in source: + fs.close() - build_glsl_header(str(x)); + out_file = filename + ".h" + fd = open(out_file, "w") + fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n") - return 0 - - - -def build_hlsl_dx9_header( filename ): - - fs = open(filename,"r") - line=fs.readline() - - vertex_lines=[] - fragment_lines=[] - uniforms=[] - fragment_uniforms=[] - attributes=[] - fbos=[] - conditionals=[] - - reading="" - line_offset=0 - vertex_offset=0 - fragment_offset=0 - - while(line): - - if (line.find("[vertex]")!=-1): - reading="vertex" - line=fs.readline() - line_offset+=1 - vertex_offset=line_offset - continue - - if (line.find("[fragment]")!=-1): - reading="fragment" - line=fs.readline() - line_offset+=1 - fragment_offset=line_offset - continue - - if (line.find("#ifdef ")!=-1): - ifdefline = line.replace("#ifdef ","").strip() - if (not ifdefline in conditionals): - conditionals+=[ifdefline] - - if (line.find("#elif defined(")!=-1): - ifdefline = line.replace("#elif defined(","").strip() - ifdefline = ifdefline.replace(")","").strip() - if (not ifdefline in conditionals): - conditionals+=[ifdefline] - if (line.find("uniform")!=-1): - uline = line.replace("uniform",""); - uline = uline.replace(";",""); - lines = uline.split(",") - for x in lines: - - x = x.strip() - x = x[ x.rfind(" ")+1: ] - if (x.find("[")!=-1): - #unfiorm array - x = x[ :x.find("[") ] - - if (not x in uniforms): - uniforms+=[x] - fragment_uniforms+=[reading=="fragment"] - line=line.replace("\r","") - line=line.replace("\n","") - line=line.replace("\\","\\\\") - line=line.replace("\"","\\\"") - line=line+"\\n\\" - - if (reading=="vertex"): - vertex_lines+=[line] - if (reading=="fragment"): - fragment_lines+=[line] - - line=fs.readline() - line_offset+=1 - - fs.close(); - - out_file = filename+".h" - fd = open(out_file,"w") - - fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n"); - - out_file_base = out_file - out_file_base = out_file_base[ out_file_base.rfind("/")+1: ] - out_file_base = out_file_base[ out_file_base.rfind("\\")+1: ] + out_file_base = out_file + out_file_base = out_file_base[out_file_base.rfind("/") + 1:] + out_file_base = out_file_base[out_file_base.rfind("\\") + 1:] # print("out file "+out_file+" base " +out_file_base) - out_file_ifdef = out_file_base.replace(".","_").upper() - fd.write("#ifndef "+out_file_ifdef+"\n") - fd.write("#define "+out_file_ifdef+"\n") - - out_file_class = out_file_base.replace(".hlsl.h","").title().replace("_","").replace(".","")+"ShaderDX9"; - fd.write("\n\n"); - fd.write("#include \"drivers/directx9/shader_dx9.h\"\n\n\n"); - fd.write("class "+out_file_class+" : public ShaderDX9 {\n\n"); - fd.write("\t virtual String get_shader_name() const { return \""+out_file_class+"\"; }\n"); - fd.write("public:\n\n"); - - if (len(conditionals)): - fd.write("\tenum Conditionals {\n"); - for x in conditionals: - fd.write("\t\t"+x+",\n"); - fd.write("\t};\n\n"); - if (len(uniforms)): - fd.write("\tenum Uniforms {\n"); - for x in uniforms: - fd.write("\t\t"+x.upper()+",\n"); - fd.write("\t};\n\n"); - - - if (len(conditionals)): - fd.write("\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n"); - - fd.write("\t#define _FU if (!_uniform_valid(p_uniform)) return; ERR_FAIL_COND( get_active()!=this );\n\n "); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, bool p_value) { _FU set_uniformb(p_uniform,p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU set_uniformf(p_uniform,p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU set_uniformf(p_uniform,p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); - #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint64_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); - #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int64_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, unsigned long p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, long p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU float col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; set_uniformfv(p_uniform,col); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU float vec2[4]={p_vec2.x,p_vec2.y,0,0}; set_uniformfv(p_uniform,vec2); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU float vec3[4]={p_vec3.x,p_vec3.y,p_vec3.z,0}; set_uniformfv(p_uniform,vec3); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU float vec2[4]={p_a,p_b,0,0}; set_uniformfv(p_uniform,vec2); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU float vec3[4]={p_a,p_b,p_c,0}; set_uniformfv(p_uniform,vec3); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU float vec4[4]={p_a,p_b,p_c,p_d}; set_uniformfv(p_uniform,vec4); }\n\n"); - - fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU + out_file_ifdef = out_file_base.replace(".", "_").upper() + fd.write("#ifndef " + out_file_ifdef + "\n") + fd.write("#define " + out_file_ifdef + "\n") + + out_file_class = out_file_base.replace(".hlsl.h", "").title().replace("_", "").replace(".", "") + "ShaderDX9" + fd.write("\n\n") + fd.write("#include \"drivers/directx9/shader_dx9.h\"\n\n\n") + fd.write("class " + out_file_class + " : public ShaderDX9 {\n\n") + fd.write("\t virtual String get_shader_name() const { return \"" + out_file_class + "\"; }\n") + fd.write("public:\n\n") + + if (len(conditionals)): + fd.write("\tenum Conditionals {\n") + for x in conditionals: + fd.write("\t\t" + x + ",\n") + fd.write("\t};\n\n") + if (len(uniforms)): + fd.write("\tenum Uniforms {\n") + for x in uniforms: + fd.write("\t\t" + x.upper() + ",\n") + fd.write("\t};\n\n") + + if (len(conditionals)): + fd.write("\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n") + + fd.write("\t#define _FU if (!_uniform_valid(p_uniform)) return; ERR_FAIL_COND( get_active()!=this );\n\n ") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, bool p_value) { _FU set_uniformb(p_uniform,p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU set_uniformf(p_uniform,p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU set_uniformf(p_uniform,p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n") + #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint64_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); + #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int64_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, unsigned long p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, long p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU float col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; set_uniformfv(p_uniform,col); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU float vec2[4]={p_vec2.x,p_vec2.y,0,0}; set_uniformfv(p_uniform,vec2); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU float vec3[4]={p_vec3.x,p_vec3.y,p_vec3.z,0}; set_uniformfv(p_uniform,vec3); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU float vec2[4]={p_a,p_b,0,0}; set_uniformfv(p_uniform,vec2); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU float vec3[4]={p_a,p_b,p_c,0}; set_uniformfv(p_uniform,vec3); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU float vec4[4]={p_a,p_b,p_c,p_d}; set_uniformfv(p_uniform,vec4); }\n\n") + + fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU const Transform &tr = p_transform; @@ -579,9 +567,9 @@ def build_hlsl_dx9_header( filename ): } - """); + """) - fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU + fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU float matrix[16]; @@ -593,301 +581,291 @@ def build_hlsl_dx9_header( filename ): } set_uniformfv(p_uniform,&matrix[0],4); - }; """); + }; """) - fd.write("\n\n#undef _FU\n\n\n"); + fd.write("\n\n#undef _FU\n\n\n") + fd.write("\tvirtual void init(IDirect3DDevice9 *p_device,ShaderSupport p_version) {\n\n") + if (len(conditionals)): - fd.write("\tvirtual void init(IDirect3DDevice9 *p_device,ShaderSupport p_version) {\n\n"); - if (len(conditionals)): + fd.write("\t\tstatic const char* _conditional_strings[]={\n") + if (len(conditionals)): + for x in conditionals: + fd.write("\t\t\t\"" + x + "\",\n") + fd.write("\t\t};\n\n") + else: + fd.write("\t\tstatic const char **_conditional_strings=NULL;\n") - fd.write("\t\tstatic const char* _conditional_strings[]={\n") - if (len(conditionals)): - for x in conditionals: - fd.write("\t\t\t\""+x+"\",\n"); - fd.write("\t\t};\n\n"); - else: - fd.write("\t\tstatic const char **_conditional_strings=NULL;\n") + if (len(uniforms)): - if (len(uniforms)): + fd.write("\t\tstatic const char* _uniform_strings[]={\n") + if (len(uniforms)): + for x in uniforms: + fd.write("\t\t\t\"" + x + "\",\n") + fd.write("\t\t};\n\n") - fd.write("\t\tstatic const char* _uniform_strings[]={\n") - if (len(uniforms)): - for x in uniforms: - fd.write("\t\t\t\""+x+"\",\n"); - fd.write("\t\t};\n\n"); + fd.write("\t\tstatic const bool _fragment_uniforms[]={\n") - fd.write("\t\tstatic const bool _fragment_uniforms[]={\n") - - if (len(uniforms)): - for x in fragment_uniforms: - if (x): - fd.write("\t\t\ttrue,\n"); - else: - fd.write("\t\t\tfalse,\n"); - fd.write("\t\t};\n\n"); - else: - fd.write("\t\tstatic const char **_uniform_strings=NULL;\n") - fd.write("\t\tstatic const bool *_fragment_uniforms=NULL;\n") + if (len(uniforms)): + for x in fragment_uniforms: + if (x): + fd.write("\t\t\ttrue,\n") + else: + fd.write("\t\t\tfalse,\n") + fd.write("\t\t};\n\n") + else: + fd.write("\t\tstatic const char **_uniform_strings=NULL;\n") + fd.write("\t\tstatic const bool *_fragment_uniforms=NULL;\n") + fd.write("\t\tstatic const char* _vertex_code=\"\\\n") + for x in vertex_lines: + fd.write("\t\t\t" + x + "\n") + fd.write("\t\t\";\n\n") - fd.write("\t\tstatic const char* _vertex_code=\"\\\n") - for x in vertex_lines: - fd.write("\t\t\t"+x+"\n"); - fd.write("\t\t\";\n\n"); + fd.write("\t\tstatic const int _vertex_code_start=" + str(vertex_offset) + ";\n") - fd.write("\t\tstatic const int _vertex_code_start="+str(vertex_offset)+";\n") + fd.write("\t\tstatic const char* _fragment_code=\"\\\n") + for x in fragment_lines: + fd.write("\t\t\t" + x + "\n") + fd.write("\t\t\";\n\n") + fd.write("\t\tstatic const int _fragment_code_start=" + str(fragment_offset) + ";\n") - fd.write("\t\tstatic const char* _fragment_code=\"\\\n") - for x in fragment_lines: - fd.write("\t\t\t"+x+"\n"); - fd.write("\t\t\";\n\n"); + fd.write("\t\tsetup(p_device,p_version,_conditional_strings," + str(len(conditionals)) + ",_uniform_strings," + str(len(uniforms)) + ",_fragment_uniforms,_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n") + fd.write("\t};\n\n") - fd.write("\t\tstatic const int _fragment_code_start="+str(fragment_offset)+";\n") + fd.write("};\n\n") + fd.write("#endif\n\n") + fd.close() - fd.write("\t\tsetup(p_device,p_version,_conditional_strings,"+str(len(conditionals))+",_uniform_strings,"+str(len(uniforms))+",_fragment_uniforms,_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n") - fd.write("\t};\n\n") - fd.write("};\n\n"); - fd.write("#endif\n\n"); - fd.close(); +def build_hlsl_dx9_headers(target, source, env): + for x in source: -def build_hlsl_dx9_headers( target, source, env ): + build_hlsl_dx9_header(str(x)) - for x in source: - - build_hlsl_dx9_header(str(x)); - - - return 0 + return 0 class LegacyGLHeaderStruct: - def __init__(self): - self.vertex_lines=[] - self.fragment_lines=[] - self.uniforms=[] - self.attributes=[] - self.fbos=[] - self.conditionals=[] - self.enums={} - self.texunits=[] - self.texunit_names=[] - self.ubos=[] - self.ubo_names=[] - - self.vertex_included_files=[] - self.fragment_included_files=[] - - self.reading="" - self.line_offset=0 - self.vertex_offset=0 - self.fragment_offset=0 - -def include_file_in_legacygl_header( filename, header_data, depth ): - fs = open(filename,"r") - line=fs.readline() - - while(line): - - if (line.find("[vertex]")!=-1): - header_data.reading="vertex" - line=fs.readline() - header_data.line_offset+=1 - header_data.vertex_offset=header_data.line_offset - continue - - if (line.find("[fragment]")!=-1): - header_data.reading="fragment" - line=fs.readline() - header_data.line_offset+=1 - header_data.fragment_offset=header_data.line_offset - continue - - while(line.find("#include ")!=-1): - includeline = line.replace("#include ","").strip()[1:-1] - - import os.path - - included_file = os.path.relpath(os.path.dirname(filename) + "/" + includeline) - if (not included_file in header_data.vertex_included_files and header_data.reading=="vertex"): - header_data.vertex_included_files+=[included_file] - if(include_file_in_legacygl_header( included_file, header_data, depth + 1 ) == None): - print "Error in file '" + filename + "': #include " + includeline + "could not be found!" - elif (not included_file in header_data.fragment_included_files and header_data.reading=="fragment"): - header_data.fragment_included_files+=[included_file] - if(include_file_in_legacygl_header( included_file, header_data, depth + 1 ) == None): - print "Error in file '" + filename + "': #include " + includeline + "could not be found!" - - line=fs.readline() - - if (line.find("#ifdef ")!=-1 or line.find("#elif defined(")!=-1): - if (line.find("#ifdef ")!=-1): - ifdefline = line.replace("#ifdef ","").strip() - else: - ifdefline = line.replace("#elif defined(","").strip() - ifdefline = ifdefline.replace(")","").strip() - - if (line.find("_EN_")!=-1): - enumbase = ifdefline[:ifdefline.find("_EN_")]; - ifdefline = ifdefline.replace("_EN_","_") - line = line.replace("_EN_","_") + + def __init__(self): + self.vertex_lines = [] + self.fragment_lines = [] + self.uniforms = [] + self.attributes = [] + self.fbos = [] + self.conditionals = [] + self.enums = {} + self.texunits = [] + self.texunit_names = [] + self.ubos = [] + self.ubo_names = [] + + self.vertex_included_files = [] + self.fragment_included_files = [] + + self.reading = "" + self.line_offset = 0 + self.vertex_offset = 0 + self.fragment_offset = 0 + + +def include_file_in_legacygl_header(filename, header_data, depth): + fs = open(filename, "r") + line = fs.readline() + + while(line): + + if (line.find("[vertex]") != -1): + header_data.reading = "vertex" + line = fs.readline() + header_data.line_offset += 1 + header_data.vertex_offset = header_data.line_offset + continue + + if (line.find("[fragment]") != -1): + header_data.reading = "fragment" + line = fs.readline() + header_data.line_offset += 1 + header_data.fragment_offset = header_data.line_offset + continue + + while(line.find("#include ") != -1): + includeline = line.replace("#include ", "").strip()[1:-1] + + import os.path + + included_file = os.path.relpath(os.path.dirname(filename) + "/" + includeline) + if (not included_file in header_data.vertex_included_files and header_data.reading == "vertex"): + header_data.vertex_included_files += [included_file] + if(include_file_in_legacygl_header(included_file, header_data, depth + 1) == None): + print "Error in file '" + filename + "': #include " + includeline + "could not be found!" + elif (not included_file in header_data.fragment_included_files and header_data.reading == "fragment"): + header_data.fragment_included_files += [included_file] + if(include_file_in_legacygl_header(included_file, header_data, depth + 1) == None): + print "Error in file '" + filename + "': #include " + includeline + "could not be found!" + + line = fs.readline() + + if (line.find("#ifdef ") != -1 or line.find("#elif defined(") != -1): + if (line.find("#ifdef ") != -1): + ifdefline = line.replace("#ifdef ", "").strip() + else: + ifdefline = line.replace("#elif defined(", "").strip() + ifdefline = ifdefline.replace(")", "").strip() + + if (line.find("_EN_") != -1): + enumbase = ifdefline[:ifdefline.find("_EN_")] + ifdefline = ifdefline.replace("_EN_", "_") + line = line.replace("_EN_", "_") # print(enumbase+":"+ifdefline); - if (enumbase not in header_data.enums): - header_data.enums[enumbase]=[] - if (ifdefline not in header_data.enums[enumbase]): - header_data.enums[enumbase].append(ifdefline); - - elif (not ifdefline in header_data.conditionals): - header_data.conditionals+=[ifdefline] - - if (line.find("uniform")!=-1 and line.lower().find("texunit:")!=-1): - #texture unit - texunitstr = line[line.find(":")+1:].strip() - if (texunitstr=="auto"): - texunit="-1" - else: - texunit = str(int(texunitstr )) - uline=line[:line.lower().find("//")] - uline = uline.replace("uniform",""); - uline = uline.replace("highp",""); - uline = uline.replace(";",""); - lines = uline.split(",") - for x in lines: - - x = x.strip() - x = x[ x.rfind(" ")+1: ] - if (x.find("[")!=-1): - #unfiorm array - x = x[ :x.find("[") ] - - if (not x in header_data.texunit_names): - header_data.texunits+=[(x,texunit)] - header_data.texunit_names+=[x] - - - - elif (line.find("uniform")!=-1): - uline = line.replace("uniform",""); - uline = uline.replace(";",""); - lines = uline.split(",") - for x in lines: - - x = x.strip() - x = x[ x.rfind(" ")+1: ] - if (x.find("[")!=-1): - #unfiorm array - x = x[ :x.find("[") ] - - if (not x in header_data.uniforms): - header_data.uniforms+=[x] - - - if ((line.strip().find("in ")==0 or line.strip().find("attribute ")==0) and line.find("attrib:")!=-1): - uline = line.replace("in ",""); - uline = uline.replace("attribute ",""); - uline = uline.replace("highp ",""); - uline = uline.replace(";",""); - uline = uline[ uline.find(" "): ].strip() - - - if (uline.find("//")!=-1): - name,bind = uline.split("//") - if (bind.find("attrib:")!=-1): - name=name.strip() - bind=bind.replace("attrib:","").strip() - header_data.attributes+=[(name,bind)] - - - line=line.replace("\r","") - line=line.replace("\n","") - #line=line.replace("\\","\\\\") - #line=line.replace("\"","\\\"") - #line=line+"\\n\\" - - if (header_data.reading=="vertex"): - header_data.vertex_lines+=[line] - if (header_data.reading=="fragment"): - header_data.fragment_lines+=[line] - - line=fs.readline() - header_data.line_offset+=1 - - fs.close(); - - return header_data - - - -def build_legacygl_header( filename, include, class_suffix, output_attribs ): - - header_data = LegacyGLHeaderStruct() - include_file_in_legacygl_header( filename, header_data, 0 ) - - out_file = filename+".h" - fd = open(out_file,"w") - - enum_constants=[] - - fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n"); - - out_file_base = out_file - out_file_base = out_file_base[ out_file_base.rfind("/")+1: ] - out_file_base = out_file_base[ out_file_base.rfind("\\")+1: ] + if (enumbase not in header_data.enums): + header_data.enums[enumbase] = [] + if (ifdefline not in header_data.enums[enumbase]): + header_data.enums[enumbase].append(ifdefline) + + elif (not ifdefline in header_data.conditionals): + header_data.conditionals += [ifdefline] + + if (line.find("uniform") != -1 and line.lower().find("texunit:") != -1): + # texture unit + texunitstr = line[line.find(":") + 1:].strip() + if (texunitstr == "auto"): + texunit = "-1" + else: + texunit = str(int(texunitstr)) + uline = line[:line.lower().find("//")] + uline = uline.replace("uniform", "") + uline = uline.replace("highp", "") + uline = uline.replace(";", "") + lines = uline.split(",") + for x in lines: + + x = x.strip() + x = x[x.rfind(" ") + 1:] + if (x.find("[") != -1): + # unfiorm array + x = x[:x.find("[")] + + if (not x in header_data.texunit_names): + header_data.texunits += [(x, texunit)] + header_data.texunit_names += [x] + + elif (line.find("uniform") != -1): + uline = line.replace("uniform", "") + uline = uline.replace(";", "") + lines = uline.split(",") + for x in lines: + + x = x.strip() + x = x[x.rfind(" ") + 1:] + if (x.find("[") != -1): + # unfiorm array + x = x[:x.find("[")] + + if (not x in header_data.uniforms): + header_data.uniforms += [x] + + if ((line.strip().find("in ") == 0 or line.strip().find("attribute ") == 0) and line.find("attrib:") != -1): + uline = line.replace("in ", "") + uline = uline.replace("attribute ", "") + uline = uline.replace("highp ", "") + uline = uline.replace(";", "") + uline = uline[uline.find(" "):].strip() + + if (uline.find("//") != -1): + name, bind = uline.split("//") + if (bind.find("attrib:") != -1): + name = name.strip() + bind = bind.replace("attrib:", "").strip() + header_data.attributes += [(name, bind)] + + line = line.replace("\r", "") + line = line.replace("\n", "") + # line=line.replace("\\","\\\\") + # line=line.replace("\"","\\\"") + # line=line+"\\n\\" + + if (header_data.reading == "vertex"): + header_data.vertex_lines += [line] + if (header_data.reading == "fragment"): + header_data.fragment_lines += [line] + + line = fs.readline() + header_data.line_offset += 1 + + fs.close() + + return header_data + + +def build_legacygl_header(filename, include, class_suffix, output_attribs): + + header_data = LegacyGLHeaderStruct() + include_file_in_legacygl_header(filename, header_data, 0) + + out_file = filename + ".h" + fd = open(out_file, "w") + + enum_constants = [] + + fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n") + + out_file_base = out_file + out_file_base = out_file_base[out_file_base.rfind("/") + 1:] + out_file_base = out_file_base[out_file_base.rfind("\\") + 1:] # print("out file "+out_file+" base " +out_file_base) - out_file_ifdef = out_file_base.replace(".","_").upper() - fd.write("#ifndef "+out_file_ifdef+class_suffix+"_120\n") - fd.write("#define "+out_file_ifdef+class_suffix+"_120\n") - - out_file_class = out_file_base.replace(".glsl.h","").title().replace("_","").replace(".","")+"Shader"+class_suffix; - fd.write("\n\n"); - fd.write("#include \"" + include + "\"\n\n\n"); - fd.write("class "+out_file_class+" : public Shader"+class_suffix+" {\n\n"); - fd.write("\t virtual String get_shader_name() const { return \""+out_file_class+"\"; }\n"); - - - fd.write("public:\n\n"); - - if (len(header_data.conditionals)): - fd.write("\tenum Conditionals {\n"); - for x in header_data.conditionals: - fd.write("\t\t"+x.upper()+",\n"); - fd.write("\t};\n\n"); - - - if (len(header_data.uniforms)): - fd.write("\tenum Uniforms {\n"); - for x in header_data.uniforms: - fd.write("\t\t"+x.upper()+",\n"); - fd.write("\t};\n\n"); - - fd.write("\t_FORCE_INLINE_ int get_uniform(Uniforms p_uniform) const { return _get_uniform(p_uniform); }\n\n"); - if (len(header_data.conditionals)): - - fd.write("\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n"); - fd.write("\t#define _FU if (get_uniform(p_uniform)<0) return; ERR_FAIL_COND( get_active()!=this );\n\n "); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, unsigned long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU GLfloat col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; glUniform4fv(get_uniform(p_uniform),1,col); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU GLfloat vec2[2]={p_vec2.x,p_vec2.y}; glUniform2fv(get_uniform(p_uniform),1,vec2); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU GLfloat vec3[3]={p_vec3.x,p_vec3.y,p_vec3.z}; glUniform3fv(get_uniform(p_uniform),1,vec3); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU glUniform2f(get_uniform(p_uniform),p_a,p_b); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU glUniform3f(get_uniform(p_uniform),p_a,p_b,p_c); }\n\n"); - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU glUniform4f(get_uniform(p_uniform),p_a,p_b,p_c,p_d); }\n\n"); - - fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU + out_file_ifdef = out_file_base.replace(".", "_").upper() + fd.write("#ifndef " + out_file_ifdef + class_suffix + "_120\n") + fd.write("#define " + out_file_ifdef + class_suffix + "_120\n") + + out_file_class = out_file_base.replace(".glsl.h", "").title().replace("_", "").replace(".", "") + "Shader" + class_suffix + fd.write("\n\n") + fd.write("#include \"" + include + "\"\n\n\n") + fd.write("class " + out_file_class + " : public Shader" + class_suffix + " {\n\n") + fd.write("\t virtual String get_shader_name() const { return \"" + out_file_class + "\"; }\n") + + fd.write("public:\n\n") + + if (len(header_data.conditionals)): + fd.write("\tenum Conditionals {\n") + for x in header_data.conditionals: + fd.write("\t\t" + x.upper() + ",\n") + fd.write("\t};\n\n") + + if (len(header_data.uniforms)): + fd.write("\tenum Uniforms {\n") + for x in header_data.uniforms: + fd.write("\t\t" + x.upper() + ",\n") + fd.write("\t};\n\n") + + fd.write("\t_FORCE_INLINE_ int get_uniform(Uniforms p_uniform) const { return _get_uniform(p_uniform); }\n\n") + if (len(header_data.conditionals)): + + fd.write("\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n") + fd.write("\t#define _FU if (get_uniform(p_uniform)<0) return; ERR_FAIL_COND( get_active()!=this );\n\n ") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") + #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); + #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); + #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, unsigned long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); + #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU GLfloat col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; glUniform4fv(get_uniform(p_uniform),1,col); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU GLfloat vec2[2]={p_vec2.x,p_vec2.y}; glUniform2fv(get_uniform(p_uniform),1,vec2); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU GLfloat vec3[3]={p_vec3.x,p_vec3.y,p_vec3.z}; glUniform3fv(get_uniform(p_uniform),1,vec3); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU glUniform2f(get_uniform(p_uniform),p_a,p_b); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU glUniform3f(get_uniform(p_uniform),p_a,p_b,p_c); }\n\n") + fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU glUniform4f(get_uniform(p_uniform),p_a,p_b,p_c,p_d); }\n\n") + + fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU const Transform &tr = p_transform; @@ -916,9 +894,9 @@ def build_legacygl_header( filename, include, class_suffix, output_attribs ): } - """); + """) - fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Matrix32& p_transform) { _FU + fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Matrix32& p_transform) { _FU const Matrix32 &tr = p_transform; @@ -947,9 +925,9 @@ def build_legacygl_header( filename, include, class_suffix, output_attribs ): } - """); + """) - fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU + fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU GLfloat matrix[16]; @@ -961,324 +939,318 @@ def build_legacygl_header( filename, include, class_suffix, output_attribs ): } glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix); - }; """); - - fd.write("\n\n#undef _FU\n\n\n"); - + }; """) - fd.write("\tvirtual void init() {\n\n"); + fd.write("\n\n#undef _FU\n\n\n") + fd.write("\tvirtual void init() {\n\n") - enum_value_count=0; + enum_value_count = 0 - if (len(header_data.enums)): + if (len(header_data.enums)): - fd.write("\t\t//Written using math, given nonstandarity of 64 bits integer constants..\n"); - fd.write("\t\tstatic const Enum _enums[]={\n") + fd.write("\t\t//Written using math, given nonstandarity of 64 bits integer constants..\n") + fd.write("\t\tstatic const Enum _enums[]={\n") - bitofs=len(header_data.conditionals) - enum_vals=[] + bitofs = len(header_data.conditionals) + enum_vals = [] - for xv in header_data.enums: - x=header_data.enums[xv] - bits=1 - amt = len(x); + for xv in header_data.enums: + x = header_data.enums[xv] + bits = 1 + amt = len(x) # print(x) - while(2**bits < amt): - bits+=1 + while(2**bits < amt): + bits += 1 # print("amount: "+str(amt)+" bits "+str(bits)); - strs="{" - for i in range(amt): - strs+="\"#define "+x[i]+"\\n\"," - - v={} - v["set_mask"]="uint64_t("+str(i)+")<<"+str(bitofs) - v["clear_mask"]="((uint64_t(1)<<40)-1) ^ (((uint64_t(1)<<"+str(bits)+") - 1)<<"+str(bitofs)+")" - enum_vals.append(v) - enum_constants.append(x[i]) - - strs+="NULL}" - - fd.write("\t\t\t{(uint64_t(1<<"+str(bits)+")-1)<<"+str(bitofs)+","+str(bitofs)+","+strs+"},\n"); - bitofs+=bits - - - fd.write("\t\t};\n\n"); + strs = "{" + for i in range(amt): + strs += "\"#define " + x[i] + "\\n\"," + + v = {} + v["set_mask"] = "uint64_t(" + str(i) + ")<<" + str(bitofs) + v["clear_mask"] = "((uint64_t(1)<<40)-1) ^ (((uint64_t(1)<<" + str(bits) + ") - 1)<<" + str(bitofs) + ")" + enum_vals.append(v) + enum_constants.append(x[i]) - fd.write("\t\tstatic const EnumValue _enum_values[]={\n") + strs += "NULL}" - enum_value_count=len(enum_vals); - for x in enum_vals: - fd.write("\t\t\t{"+x["set_mask"]+","+x["clear_mask"]+"},\n"); + fd.write("\t\t\t{(uint64_t(1<<" + str(bits) + ")-1)<<" + str(bitofs) + "," + str(bitofs) + "," + strs + "},\n") + bitofs += bits - fd.write("\t\t};\n\n"); - else: - fd.write("\t\tstatic const Enum *_enums=NULL;\n") - fd.write("\t\tstatic const EnumValue *_enum_values=NULL;\n") + fd.write("\t\t};\n\n") - if (len(header_data.conditionals)): + fd.write("\t\tstatic const EnumValue _enum_values[]={\n") - fd.write("\t\tstatic const char* _conditional_strings[]={\n") - if (len(header_data.conditionals)): - for x in header_data.conditionals: - fd.write("\t\t\t\"#define "+x+"\\n\",\n"); - fd.write("\t\t};\n\n"); - else: - fd.write("\t\tstatic const char **_conditional_strings=NULL;\n") + enum_value_count = len(enum_vals) + for x in enum_vals: + fd.write("\t\t\t{" + x["set_mask"] + "," + x["clear_mask"] + "},\n") - if (len(header_data.uniforms)): + fd.write("\t\t};\n\n") + else: + fd.write("\t\tstatic const Enum *_enums=NULL;\n") + fd.write("\t\tstatic const EnumValue *_enum_values=NULL;\n") - fd.write("\t\tstatic const char* _uniform_strings[]={\n") - if (len(header_data.uniforms)): - for x in header_data.uniforms: - fd.write("\t\t\t\""+x+"\",\n"); - fd.write("\t\t};\n\n"); - else: - fd.write("\t\tstatic const char **_uniform_strings=NULL;\n") + if (len(header_data.conditionals)): - if output_attribs: - if (len(header_data.attributes)): + fd.write("\t\tstatic const char* _conditional_strings[]={\n") + if (len(header_data.conditionals)): + for x in header_data.conditionals: + fd.write("\t\t\t\"#define " + x + "\\n\",\n") + fd.write("\t\t};\n\n") + else: + fd.write("\t\tstatic const char **_conditional_strings=NULL;\n") - fd.write("\t\tstatic AttributePair _attribute_pairs[]={\n") - for x in header_data.attributes: - fd.write("\t\t\t{\""+x[0]+"\","+x[1]+"},\n"); - fd.write("\t\t};\n\n"); - else: - fd.write("\t\tstatic AttributePair *_attribute_pairs=NULL;\n") + if (len(header_data.uniforms)): + fd.write("\t\tstatic const char* _uniform_strings[]={\n") + if (len(header_data.uniforms)): + for x in header_data.uniforms: + fd.write("\t\t\t\"" + x + "\",\n") + fd.write("\t\t};\n\n") + else: + fd.write("\t\tstatic const char **_uniform_strings=NULL;\n") - if (len(header_data.texunits)): - fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n") - for x in header_data.texunits: - fd.write("\t\t\t{\""+x[0]+"\","+x[1]+"},\n"); - fd.write("\t\t};\n\n"); - else: - fd.write("\t\tstatic TexUnitPair *_texunit_pairs=NULL;\n") + if output_attribs: + if (len(header_data.attributes)): - fd.write("\t\tstatic const char _vertex_code[]={\n") - for x in header_data.vertex_lines: - for i in range(len(x)): - fd.write(str(ord(x[i]))+","); + fd.write("\t\tstatic AttributePair _attribute_pairs[]={\n") + for x in header_data.attributes: + fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n") + fd.write("\t\t};\n\n") + else: + fd.write("\t\tstatic AttributePair *_attribute_pairs=NULL;\n") - fd.write(str(ord('\n'))+","); - fd.write("\t\t0};\n\n"); + if (len(header_data.texunits)): + fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n") + for x in header_data.texunits: + fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n") + fd.write("\t\t};\n\n") + else: + fd.write("\t\tstatic TexUnitPair *_texunit_pairs=NULL;\n") - fd.write("\t\tstatic const int _vertex_code_start="+str(header_data.vertex_offset)+";\n") + fd.write("\t\tstatic const char _vertex_code[]={\n") + for x in header_data.vertex_lines: + for i in range(len(x)): + fd.write(str(ord(x[i])) + ",") + fd.write(str(ord('\n')) + ",") + fd.write("\t\t0};\n\n") - fd.write("\t\tstatic const char _fragment_code[]={\n") - for x in header_data.fragment_lines: - for i in range(len(x)): - fd.write(str(ord(x[i]))+","); + fd.write("\t\tstatic const int _vertex_code_start=" + str(header_data.vertex_offset) + ";\n") - fd.write(str(ord('\n'))+","); - fd.write("\t\t0};\n\n"); + fd.write("\t\tstatic const char _fragment_code[]={\n") + for x in header_data.fragment_lines: + for i in range(len(x)): + fd.write(str(ord(x[i])) + ",") - fd.write("\t\tstatic const int _fragment_code_start="+str(header_data.fragment_offset)+";\n") + fd.write(str(ord('\n')) + ",") + fd.write("\t\t0};\n\n") - if output_attribs: - fd.write("\t\tsetup(_conditional_strings,"+str(len(header_data.conditionals))+",_uniform_strings,"+str(len(header_data.uniforms))+",_attribute_pairs,"+str(len(header_data.attributes))+", _texunit_pairs,"+str(len(header_data.texunits))+",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n") - else: - fd.write("\t\tsetup(_conditional_strings,"+str(len(header_data.conditionals))+",_uniform_strings,"+str(len(header_data.uniforms))+",_texunit_pairs,"+str(len(header_data.texunits))+",_enums,"+str(len(header_data.enums))+",_enum_values,"+str(enum_value_count)+",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n") + fd.write("\t\tstatic const int _fragment_code_start=" + str(header_data.fragment_offset) + ";\n") - fd.write("\t};\n\n") + if output_attribs: + fd.write("\t\tsetup(_conditional_strings," + str(len(header_data.conditionals)) + ",_uniform_strings," + str(len(header_data.uniforms)) + ",_attribute_pairs," + str(len(header_data.attributes)) + ", _texunit_pairs," + str(len(header_data.texunits)) + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n") + else: + fd.write("\t\tsetup(_conditional_strings," + str(len(header_data.conditionals)) + ",_uniform_strings," + str(len(header_data.uniforms)) + ",_texunit_pairs," + str(len(header_data.texunits)) + ",_enums," + str(len(header_data.enums)) + ",_enum_values," + str(enum_value_count) + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n") + fd.write("\t};\n\n") - if (len(enum_constants)): + if (len(enum_constants)): - fd.write("\tenum EnumConditionals {\n") - for x in enum_constants: - fd.write("\t\t"+x.upper()+",\n"); - fd.write("\t};\n\n"); - fd.write("\tvoid set_enum_conditional(EnumConditionals p_cond) { _set_enum_conditional(p_cond); }\n") + fd.write("\tenum EnumConditionals {\n") + for x in enum_constants: + fd.write("\t\t" + x.upper() + ",\n") + fd.write("\t};\n\n") + fd.write("\tvoid set_enum_conditional(EnumConditionals p_cond) { _set_enum_conditional(p_cond); }\n") + fd.write("};\n\n") + fd.write("#endif\n\n") + fd.close() - fd.write("};\n\n"); - fd.write("#endif\n\n"); - fd.close(); +def build_legacygl_headers(target, source, env): -def build_legacygl_headers( target, source, env ): + for x in source: - for x in source: + build_legacygl_header(str(x), include="drivers/legacygl/shader_lgl.h", class_suffix="LGL", output_attribs=False) - build_legacygl_header(str(x), include = "drivers/legacygl/shader_lgl.h", class_suffix = "LGL", output_attribs = False); + return 0 - return 0 +def build_gles2_headers(target, source, env): -def build_gles2_headers( target, source, env ): + for x in source: + build_legacygl_header(str(x), include="drivers/gles2/shader_gles2.h", class_suffix="GLES2", output_attribs=True) - for x in source: - build_legacygl_header(str(x), include="drivers/gles2/shader_gles2.h", class_suffix = "GLES2", output_attribs = True) def update_version(): - rev = "custom_build" + rev = "custom_build" - if (os.getenv("BUILD_REVISION")!=None): - rev=os.getenv("BUILD_REVISION") - print("Using custom revision: "+rev) - import version + if (os.getenv("BUILD_REVISION") != None): + rev = os.getenv("BUILD_REVISION") + print("Using custom revision: " + rev) + import version + f = open("core/version.h", "wb") + f.write("#define VERSION_SHORT_NAME " + str(version.short_name) + "\n") + f.write("#define VERSION_NAME " + str(version.name) + "\n") + f.write("#define VERSION_MAJOR " + str(version.major) + "\n") + f.write("#define VERSION_MINOR " + str(version.minor) + "\n") + if (hasattr(version, 'patch')): + f.write("#define VERSION_PATCH " + str(version.patch) + "\n") + f.write("#define VERSION_REVISION " + str(rev) + "\n") + f.write("#define VERSION_STATUS " + str(version.status) + "\n") + import datetime + f.write("#define VERSION_YEAR " + str(datetime.datetime.now().year) + "\n") - f=open("core/version.h","wb") - f.write("#define VERSION_SHORT_NAME "+str(version.short_name)+"\n") - f.write("#define VERSION_NAME "+str(version.name)+"\n") - f.write("#define VERSION_MAJOR "+str(version.major)+"\n") - f.write("#define VERSION_MINOR "+str(version.minor)+"\n") - if (hasattr(version, 'patch')): - f.write("#define VERSION_PATCH "+str(version.patch)+"\n") - f.write("#define VERSION_REVISION "+str(rev)+"\n") - f.write("#define VERSION_STATUS "+str(version.status)+"\n") - import datetime - f.write("#define VERSION_YEAR "+str(datetime.datetime.now().year)+"\n") def parse_cg_file(fname, uniforms, sizes, conditionals): - import re - fs = open(fname, "r") - line=fs.readline() + import re + fs = open(fname, "r") + line = fs.readline() - while line: + while line: - if re.match(r"^\s*uniform", line): + if re.match(r"^\s*uniform", line): - res = re.match(r"uniform ([\d\w]*) ([\d\w]*)") - type = res.groups(1) - name = res.groups(2) + res = re.match(r"uniform ([\d\w]*) ([\d\w]*)") + type = res.groups(1) + name = res.groups(2) - uniforms.append(name); + uniforms.append(name) - if (type.find("texobj") != -1): - sizes.append(1); - else: - t = re.match(r"float(\d)x(\d)", type); - if t: - sizes.append(int(t.groups(1)) * int(t.groups(2))) - else: - t = re.match(r"float(\d)", type); - sizes.append(int(t.groups(1))) + if (type.find("texobj") != -1): + sizes.append(1) + else: + t = re.match(r"float(\d)x(\d)", type) + if t: + sizes.append(int(t.groups(1)) * int(t.groups(2))) + else: + t = re.match(r"float(\d)", type) + sizes.append(int(t.groups(1))) - if line.find("[branch]") != -1: - conditionals.append(name); + if line.find("[branch]") != -1: + conditionals.append(name) - line = fs.readline(); + line = fs.readline() def build_cg_shader(sname): - vp_uniforms = [] - vp_uniform_sizes = [] - vp_conditionals = [] - - parse_cg_file("vp_"+sname+".cg", vp_uniforms, vp_uniform_sizes, vp_conditionals); + vp_uniforms = [] + vp_uniform_sizes = [] + vp_conditionals = [] - fp_uniforms = [] - fp_uniform_sizes = [] - fp_conditionals = [] + parse_cg_file("vp_" + sname + ".cg", vp_uniforms, vp_uniform_sizes, vp_conditionals) - parse_cg_file("fp_"+sname+".cg", fp_uniforms, fp_uniform_sizes, fp_conditionals); + fp_uniforms = [] + fp_uniform_sizes = [] + fp_conditionals = [] - fd = open("shader_"+sname+".cg.h", "w"); + parse_cg_file("fp_" + sname + ".cg", fp_uniforms, fp_uniform_sizes, fp_conditionals) - fd.write('\n#include "shader_cell.h"\n'); - fd.write("\nclass Shader_" + sname + " : public ShaderCell {\n"); - fd.write("\n\tstatic struct VertexUniforms[] = {\n"); + fd = open("shader_" + sname + ".cg.h", "w") - offset = 0; - for i in range(0, len(vp_uniforms)): + fd.write('\n#include "shader_cell.h"\n') + fd.write("\nclass Shader_" + sname + " : public ShaderCell {\n") + fd.write("\n\tstatic struct VertexUniforms[] = {\n") - fd.write('\t\t{ "%s", %d, %d },\n' % (vp_uniforms[i], offset, vp_uniform_sizes[i])) - offset = offset + vp_uniform_sizes[i]; - fd.write("\t};\n\n"); + offset = 0 + for i in range(0, len(vp_uniforms)): - fd.write("public:\n\n"); + fd.write('\t\t{ "%s", %d, %d },\n' % (vp_uniforms[i], offset, vp_uniform_sizes[i])) + offset = offset + vp_uniform_sizes[i] + fd.write("\t};\n\n") - fd.write("\tenum {\n"); + fd.write("public:\n\n") - for i in range(0, len(vp_uniforms)): + fd.write("\tenum {\n") - fd.write('\t\tVP_%s,\n' % vp_uniforms[i].upper()) + for i in range(0, len(vp_uniforms)): - fd.write("\t};\n"); + fd.write('\t\tVP_%s,\n' % vp_uniforms[i].upper()) + fd.write("\t};\n") import glob + + def detect_modules(): - module_list=[] - includes_cpp="" - register_cpp="" - unregister_cpp="" - - files = glob.glob("modules/*") - files.sort() #so register_module_types does not change that often, and also plugins are registered in alphabetic order - for x in files: - if (not os.path.isdir(x)): - continue - x=x.replace("modules/","") # rest of world - x=x.replace("modules\\","") # win32 - module_list.append(x) - try: - with open("modules/"+x+"/register_types.h"): - includes_cpp+='#include "modules/'+x+'/register_types.h"\n' - register_cpp+='#ifdef MODULE_'+x.upper()+'_ENABLED\n' - register_cpp+='\tregister_'+x+'_types();\n' - register_cpp+='#endif\n' - unregister_cpp+='#ifdef MODULE_'+x.upper()+'_ENABLED\n' - unregister_cpp+='\tunregister_'+x+'_types();\n' - unregister_cpp+='#endif\n' - except IOError: - pass - - modules_cpp=""" + module_list = [] + includes_cpp = "" + register_cpp = "" + unregister_cpp = "" + + files = glob.glob("modules/*") + files.sort() # so register_module_types does not change that often, and also plugins are registered in alphabetic order + for x in files: + if (not os.path.isdir(x)): + continue + x = x.replace("modules/", "") # rest of world + x = x.replace("modules\\", "") # win32 + module_list.append(x) + try: + with open("modules/" + x + "/register_types.h"): + includes_cpp += '#include "modules/' + x + '/register_types.h"\n' + register_cpp += '#ifdef MODULE_' + x.upper() + '_ENABLED\n' + register_cpp += '\tregister_' + x + '_types();\n' + register_cpp += '#endif\n' + unregister_cpp += '#ifdef MODULE_' + x.upper() + '_ENABLED\n' + unregister_cpp += '\tunregister_' + x + '_types();\n' + unregister_cpp += '#endif\n' + except IOError: + pass + + modules_cpp = """ // modules.cpp - THIS FILE IS GENERATED, DO NOT EDIT!!!!!!! #include "register_module_types.h" -"""+includes_cpp+""" +""" + includes_cpp + """ void register_module_types() { -"""+register_cpp+""" +""" + register_cpp + """ } void unregister_module_types() { -"""+unregister_cpp+""" +""" + unregister_cpp + """ } """ - f=open("modules/register_module_types.cpp","wb") - f.write(modules_cpp) - - return module_list + f = open("modules/register_module_types.cpp", "wb") + f.write(modules_cpp) + return module_list def win32_spawn(sh, escape, cmd, args, env): - import subprocess - newargs = ' '.join(args[1:]) - cmdline = cmd + " " + newargs - startupinfo = subprocess.STARTUPINFO() - #startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW - for e in env: - if type(env[e]) != type(""): - env[e] = str(env[e]) - 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 + import subprocess + newargs = ' '.join(args[1:]) + cmdline = cmd + " " + newargs + startupinfo = subprocess.STARTUPINFO() + #startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + for e in env: + if type(env[e]) != type(""): + env[e] = str(env[e]) + 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 win32_spawn(sh, escape, cmd, args, spawnenv): @@ -1309,48 +1281,65 @@ def win32_spawn(sh, escape, cmd, args, spawnenv): return exit_code """ -def android_add_maven_repository(self,url): - self.android_maven_repos.append(url) - -def android_add_dependency(self,depline): - self.android_dependencies.append(depline) - -def android_add_java_dir(self,subpath): - base_path = self.Dir(".").abspath+"/modules/"+self.current_module+"/"+subpath - self.android_java_dirs.append(base_path) - -def android_add_res_dir(self,subpath): - base_path = self.Dir(".").abspath+"/modules/"+self.current_module+"/"+subpath - self.android_res_dirs.append(base_path) -def android_add_aidl_dir(self,subpath): - base_path = self.Dir(".").abspath+"/modules/"+self.current_module+"/"+subpath - self.android_aidl_dirs.append(base_path) -def android_add_jni_dir(self,subpath): - base_path = self.Dir(".").abspath+"/modules/"+self.current_module+"/"+subpath - self.android_jni_dirs.append(base_path) -def android_add_default_config(self,config): - self.android_default_config.append(config) - -def android_add_to_manifest(self,file): - base_path = self.Dir(".").abspath+"/modules/"+self.current_module+"/"+file - f = open(base_path,"rb") - self.android_manifest_chunk+=f.read() -def android_add_to_permissions(self,file): - base_path = self.Dir(".").abspath+"/modules/"+self.current_module+"/"+file - f = open(base_path,"rb") - self.android_permission_chunk+=f.read() -def android_add_to_attributes(self,file): - base_path = self.Dir(".").abspath+"/modules/"+self.current_module+"/"+file - f = open(base_path,"rb") - self.android_appattributes_chunk+=f.read() + +def android_add_maven_repository(self, url): + self.android_maven_repos.append(url) + + +def android_add_dependency(self, depline): + self.android_dependencies.append(depline) + + +def android_add_java_dir(self, subpath): + base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + subpath + self.android_java_dirs.append(base_path) + + +def android_add_res_dir(self, subpath): + base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + subpath + self.android_res_dirs.append(base_path) + + +def android_add_aidl_dir(self, subpath): + base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + subpath + self.android_aidl_dirs.append(base_path) + + +def android_add_jni_dir(self, subpath): + base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + subpath + self.android_jni_dirs.append(base_path) + + +def android_add_default_config(self, config): + self.android_default_config.append(config) + + +def android_add_to_manifest(self, file): + base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + file + f = open(base_path, "rb") + self.android_manifest_chunk += f.read() + + +def android_add_to_permissions(self, file): + base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + file + f = open(base_path, "rb") + self.android_permission_chunk += f.read() + + +def android_add_to_attributes(self, file): + base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + file + f = open(base_path, "rb") + self.android_appattributes_chunk += f.read() + def disable_module(self): - self.disabled_modules.append(self.current_module) + self.disabled_modules.append(self.current_module) + def use_windows_spawn_fix(self, platform=None): - if (os.name!="nt"): - return #not needed, only for windows + if (os.name != "nt"): + return # not needed, only for windows # On Windows, due to the limited command line length, when creating a static library # from a very high number of objects SCons will invoke "ar" once per object file; @@ -1364,212 +1353,212 @@ def use_windows_spawn_fix(self, platform=None): import subprocess - def mySubProcess(cmdline,env): - prefix = "" - if(platform == 'javascript'): - prefix = "python.exe " - - startupinfo = subprocess.STARTUPINFO() - startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW - proc = subprocess.Popen(prefix + 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 mySubProcess(cmdline, env): + prefix = "" + if(platform == 'javascript'): + prefix = "python.exe " + + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + proc = subprocess.Popen(prefix + 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 + newargs = ' '.join(args[1:]) + cmdline = cmd + " " + newargs - rv=0 - env = {str(key): str(value) for key, value in env.iteritems()} - 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 ) + rv = 0 + env = {str(key): str(value) for key, value in env.iteritems()} + 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 + return rv self['SPAWN'] = mySpawn def split_lib(self, libname): - import string - env = self - - num = 0 - cur_base = "" - max_src = 64 - list = [] - lib_list = [] - - for f in getattr(env, libname + "_sources"): - fname = "" - if type(f) == type(""): - fname = env.File(f).path - else: - fname = env.File(f)[0].path - fname = fname.replace("\\", "/") - base = string.join(fname.split("/")[:2], "/") - if base != cur_base and len(list) > max_src: - if num > 0: - lib = env.Library(libname + str(num), list) - lib_list.append(lib) - list = [] - num = num + 1 - cur_base = base - list.append(f) - - lib = env.Library(libname + str(num), list) - lib_list.append(lib) - - if len(lib_list) > 0: - import os, sys - if os.name == 'posix' and sys.platform == 'msys': - env.Replace(ARFLAGS = ['rcsT']) - lib = env.Library(libname + "_collated", lib_list) - lib_list = [lib] - - lib_base = [] - env.add_source_files(lib_base, "*.cpp") - lib_list.insert(0, env.Library(libname, lib_base)) - - env.Prepend(LIBS = lib_list) - - -def save_active_platforms(apnames,ap): - - for x in ap: - pth = x+"/logo.png" + import string + env = self + + num = 0 + cur_base = "" + max_src = 64 + list = [] + lib_list = [] + + for f in getattr(env, libname + "_sources"): + fname = "" + if type(f) == type(""): + fname = env.File(f).path + else: + fname = env.File(f)[0].path + fname = fname.replace("\\", "/") + base = string.join(fname.split("/")[:2], "/") + if base != cur_base and len(list) > max_src: + if num > 0: + lib = env.Library(libname + str(num), list) + lib_list.append(lib) + list = [] + num = num + 1 + cur_base = base + list.append(f) + + lib = env.Library(libname + str(num), list) + lib_list.append(lib) + + if len(lib_list) > 0: + import os, sys + if os.name == 'posix' and sys.platform == 'msys': + env.Replace(ARFLAGS=['rcsT']) + lib = env.Library(libname + "_collated", lib_list) + lib_list = [lib] + + lib_base = [] + env.add_source_files(lib_base, "*.cpp") + lib_list.insert(0, env.Library(libname, lib_base)) + + env.Prepend(LIBS=lib_list) + + +def save_active_platforms(apnames, ap): + + for x in ap: + pth = x + "/logo.png" # print("open path: "+pth) - pngf=open(pth,"rb"); - b=pngf.read(1); - str=" /* AUTOGENERATED FILE, DO NOT EDIT */ \n" - str+=" static const unsigned char _"+x[9:]+"_logo[]={" - while(len(b)==1): - str+=hex(ord(b)) - b=pngf.read(1); - if (len(b)==1): - str+="," - - str+="};\n" - - wf = x+"/logo.h" - logow = open(wf,"wb") - logow.write(str) - - -def no_verbose(sys,env): - - #If the output is not a terminal, do nothing - if not sys.stdout.isatty(): - return - - colors = {} - colors['cyan'] = '\033[96m' - colors['purple'] = '\033[95m' - colors['blue'] = '\033[94m' - colors['green'] = '\033[92m' - colors['yellow'] = '\033[93m' - colors['red'] = '\033[91m' - colors['end'] = '\033[0m' - - compile_source_message = '%sCompiling %s==> %s$SOURCE%s' % (colors['blue'], colors['purple'], colors['yellow'], colors['end']) - java_compile_source_message = '%sCompiling %s==> %s$SOURCE%s' % (colors['blue'], colors['purple'], colors['yellow'], colors['end']) - compile_shared_source_message = '%sCompiling shared %s==> %s$SOURCE%s' % (colors['blue'], colors['purple'], colors['yellow'], colors['end']) - link_program_message = '%sLinking Program %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) - link_library_message = '%sLinking Static Library %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) - ranlib_library_message = '%sRanlib Library %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) - link_shared_library_message = '%sLinking Shared Library %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) - java_library_message = '%sCreating Java Archive %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) - - env.Append( CXXCOMSTR=[compile_source_message] ) - env.Append( CCCOMSTR=[compile_source_message] ) - env.Append( SHCCCOMSTR=[compile_shared_source_message] ) - env.Append( SHCXXCOMSTR=[compile_shared_source_message] ) - env.Append( ARCOMSTR=[link_library_message] ) - env.Append( RANLIBCOMSTR=[ranlib_library_message] ) - env.Append( SHLINKCOMSTR=[link_shared_library_message] ) - env.Append( LINKCOMSTR=[link_program_message] ) - env.Append( JARCOMSTR=[java_library_message] ) - env.Append( JAVACCOMSTR=[java_compile_source_message] ) + pngf = open(pth, "rb") + b = pngf.read(1) + str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n" + str += " static const unsigned char _" + x[9:] + "_logo[]={" + while(len(b) == 1): + str += hex(ord(b)) + b = pngf.read(1) + if (len(b) == 1): + str += "," + + str += "};\n" + + wf = x + "/logo.h" + logow = open(wf, "wb") + logow.write(str) + + +def no_verbose(sys, env): + + # If the output is not a terminal, do nothing + if not sys.stdout.isatty(): + return + + colors = {} + colors['cyan'] = '\033[96m' + colors['purple'] = '\033[95m' + colors['blue'] = '\033[94m' + colors['green'] = '\033[92m' + colors['yellow'] = '\033[93m' + colors['red'] = '\033[91m' + colors['end'] = '\033[0m' + + compile_source_message = '%sCompiling %s==> %s$SOURCE%s' % (colors['blue'], colors['purple'], colors['yellow'], colors['end']) + java_compile_source_message = '%sCompiling %s==> %s$SOURCE%s' % (colors['blue'], colors['purple'], colors['yellow'], colors['end']) + compile_shared_source_message = '%sCompiling shared %s==> %s$SOURCE%s' % (colors['blue'], colors['purple'], colors['yellow'], colors['end']) + link_program_message = '%sLinking Program %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) + link_library_message = '%sLinking Static Library %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) + ranlib_library_message = '%sRanlib Library %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) + link_shared_library_message = '%sLinking Shared Library %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) + java_library_message = '%sCreating Java Archive %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) + + env.Append(CXXCOMSTR=[compile_source_message]) + env.Append(CCCOMSTR=[compile_source_message]) + env.Append(SHCCCOMSTR=[compile_shared_source_message]) + env.Append(SHCXXCOMSTR=[compile_shared_source_message]) + env.Append(ARCOMSTR=[link_library_message]) + env.Append(RANLIBCOMSTR=[ranlib_library_message]) + env.Append(SHLINKCOMSTR=[link_shared_library_message]) + env.Append(LINKCOMSTR=[link_program_message]) + env.Append(JARCOMSTR=[java_library_message]) + env.Append(JAVACCOMSTR=[java_compile_source_message]) + def detect_visual_c_compiler_version(tools_env): - # tools_env is the variable scons uses to call tools that execute tasks, SCons's env['ENV'] that executes tasks... - # (see the SCons documentation for more information on what it does)... - # in order for this function to be well encapsulated i choose to force it to recieve SCons's TOOLS env (env['ENV'] - # and not scons setup environment (env)... so make sure you call the right environment on it or it will fail to detect - # the propper vc version that will be called - - # These is no flag to give to visual c compilers to set the architecture, ie scons bits argument (32,64,ARM etc) - # There are many different cl.exe files that are run, and each one compiles & links to a different architecture - # As far as I know, the only way to figure out what compiler will be run when Scons calls cl.exe via Program() - # is to check the PATH varaible and figure out which one will be called first. Code bellow does that and returns: - # the following string values: - - # "" Compiler not detected - # "amd64" Native 64 bit compiler - # "amd64_x86" 64 bit Cross Compiler for 32 bit - # "x86" Native 32 bit compiler - # "x86_amd64" 32 bit Cross Compiler for 64 bit - - # There are other architectures, but Godot does not support them currently, so this function does not detect arm/amd64_arm - # and similar architectures/compilers - - # Set chosen compiler to "not detected" - vc_chosen_compiler_index = -1 - vc_chosen_compiler_str = "" - - # find() works with -1 so big ifs bellow are needed... the simplest solution, in fact - # First test if amd64 and amd64_x86 compilers are present in the path - vc_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"]+"BIN\\amd64;") - if(vc_amd64_compiler_detection_index > -1): - vc_chosen_compiler_index = vc_amd64_compiler_detection_index - vc_chosen_compiler_str = "amd64" - - vc_amd64_x86_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"]+"BIN\\amd64_x86;") - if(vc_amd64_x86_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_amd64_x86_compiler_detection_index)): - vc_chosen_compiler_index = vc_amd64_x86_compiler_detection_index - vc_chosen_compiler_str = "amd64_x86" - - - # Now check the 32 bit compilers - vc_x86_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"]+"BIN;") - if(vc_x86_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_x86_compiler_detection_index)): - vc_chosen_compiler_index = vc_x86_compiler_detection_index - vc_chosen_compiler_str = "x86" - - vc_x86_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env['VCINSTALLDIR']+"BIN\\x86_amd64;") - if(vc_x86_amd64_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_x86_amd64_compiler_detection_index)): - vc_chosen_compiler_index = vc_x86_amd64_compiler_detection_index - vc_chosen_compiler_str = "x86_amd64" - - # debug help - #print vc_amd64_compiler_detection_index - #print vc_amd64_x86_compiler_detection_index - #print vc_x86_compiler_detection_index - #print vc_x86_amd64_compiler_detection_index - #print "chosen "+str(vc_chosen_compiler_index)+ " | "+str(vc_chosen_compiler_str) - - return vc_chosen_compiler_str + # tools_env is the variable scons uses to call tools that execute tasks, SCons's env['ENV'] that executes tasks... + # (see the SCons documentation for more information on what it does)... + # in order for this function to be well encapsulated i choose to force it to recieve SCons's TOOLS env (env['ENV'] + # and not scons setup environment (env)... so make sure you call the right environment on it or it will fail to detect + # the propper vc version that will be called + + # These is no flag to give to visual c compilers to set the architecture, ie scons bits argument (32,64,ARM etc) + # There are many different cl.exe files that are run, and each one compiles & links to a different architecture + # As far as I know, the only way to figure out what compiler will be run when Scons calls cl.exe via Program() + # is to check the PATH varaible and figure out which one will be called first. Code bellow does that and returns: + # the following string values: + + # "" Compiler not detected + # "amd64" Native 64 bit compiler + # "amd64_x86" 64 bit Cross Compiler for 32 bit + # "x86" Native 32 bit compiler + # "x86_amd64" 32 bit Cross Compiler for 64 bit + + # There are other architectures, but Godot does not support them currently, so this function does not detect arm/amd64_arm + # and similar architectures/compilers + + # Set chosen compiler to "not detected" + vc_chosen_compiler_index = -1 + vc_chosen_compiler_str = "" + + # find() works with -1 so big ifs bellow are needed... the simplest solution, in fact + # First test if amd64 and amd64_x86 compilers are present in the path + vc_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN\\amd64;") + if(vc_amd64_compiler_detection_index > -1): + vc_chosen_compiler_index = vc_amd64_compiler_detection_index + vc_chosen_compiler_str = "amd64" + + vc_amd64_x86_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN\\amd64_x86;") + if(vc_amd64_x86_compiler_detection_index > -1 + and (vc_chosen_compiler_index == -1 + or vc_chosen_compiler_index > vc_amd64_x86_compiler_detection_index)): + vc_chosen_compiler_index = vc_amd64_x86_compiler_detection_index + vc_chosen_compiler_str = "amd64_x86" + + # Now check the 32 bit compilers + vc_x86_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN;") + if(vc_x86_compiler_detection_index > -1 + and (vc_chosen_compiler_index == -1 + or vc_chosen_compiler_index > vc_x86_compiler_detection_index)): + vc_chosen_compiler_index = vc_x86_compiler_detection_index + vc_chosen_compiler_str = "x86" + + vc_x86_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env['VCINSTALLDIR'] + "BIN\\x86_amd64;") + if(vc_x86_amd64_compiler_detection_index > -1 + and (vc_chosen_compiler_index == -1 + or vc_chosen_compiler_index > vc_x86_amd64_compiler_detection_index)): + vc_chosen_compiler_index = vc_x86_amd64_compiler_detection_index + vc_chosen_compiler_str = "x86_amd64" + + # debug help + # print vc_amd64_compiler_detection_index + # print vc_amd64_x86_compiler_detection_index + # print vc_x86_compiler_detection_index + # print vc_x86_amd64_compiler_detection_index + # print "chosen "+str(vc_chosen_compiler_index)+ " | "+str(vc_chosen_compiler_str) + + return vc_chosen_compiler_str def precious_program(env, program, sources, **args): - program = env.ProgramOriginal(program, sources, **args) - env.Precious(program) - return program + program = env.ProgramOriginal(program, sources, **args) + env.Precious(program) + return program diff --git a/modules/SCsub b/modules/SCsub index 4084248086..4b9c08cf78 100644 --- a/modules/SCsub +++ b/modules/SCsub @@ -6,18 +6,18 @@ env_modules = env.Clone() Export('env_modules') -env.modules_sources=[ - "register_module_types.cpp", +env.modules_sources = [ + "register_module_types.cpp", ] -#env.add_source_files(env.modules_sources,"*.cpp") +# env.add_source_files(env.modules_sources,"*.cpp") Export('env') for x in env.module_list: - if (x in env.disabled_modules): - continue - env_modules.Append(CPPFLAGS=["-DMODULE_"+x.upper()+"_ENABLED"]) - SConscript(x+"/SCsub") + if (x in env.disabled_modules): + continue + env_modules.Append(CPPFLAGS=["-DMODULE_" + x.upper() + "_ENABLED"]) + SConscript(x + "/SCsub") -lib = env_modules.Library("modules",env.modules_sources) +lib = env_modules.Library("modules", env.modules_sources) env.Prepend(LIBS=[lib]) diff --git a/modules/chibi/config.py b/modules/chibi/config.py index 368e97e152..fb920482f5 100644 --- a/modules/chibi/config.py +++ b/modules/chibi/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/cscript/config.py b/modules/cscript/config.py index ea7e83378a..5698a37295 100644 --- a/modules/cscript/config.py +++ b/modules/cscript/config.py @@ -1,11 +1,8 @@ def can_build(platform): - return True + return True def configure(env): - pass - - - + pass diff --git a/modules/dds/config.py b/modules/dds/config.py index 368e97e152..fb920482f5 100644 --- a/modules/dds/config.py +++ b/modules/dds/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/enet/SCsub b/modules/enet/SCsub index 5175803f44..fb22d1cff0 100644 --- a/modules/enet/SCsub +++ b/modules/enet/SCsub @@ -7,22 +7,22 @@ Import('env_modules') env_enet = env_modules.Clone() -if (env["enet"] != "system"): # builtin - thirdparty_dir = "#thirdparty/enet/" - thirdparty_sources = [ - "callbacks.c", - "compress.c", - "host.c", - "list.c", - "packet.c", - "peer.c", - "protocol.c", - "unix.c", - "win32.c", - ] - thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] +if (env['builtin_enet'] != 'no'): + thirdparty_dir = "#thirdparty/enet/" + thirdparty_sources = [ + "callbacks.c", + "compress.c", + "host.c", + "list.c", + "packet.c", + "peer.c", + "protocol.c", + "unix.c", + "win32.c", + ] + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - env_enet.add_source_files(env.modules_sources, thirdparty_sources) - env_enet.Append(CPPPATH = [thirdparty_dir]) + env_enet.add_source_files(env.modules_sources, thirdparty_sources) + env_enet.Append(CPPPATH=[thirdparty_dir]) env_enet.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/enet/config.py b/modules/enet/config.py index 368e97e152..fb920482f5 100644 --- a/modules/enet/config.py +++ b/modules/enet/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/etc1/SCsub b/modules/etc1/SCsub index ea035fcde3..0c5dc66d2e 100644 --- a/modules/etc1/SCsub +++ b/modules/etc1/SCsub @@ -9,12 +9,12 @@ env_etc1 = env_modules.Clone() # Not unbundled so far since not widespread as shared library thirdparty_dir = "#thirdparty/rg-etc1/" thirdparty_sources = [ - "rg_etc1.cpp", + "rg_etc1.cpp", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] env_etc1.add_source_files(env.modules_sources, thirdparty_sources) -env_etc1.Append(CPPPATH = [thirdparty_dir]) +env_etc1.Append(CPPPATH=[thirdparty_dir]) # Godot source files env_etc1.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/etc1/config.py b/modules/etc1/config.py index 368e97e152..fb920482f5 100644 --- a/modules/etc1/config.py +++ b/modules/etc1/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub index 1f759dee9a..87652a3ddf 100644 --- a/modules/freetype/SCsub +++ b/modules/freetype/SCsub @@ -5,66 +5,66 @@ Import('env') # Not building in a separate env as core needs it # Thirdparty source files -if (env["freetype"] != "system"): # builtin - thirdparty_dir = "#thirdparty/freetype/" - thirdparty_sources = [ - "src/autofit/autofit.c", - "src/base/ftapi.c", - "src/base/ftbase.c", - "src/base/ftbbox.c", - "src/base/ftbdf.c", - "src/base/ftbitmap.c", - "src/base/ftcid.c", - "src/base/ftdebug.c", - "src/base/ftfntfmt.c", - "src/base/ftfstype.c", - "src/base/ftgasp.c", - "src/base/ftglyph.c", - "src/base/ftgxval.c", - "src/base/ftinit.c", - "src/base/ftlcdfil.c", - "src/base/ftmm.c", - "src/base/ftotval.c", - "src/base/ftpatent.c", - "src/base/ftpfr.c", - "src/base/ftpic.c", - "src/base/ftstroke.c", - "src/base/ftsynth.c", - "src/base/ftsystem.c", - "src/base/fttype1.c", - "src/base/ftwinfnt.c", - "src/bdf/bdf.c", - "src/cache/ftcache.c", - "src/cff/cff.c", - "src/cid/type1cid.c", - "src/gxvalid/gxvalid.c", - "src/otvalid/otvalid.c", - "src/pcf/pcf.c", - "src/pfr/pfr.c", - "src/psaux/psaux.c", - "src/pshinter/pshinter.c", - "src/psnames/psnames.c", - "src/raster/raster.c", - "src/sfnt/sfnt.c", - "src/smooth/smooth.c", - "src/truetype/truetype.c", - "src/type1/type1.c", - "src/type42/type42.c", - "src/winfonts/winfnt.c", - ] - thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] +if (env['builtin_freetype'] != 'no'): + thirdparty_dir = "#thirdparty/freetype/" + thirdparty_sources = [ + "src/autofit/autofit.c", + "src/base/ftapi.c", + "src/base/ftbase.c", + "src/base/ftbbox.c", + "src/base/ftbdf.c", + "src/base/ftbitmap.c", + "src/base/ftcid.c", + "src/base/ftdebug.c", + "src/base/ftfntfmt.c", + "src/base/ftfstype.c", + "src/base/ftgasp.c", + "src/base/ftglyph.c", + "src/base/ftgxval.c", + "src/base/ftinit.c", + "src/base/ftlcdfil.c", + "src/base/ftmm.c", + "src/base/ftotval.c", + "src/base/ftpatent.c", + "src/base/ftpfr.c", + "src/base/ftpic.c", + "src/base/ftstroke.c", + "src/base/ftsynth.c", + "src/base/ftsystem.c", + "src/base/fttype1.c", + "src/base/ftwinfnt.c", + "src/bdf/bdf.c", + "src/cache/ftcache.c", + "src/cff/cff.c", + "src/cid/type1cid.c", + "src/gxvalid/gxvalid.c", + "src/otvalid/otvalid.c", + "src/pcf/pcf.c", + "src/pfr/pfr.c", + "src/psaux/psaux.c", + "src/pshinter/pshinter.c", + "src/psnames/psnames.c", + "src/raster/raster.c", + "src/sfnt/sfnt.c", + "src/smooth/smooth.c", + "src/truetype/truetype.c", + "src/type1/type1.c", + "src/type42/type42.c", + "src/winfonts/winfnt.c", + ] + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - # Include header for WinRT to fix build issues - if "platform" in env and env["platform"] == "winrt": - env.Append(CCFLAGS = ['/FI', '"modules/freetype/winrtdef.h"']) + # Include header for WinRT to fix build issues + if "platform" in env and env["platform"] == "winrt": + env.Append(CCFLAGS=['/FI', '"modules/freetype/winrtdef.h"']) - env.Append(CPPPATH = [thirdparty_dir, thirdparty_dir + "/include"]) + env.Append(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include"]) - # also requires libpng headers - if (env["libpng"] != "system"): # builtin - env.Append(CPPPATH = ["#thirdparty/libpng"]) + # also requires libpng headers + if (env['builtin_libpng'] != 'no'): + env.Append(CPPPATH=["#thirdparty/libpng"]) - """ FIXME: Remove this commented code if Windows can handle the monolithic lib + """ FIXME: Remove this commented code if Windows can handle the monolithic lib # fix for Windows' shell miserably failing on long lines, split in two libraries half1 = [] half2 = [] @@ -80,11 +80,11 @@ if (env["freetype"] != "system"): # builtin env.Append(LIBS = [lib]) """ - lib = env.Library("freetype_builtin", thirdparty_sources) - env.Append(LIBS = [lib]) + lib = env.Library("freetype_builtin", thirdparty_sources) + env.Append(LIBS=[lib]) # Godot source files env.add_source_files(env.modules_sources, "*.cpp") -env.Append(CCFLAGS = ['-DFREETYPE_ENABLED']) +env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) Export('env') diff --git a/modules/freetype/config.py b/modules/freetype/config.py index 368e97e152..fb920482f5 100644 --- a/modules/freetype/config.py +++ b/modules/freetype/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/gdscript/config.py b/modules/gdscript/config.py index ea7e83378a..5698a37295 100644 --- a/modules/gdscript/config.py +++ b/modules/gdscript/config.py @@ -1,11 +1,8 @@ def can_build(platform): - return True + return True def configure(env): - pass - - - + pass diff --git a/modules/gridmap/config.py b/modules/gridmap/config.py index ea7e83378a..5698a37295 100644 --- a/modules/gridmap/config.py +++ b/modules/gridmap/config.py @@ -1,11 +1,8 @@ def can_build(platform): - return True + return True def configure(env): - pass - - - + pass diff --git a/modules/ik/config.py b/modules/ik/config.py index f9bd7da08d..5698a37295 100644 --- a/modules/ik/config.py +++ b/modules/ik/config.py @@ -1,11 +1,8 @@ def can_build(platform): - return True - - + return True + + def configure(env): - pass - - - + pass diff --git a/modules/jpg/SCsub b/modules/jpg/SCsub index 28fb81895d..e72dc6a1ca 100644 --- a/modules/jpg/SCsub +++ b/modules/jpg/SCsub @@ -9,12 +9,12 @@ env_jpg = env_modules.Clone() # Not unbundled for now as they are not commonly available as shared library thirdparty_dir = "#thirdparty/jpeg-compressor/" thirdparty_sources = [ - "jpgd.cpp", + "jpgd.cpp", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] env_jpg.add_source_files(env.modules_sources, thirdparty_sources) -env_jpg.Append(CPPPATH = [thirdparty_dir]) +env_jpg.Append(CPPPATH=[thirdparty_dir]) # Godot's own source files env_jpg.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/jpg/config.py b/modules/jpg/config.py index 368e97e152..fb920482f5 100644 --- a/modules/jpg/config.py +++ b/modules/jpg/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/mpc/SCsub b/modules/mpc/SCsub index 09f0c05daa..76b7cbea7a 100644 --- a/modules/mpc/SCsub +++ b/modules/mpc/SCsub @@ -6,23 +6,23 @@ Import('env_modules') env_mpc = env_modules.Clone() # Thirdparty source files -if (env["libmpcdec"] != "system"): # builtin - thirdparty_dir = "#thirdparty/libmpcdec/" - thirdparty_sources = [ - "huffman.c", - "mpc_bits_reader.c", - "mpc_decoder.c", - "mpc_demux.c", - "mpc_reader.c", - "requant.c", - "streaminfo.c", - "synth_filter.c", - ] +if (env['builtin_libmpcdec'] != 'no'): + thirdparty_dir = "#thirdparty/libmpcdec/" + thirdparty_sources = [ + "huffman.c", + "mpc_bits_reader.c", + "mpc_decoder.c", + "mpc_demux.c", + "mpc_reader.c", + "requant.c", + "streaminfo.c", + "synth_filter.c", + ] - thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - env_mpc.add_source_files(env.modules_sources, thirdparty_sources) - env_mpc.Append(CPPPATH = [thirdparty_dir]) + env_mpc.add_source_files(env.modules_sources, thirdparty_sources) + env_mpc.Append(CPPPATH=[thirdparty_dir]) # Godot source files env_mpc.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/mpc/config.py b/modules/mpc/config.py index 368e97e152..fb920482f5 100644 --- a/modules/mpc/config.py +++ b/modules/mpc/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/ogg/SCsub b/modules/ogg/SCsub index 2e1fe2e0c0..5eabaf6f2b 100644 --- a/modules/ogg/SCsub +++ b/modules/ogg/SCsub @@ -6,16 +6,16 @@ Import('env_modules') env_ogg = env_modules.Clone() # Thirdparty source files -if (env["libogg"] != "system"): # builtin - thirdparty_dir = "#thirdparty/libogg/" - thirdparty_sources = [ - "bitwise.c", - "framing.c", - ] - thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] +if (env['builtin_libogg'] != 'no'): + thirdparty_dir = "#thirdparty/libogg/" + thirdparty_sources = [ + "bitwise.c", + "framing.c", + ] + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - env_ogg.add_source_files(env.modules_sources, thirdparty_sources) - env_ogg.Append(CPPPATH = [thirdparty_dir]) + env_ogg.add_source_files(env.modules_sources, thirdparty_sources) + env_ogg.Append(CPPPATH=[thirdparty_dir]) # Godot source files env_ogg.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/ogg/config.py b/modules/ogg/config.py index 368e97e152..fb920482f5 100644 --- a/modules/ogg/config.py +++ b/modules/ogg/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/openssl/SCsub b/modules/openssl/SCsub index 2327cf483c..ccd90d1534 100644 --- a/modules/openssl/SCsub +++ b/modules/openssl/SCsub @@ -6,673 +6,673 @@ Import('env_modules') env_openssl = env_modules.Clone() # Thirdparty source files -if (env["openssl"] != "system"): # builtin - thirdparty_dir = "#thirdparty/openssl/" +if (env['builtin_openssl'] != 'no'): + thirdparty_dir = "#thirdparty/openssl/" - thirdparty_sources = [ - "ssl/t1_lib.c", - "ssl/t1_ext.c", - "ssl/s3_srvr.c", - "ssl/t1_enc.c", - "ssl/t1_meth.c", - "ssl/s23_clnt.c", - "ssl/ssl_asn1.c", - "ssl/tls_srp.c", - "ssl/kssl.c", - "ssl/d1_both.c", - "ssl/t1_clnt.c", - "ssl/bio_ssl.c", - "ssl/d1_srtp.c", - "ssl/t1_reneg.c", - "ssl/ssl_cert.c", - "ssl/s3_lib.c", - "ssl/d1_srvr.c", - "ssl/s23_meth.c", - "ssl/ssl_stat.c", - "ssl/ssl_err.c", - "ssl/ssl_algs.c", - "ssl/s3_cbc.c", - "ssl/d1_clnt.c", - "ssl/s3_pkt.c", - "ssl/d1_meth.c", - "ssl/s3_both.c", - "ssl/s2_enc.c", - "ssl/s3_meth.c", - "ssl/s3_enc.c", - "ssl/s23_pkt.c", - "ssl/s2_pkt.c", - "ssl/d1_pkt.c", - "ssl/ssl_rsa.c", - "ssl/s23_srvr.c", - "ssl/s2_meth.c", - "ssl/s3_clnt.c", - "ssl/s23_lib.c", - "ssl/t1_srvr.c", - "ssl/ssl_lib.c", - "ssl/ssl_txt.c", - "ssl/s2_srvr.c", - "ssl/ssl_sess.c", - "ssl/s2_clnt.c", - "ssl/d1_lib.c", - "ssl/s2_lib.c", - "ssl/ssl_err2.c", - "ssl/ssl_ciph.c", - "crypto/dsa/dsa_lib.c", - "crypto/dsa/dsa_pmeth.c", - "crypto/dsa/dsa_ossl.c", - "crypto/dsa/dsa_gen.c", - "crypto/dsa/dsa_asn1.c", - "crypto/dsa/dsa_prn.c", - "crypto/dsa/dsa_sign.c", - "crypto/dsa/dsa_key.c", - "crypto/dsa/dsa_vrf.c", - "crypto/dsa/dsa_err.c", - "crypto/dsa/dsa_ameth.c", - "crypto/dsa/dsa_depr.c", - "crypto/x509/x509_lu.c", - "crypto/x509/x509cset.c", - "crypto/x509/x509_set.c", - "crypto/x509/x509_d2.c", - "crypto/x509/x509_txt.c", - "crypto/x509/x509rset.c", - "crypto/x509/by_dir.c", - "crypto/x509/x509_vpm.c", - "crypto/x509/x509_vfy.c", - "crypto/x509/x509_trs.c", - "crypto/x509/by_file.c", - "crypto/x509/x509_obj.c", - "crypto/x509/x509spki.c", - "crypto/x509/x509_v3.c", - "crypto/x509/x509_req.c", - "crypto/x509/x509_att.c", - "crypto/x509/x_all.c", - "crypto/x509/x509_ext.c", - "crypto/x509/x509type.c", - "crypto/x509/x509_def.c", - "crypto/x509/x509_err.c", - "crypto/x509/x509name.c", - "crypto/x509/x509_r2x.c", - "crypto/x509/x509_cmp.c", - "crypto/asn1/x_pkey.c", - "crypto/asn1/a_gentm.c", - "crypto/asn1/x_sig.c", - "crypto/asn1/t_req.c", - "crypto/asn1/t_pkey.c", - "crypto/asn1/p8_pkey.c", - "crypto/asn1/a_i2d_fp.c", - "crypto/asn1/x_val.c", - "crypto/asn1/f_string.c", - "crypto/asn1/p5_pbe.c", - "crypto/asn1/bio_ndef.c", - "crypto/asn1/a_bool.c", - "crypto/asn1/asn1_gen.c", - "crypto/asn1/x_algor.c", - "crypto/asn1/bio_asn1.c", - "crypto/asn1/asn_mime.c", - "crypto/asn1/t_x509.c", - "crypto/asn1/a_strex.c", - "crypto/asn1/x_nx509.c", - "crypto/asn1/asn1_err.c", - "crypto/asn1/x_crl.c", - "crypto/asn1/a_print.c", - "crypto/asn1/a_type.c", - "crypto/asn1/tasn_new.c", - "crypto/asn1/n_pkey.c", - "crypto/asn1/x_bignum.c", - "crypto/asn1/asn_pack.c", - "crypto/asn1/evp_asn1.c", - "crypto/asn1/t_bitst.c", - "crypto/asn1/x_req.c", - "crypto/asn1/a_time.c", - "crypto/asn1/x_name.c", - "crypto/asn1/x_pubkey.c", - "crypto/asn1/tasn_typ.c", - "crypto/asn1/asn_moid.c", - "crypto/asn1/a_utctm.c", - "crypto/asn1/asn1_lib.c", - "crypto/asn1/x_x509a.c", - "crypto/asn1/a_set.c", - "crypto/asn1/t_crl.c", - "crypto/asn1/p5_pbev2.c", - "crypto/asn1/tasn_enc.c", - "crypto/asn1/a_mbstr.c", - "crypto/asn1/tasn_dec.c", - "crypto/asn1/x_x509.c", - "crypto/asn1/a_octet.c", - "crypto/asn1/x_long.c", - "crypto/asn1/a_bytes.c", - "crypto/asn1/t_x509a.c", - "crypto/asn1/a_enum.c", - "crypto/asn1/a_int.c", - "crypto/asn1/tasn_prn.c", - "crypto/asn1/i2d_pr.c", - "crypto/asn1/a_utf8.c", - "crypto/asn1/t_spki.c", - "crypto/asn1/a_digest.c", - "crypto/asn1/a_dup.c", - "crypto/asn1/i2d_pu.c", - "crypto/asn1/a_verify.c", - "crypto/asn1/f_enum.c", - "crypto/asn1/a_sign.c", - "crypto/asn1/d2i_pr.c", - "crypto/asn1/asn1_par.c", - "crypto/asn1/x_spki.c", - "crypto/asn1/a_d2i_fp.c", - "crypto/asn1/f_int.c", - "crypto/asn1/x_exten.c", - "crypto/asn1/tasn_utl.c", - "crypto/asn1/nsseq.c", - "crypto/asn1/a_bitstr.c", - "crypto/asn1/x_info.c", - "crypto/asn1/a_strnid.c", - "crypto/asn1/a_object.c", - "crypto/asn1/tasn_fre.c", - "crypto/asn1/d2i_pu.c", - "crypto/asn1/ameth_lib.c", - "crypto/asn1/x_attrib.c", - "crypto/evp/m_sha.c", - "crypto/evp/e_camellia.c", - "crypto/evp/e_aes.c", - "crypto/evp/bio_b64.c", - "crypto/evp/m_sigver.c", - "crypto/evp/m_wp.c", - "crypto/evp/m_sha1.c", - "crypto/evp/p_seal.c", - "crypto/evp/c_alld.c", - "crypto/evp/p5_crpt.c", - "crypto/evp/e_rc4.c", - "crypto/evp/m_ecdsa.c", - "crypto/evp/bio_enc.c", - "crypto/evp/e_des3.c", - "crypto/evp/m_null.c", - "crypto/evp/bio_ok.c", - "crypto/evp/pmeth_gn.c", - "crypto/evp/e_rc5.c", - "crypto/evp/e_rc2.c", - "crypto/evp/p_dec.c", - "crypto/evp/p_verify.c", - "crypto/evp/e_rc4_hmac_md5.c", - "crypto/evp/pmeth_lib.c", - "crypto/evp/m_ripemd.c", - "crypto/evp/m_md5.c", - "crypto/evp/e_bf.c", - "crypto/evp/p_enc.c", - "crypto/evp/m_dss.c", - "crypto/evp/bio_md.c", - "crypto/evp/evp_pbe.c", - "crypto/evp/e_seed.c", - "crypto/evp/e_cast.c", - "crypto/evp/p_open.c", - "crypto/evp/p5_crpt2.c", - "crypto/evp/m_dss1.c", - "crypto/evp/names.c", - "crypto/evp/evp_acnf.c", - "crypto/evp/e_des.c", - "crypto/evp/evp_cnf.c", - "crypto/evp/evp_lib.c", - "crypto/evp/digest.c", - "crypto/evp/evp_err.c", - "crypto/evp/evp_enc.c", - "crypto/evp/e_old.c", - "crypto/evp/c_all.c", - "crypto/evp/m_md2.c", - "crypto/evp/e_xcbc_d.c", - "crypto/evp/pmeth_fn.c", - "crypto/evp/p_lib.c", - "crypto/evp/evp_key.c", - "crypto/evp/encode.c", - "crypto/evp/e_aes_cbc_hmac_sha1.c", - "crypto/evp/e_aes_cbc_hmac_sha256.c", - "crypto/evp/m_mdc2.c", - "crypto/evp/e_null.c", - "crypto/evp/p_sign.c", - "crypto/evp/e_idea.c", - "crypto/evp/c_allc.c", - "crypto/evp/evp_pkey.c", - "crypto/evp/m_md4.c", - "crypto/ex_data.c", - "crypto/pkcs12/p12_p8e.c", - "crypto/pkcs12/p12_crt.c", - "crypto/pkcs12/p12_utl.c", - "crypto/pkcs12/p12_attr.c", - "crypto/pkcs12/p12_npas.c", - "crypto/pkcs12/p12_decr.c", - "crypto/pkcs12/p12_init.c", - "crypto/pkcs12/p12_kiss.c", - "crypto/pkcs12/p12_add.c", - "crypto/pkcs12/p12_p8d.c", - "crypto/pkcs12/p12_mutl.c", - "crypto/pkcs12/p12_crpt.c", - "crypto/pkcs12/pk12err.c", - "crypto/pkcs12/p12_asn.c", - "crypto/pkcs12/p12_key.c", - "crypto/ecdh/ech_key.c", - "crypto/ecdh/ech_ossl.c", - "crypto/ecdh/ech_lib.c", - "crypto/ecdh/ech_err.c", - "crypto/ecdh/ech_kdf.c", - "crypto/o_str.c", - "crypto/conf/conf_api.c", - "crypto/conf/conf_err.c", - "crypto/conf/conf_def.c", - "crypto/conf/conf_lib.c", - "crypto/conf/conf_mall.c", - "crypto/conf/conf_sap.c", - "crypto/conf/conf_mod.c", - "crypto/ebcdic.c", - "crypto/ecdsa/ecs_lib.c", - "crypto/ecdsa/ecs_asn1.c", - "crypto/ecdsa/ecs_ossl.c", - "crypto/ecdsa/ecs_vrf.c", - "crypto/ecdsa/ecs_sign.c", - "crypto/ecdsa/ecs_err.c", - "crypto/dso/dso_win32.c", - "crypto/dso/dso_lib.c", - "crypto/dso/dso_dlfcn.c", - "crypto/dso/dso_dl.c", - "crypto/dso/dso_beos.c", - "crypto/dso/dso_null.c", - "crypto/dso/dso_vms.c", - "crypto/dso/dso_err.c", - "crypto/dso/dso_openssl.c", - "crypto/cryptlib.c", - "crypto/md5/md5_one.c", - "crypto/md5/md5_dgst.c", - "crypto/pkcs7/pkcs7err.c", - "crypto/pkcs7/pk7_smime.c", - "crypto/pkcs7/bio_pk7.c", - "crypto/pkcs7/pk7_mime.c", - "crypto/pkcs7/pk7_lib.c", - "crypto/pkcs7/pk7_asn1.c", - "crypto/pkcs7/pk7_doit.c", - "crypto/pkcs7/pk7_attr.c", - "crypto/md4/md4_one.c", - "crypto/md4/md4_dgst.c", - "crypto/o_dir.c", - "crypto/buffer/buf_err.c", - "crypto/buffer/buf_str.c", - "crypto/buffer/buffer.c", - "crypto/cms/cms_lib.c", - "crypto/cms/cms_io.c", - "crypto/cms/cms_err.c", - "crypto/cms/cms_dd.c", - "crypto/cms/cms_smime.c", - "crypto/cms/cms_att.c", - "crypto/cms/cms_pwri.c", - "crypto/cms/cms_cd.c", - "crypto/cms/cms_sd.c", - "crypto/cms/cms_asn1.c", - "crypto/cms/cms_env.c", - "crypto/cms/cms_enc.c", - "crypto/cms/cms_ess.c", - "crypto/cms/cms_kari.c", - "crypto/mem_dbg.c", - "crypto/uid.c", - "crypto/stack/stack.c", - "crypto/ec/ec_ameth.c", - "crypto/ec/ec_err.c", - "crypto/ec/ec_lib.c", - "crypto/ec/ec_curve.c", - "crypto/ec/ec_oct.c", - "crypto/ec/ec_asn1.c", - "crypto/ec/ecp_oct.c", - "crypto/ec/ec_print.c", - "crypto/ec/ec2_smpl.c", - "crypto/ec/ecp_nistp224.c", - "crypto/ec/ec2_oct.c", - "crypto/ec/eck_prn.c", - "crypto/ec/ec_key.c", - "crypto/ec/ecp_nist.c", - "crypto/ec/ec_check.c", - "crypto/ec/ecp_smpl.c", - "crypto/ec/ec2_mult.c", - "crypto/ec/ecp_mont.c", - "crypto/ec/ecp_nistp521.c", - "crypto/ec/ec_mult.c", - "crypto/ec/ecp_nistputil.c", - "crypto/ec/ec_pmeth.c", - "crypto/ec/ec_cvt.c", - "crypto/ec/ecp_nistp256.c", - "crypto/krb5/krb5_asn.c", - "crypto/hmac/hmac.c", - "crypto/hmac/hm_ameth.c", - "crypto/hmac/hm_pmeth.c", - "crypto/comp/c_rle.c", - "crypto/comp/c_zlib.c", - "crypto/comp/comp_lib.c", - "crypto/comp/comp_err.c", - "crypto/des/fcrypt.c", - "crypto/des/str2key.c", - "crypto/des/cbc_cksm.c", - "crypto/des/des_enc.c", - "crypto/des/ofb_enc.c", - "crypto/des/read2pwd.c", - "crypto/des/ecb3_enc.c", - "crypto/des/rand_key.c", - "crypto/des/cfb64ede.c", - "crypto/des/rpc_enc.c", - "crypto/des/ofb64ede.c", - "crypto/des/qud_cksm.c", - "crypto/des/enc_writ.c", - "crypto/des/set_key.c", - "crypto/des/xcbc_enc.c", - "crypto/des/fcrypt_b.c", - "crypto/des/ede_cbcm_enc.c", - "crypto/des/des_old2.c", - "crypto/des/cfb_enc.c", - "crypto/des/ecb_enc.c", - "crypto/des/enc_read.c", - "crypto/des/des_old.c", - "crypto/des/ofb64enc.c", - "crypto/des/pcbc_enc.c", - "crypto/des/cbc_enc.c", - "crypto/des/cfb64enc.c", - "crypto/lhash/lh_stats.c", - "crypto/lhash/lhash.c", - "crypto/x509v3/v3_genn.c", - "crypto/x509v3/pcy_cache.c", - "crypto/x509v3/v3_sxnet.c", - "crypto/x509v3/v3_scts.c", - "crypto/x509v3/v3err.c", - "crypto/x509v3/v3_conf.c", - "crypto/x509v3/v3_utl.c", - "crypto/x509v3/v3_akeya.c", - "crypto/x509v3/v3_lib.c", - "crypto/x509v3/pcy_lib.c", - "crypto/x509v3/v3_cpols.c", - "crypto/x509v3/v3_ia5.c", - "crypto/x509v3/v3_bitst.c", - "crypto/x509v3/v3_skey.c", - "crypto/x509v3/v3_info.c", - "crypto/x509v3/v3_asid.c", - "crypto/x509v3/pcy_tree.c", - "crypto/x509v3/v3_pcons.c", - "crypto/x509v3/v3_bcons.c", - "crypto/x509v3/v3_pku.c", - "crypto/x509v3/v3_ocsp.c", - "crypto/x509v3/pcy_map.c", - "crypto/x509v3/v3_ncons.c", - "crypto/x509v3/v3_purp.c", - "crypto/x509v3/v3_enum.c", - "crypto/x509v3/v3_pmaps.c", - "crypto/x509v3/pcy_node.c", - "crypto/x509v3/v3_pcia.c", - "crypto/x509v3/v3_crld.c", - "crypto/x509v3/v3_pci.c", - "crypto/x509v3/v3_akey.c", - "crypto/x509v3/v3_addr.c", - "crypto/x509v3/v3_int.c", - "crypto/x509v3/v3_alt.c", - "crypto/x509v3/v3_extku.c", - "crypto/x509v3/v3_prn.c", - "crypto/x509v3/pcy_data.c", - "crypto/aes/aes_ofb.c", - "crypto/aes/aes_ctr.c", - "crypto/aes/aes_ecb.c", - "crypto/aes/aes_cfb.c", - "crypto/aes/aes_wrap.c", - "crypto/aes/aes_ige.c", - "crypto/aes/aes_misc.c", - "crypto/pqueue/pqueue.c", - "crypto/sha/sha_one.c", - "crypto/sha/sha_dgst.c", - "crypto/sha/sha512.c", - "crypto/sha/sha1_one.c", - "crypto/sha/sha1dgst.c", - "crypto/sha/sha256.c", - "crypto/whrlpool/wp_dgst.c", - "crypto/objects/obj_xref.c", - "crypto/objects/o_names.c", - "crypto/objects/obj_err.c", - "crypto/objects/obj_dat.c", - "crypto/objects/obj_lib.c", - "crypto/mem.c", - "crypto/fips_ers.c", - "crypto/o_fips.c", - "crypto/engine/eng_rdrand.c", - "crypto/engine/eng_err.c", - "crypto/engine/tb_ecdsa.c", - "crypto/engine/tb_rsa.c", - "crypto/engine/tb_cipher.c", - "crypto/engine/tb_dsa.c", - "crypto/engine/eng_lib.c", - "crypto/engine/tb_asnmth.c", - "crypto/engine/tb_ecdh.c", - "crypto/engine/tb_dh.c", - "crypto/engine/tb_store.c", - "crypto/engine/eng_init.c", - "crypto/engine/eng_cnf.c", - "crypto/engine/eng_all.c", - "crypto/engine/tb_digest.c", - "crypto/engine/tb_pkmeth.c", - "crypto/engine/eng_table.c", - "crypto/engine/eng_ctrl.c", - "crypto/engine/eng_list.c", - "crypto/engine/eng_cryptodev.c", - "crypto/engine/eng_pkey.c", - "crypto/engine/tb_rand.c", - "crypto/engine/eng_openssl.c", - "crypto/engine/eng_fat.c", - "crypto/engine/eng_dyn.c", - "crypto/ts/ts_rsp_verify.c", - "crypto/ts/ts_req_print.c", - "crypto/ts/ts_verify_ctx.c", - "crypto/ts/ts_req_utils.c", - "crypto/ts/ts_err.c", - "crypto/ts/ts_rsp_print.c", - "crypto/ts/ts_rsp_utils.c", - "crypto/ts/ts_lib.c", - "crypto/ts/ts_conf.c", - "crypto/ts/ts_asn1.c", - "crypto/ts/ts_rsp_sign.c", - "crypto/ocsp/ocsp_ext.c", - "crypto/ocsp/ocsp_cl.c", - "crypto/ocsp/ocsp_ht.c", - "crypto/ocsp/ocsp_lib.c", - "crypto/ocsp/ocsp_srv.c", - "crypto/ocsp/ocsp_vfy.c", - "crypto/ocsp/ocsp_err.c", - "crypto/ocsp/ocsp_prn.c", - "crypto/ocsp/ocsp_asn.c", - "crypto/bf/bf_cfb64.c", - "crypto/bf/bf_ecb.c", - "crypto/bf/bf_enc.c", - "crypto/bf/bf_skey.c", - "crypto/bf/bf_ofb64.c", - "crypto/idea/i_skey.c", - "crypto/idea/i_ofb64.c", - "crypto/idea/i_cbc.c", - "crypto/idea/i_ecb.c", - "crypto/idea/i_cfb64.c", - "crypto/cmac/cm_ameth.c", - "crypto/cmac/cmac.c", - "crypto/cmac/cm_pmeth.c", - "crypto/dh/dh_lib.c", - "crypto/dh/dh_key.c", - "crypto/dh/dh_asn1.c", - "crypto/dh/dh_depr.c", - "crypto/dh/dh_pmeth.c", - "crypto/dh/dh_prn.c", - "crypto/dh/dh_gen.c", - "crypto/dh/dh_ameth.c", - "crypto/dh/dh_check.c", - "crypto/dh/dh_err.c", - "crypto/dh/dh_kdf.c", - "crypto/dh/dh_rfc5114.c", - "crypto/modes/ccm128.c", - "crypto/modes/ofb128.c", - "crypto/modes/cts128.c", - "crypto/modes/ctr128.c", - "crypto/modes/gcm128.c", - "crypto/modes/cbc128.c", - "crypto/modes/cfb128.c", - "crypto/modes/xts128.c", - "crypto/modes/wrap128.c", - "crypto/camellia/cmll_cfb.c", - "crypto/camellia/cmll_ecb.c", - "crypto/camellia/cmll_utl.c", - "crypto/camellia/cmll_misc.c", - "crypto/camellia/cmll_ofb.c", - "crypto/camellia/cmll_ctr.c", - "crypto/seed/seed_ecb.c", - "crypto/seed/seed_cbc.c", - "crypto/seed/seed.c", - "crypto/seed/seed_ofb.c", - "crypto/seed/seed_cfb.c", - "crypto/txt_db/txt_db.c", - "crypto/cpt_err.c", - "crypto/pem/pem_pk8.c", - "crypto/pem/pem_lib.c", - "crypto/pem/pem_sign.c", - "crypto/pem/pem_all.c", - "crypto/pem/pem_info.c", - "crypto/pem/pem_pkey.c", - "crypto/pem/pem_seal.c", - "crypto/pem/pem_err.c", - "crypto/pem/pem_xaux.c", - "crypto/pem/pvkfmt.c", - "crypto/pem/pem_x509.c", - "crypto/pem/pem_oth.c", - "crypto/rand/rand_lib.c", - "crypto/rand/randfile.c", - "crypto/rand/rand_os2.c", - "crypto/rand/rand_unix.c", - "crypto/rand/rand_nw.c", - "crypto/rand/md_rand.c", - "crypto/rand/rand_err.c", - "crypto/rand/rand_win.c", - "crypto/rand/rand_egd.c", - "crypto/cversion.c", - "crypto/cast/c_ecb.c", - "crypto/cast/c_skey.c", - "crypto/cast/c_ofb64.c", - "crypto/cast/c_enc.c", - "crypto/cast/c_cfb64.c", - "crypto/o_time.c", - "crypto/mdc2/mdc2dgst.c", - "crypto/mdc2/mdc2_one.c", - "crypto/rc4/rc4_utl.c", - "crypto/ui/ui_compat.c", - "crypto/ui/ui_util.c", - "crypto/ui/ui_lib.c", - "crypto/ui/ui_err.c", - "crypto/ui/ui_openssl.c", - "crypto/bio/bf_buff.c", - "crypto/bio/bss_null.c", - "crypto/bio/bss_acpt.c", - "crypto/bio/bss_conn.c", - "crypto/bio/bss_fd.c", - "crypto/bio/bf_null.c", - "crypto/bio/bio_err.c", - "crypto/bio/bss_sock.c", - "crypto/bio/bss_mem.c", - "crypto/bio/b_dump.c", - "crypto/bio/b_print.c", - "crypto/bio/b_sock.c", - "crypto/bio/bss_dgram.c", - "crypto/bio/bf_nbio.c", - "crypto/bio/bio_lib.c", - "crypto/bio/bss_file.c", - "crypto/bio/bss_bio.c", - "crypto/bio/bss_log.c", - "crypto/bio/bio_cb.c", - "crypto/o_init.c", - "crypto/rc2/rc2_skey.c", - "crypto/rc2/rc2_cbc.c", - "crypto/rc2/rc2cfb64.c", - "crypto/rc2/rc2_ecb.c", - "crypto/rc2/rc2ofb64.c", - "crypto/bn/bn_x931p.c", - "crypto/bn/bn_blind.c", - "crypto/bn/bn_gf2m.c", - "crypto/bn/bn_const.c", - "crypto/bn/bn_sqr.c", - "crypto/bn/bn_nist.c", - "crypto/bn/bn_rand.c", - "crypto/bn/bn_err.c", - "crypto/bn/bn_div.c", - "crypto/bn/bn_kron.c", - "crypto/bn/bn_ctx.c", - "crypto/bn/bn_shift.c", - "crypto/bn/bn_mod.c", - "crypto/bn/bn_exp2.c", - "crypto/bn/bn_word.c", - "crypto/bn/bn_add.c", - "crypto/bn/bn_exp.c", - "crypto/bn/bn_mont.c", - "crypto/bn/bn_print.c", - "crypto/bn/bn_mul.c", - "crypto/bn/bn_prime.c", - "crypto/bn/bn_depr.c", - "crypto/bn/bn_gcd.c", - "crypto/bn/bn_mpi.c", - "crypto/bn/bn_sqrt.c", - "crypto/bn/bn_recp.c", - "crypto/bn/bn_lib.c", - "crypto/ripemd/rmd_dgst.c", - "crypto/ripemd/rmd_one.c", - "crypto/rsa/rsa_x931.c", - "crypto/rsa/rsa_depr.c", - "crypto/rsa/rsa_saos.c", - "crypto/rsa/rsa_crpt.c", - "crypto/rsa/rsa_pss.c", - "crypto/rsa/rsa_oaep.c", - "crypto/rsa/rsa_null.c", - "crypto/rsa/rsa_gen.c", - "crypto/rsa/rsa_prn.c", - "crypto/rsa/rsa_pmeth.c", - "crypto/rsa/rsa_asn1.c", - "crypto/rsa/rsa_ssl.c", - "crypto/rsa/rsa_ameth.c", - "crypto/rsa/rsa_pk1.c", - "crypto/rsa/rsa_err.c", - "crypto/rsa/rsa_lib.c", - "crypto/rsa/rsa_none.c", - "crypto/rsa/rsa_chk.c", - "crypto/rsa/rsa_eay.c", - "crypto/rsa/rsa_sign.c", - "crypto/srp/srp_lib.c", - "crypto/srp/srp_vfy.c", - "crypto/err/err.c", - "crypto/err/err_prn.c", - "crypto/err/err_all.c", - "crypto/mem_clr.c", - "crypto/rc4/rc4_skey.c", - "crypto/rc4/rc4_enc.c", - "crypto/camellia/camellia.c", - "crypto/camellia/cmll_cbc.c", - #"crypto/aes/aes_x86core.c", - "crypto/aes/aes_core.c", - "crypto/aes/aes_cbc.c", - "crypto/whrlpool/wp_block.c", - "crypto/bn/bn_asm.c", - ] + thirdparty_sources = [ + "ssl/t1_lib.c", + "ssl/t1_ext.c", + "ssl/s3_srvr.c", + "ssl/t1_enc.c", + "ssl/t1_meth.c", + "ssl/s23_clnt.c", + "ssl/ssl_asn1.c", + "ssl/tls_srp.c", + "ssl/kssl.c", + "ssl/d1_both.c", + "ssl/t1_clnt.c", + "ssl/bio_ssl.c", + "ssl/d1_srtp.c", + "ssl/t1_reneg.c", + "ssl/ssl_cert.c", + "ssl/s3_lib.c", + "ssl/d1_srvr.c", + "ssl/s23_meth.c", + "ssl/ssl_stat.c", + "ssl/ssl_err.c", + "ssl/ssl_algs.c", + "ssl/s3_cbc.c", + "ssl/d1_clnt.c", + "ssl/s3_pkt.c", + "ssl/d1_meth.c", + "ssl/s3_both.c", + "ssl/s2_enc.c", + "ssl/s3_meth.c", + "ssl/s3_enc.c", + "ssl/s23_pkt.c", + "ssl/s2_pkt.c", + "ssl/d1_pkt.c", + "ssl/ssl_rsa.c", + "ssl/s23_srvr.c", + "ssl/s2_meth.c", + "ssl/s3_clnt.c", + "ssl/s23_lib.c", + "ssl/t1_srvr.c", + "ssl/ssl_lib.c", + "ssl/ssl_txt.c", + "ssl/s2_srvr.c", + "ssl/ssl_sess.c", + "ssl/s2_clnt.c", + "ssl/d1_lib.c", + "ssl/s2_lib.c", + "ssl/ssl_err2.c", + "ssl/ssl_ciph.c", + "crypto/dsa/dsa_lib.c", + "crypto/dsa/dsa_pmeth.c", + "crypto/dsa/dsa_ossl.c", + "crypto/dsa/dsa_gen.c", + "crypto/dsa/dsa_asn1.c", + "crypto/dsa/dsa_prn.c", + "crypto/dsa/dsa_sign.c", + "crypto/dsa/dsa_key.c", + "crypto/dsa/dsa_vrf.c", + "crypto/dsa/dsa_err.c", + "crypto/dsa/dsa_ameth.c", + "crypto/dsa/dsa_depr.c", + "crypto/x509/x509_lu.c", + "crypto/x509/x509cset.c", + "crypto/x509/x509_set.c", + "crypto/x509/x509_d2.c", + "crypto/x509/x509_txt.c", + "crypto/x509/x509rset.c", + "crypto/x509/by_dir.c", + "crypto/x509/x509_vpm.c", + "crypto/x509/x509_vfy.c", + "crypto/x509/x509_trs.c", + "crypto/x509/by_file.c", + "crypto/x509/x509_obj.c", + "crypto/x509/x509spki.c", + "crypto/x509/x509_v3.c", + "crypto/x509/x509_req.c", + "crypto/x509/x509_att.c", + "crypto/x509/x_all.c", + "crypto/x509/x509_ext.c", + "crypto/x509/x509type.c", + "crypto/x509/x509_def.c", + "crypto/x509/x509_err.c", + "crypto/x509/x509name.c", + "crypto/x509/x509_r2x.c", + "crypto/x509/x509_cmp.c", + "crypto/asn1/x_pkey.c", + "crypto/asn1/a_gentm.c", + "crypto/asn1/x_sig.c", + "crypto/asn1/t_req.c", + "crypto/asn1/t_pkey.c", + "crypto/asn1/p8_pkey.c", + "crypto/asn1/a_i2d_fp.c", + "crypto/asn1/x_val.c", + "crypto/asn1/f_string.c", + "crypto/asn1/p5_pbe.c", + "crypto/asn1/bio_ndef.c", + "crypto/asn1/a_bool.c", + "crypto/asn1/asn1_gen.c", + "crypto/asn1/x_algor.c", + "crypto/asn1/bio_asn1.c", + "crypto/asn1/asn_mime.c", + "crypto/asn1/t_x509.c", + "crypto/asn1/a_strex.c", + "crypto/asn1/x_nx509.c", + "crypto/asn1/asn1_err.c", + "crypto/asn1/x_crl.c", + "crypto/asn1/a_print.c", + "crypto/asn1/a_type.c", + "crypto/asn1/tasn_new.c", + "crypto/asn1/n_pkey.c", + "crypto/asn1/x_bignum.c", + "crypto/asn1/asn_pack.c", + "crypto/asn1/evp_asn1.c", + "crypto/asn1/t_bitst.c", + "crypto/asn1/x_req.c", + "crypto/asn1/a_time.c", + "crypto/asn1/x_name.c", + "crypto/asn1/x_pubkey.c", + "crypto/asn1/tasn_typ.c", + "crypto/asn1/asn_moid.c", + "crypto/asn1/a_utctm.c", + "crypto/asn1/asn1_lib.c", + "crypto/asn1/x_x509a.c", + "crypto/asn1/a_set.c", + "crypto/asn1/t_crl.c", + "crypto/asn1/p5_pbev2.c", + "crypto/asn1/tasn_enc.c", + "crypto/asn1/a_mbstr.c", + "crypto/asn1/tasn_dec.c", + "crypto/asn1/x_x509.c", + "crypto/asn1/a_octet.c", + "crypto/asn1/x_long.c", + "crypto/asn1/a_bytes.c", + "crypto/asn1/t_x509a.c", + "crypto/asn1/a_enum.c", + "crypto/asn1/a_int.c", + "crypto/asn1/tasn_prn.c", + "crypto/asn1/i2d_pr.c", + "crypto/asn1/a_utf8.c", + "crypto/asn1/t_spki.c", + "crypto/asn1/a_digest.c", + "crypto/asn1/a_dup.c", + "crypto/asn1/i2d_pu.c", + "crypto/asn1/a_verify.c", + "crypto/asn1/f_enum.c", + "crypto/asn1/a_sign.c", + "crypto/asn1/d2i_pr.c", + "crypto/asn1/asn1_par.c", + "crypto/asn1/x_spki.c", + "crypto/asn1/a_d2i_fp.c", + "crypto/asn1/f_int.c", + "crypto/asn1/x_exten.c", + "crypto/asn1/tasn_utl.c", + "crypto/asn1/nsseq.c", + "crypto/asn1/a_bitstr.c", + "crypto/asn1/x_info.c", + "crypto/asn1/a_strnid.c", + "crypto/asn1/a_object.c", + "crypto/asn1/tasn_fre.c", + "crypto/asn1/d2i_pu.c", + "crypto/asn1/ameth_lib.c", + "crypto/asn1/x_attrib.c", + "crypto/evp/m_sha.c", + "crypto/evp/e_camellia.c", + "crypto/evp/e_aes.c", + "crypto/evp/bio_b64.c", + "crypto/evp/m_sigver.c", + "crypto/evp/m_wp.c", + "crypto/evp/m_sha1.c", + "crypto/evp/p_seal.c", + "crypto/evp/c_alld.c", + "crypto/evp/p5_crpt.c", + "crypto/evp/e_rc4.c", + "crypto/evp/m_ecdsa.c", + "crypto/evp/bio_enc.c", + "crypto/evp/e_des3.c", + "crypto/evp/m_null.c", + "crypto/evp/bio_ok.c", + "crypto/evp/pmeth_gn.c", + "crypto/evp/e_rc5.c", + "crypto/evp/e_rc2.c", + "crypto/evp/p_dec.c", + "crypto/evp/p_verify.c", + "crypto/evp/e_rc4_hmac_md5.c", + "crypto/evp/pmeth_lib.c", + "crypto/evp/m_ripemd.c", + "crypto/evp/m_md5.c", + "crypto/evp/e_bf.c", + "crypto/evp/p_enc.c", + "crypto/evp/m_dss.c", + "crypto/evp/bio_md.c", + "crypto/evp/evp_pbe.c", + "crypto/evp/e_seed.c", + "crypto/evp/e_cast.c", + "crypto/evp/p_open.c", + "crypto/evp/p5_crpt2.c", + "crypto/evp/m_dss1.c", + "crypto/evp/names.c", + "crypto/evp/evp_acnf.c", + "crypto/evp/e_des.c", + "crypto/evp/evp_cnf.c", + "crypto/evp/evp_lib.c", + "crypto/evp/digest.c", + "crypto/evp/evp_err.c", + "crypto/evp/evp_enc.c", + "crypto/evp/e_old.c", + "crypto/evp/c_all.c", + "crypto/evp/m_md2.c", + "crypto/evp/e_xcbc_d.c", + "crypto/evp/pmeth_fn.c", + "crypto/evp/p_lib.c", + "crypto/evp/evp_key.c", + "crypto/evp/encode.c", + "crypto/evp/e_aes_cbc_hmac_sha1.c", + "crypto/evp/e_aes_cbc_hmac_sha256.c", + "crypto/evp/m_mdc2.c", + "crypto/evp/e_null.c", + "crypto/evp/p_sign.c", + "crypto/evp/e_idea.c", + "crypto/evp/c_allc.c", + "crypto/evp/evp_pkey.c", + "crypto/evp/m_md4.c", + "crypto/ex_data.c", + "crypto/pkcs12/p12_p8e.c", + "crypto/pkcs12/p12_crt.c", + "crypto/pkcs12/p12_utl.c", + "crypto/pkcs12/p12_attr.c", + "crypto/pkcs12/p12_npas.c", + "crypto/pkcs12/p12_decr.c", + "crypto/pkcs12/p12_init.c", + "crypto/pkcs12/p12_kiss.c", + "crypto/pkcs12/p12_add.c", + "crypto/pkcs12/p12_p8d.c", + "crypto/pkcs12/p12_mutl.c", + "crypto/pkcs12/p12_crpt.c", + "crypto/pkcs12/pk12err.c", + "crypto/pkcs12/p12_asn.c", + "crypto/pkcs12/p12_key.c", + "crypto/ecdh/ech_key.c", + "crypto/ecdh/ech_ossl.c", + "crypto/ecdh/ech_lib.c", + "crypto/ecdh/ech_err.c", + "crypto/ecdh/ech_kdf.c", + "crypto/o_str.c", + "crypto/conf/conf_api.c", + "crypto/conf/conf_err.c", + "crypto/conf/conf_def.c", + "crypto/conf/conf_lib.c", + "crypto/conf/conf_mall.c", + "crypto/conf/conf_sap.c", + "crypto/conf/conf_mod.c", + "crypto/ebcdic.c", + "crypto/ecdsa/ecs_lib.c", + "crypto/ecdsa/ecs_asn1.c", + "crypto/ecdsa/ecs_ossl.c", + "crypto/ecdsa/ecs_vrf.c", + "crypto/ecdsa/ecs_sign.c", + "crypto/ecdsa/ecs_err.c", + "crypto/dso/dso_win32.c", + "crypto/dso/dso_lib.c", + "crypto/dso/dso_dlfcn.c", + "crypto/dso/dso_dl.c", + "crypto/dso/dso_beos.c", + "crypto/dso/dso_null.c", + "crypto/dso/dso_vms.c", + "crypto/dso/dso_err.c", + "crypto/dso/dso_openssl.c", + "crypto/cryptlib.c", + "crypto/md5/md5_one.c", + "crypto/md5/md5_dgst.c", + "crypto/pkcs7/pkcs7err.c", + "crypto/pkcs7/pk7_smime.c", + "crypto/pkcs7/bio_pk7.c", + "crypto/pkcs7/pk7_mime.c", + "crypto/pkcs7/pk7_lib.c", + "crypto/pkcs7/pk7_asn1.c", + "crypto/pkcs7/pk7_doit.c", + "crypto/pkcs7/pk7_attr.c", + "crypto/md4/md4_one.c", + "crypto/md4/md4_dgst.c", + "crypto/o_dir.c", + "crypto/buffer/buf_err.c", + "crypto/buffer/buf_str.c", + "crypto/buffer/buffer.c", + "crypto/cms/cms_lib.c", + "crypto/cms/cms_io.c", + "crypto/cms/cms_err.c", + "crypto/cms/cms_dd.c", + "crypto/cms/cms_smime.c", + "crypto/cms/cms_att.c", + "crypto/cms/cms_pwri.c", + "crypto/cms/cms_cd.c", + "crypto/cms/cms_sd.c", + "crypto/cms/cms_asn1.c", + "crypto/cms/cms_env.c", + "crypto/cms/cms_enc.c", + "crypto/cms/cms_ess.c", + "crypto/cms/cms_kari.c", + "crypto/mem_dbg.c", + "crypto/uid.c", + "crypto/stack/stack.c", + "crypto/ec/ec_ameth.c", + "crypto/ec/ec_err.c", + "crypto/ec/ec_lib.c", + "crypto/ec/ec_curve.c", + "crypto/ec/ec_oct.c", + "crypto/ec/ec_asn1.c", + "crypto/ec/ecp_oct.c", + "crypto/ec/ec_print.c", + "crypto/ec/ec2_smpl.c", + "crypto/ec/ecp_nistp224.c", + "crypto/ec/ec2_oct.c", + "crypto/ec/eck_prn.c", + "crypto/ec/ec_key.c", + "crypto/ec/ecp_nist.c", + "crypto/ec/ec_check.c", + "crypto/ec/ecp_smpl.c", + "crypto/ec/ec2_mult.c", + "crypto/ec/ecp_mont.c", + "crypto/ec/ecp_nistp521.c", + "crypto/ec/ec_mult.c", + "crypto/ec/ecp_nistputil.c", + "crypto/ec/ec_pmeth.c", + "crypto/ec/ec_cvt.c", + "crypto/ec/ecp_nistp256.c", + "crypto/krb5/krb5_asn.c", + "crypto/hmac/hmac.c", + "crypto/hmac/hm_ameth.c", + "crypto/hmac/hm_pmeth.c", + "crypto/comp/c_rle.c", + "crypto/comp/c_zlib.c", + "crypto/comp/comp_lib.c", + "crypto/comp/comp_err.c", + "crypto/des/fcrypt.c", + "crypto/des/str2key.c", + "crypto/des/cbc_cksm.c", + "crypto/des/des_enc.c", + "crypto/des/ofb_enc.c", + "crypto/des/read2pwd.c", + "crypto/des/ecb3_enc.c", + "crypto/des/rand_key.c", + "crypto/des/cfb64ede.c", + "crypto/des/rpc_enc.c", + "crypto/des/ofb64ede.c", + "crypto/des/qud_cksm.c", + "crypto/des/enc_writ.c", + "crypto/des/set_key.c", + "crypto/des/xcbc_enc.c", + "crypto/des/fcrypt_b.c", + "crypto/des/ede_cbcm_enc.c", + "crypto/des/des_old2.c", + "crypto/des/cfb_enc.c", + "crypto/des/ecb_enc.c", + "crypto/des/enc_read.c", + "crypto/des/des_old.c", + "crypto/des/ofb64enc.c", + "crypto/des/pcbc_enc.c", + "crypto/des/cbc_enc.c", + "crypto/des/cfb64enc.c", + "crypto/lhash/lh_stats.c", + "crypto/lhash/lhash.c", + "crypto/x509v3/v3_genn.c", + "crypto/x509v3/pcy_cache.c", + "crypto/x509v3/v3_sxnet.c", + "crypto/x509v3/v3_scts.c", + "crypto/x509v3/v3err.c", + "crypto/x509v3/v3_conf.c", + "crypto/x509v3/v3_utl.c", + "crypto/x509v3/v3_akeya.c", + "crypto/x509v3/v3_lib.c", + "crypto/x509v3/pcy_lib.c", + "crypto/x509v3/v3_cpols.c", + "crypto/x509v3/v3_ia5.c", + "crypto/x509v3/v3_bitst.c", + "crypto/x509v3/v3_skey.c", + "crypto/x509v3/v3_info.c", + "crypto/x509v3/v3_asid.c", + "crypto/x509v3/pcy_tree.c", + "crypto/x509v3/v3_pcons.c", + "crypto/x509v3/v3_bcons.c", + "crypto/x509v3/v3_pku.c", + "crypto/x509v3/v3_ocsp.c", + "crypto/x509v3/pcy_map.c", + "crypto/x509v3/v3_ncons.c", + "crypto/x509v3/v3_purp.c", + "crypto/x509v3/v3_enum.c", + "crypto/x509v3/v3_pmaps.c", + "crypto/x509v3/pcy_node.c", + "crypto/x509v3/v3_pcia.c", + "crypto/x509v3/v3_crld.c", + "crypto/x509v3/v3_pci.c", + "crypto/x509v3/v3_akey.c", + "crypto/x509v3/v3_addr.c", + "crypto/x509v3/v3_int.c", + "crypto/x509v3/v3_alt.c", + "crypto/x509v3/v3_extku.c", + "crypto/x509v3/v3_prn.c", + "crypto/x509v3/pcy_data.c", + "crypto/aes/aes_ofb.c", + "crypto/aes/aes_ctr.c", + "crypto/aes/aes_ecb.c", + "crypto/aes/aes_cfb.c", + "crypto/aes/aes_wrap.c", + "crypto/aes/aes_ige.c", + "crypto/aes/aes_misc.c", + "crypto/pqueue/pqueue.c", + "crypto/sha/sha_one.c", + "crypto/sha/sha_dgst.c", + "crypto/sha/sha512.c", + "crypto/sha/sha1_one.c", + "crypto/sha/sha1dgst.c", + "crypto/sha/sha256.c", + "crypto/whrlpool/wp_dgst.c", + "crypto/objects/obj_xref.c", + "crypto/objects/o_names.c", + "crypto/objects/obj_err.c", + "crypto/objects/obj_dat.c", + "crypto/objects/obj_lib.c", + "crypto/mem.c", + "crypto/fips_ers.c", + "crypto/o_fips.c", + "crypto/engine/eng_rdrand.c", + "crypto/engine/eng_err.c", + "crypto/engine/tb_ecdsa.c", + "crypto/engine/tb_rsa.c", + "crypto/engine/tb_cipher.c", + "crypto/engine/tb_dsa.c", + "crypto/engine/eng_lib.c", + "crypto/engine/tb_asnmth.c", + "crypto/engine/tb_ecdh.c", + "crypto/engine/tb_dh.c", + "crypto/engine/tb_store.c", + "crypto/engine/eng_init.c", + "crypto/engine/eng_cnf.c", + "crypto/engine/eng_all.c", + "crypto/engine/tb_digest.c", + "crypto/engine/tb_pkmeth.c", + "crypto/engine/eng_table.c", + "crypto/engine/eng_ctrl.c", + "crypto/engine/eng_list.c", + "crypto/engine/eng_cryptodev.c", + "crypto/engine/eng_pkey.c", + "crypto/engine/tb_rand.c", + "crypto/engine/eng_openssl.c", + "crypto/engine/eng_fat.c", + "crypto/engine/eng_dyn.c", + "crypto/ts/ts_rsp_verify.c", + "crypto/ts/ts_req_print.c", + "crypto/ts/ts_verify_ctx.c", + "crypto/ts/ts_req_utils.c", + "crypto/ts/ts_err.c", + "crypto/ts/ts_rsp_print.c", + "crypto/ts/ts_rsp_utils.c", + "crypto/ts/ts_lib.c", + "crypto/ts/ts_conf.c", + "crypto/ts/ts_asn1.c", + "crypto/ts/ts_rsp_sign.c", + "crypto/ocsp/ocsp_ext.c", + "crypto/ocsp/ocsp_cl.c", + "crypto/ocsp/ocsp_ht.c", + "crypto/ocsp/ocsp_lib.c", + "crypto/ocsp/ocsp_srv.c", + "crypto/ocsp/ocsp_vfy.c", + "crypto/ocsp/ocsp_err.c", + "crypto/ocsp/ocsp_prn.c", + "crypto/ocsp/ocsp_asn.c", + "crypto/bf/bf_cfb64.c", + "crypto/bf/bf_ecb.c", + "crypto/bf/bf_enc.c", + "crypto/bf/bf_skey.c", + "crypto/bf/bf_ofb64.c", + "crypto/idea/i_skey.c", + "crypto/idea/i_ofb64.c", + "crypto/idea/i_cbc.c", + "crypto/idea/i_ecb.c", + "crypto/idea/i_cfb64.c", + "crypto/cmac/cm_ameth.c", + "crypto/cmac/cmac.c", + "crypto/cmac/cm_pmeth.c", + "crypto/dh/dh_lib.c", + "crypto/dh/dh_key.c", + "crypto/dh/dh_asn1.c", + "crypto/dh/dh_depr.c", + "crypto/dh/dh_pmeth.c", + "crypto/dh/dh_prn.c", + "crypto/dh/dh_gen.c", + "crypto/dh/dh_ameth.c", + "crypto/dh/dh_check.c", + "crypto/dh/dh_err.c", + "crypto/dh/dh_kdf.c", + "crypto/dh/dh_rfc5114.c", + "crypto/modes/ccm128.c", + "crypto/modes/ofb128.c", + "crypto/modes/cts128.c", + "crypto/modes/ctr128.c", + "crypto/modes/gcm128.c", + "crypto/modes/cbc128.c", + "crypto/modes/cfb128.c", + "crypto/modes/xts128.c", + "crypto/modes/wrap128.c", + "crypto/camellia/cmll_cfb.c", + "crypto/camellia/cmll_ecb.c", + "crypto/camellia/cmll_utl.c", + "crypto/camellia/cmll_misc.c", + "crypto/camellia/cmll_ofb.c", + "crypto/camellia/cmll_ctr.c", + "crypto/seed/seed_ecb.c", + "crypto/seed/seed_cbc.c", + "crypto/seed/seed.c", + "crypto/seed/seed_ofb.c", + "crypto/seed/seed_cfb.c", + "crypto/txt_db/txt_db.c", + "crypto/cpt_err.c", + "crypto/pem/pem_pk8.c", + "crypto/pem/pem_lib.c", + "crypto/pem/pem_sign.c", + "crypto/pem/pem_all.c", + "crypto/pem/pem_info.c", + "crypto/pem/pem_pkey.c", + "crypto/pem/pem_seal.c", + "crypto/pem/pem_err.c", + "crypto/pem/pem_xaux.c", + "crypto/pem/pvkfmt.c", + "crypto/pem/pem_x509.c", + "crypto/pem/pem_oth.c", + "crypto/rand/rand_lib.c", + "crypto/rand/randfile.c", + "crypto/rand/rand_os2.c", + "crypto/rand/rand_unix.c", + "crypto/rand/rand_nw.c", + "crypto/rand/md_rand.c", + "crypto/rand/rand_err.c", + "crypto/rand/rand_win.c", + "crypto/rand/rand_egd.c", + "crypto/cversion.c", + "crypto/cast/c_ecb.c", + "crypto/cast/c_skey.c", + "crypto/cast/c_ofb64.c", + "crypto/cast/c_enc.c", + "crypto/cast/c_cfb64.c", + "crypto/o_time.c", + "crypto/mdc2/mdc2dgst.c", + "crypto/mdc2/mdc2_one.c", + "crypto/rc4/rc4_utl.c", + "crypto/ui/ui_compat.c", + "crypto/ui/ui_util.c", + "crypto/ui/ui_lib.c", + "crypto/ui/ui_err.c", + "crypto/ui/ui_openssl.c", + "crypto/bio/bf_buff.c", + "crypto/bio/bss_null.c", + "crypto/bio/bss_acpt.c", + "crypto/bio/bss_conn.c", + "crypto/bio/bss_fd.c", + "crypto/bio/bf_null.c", + "crypto/bio/bio_err.c", + "crypto/bio/bss_sock.c", + "crypto/bio/bss_mem.c", + "crypto/bio/b_dump.c", + "crypto/bio/b_print.c", + "crypto/bio/b_sock.c", + "crypto/bio/bss_dgram.c", + "crypto/bio/bf_nbio.c", + "crypto/bio/bio_lib.c", + "crypto/bio/bss_file.c", + "crypto/bio/bss_bio.c", + "crypto/bio/bss_log.c", + "crypto/bio/bio_cb.c", + "crypto/o_init.c", + "crypto/rc2/rc2_skey.c", + "crypto/rc2/rc2_cbc.c", + "crypto/rc2/rc2cfb64.c", + "crypto/rc2/rc2_ecb.c", + "crypto/rc2/rc2ofb64.c", + "crypto/bn/bn_x931p.c", + "crypto/bn/bn_blind.c", + "crypto/bn/bn_gf2m.c", + "crypto/bn/bn_const.c", + "crypto/bn/bn_sqr.c", + "crypto/bn/bn_nist.c", + "crypto/bn/bn_rand.c", + "crypto/bn/bn_err.c", + "crypto/bn/bn_div.c", + "crypto/bn/bn_kron.c", + "crypto/bn/bn_ctx.c", + "crypto/bn/bn_shift.c", + "crypto/bn/bn_mod.c", + "crypto/bn/bn_exp2.c", + "crypto/bn/bn_word.c", + "crypto/bn/bn_add.c", + "crypto/bn/bn_exp.c", + "crypto/bn/bn_mont.c", + "crypto/bn/bn_print.c", + "crypto/bn/bn_mul.c", + "crypto/bn/bn_prime.c", + "crypto/bn/bn_depr.c", + "crypto/bn/bn_gcd.c", + "crypto/bn/bn_mpi.c", + "crypto/bn/bn_sqrt.c", + "crypto/bn/bn_recp.c", + "crypto/bn/bn_lib.c", + "crypto/ripemd/rmd_dgst.c", + "crypto/ripemd/rmd_one.c", + "crypto/rsa/rsa_x931.c", + "crypto/rsa/rsa_depr.c", + "crypto/rsa/rsa_saos.c", + "crypto/rsa/rsa_crpt.c", + "crypto/rsa/rsa_pss.c", + "crypto/rsa/rsa_oaep.c", + "crypto/rsa/rsa_null.c", + "crypto/rsa/rsa_gen.c", + "crypto/rsa/rsa_prn.c", + "crypto/rsa/rsa_pmeth.c", + "crypto/rsa/rsa_asn1.c", + "crypto/rsa/rsa_ssl.c", + "crypto/rsa/rsa_ameth.c", + "crypto/rsa/rsa_pk1.c", + "crypto/rsa/rsa_err.c", + "crypto/rsa/rsa_lib.c", + "crypto/rsa/rsa_none.c", + "crypto/rsa/rsa_chk.c", + "crypto/rsa/rsa_eay.c", + "crypto/rsa/rsa_sign.c", + "crypto/srp/srp_lib.c", + "crypto/srp/srp_vfy.c", + "crypto/err/err.c", + "crypto/err/err_prn.c", + "crypto/err/err_all.c", + "crypto/mem_clr.c", + "crypto/rc4/rc4_skey.c", + "crypto/rc4/rc4_enc.c", + "crypto/camellia/camellia.c", + "crypto/camellia/cmll_cbc.c", + #"crypto/aes/aes_x86core.c", + "crypto/aes/aes_core.c", + "crypto/aes/aes_cbc.c", + "crypto/whrlpool/wp_block.c", + "crypto/bn/bn_asm.c", + ] - if "platform" in env and env["platform"] == "winrt": - thirdparty_sources += ['winrt.cpp'] + if "platform" in env and env["platform"] == "winrt": + thirdparty_sources += ['winrt.cpp'] - thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - env_openssl.add_source_files(env.modules_sources, thirdparty_sources) + env_openssl.add_source_files(env.modules_sources, thirdparty_sources) - # FIXME: Clone the environment to make a env_openssl and not pollute the modules env - thirdparty_include_paths = [ - "", - "crypto", - "crypto/asn1", - "crypto/evp", - "crypto/modes", - "openssl", - ] - env_openssl.Append(CPPPATH = [thirdparty_dir + "/" + dir for dir in thirdparty_include_paths]) + # FIXME: Clone the environment to make a env_openssl and not pollute the modules env + thirdparty_include_paths = [ + "", + "crypto", + "crypto/asn1", + "crypto/evp", + "crypto/modes", + "openssl", + ] + env_openssl.Append(CPPPATH=[thirdparty_dir + "/" + dir for dir in thirdparty_include_paths]) - env_openssl.Append(CPPFLAGS = ["-DOPENSSL_NO_ASM", "-DOPENSSL_THREADS", "-DL_ENDIAN"]) + env_openssl.Append(CPPFLAGS=["-DOPENSSL_NO_ASM", "-DOPENSSL_THREADS", "-DL_ENDIAN"]) - # Workaround for compilation error with GCC/Clang when -Werror is too greedy (GH-4517) - import os - import methods - if not (os.name=="nt" and os.getenv("VCINSTALLDIR")): # not Windows and not MSVC - env_openssl.Append(CFLAGS = ["-Wno-error=implicit-function-declaration"]) + # Workaround for compilation error with GCC/Clang when -Werror is too greedy (GH-4517) + import os + import methods + if not (os.name == "nt" and os.getenv("VCINSTALLDIR")): # not Windows and not MSVC + env_openssl.Append(CFLAGS=["-Wno-error=implicit-function-declaration"]) # Module sources @@ -681,7 +681,7 @@ env_openssl.add_source_files(env.modules_sources, "*.c") # platform/winrt need to know openssl is available, pass to main env if "platform" in env and env["platform"] == "winrt": - env.Append(CPPPATH = [thirdparty_dir]) - env.Append(CPPFLAGS = ['-DOPENSSL_ENABLED']); + env.Append(CPPPATH=[thirdparty_dir]) + env.Append(CPPFLAGS=['-DOPENSSL_ENABLED']) Export('env') diff --git a/modules/openssl/config.py b/modules/openssl/config.py index 368e97e152..fb920482f5 100644 --- a/modules/openssl/config.py +++ b/modules/openssl/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/opus/SCsub b/modules/opus/SCsub index 603f5a48c4..4d3053c7ec 100644 --- a/modules/opus/SCsub +++ b/modules/opus/SCsub @@ -6,210 +6,211 @@ Import('env_modules') env_opus = env_modules.Clone() # Thirdparty source files -if (env["opus"] != "system"): # builtin - thirdparty_dir = "#thirdparty/opus/" +if (env['builtin_opus'] != 'no'): + thirdparty_dir = "#thirdparty/opus/" - thirdparty_sources = [ - "silk/tables_other.c", - "silk/sum_sqr_shift.c", - "silk/PLC.c", - "silk/dec_API.c", - "silk/decode_pulses.c", - "silk/inner_prod_aligned.c", - "silk/init_encoder.c", - "silk/interpolate.c", - "silk/stereo_encode_pred.c", - "silk/decode_frame.c", - "silk/NLSF_del_dec_quant.c", - "silk/VAD.c", - "silk/resampler_private_AR2.c", - "silk/NLSF_unpack.c", - "silk/resampler_down2.c", - "silk/sort.c", - "silk/resampler_private_IIR_FIR.c", - "silk/resampler_down2_3.c", - "silk/resampler_private_up2_HQ.c", - "silk/tables_gain.c", - "silk/stereo_find_predictor.c", - "silk/stereo_quant_pred.c", - "silk/NLSF_stabilize.c", - "silk/ana_filt_bank_1.c", - "silk/check_control_input.c", - "silk/bwexpander.c", - "silk/A2NLSF.c", - "silk/LPC_inv_pred_gain.c", - "silk/log2lin.c", - "silk/process_NLSFs.c", - "silk/sigm_Q15.c", - "silk/VQ_WMat_EC.c", - "silk/quant_LTP_gains.c", - "silk/resampler_private_down_FIR.c", - "silk/NLSF_decode.c", - "silk/control_codec.c", - "silk/NLSF_VQ_weights_laroia.c", - "silk/decode_pitch.c", - "silk/stereo_decode_pred.c", - "silk/tables_pulses_per_block.c", - "silk/init_decoder.c", - "silk/table_LSF_cos.c", - "silk/decode_core.c", - "silk/code_signs.c", - "silk/enc_API.c", - "silk/tables_LTP.c", - "silk/pitch_est_tables.c", - "silk/biquad_alt.c", - "silk/encode_indices.c", - "silk/tables_NLSF_CB_WB.c", - "silk/debug.c", - "silk/decode_parameters.c", - "silk/tables_pitch_lag.c", - "silk/NLSF2A.c", - "silk/resampler.c", - "silk/decode_indices.c", - "silk/NLSF_VQ.c", - "silk/bwexpander_32.c", - "silk/tables_NLSF_CB_NB_MB.c", - "silk/encode_pulses.c", - "silk/NSQ_del_dec.c", - "silk/control_SNR.c", - "silk/shell_coder.c", - "silk/NLSF_encode.c", - "silk/stereo_MS_to_LR.c", - "silk/stereo_LR_to_MS.c", - "silk/HP_variable_cutoff.c", - "silk/LPC_analysis_filter.c", - "silk/CNG.c", - "silk/decoder_set_fs.c", - "silk/resampler_rom.c", - "silk/control_audio_bandwidth.c", - "silk/lin2log.c", - "silk/LP_variable_cutoff.c", - "silk/NSQ.c", - "silk/gain_quant.c", - "celt/laplace.c", - "celt/vq.c", - "celt/quant_bands.c", - "celt/kiss_fft.c", - "celt/entcode.c", - "celt/entenc.c", - "celt/celt_lpc.c", - "celt/pitch.c", - "celt/rate.c", - "celt/mathops.c", - #"celt/arm/armcpu.c", - #"celt/arm/celt_neon_intr.c", - #"celt/arm/celt_ne10_mdct.c", - #"celt/arm/celt_ne10_fft.c", - #"celt/arm/arm_celt_map.c", - "celt/celt_encoder.c", - "celt/celt.c", - "celt/bands.c", - "celt/cwrs.c", - "celt/entdec.c", - "celt/celt_decoder.c", - "celt/mdct.c", - "celt/modes.c", - "repacketizer.c", - "mlp_data.c", - "opus_multistream.c", - "opusfile.c", - "opus_encoder.c", - "analysis.c", - "mlp.c", - "info.c", - "stream.c", - "opus_decoder.c", - "internal.c", - "wincerts.c", - "opus.c", - "opus_multistream_encoder.c", - "http.c", - "opus_multistream_decoder.c" - ] + thirdparty_sources = [ + "silk/tables_other.c", + "silk/sum_sqr_shift.c", + "silk/PLC.c", + "silk/dec_API.c", + "silk/decode_pulses.c", + "silk/inner_prod_aligned.c", + "silk/init_encoder.c", + "silk/interpolate.c", + "silk/stereo_encode_pred.c", + "silk/decode_frame.c", + "silk/NLSF_del_dec_quant.c", + "silk/VAD.c", + "silk/resampler_private_AR2.c", + "silk/NLSF_unpack.c", + "silk/resampler_down2.c", + "silk/sort.c", + "silk/resampler_private_IIR_FIR.c", + "silk/resampler_down2_3.c", + "silk/resampler_private_up2_HQ.c", + "silk/tables_gain.c", + "silk/stereo_find_predictor.c", + "silk/stereo_quant_pred.c", + "silk/NLSF_stabilize.c", + "silk/ana_filt_bank_1.c", + "silk/check_control_input.c", + "silk/bwexpander.c", + "silk/A2NLSF.c", + "silk/LPC_inv_pred_gain.c", + "silk/log2lin.c", + "silk/process_NLSFs.c", + "silk/sigm_Q15.c", + "silk/VQ_WMat_EC.c", + "silk/quant_LTP_gains.c", + "silk/resampler_private_down_FIR.c", + "silk/NLSF_decode.c", + "silk/control_codec.c", + "silk/NLSF_VQ_weights_laroia.c", + "silk/decode_pitch.c", + "silk/stereo_decode_pred.c", + "silk/tables_pulses_per_block.c", + "silk/init_decoder.c", + "silk/table_LSF_cos.c", + "silk/decode_core.c", + "silk/code_signs.c", + "silk/enc_API.c", + "silk/tables_LTP.c", + "silk/pitch_est_tables.c", + "silk/biquad_alt.c", + "silk/encode_indices.c", + "silk/tables_NLSF_CB_WB.c", + "silk/debug.c", + "silk/decode_parameters.c", + "silk/tables_pitch_lag.c", + "silk/NLSF2A.c", + "silk/resampler.c", + "silk/decode_indices.c", + "silk/NLSF_VQ.c", + "silk/bwexpander_32.c", + "silk/tables_NLSF_CB_NB_MB.c", + "silk/encode_pulses.c", + "silk/NSQ_del_dec.c", + "silk/control_SNR.c", + "silk/shell_coder.c", + "silk/NLSF_encode.c", + "silk/stereo_MS_to_LR.c", + "silk/stereo_LR_to_MS.c", + "silk/HP_variable_cutoff.c", + "silk/LPC_analysis_filter.c", + "silk/CNG.c", + "silk/decoder_set_fs.c", + "silk/resampler_rom.c", + "silk/control_audio_bandwidth.c", + "silk/lin2log.c", + "silk/LP_variable_cutoff.c", + "silk/NSQ.c", + "silk/gain_quant.c", + "celt/laplace.c", + "celt/vq.c", + "celt/quant_bands.c", + "celt/kiss_fft.c", + "celt/entcode.c", + "celt/entenc.c", + "celt/celt_lpc.c", + "celt/pitch.c", + "celt/rate.c", + "celt/mathops.c", + #"celt/arm/armcpu.c", + #"celt/arm/celt_neon_intr.c", + #"celt/arm/celt_ne10_mdct.c", + #"celt/arm/celt_ne10_fft.c", + #"celt/arm/arm_celt_map.c", + "celt/celt_encoder.c", + "celt/celt.c", + "celt/bands.c", + "celt/cwrs.c", + "celt/entdec.c", + "celt/celt_decoder.c", + "celt/mdct.c", + "celt/modes.c", + "repacketizer.c", + "mlp_data.c", + "opus_multistream.c", + "opusfile.c", + "opus_encoder.c", + "analysis.c", + "mlp.c", + "info.c", + "stream.c", + "opus_decoder.c", + "internal.c", + "wincerts.c", + "opus.c", + "opus_multistream_encoder.c", + "http.c", + "opus_multistream_decoder.c" + ] - opus_sources_silk = [] + opus_sources_silk = [] - if("opus_fixed_point" in env and env.opus_fixed_point=="yes"): - env_opus.Append(CFLAGS = ["-DFIXED_POINT"]) - opus_sources_silk = [ - "silk/fixed/schur64_FIX.c", - "silk/fixed/residual_energy16_FIX.c", - "silk/fixed/encode_frame_FIX.c", - "silk/fixed/regularize_correlations_FIX.c", - "silk/fixed/apply_sine_window_FIX.c", - "silk/fixed/solve_LS_FIX.c", - "silk/fixed/schur_FIX.c", - "silk/fixed/pitch_analysis_core_FIX.c", - "silk/fixed/noise_shape_analysis_FIX.c", - "silk/fixed/find_LTP_FIX.c", - "silk/fixed/vector_ops_FIX.c", - "silk/fixed/autocorr_FIX.c", - "silk/fixed/warped_autocorrelation_FIX.c", - "silk/fixed/find_pitch_lags_FIX.c", - "silk/fixed/k2a_Q16_FIX.c", - "silk/fixed/LTP_scale_ctrl_FIX.c", - "silk/fixed/corrMatrix_FIX.c", - "silk/fixed/prefilter_FIX.c", - "silk/fixed/find_LPC_FIX.c", - "silk/fixed/residual_energy_FIX.c", - "silk/fixed/process_gains_FIX.c", - "silk/fixed/LTP_analysis_filter_FIX.c", - "silk/fixed/k2a_FIX.c", - "silk/fixed/burg_modified_FIX.c", - "silk/fixed/find_pred_coefs_FIX.c" - ] - else: - opus_sources_silk = [ - "silk/float/LTP_scale_ctrl_FLP.c", - "silk/float/regularize_correlations_FLP.c", - "silk/float/corrMatrix_FLP.c", - "silk/float/LPC_analysis_filter_FLP.c", - "silk/float/levinsondurbin_FLP.c", - "silk/float/schur_FLP.c", - "silk/float/scale_vector_FLP.c", - "silk/float/apply_sine_window_FLP.c", - "silk/float/pitch_analysis_core_FLP.c", - "silk/float/wrappers_FLP.c", - "silk/float/bwexpander_FLP.c", - "silk/float/warped_autocorrelation_FLP.c", - "silk/float/solve_LS_FLP.c", - "silk/float/find_LPC_FLP.c", - "silk/float/autocorrelation_FLP.c", - "silk/float/find_pred_coefs_FLP.c", - "silk/float/find_pitch_lags_FLP.c", - "silk/float/burg_modified_FLP.c", - "silk/float/find_LTP_FLP.c", - "silk/float/energy_FLP.c", - "silk/float/sort_FLP.c", - "silk/float/LPC_inv_pred_gain_FLP.c", - "silk/float/k2a_FLP.c", - "silk/float/noise_shape_analysis_FLP.c", - "silk/float/inner_product_FLP.c", - "silk/float/process_gains_FLP.c", - "silk/float/encode_frame_FLP.c", - "silk/float/scale_copy_vector_FLP.c", - "silk/float/residual_energy_FLP.c", - "silk/float/LTP_analysis_filter_FLP.c", - "silk/float/prefilter_FLP.c" - ] + if("opus_fixed_point" in env and env.opus_fixed_point == "yes"): + env_opus.Append(CFLAGS=["-DFIXED_POINT"]) + opus_sources_silk = [ + "silk/fixed/schur64_FIX.c", + "silk/fixed/residual_energy16_FIX.c", + "silk/fixed/encode_frame_FIX.c", + "silk/fixed/regularize_correlations_FIX.c", + "silk/fixed/apply_sine_window_FIX.c", + "silk/fixed/solve_LS_FIX.c", + "silk/fixed/schur_FIX.c", + "silk/fixed/pitch_analysis_core_FIX.c", + "silk/fixed/noise_shape_analysis_FIX.c", + "silk/fixed/find_LTP_FIX.c", + "silk/fixed/vector_ops_FIX.c", + "silk/fixed/autocorr_FIX.c", + "silk/fixed/warped_autocorrelation_FIX.c", + "silk/fixed/find_pitch_lags_FIX.c", + "silk/fixed/k2a_Q16_FIX.c", + "silk/fixed/LTP_scale_ctrl_FIX.c", + "silk/fixed/corrMatrix_FIX.c", + "silk/fixed/prefilter_FIX.c", + "silk/fixed/find_LPC_FIX.c", + "silk/fixed/residual_energy_FIX.c", + "silk/fixed/process_gains_FIX.c", + "silk/fixed/LTP_analysis_filter_FIX.c", + "silk/fixed/k2a_FIX.c", + "silk/fixed/burg_modified_FIX.c", + "silk/fixed/find_pred_coefs_FIX.c" + ] + else: + opus_sources_silk = [ + "silk/float/LTP_scale_ctrl_FLP.c", + "silk/float/regularize_correlations_FLP.c", + "silk/float/corrMatrix_FLP.c", + "silk/float/LPC_analysis_filter_FLP.c", + "silk/float/levinsondurbin_FLP.c", + "silk/float/schur_FLP.c", + "silk/float/scale_vector_FLP.c", + "silk/float/apply_sine_window_FLP.c", + "silk/float/pitch_analysis_core_FLP.c", + "silk/float/wrappers_FLP.c", + "silk/float/bwexpander_FLP.c", + "silk/float/warped_autocorrelation_FLP.c", + "silk/float/solve_LS_FLP.c", + "silk/float/find_LPC_FLP.c", + "silk/float/autocorrelation_FLP.c", + "silk/float/find_pred_coefs_FLP.c", + "silk/float/find_pitch_lags_FLP.c", + "silk/float/burg_modified_FLP.c", + "silk/float/find_LTP_FLP.c", + "silk/float/energy_FLP.c", + "silk/float/sort_FLP.c", + "silk/float/LPC_inv_pred_gain_FLP.c", + "silk/float/k2a_FLP.c", + "silk/float/noise_shape_analysis_FLP.c", + "silk/float/inner_product_FLP.c", + "silk/float/process_gains_FLP.c", + "silk/float/encode_frame_FLP.c", + "silk/float/scale_copy_vector_FLP.c", + "silk/float/residual_energy_FLP.c", + "silk/float/LTP_analysis_filter_FLP.c", + "silk/float/prefilter_FLP.c" + ] - thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources + opus_sources_silk] + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources + opus_sources_silk] - env_opus.add_source_files(env.modules_sources, thirdparty_sources) - env_opus.Append(CFLAGS=["-DHAVE_CONFIG_H"]) + env_opus.add_source_files(env.modules_sources, thirdparty_sources) + env_opus.Append(CFLAGS=["-DHAVE_CONFIG_H"]) - thirdparty_include_paths = [ - "", - "celt", - "silk", - "silk/fixed", - "silk/float", - ] - env_opus.Append(CPPPATH = [thirdparty_dir + "/" + dir for dir in thirdparty_include_paths]) + thirdparty_include_paths = [ + "", + "celt", + "opus", + "silk", + "silk/fixed", + "silk/float", + ] + env_opus.Append(CPPPATH=[thirdparty_dir + "/" + dir for dir in thirdparty_include_paths]) - # also requires libogg - if (env["libogg"] != "system"): # builtin - env_opus.Append(CPPPATH = ["#thirdparty/libogg"]) + # also requires libogg + if (env['builtin_libogg'] != 'no'): + env_opus.Append(CPPPATH=["#thirdparty/libogg"]) # Module files env_opus.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/opus/audio_stream_opus.h b/modules/opus/audio_stream_opus.h index 4da66fe167..abf0b5c150 100644 --- a/modules/opus/audio_stream_opus.h +++ b/modules/opus/audio_stream_opus.h @@ -36,7 +36,7 @@ #include "os/file_access.h" #include "scene/resources/audio_stream.h" -#include <opusfile.h> +#include <opus/opusfile.h> class AudioStreamPlaybackOpus : public AudioStreamPlayback { diff --git a/modules/opus/config.py b/modules/opus/config.py index 368e97e152..fb920482f5 100644 --- a/modules/opus/config.py +++ b/modules/opus/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/pbm/config.py b/modules/pbm/config.py index 368e97e152..fb920482f5 100644 --- a/modules/pbm/config.py +++ b/modules/pbm/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/pvr/SCsub b/modules/pvr/SCsub index 4ead52f82f..ddca7a794e 100644 --- a/modules/pvr/SCsub +++ b/modules/pvr/SCsub @@ -9,16 +9,16 @@ env_pvr = env_modules.Clone() # Not unbundled so far since not widespread as shared library thirdparty_dir = "#thirdparty/pvrtccompressor/" thirdparty_sources = [ - "BitScale.cpp", - "MortonTable.cpp", - "PvrTcDecoder.cpp", - "PvrTcEncoder.cpp", - "PvrTcPacket.cpp", + "BitScale.cpp", + "MortonTable.cpp", + "PvrTcDecoder.cpp", + "PvrTcEncoder.cpp", + "PvrTcPacket.cpp", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] env_pvr.add_source_files(env.modules_sources, thirdparty_sources) -env_pvr.Append(CPPPATH = [thirdparty_dir]) +env_pvr.Append(CPPPATH=[thirdparty_dir]) # Godot source files env_pvr.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/pvr/config.py b/modules/pvr/config.py index 368e97e152..fb920482f5 100644 --- a/modules/pvr/config.py +++ b/modules/pvr/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/regex/config.py b/modules/regex/config.py index 667b5d8ba6..5347cfd243 100644 --- a/modules/regex/config.py +++ b/modules/regex/config.py @@ -1,8 +1,9 @@ #!/usr/bin/env python + def can_build(platform): return True + def configure(env): pass - diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp index a0f4b4934c..0197da46fb 100644 --- a/modules/regex/regex.cpp +++ b/modules/regex/regex.cpp @@ -97,6 +97,9 @@ struct RegExNode { memdelete(next); } + // For avoiding RTTI + virtual bool is_look_behind() { return false; } + virtual int test(RegExSearch& s, int pos) const { return next ? next->test(s, pos) : -1; @@ -750,6 +753,8 @@ struct RegExNodeLookBehind : public RegExNodeGroup { reset_pos = true; } + virtual bool is_look_behind() { return true; } + virtual int test(RegExSearch& s, int pos) const { if (pos < length) @@ -1089,7 +1094,7 @@ Error RegEx::compile(const String& p_pattern) { REGEX_COMPILE_FAIL("backreference not found"); for (int i = 0; i < stack.size(); ++i) - if (dynamic_cast<RegExNodeLookBehind*>(stack[i])) + if (stack[i]->is_look_behind()) REGEX_COMPILE_FAIL("backreferences inside lookbehind not supported"); for (int i = 0; i < group_names.size(); ++i) { @@ -1112,7 +1117,7 @@ Error RegEx::compile(const String& p_pattern) { c = d; for (int i = 0; i < stack.size(); ++i) - if (dynamic_cast<RegExNodeLookBehind*>(stack[i])) + if (stack[i]->is_look_behind()) REGEX_COMPILE_FAIL("backreferences inside lookbehind not supported"); int ref = -1; @@ -1238,7 +1243,7 @@ Error RegEx::compile(const String& p_pattern) { break; case '|': for (int i = 0; i < stack.size(); ++i) - if (dynamic_cast<RegExNodeLookBehind*>(stack[i])) + if (stack[i]->is_look_behind()) REGEX_COMPILE_FAIL("alternations inside lookbehind not supported"); stack[0]->add_childset(); break; @@ -1312,7 +1317,7 @@ Error RegEx::compile(const String& p_pattern) { if (min_val != max_val) for (int i = 0; i < stack.size(); ++i) - if (dynamic_cast<RegExNodeLookBehind*>(stack[i])) + if (stack[i]->is_look_behind()) REGEX_COMPILE_FAIL("variable length quantifiers inside lookbehind not supported"); RegExNodeQuantifier* quant = memnew(RegExNodeQuantifier(min_val, max_val)); diff --git a/modules/squish/SCsub b/modules/squish/SCsub index 3fdc587652..cca7c038f1 100644 --- a/modules/squish/SCsub +++ b/modules/squish/SCsub @@ -6,24 +6,24 @@ Import('env_modules') env_squish = env_modules.Clone() # Thirdparty source files -if (env["squish"] != "system"): # builtin - thirdparty_dir = "#thirdparty/squish/" - thirdparty_sources = [ - "alpha.cpp", - "clusterfit.cpp", - "colourblock.cpp", - "colourfit.cpp", - "colourset.cpp", - "maths.cpp", - "rangefit.cpp", - "singlecolourfit.cpp", - "squish.cpp", - ] +if (env['builtin_squish'] != 'no'): + thirdparty_dir = "#thirdparty/squish/" + thirdparty_sources = [ + "alpha.cpp", + "clusterfit.cpp", + "colourblock.cpp", + "colourfit.cpp", + "colourset.cpp", + "maths.cpp", + "rangefit.cpp", + "singlecolourfit.cpp", + "squish.cpp", + ] - thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - env_squish.add_source_files(env.modules_sources, thirdparty_sources) - env_squish.Append(CPPPATH = [thirdparty_dir]) + env_squish.add_source_files(env.modules_sources, thirdparty_sources) + env_squish.Append(CPPPATH=[thirdparty_dir]) # Godot source files env_squish.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/squish/config.py b/modules/squish/config.py index d28d9c702e..cc8f098010 100644 --- a/modules/squish/config.py +++ b/modules/squish/config.py @@ -1,10 +1,11 @@ def can_build(platform): - return True + return True + def configure(env): - # Tools only, disabled for non-tools - # TODO: Find a cleaner way to achieve that - if (env["tools"] == "no"): - env["module_squish_enabled"] = "no" - env.disabled_modules.append("squish") + # Tools only, disabled for non-tools + # TODO: Find a cleaner way to achieve that + if (env["tools"] == "no"): + env["module_squish_enabled"] = "no" + env.disabled_modules.append("squish") diff --git a/modules/theora/SCsub b/modules/theora/SCsub index 22c618fe8b..2de4d29640 100644 --- a/modules/theora/SCsub +++ b/modules/theora/SCsub @@ -6,78 +6,78 @@ Import('env_modules') env_theora = env_modules.Clone() # Thirdparty source files -if (env["libtheora"] != "system"): # builtin - thirdparty_dir = "#thirdparty/libtheora/" - thirdparty_sources = [ - #"analyze.c", - #"apiwrapper.c", - "bitpack.c", - "cpu.c", - #"decapiwrapper.c", - "decinfo.c", - "decode.c", - "dequant.c", - #"encapiwrapper.c", - #"encfrag.c", - #"encinfo.c", - #"encode.c", - #"encoder_disabled.c", - #"enquant.c", - #"fdct.c", - "fragment.c", - "huffdec.c", - #"huffenc.c", - "idct.c", - "info.c", - "internal.c", - #"mathops.c", - #"mcenc.c", - "quant.c", - #"rate.c", - "state.c", - #"tokenize.c", - ] +if (env['builtin_libtheora'] != 'no'): + thirdparty_dir = "#thirdparty/libtheora/" + thirdparty_sources = [ + #"analyze.c", + #"apiwrapper.c", + "bitpack.c", + "cpu.c", + #"decapiwrapper.c", + "decinfo.c", + "decode.c", + "dequant.c", + #"encapiwrapper.c", + #"encfrag.c", + #"encinfo.c", + #"encode.c", + #"encoder_disabled.c", + #"enquant.c", + #"fdct.c", + "fragment.c", + "huffdec.c", + #"huffenc.c", + "idct.c", + "info.c", + "internal.c", + #"mathops.c", + #"mcenc.c", + "quant.c", + #"rate.c", + "state.c", + #"tokenize.c", + ] - thirdparty_sources_x86 = [ - #"x86/mmxencfrag.c", - #"x86/mmxfdct.c", - "x86/mmxfrag.c", - "x86/mmxidct.c", - "x86/mmxstate.c", - #"x86/sse2fdct.c", - #"x86/x86enc.c", - "x86/x86state.c", - ] + thirdparty_sources_x86 = [ + #"x86/mmxencfrag.c", + #"x86/mmxfdct.c", + "x86/mmxfrag.c", + "x86/mmxidct.c", + "x86/mmxstate.c", + #"x86/sse2fdct.c", + #"x86/x86enc.c", + "x86/x86state.c", + ] - thirdparty_sources_x86_vc = [ - #"x86_vc/mmxencfrag.c", - #"x86_vc/mmxfdct.c", - "x86_vc/mmxfrag.c", - "x86_vc/mmxidct.c", - "x86_vc/mmxstate.c", - #"x86_vc/x86enc.c", - "x86_vc/x86state.c", - ] + thirdparty_sources_x86_vc = [ + #"x86_vc/mmxencfrag.c", + #"x86_vc/mmxfdct.c", + "x86_vc/mmxfrag.c", + "x86_vc/mmxidct.c", + "x86_vc/mmxstate.c", + #"x86_vc/x86enc.c", + "x86_vc/x86state.c", + ] - if (env["x86_libtheora_opt_gcc"]): - thirdparty_sources += thirdparty_sources_x86 + if (env["x86_libtheora_opt_gcc"]): + thirdparty_sources += thirdparty_sources_x86 - if (env["x86_libtheora_opt_vc"]): - thirdparty_sources += thirdparty_sources_x86_vc + if (env["x86_libtheora_opt_vc"]): + thirdparty_sources += thirdparty_sources_x86_vc - if (env["x86_libtheora_opt_gcc"] or env["x86_libtheora_opt_vc"]): - env_theora.Append(CCFLAGS = ["-DOC_X86_ASM"]) + if (env["x86_libtheora_opt_gcc"] or env["x86_libtheora_opt_vc"]): + env_theora.Append(CCFLAGS=["-DOC_X86_ASM"]) - thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - env_theora.add_source_files(env.modules_sources, thirdparty_sources) - env_theora.Append(CPPPATH = [thirdparty_dir]) + env_theora.add_source_files(env.modules_sources, thirdparty_sources) + env_theora.Append(CPPPATH=[thirdparty_dir]) - # also requires libogg and libvorbis - if (env["libogg"] != "system"): # builtin - env_theora.Append(CPPPATH = ["#thirdparty/libogg"]) - if (env["libvorbis"] != "system"): # builtin - env_theora.Append(CPPPATH = ["#thirdparty/libvorbis"]) + # also requires libogg and libvorbis + if (env['builtin_libogg'] != 'no'): + env_theora.Append(CPPPATH=["#thirdparty/libogg"]) + if (env['builtin_libvorbis'] != 'no'): + env_theora.Append(CPPPATH=["#thirdparty/libvorbis"]) # Godot source files env_theora.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/theora/config.py b/modules/theora/config.py index 368e97e152..fb920482f5 100644 --- a/modules/theora/config.py +++ b/modules/theora/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/visual_script/config.py b/modules/visual_script/config.py index ea7e83378a..5698a37295 100644 --- a/modules/visual_script/config.py +++ b/modules/visual_script/config.py @@ -1,11 +1,8 @@ def can_build(platform): - return True + return True def configure(env): - pass - - - + pass diff --git a/modules/vorbis/SCsub b/modules/vorbis/SCsub index 3220cb454c..d3e4f7e15a 100644 --- a/modules/vorbis/SCsub +++ b/modules/vorbis/SCsub @@ -6,44 +6,44 @@ Import('env_modules') env_vorbis = env_modules.Clone() # Thirdparty source files -if (env["libvorbis"] != "system"): # builtin - thirdparty_dir = "#thirdparty/libvorbis/" - thirdparty_sources = [ - #"analysis.c", - #"barkmel.c", - "bitrate.c", - "block.c", - "codebook.c", - "envelope.c", - "floor0.c", - "floor1.c", - "info.c", - "lookup.c", - "lpc.c", - "lsp.c", - "mapping0.c", - "mdct.c", - "psy.c", - #"psytune.c", - "registry.c", - "res0.c", - "sharedbook.c", - "smallft.c", - "synthesis.c", - #"tone.c", - #"vorbisenc.c", - "vorbisfile.c", - "window.c", - ] +if (env['builtin_libvorbis'] != 'no'): + thirdparty_dir = "#thirdparty/libvorbis/" + thirdparty_sources = [ + #"analysis.c", + #"barkmel.c", + "bitrate.c", + "block.c", + "codebook.c", + "envelope.c", + "floor0.c", + "floor1.c", + "info.c", + "lookup.c", + "lpc.c", + "lsp.c", + "mapping0.c", + "mdct.c", + "psy.c", + #"psytune.c", + "registry.c", + "res0.c", + "sharedbook.c", + "smallft.c", + "synthesis.c", + #"tone.c", + #"vorbisenc.c", + "vorbisfile.c", + "window.c", + ] - thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - env_vorbis.add_source_files(env.modules_sources, thirdparty_sources) - env_vorbis.Append(CPPPATH = [thirdparty_dir]) + env_vorbis.add_source_files(env.modules_sources, thirdparty_sources) + env_vorbis.Append(CPPPATH=[thirdparty_dir]) - # also requires libogg - if (env["libogg"] != "system"): # builtin - env_vorbis.Append(CPPPATH = ["#thirdparty/libogg"]) + # also requires libogg + if (env['builtin_libogg'] != 'no'): + env_vorbis.Append(CPPPATH=["#thirdparty/libogg"]) # Godot source files env_vorbis.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/vorbis/config.py b/modules/vorbis/config.py index 368e97e152..fb920482f5 100644 --- a/modules/vorbis/config.py +++ b/modules/vorbis/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/webm/SCsub b/modules/webm/SCsub index fbd936a2c3..889f5e83aa 100644 --- a/modules/webm/SCsub +++ b/modules/webm/SCsub @@ -8,27 +8,27 @@ env_webm = env_modules.Clone() # Thirdparty source files thirdparty_libsimplewebm_dir = "#thirdparty/libsimplewebm/" thirdparty_libsimplewebm_sources = [ - "libwebm/mkvparser/mkvparser.cc", - "OpusVorbisDecoder.cpp", - "VPXDecoder.cpp", - "WebMDemuxer.cpp", + "libwebm/mkvparser/mkvparser.cc", + "OpusVorbisDecoder.cpp", + "VPXDecoder.cpp", + "WebMDemuxer.cpp", ] thirdparty_libsimplewebm_sources = [thirdparty_libsimplewebm_dir + file for file in thirdparty_libsimplewebm_sources] env_webm.add_source_files(env.modules_sources, thirdparty_libsimplewebm_sources) -env_webm.Append(CPPPATH = [thirdparty_libsimplewebm_dir, thirdparty_libsimplewebm_dir + "libwebm/"]) +env_webm.Append(CPPPATH=[thirdparty_libsimplewebm_dir, thirdparty_libsimplewebm_dir + "libwebm/"]) # also requires libogg, libvorbis and libopus -if (env["libogg"] != "system"): # builtin - env_webm.Append(CPPPATH = ["#thirdparty/libogg"]) -if (env["libvorbis"] != "system"): # builtin - env_webm.Append(CPPPATH = ["#thirdparty/libvorbis"]) -if (env["opus"] != "system"): # builtin - env_webm.Append(CPPPATH = ["#thirdparty"]) +if (env['builtin_libogg'] != 'no'): + env_webm.Append(CPPPATH=["#thirdparty/libogg"]) +if (env['builtin_libvorbis'] != 'no'): + env_webm.Append(CPPPATH=["#thirdparty/libvorbis"]) +if (env['builtin_opus'] != 'no'): + env_webm.Append(CPPPATH=["#thirdparty/opus"]) -if (env["libvpx"] != "system"): # builtin - Export('env_webm') - SConscript("libvpx/SCsub") +if (env['builtin_libvpx'] != 'no'): + Export('env_webm') + SConscript("libvpx/SCsub") # Godot source files env_webm.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/webm/config.py b/modules/webm/config.py index 368e97e152..fb920482f5 100644 --- a/modules/webm/config.py +++ b/modules/webm/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/webm/libvpx/SCsub b/modules/webm/libvpx/SCsub index 706db97206..a7eca29c05 100644 --- a/modules/webm/libvpx/SCsub +++ b/modules/webm/libvpx/SCsub @@ -3,231 +3,231 @@ libvpx_dir = "#thirdparty/libvpx/" libvpx_sources = [ - "vp8/vp8_dx_iface.c", - - "vp8/common/generic/systemdependent.c", - - "vp8/common/alloccommon.c", - "vp8/common/blockd.c", - "vp8/common/copy_c.c", - "vp8/common/debugmodes.c", - "vp8/common/dequantize.c", - "vp8/common/entropy.c", - "vp8/common/entropymode.c", - "vp8/common/entropymv.c", - "vp8/common/extend.c", - "vp8/common/filter.c", - "vp8/common/findnearmv.c", - "vp8/common/idct_blk.c", - "vp8/common/idctllm.c", - "vp8/common/loopfilter_filters.c", - "vp8/common/mbpitch.c", - "vp8/common/modecont.c", - "vp8/common/quant_common.c", - "vp8/common/reconinter.c", - "vp8/common/reconintra.c", - "vp8/common/reconintra4x4.c", - "vp8/common/rtcd.c", - "vp8/common/setupintrarecon.c", - "vp8/common/swapyv12buffer.c", - "vp8/common/treecoder.c", - "vp8/common/vp8_loopfilter.c", - - "vp8/decoder/dboolhuff.c", - "vp8/decoder/decodeframe.c", - "vp8/decoder/decodemv.c", - "vp8/decoder/detokenize.c", - "vp8/decoder/onyxd_if.c", - "vp8/decoder/threading.c", - - - "vp9/vp9_dx_iface.c", - - "vp9/common/vp9_alloccommon.c", - "vp9/common/vp9_blockd.c", - "vp9/common/vp9_common_data.c", - "vp9/common/vp9_debugmodes.c", - "vp9/common/vp9_entropy.c", - "vp9/common/vp9_entropymode.c", - "vp9/common/vp9_entropymv.c", - "vp9/common/vp9_filter.c", - "vp9/common/vp9_frame_buffers.c", - "vp9/common/vp9_idct.c", - "vp9/common/vp9_loopfilter.c", - "vp9/common/vp9_mvref_common.c", - "vp9/common/vp9_pred_common.c", - "vp9/common/vp9_quant_common.c", - "vp9/common/vp9_reconinter.c", - "vp9/common/vp9_reconintra.c", - "vp9/common/vp9_rtcd.c", - "vp9/common/vp9_scale.c", - "vp9/common/vp9_scan.c", - "vp9/common/vp9_seg_common.c", - "vp9/common/vp9_thread_common.c", - "vp9/common/vp9_tile_common.c", - - "vp9/decoder/vp9_decodeframe.c", - "vp9/decoder/vp9_decodemv.c", - "vp9/decoder/vp9_decoder.c", - "vp9/decoder/vp9_detokenize.c", - "vp9/decoder/vp9_dsubexp.c", - "vp9/decoder/vp9_dthread.c", - - - "vpx/src/vpx_codec.c", - "vpx/src/vpx_decoder.c", - "vpx/src/vpx_image.c", - "vpx/src/vpx_psnr.c", - - - "vpx_dsp/bitreader.c", - "vpx_dsp/bitreader_buffer.c", - "vpx_dsp/intrapred.c", - "vpx_dsp/inv_txfm.c", - "vpx_dsp/loopfilter.c", - "vpx_dsp/prob.c", - "vpx_dsp/vpx_convolve.c", - "vpx_dsp/vpx_dsp_rtcd.c", - - - "vpx_mem/vpx_mem.c", - - - "vpx_scale/vpx_scale_rtcd.c", - - "vpx_scale/generic/yv12config.c", - "vpx_scale/generic/yv12extend.c", - - - "vpx_util/vpx_thread.c" + "vp8/vp8_dx_iface.c", + + "vp8/common/generic/systemdependent.c", + + "vp8/common/alloccommon.c", + "vp8/common/blockd.c", + "vp8/common/copy_c.c", + "vp8/common/debugmodes.c", + "vp8/common/dequantize.c", + "vp8/common/entropy.c", + "vp8/common/entropymode.c", + "vp8/common/entropymv.c", + "vp8/common/extend.c", + "vp8/common/filter.c", + "vp8/common/findnearmv.c", + "vp8/common/idct_blk.c", + "vp8/common/idctllm.c", + "vp8/common/loopfilter_filters.c", + "vp8/common/mbpitch.c", + "vp8/common/modecont.c", + "vp8/common/quant_common.c", + "vp8/common/reconinter.c", + "vp8/common/reconintra.c", + "vp8/common/reconintra4x4.c", + "vp8/common/rtcd.c", + "vp8/common/setupintrarecon.c", + "vp8/common/swapyv12buffer.c", + "vp8/common/treecoder.c", + "vp8/common/vp8_loopfilter.c", + + "vp8/decoder/dboolhuff.c", + "vp8/decoder/decodeframe.c", + "vp8/decoder/decodemv.c", + "vp8/decoder/detokenize.c", + "vp8/decoder/onyxd_if.c", + "vp8/decoder/threading.c", + + + "vp9/vp9_dx_iface.c", + + "vp9/common/vp9_alloccommon.c", + "vp9/common/vp9_blockd.c", + "vp9/common/vp9_common_data.c", + "vp9/common/vp9_debugmodes.c", + "vp9/common/vp9_entropy.c", + "vp9/common/vp9_entropymode.c", + "vp9/common/vp9_entropymv.c", + "vp9/common/vp9_filter.c", + "vp9/common/vp9_frame_buffers.c", + "vp9/common/vp9_idct.c", + "vp9/common/vp9_loopfilter.c", + "vp9/common/vp9_mvref_common.c", + "vp9/common/vp9_pred_common.c", + "vp9/common/vp9_quant_common.c", + "vp9/common/vp9_reconinter.c", + "vp9/common/vp9_reconintra.c", + "vp9/common/vp9_rtcd.c", + "vp9/common/vp9_scale.c", + "vp9/common/vp9_scan.c", + "vp9/common/vp9_seg_common.c", + "vp9/common/vp9_thread_common.c", + "vp9/common/vp9_tile_common.c", + + "vp9/decoder/vp9_decodeframe.c", + "vp9/decoder/vp9_decodemv.c", + "vp9/decoder/vp9_decoder.c", + "vp9/decoder/vp9_detokenize.c", + "vp9/decoder/vp9_dsubexp.c", + "vp9/decoder/vp9_dthread.c", + + + "vpx/src/vpx_codec.c", + "vpx/src/vpx_decoder.c", + "vpx/src/vpx_image.c", + "vpx/src/vpx_psnr.c", + + + "vpx_dsp/bitreader.c", + "vpx_dsp/bitreader_buffer.c", + "vpx_dsp/intrapred.c", + "vpx_dsp/inv_txfm.c", + "vpx_dsp/loopfilter.c", + "vpx_dsp/prob.c", + "vpx_dsp/vpx_convolve.c", + "vpx_dsp/vpx_dsp_rtcd.c", + + + "vpx_mem/vpx_mem.c", + + + "vpx_scale/vpx_scale_rtcd.c", + + "vpx_scale/generic/yv12config.c", + "vpx_scale/generic/yv12extend.c", + + + "vpx_util/vpx_thread.c" ] libvpx_sources_intrin_x86 = [ - "vp8/common/x86/filter_x86.c", - "vp8/common/x86/loopfilter_x86.c", - "vp8/common/x86/vp8_asm_stubs.c", + "vp8/common/x86/filter_x86.c", + "vp8/common/x86/loopfilter_x86.c", + "vp8/common/x86/vp8_asm_stubs.c", - "vpx_dsp/x86/vpx_asm_stubs.c" + "vpx_dsp/x86/vpx_asm_stubs.c" ] libvpx_sources_intrin_x86_mmx = [ - "vp8/common/x86/idct_blk_mmx.c", + "vp8/common/x86/idct_blk_mmx.c", ] libvpx_sources_intrin_x86_sse2 = [ - "vp8/common/x86/idct_blk_sse2.c", + "vp8/common/x86/idct_blk_sse2.c", - "vp9/common/x86/vp9_idct_intrin_sse2.c", + "vp9/common/x86/vp9_idct_intrin_sse2.c", - "vpx_dsp/x86/inv_txfm_sse2.c", - "vpx_dsp/x86/loopfilter_sse2.c", + "vpx_dsp/x86/inv_txfm_sse2.c", + "vpx_dsp/x86/loopfilter_sse2.c", ] libvpx_sources_intrin_x86_ssse3 = [ - "vpx_dsp/x86/vpx_subpixel_8t_intrin_ssse3.c" + "vpx_dsp/x86/vpx_subpixel_8t_intrin_ssse3.c" ] libvpx_sources_intrin_x86_avx2 = [ - "vpx_dsp/x86/loopfilter_avx2.c", - "vpx_dsp/x86/vpx_subpixel_8t_intrin_avx2.c" + "vpx_dsp/x86/loopfilter_avx2.c", + "vpx_dsp/x86/vpx_subpixel_8t_intrin_avx2.c" ] libvpx_sources_x86asm = [ - "vp8/common/x86/copy_sse2.asm", - "vp8/common/x86/copy_sse3.asm", - "vp8/common/x86/dequantize_mmx.asm", - "vp8/common/x86/idctllm_mmx.asm", - "vp8/common/x86/idctllm_sse2.asm", - "vp8/common/x86/iwalsh_mmx.asm", - "vp8/common/x86/iwalsh_sse2.asm", - "vp8/common/x86/loopfilter_sse2.asm", - "vp8/common/x86/recon_mmx.asm", - "vp8/common/x86/recon_sse2.asm", - "vp8/common/x86/subpixel_mmx.asm", - "vp8/common/x86/subpixel_sse2.asm", - "vp8/common/x86/subpixel_ssse3.asm", - "vp8/common/x86/vp8_loopfilter_mmx.asm", - - - "vpx_dsp/x86/intrapred_sse2.asm", - "vpx_dsp/x86/intrapred_ssse3.asm", - "vpx_dsp/x86/inv_wht_sse2.asm", - "vpx_dsp/x86/vpx_convolve_copy_sse2.asm", - "vpx_dsp/x86/vpx_subpixel_8t_sse2.asm", - "vpx_dsp/x86/vpx_subpixel_8t_ssse3.asm", - "vpx_dsp/x86/vpx_subpixel_bilinear_sse2.asm", - "vpx_dsp/x86/vpx_subpixel_bilinear_ssse3.asm", - - - "vpx_ports/emms.asm" + "vp8/common/x86/copy_sse2.asm", + "vp8/common/x86/copy_sse3.asm", + "vp8/common/x86/dequantize_mmx.asm", + "vp8/common/x86/idctllm_mmx.asm", + "vp8/common/x86/idctllm_sse2.asm", + "vp8/common/x86/iwalsh_mmx.asm", + "vp8/common/x86/iwalsh_sse2.asm", + "vp8/common/x86/loopfilter_sse2.asm", + "vp8/common/x86/recon_mmx.asm", + "vp8/common/x86/recon_sse2.asm", + "vp8/common/x86/subpixel_mmx.asm", + "vp8/common/x86/subpixel_sse2.asm", + "vp8/common/x86/subpixel_ssse3.asm", + "vp8/common/x86/vp8_loopfilter_mmx.asm", + + + "vpx_dsp/x86/intrapred_sse2.asm", + "vpx_dsp/x86/intrapred_ssse3.asm", + "vpx_dsp/x86/inv_wht_sse2.asm", + "vpx_dsp/x86/vpx_convolve_copy_sse2.asm", + "vpx_dsp/x86/vpx_subpixel_8t_sse2.asm", + "vpx_dsp/x86/vpx_subpixel_8t_ssse3.asm", + "vpx_dsp/x86/vpx_subpixel_bilinear_sse2.asm", + "vpx_dsp/x86/vpx_subpixel_bilinear_ssse3.asm", + + + "vpx_ports/emms.asm" ] libvpx_sources_x86_64asm = [ - "vp8/common/x86/loopfilter_block_sse2_x86_64.asm", + "vp8/common/x86/loopfilter_block_sse2_x86_64.asm", - "vpx_dsp/x86/inv_txfm_ssse3_x86_64.asm" + "vpx_dsp/x86/inv_txfm_ssse3_x86_64.asm" ] libvpx_sources_arm = [ - "vpx_ports/arm_cpudetect.c", + "vpx_ports/arm_cpudetect.c", - "vp8/common/arm/loopfilter_arm.c", + "vp8/common/arm/loopfilter_arm.c", ] libvpx_sources_arm_neon = [ - "vp8/common/arm/neon/bilinearpredict_neon.c", - "vp8/common/arm/neon/copymem_neon.c", - "vp8/common/arm/neon/dc_only_idct_add_neon.c", - "vp8/common/arm/neon/dequant_idct_neon.c", - "vp8/common/arm/neon/dequantizeb_neon.c", - "vp8/common/arm/neon/idct_blk_neon.c", - "vp8/common/arm/neon/idct_dequant_0_2x_neon.c", - "vp8/common/arm/neon/idct_dequant_full_2x_neon.c", - "vp8/common/arm/neon/iwalsh_neon.c", - "vp8/common/arm/neon/loopfiltersimplehorizontaledge_neon.c", - "vp8/common/arm/neon/loopfiltersimpleverticaledge_neon.c", - "vp8/common/arm/neon/mbloopfilter_neon.c", - "vp8/common/arm/neon/shortidct4x4llm_neon.c", - "vp8/common/arm/neon/sixtappredict_neon.c", - "vp8/common/arm/neon/vp8_loopfilter_neon.c", - - - "vp9/common/arm/neon/vp9_iht4x4_add_neon.c", - "vp9/common/arm/neon/vp9_iht8x8_add_neon.c", - - - "vpx_dsp/arm/idct16x16_1_add_neon.c", - "vpx_dsp/arm/idct16x16_add_neon.c", - "vpx_dsp/arm/idct16x16_neon.c", - "vpx_dsp/arm/idct32x32_1_add_neon.c", - "vpx_dsp/arm/idct32x32_add_neon.c", - "vpx_dsp/arm/idct4x4_1_add_neon.c", - "vpx_dsp/arm/idct4x4_add_neon.c", - "vpx_dsp/arm/idct8x8_1_add_neon.c", - "vpx_dsp/arm/idct8x8_add_neon.c", - "vpx_dsp/arm/intrapred_neon.c", - "vpx_dsp/arm/loopfilter_16_neon.c", - "vpx_dsp/arm/loopfilter_4_neon.c", - "vpx_dsp/arm/loopfilter_8_neon.c", - "vpx_dsp/arm/loopfilter_neon.c", - "vpx_dsp/arm/vpx_convolve8_avg_neon.c", - "vpx_dsp/arm/vpx_convolve8_neon.c", - "vpx_dsp/arm/vpx_convolve_avg_neon.c", - "vpx_dsp/arm/vpx_convolve_copy_neon.c", - "vpx_dsp/arm/vpx_convolve_neon.c" + "vp8/common/arm/neon/bilinearpredict_neon.c", + "vp8/common/arm/neon/copymem_neon.c", + "vp8/common/arm/neon/dc_only_idct_add_neon.c", + "vp8/common/arm/neon/dequant_idct_neon.c", + "vp8/common/arm/neon/dequantizeb_neon.c", + "vp8/common/arm/neon/idct_blk_neon.c", + "vp8/common/arm/neon/idct_dequant_0_2x_neon.c", + "vp8/common/arm/neon/idct_dequant_full_2x_neon.c", + "vp8/common/arm/neon/iwalsh_neon.c", + "vp8/common/arm/neon/loopfiltersimplehorizontaledge_neon.c", + "vp8/common/arm/neon/loopfiltersimpleverticaledge_neon.c", + "vp8/common/arm/neon/mbloopfilter_neon.c", + "vp8/common/arm/neon/shortidct4x4llm_neon.c", + "vp8/common/arm/neon/sixtappredict_neon.c", + "vp8/common/arm/neon/vp8_loopfilter_neon.c", + + + "vp9/common/arm/neon/vp9_iht4x4_add_neon.c", + "vp9/common/arm/neon/vp9_iht8x8_add_neon.c", + + + "vpx_dsp/arm/idct16x16_1_add_neon.c", + "vpx_dsp/arm/idct16x16_add_neon.c", + "vpx_dsp/arm/idct16x16_neon.c", + "vpx_dsp/arm/idct32x32_1_add_neon.c", + "vpx_dsp/arm/idct32x32_add_neon.c", + "vpx_dsp/arm/idct4x4_1_add_neon.c", + "vpx_dsp/arm/idct4x4_add_neon.c", + "vpx_dsp/arm/idct8x8_1_add_neon.c", + "vpx_dsp/arm/idct8x8_add_neon.c", + "vpx_dsp/arm/intrapred_neon.c", + "vpx_dsp/arm/loopfilter_16_neon.c", + "vpx_dsp/arm/loopfilter_4_neon.c", + "vpx_dsp/arm/loopfilter_8_neon.c", + "vpx_dsp/arm/loopfilter_neon.c", + "vpx_dsp/arm/vpx_convolve8_avg_neon.c", + "vpx_dsp/arm/vpx_convolve8_neon.c", + "vpx_dsp/arm/vpx_convolve_avg_neon.c", + "vpx_dsp/arm/vpx_convolve_copy_neon.c", + "vpx_dsp/arm/vpx_convolve_neon.c" ] libvpx_sources_arm_neon_gas = [ - "vpx_dsp/arm/gas/intrapred_neon_asm.s", - "vpx_dsp/arm/gas/loopfilter_mb_neon.s", - "vpx_dsp/arm/gas/save_reg_neon.s" + "vpx_dsp/arm/gas/intrapred_neon_asm.s", + "vpx_dsp/arm/gas/loopfilter_mb_neon.s", + "vpx_dsp/arm/gas/save_reg_neon.s" ] libvpx_sources_arm_neon_armasm_ms = [ - "vpx_dsp/arm/armasm_ms/intrapred_neon_asm.asm", - "vpx_dsp/arm/armasm_ms/loopfilter_mb_neon.asm", - "vpx_dsp/arm/armasm_ms/save_reg_neon.asm" + "vpx_dsp/arm/armasm_ms/intrapred_neon_asm.asm", + "vpx_dsp/arm/armasm_ms/loopfilter_mb_neon.asm", + "vpx_dsp/arm/armasm_ms/save_reg_neon.asm" ] libvpx_sources_arm_neon_gas_apple = [ - "vpx_dsp/arm/gas_apple/intrapred_neon_asm.s", - "vpx_dsp/arm/gas_apple/loopfilter_mb_neon.s", - "vpx_dsp/arm/gas_apple/save_reg_neon.s" + "vpx_dsp/arm/gas_apple/intrapred_neon_asm.s", + "vpx_dsp/arm/gas_apple/loopfilter_mb_neon.s", + "vpx_dsp/arm/gas_apple/save_reg_neon.s" ] libvpx_sources = [libvpx_dir + file for file in libvpx_sources] @@ -248,143 +248,143 @@ libvpx_sources_arm_neon_gas_apple = [libvpx_dir + file for file in libvpx_source Import('env') Import('env_webm') -env_webm.Append(CPPPATH = [libvpx_dir]) +env_webm.Append(CPPPATH=[libvpx_dir]) env_libvpx = env.Clone() -env_libvpx.Append(CPPPATH = [libvpx_dir]) +env_libvpx.Append(CPPPATH=[libvpx_dir]) cpu_bits = env["bits"] osx_fat = (env["platform"] == 'osx' and cpu_bits == 'fat') webm_cpu_x86 = False webm_cpu_arm = False if env["platform"] == 'winrt': - if 'arm' in env["PROGSUFFIX"]: - webm_cpu_arm = True - else: - webm_cpu_x86 = True + if 'arm' in env["PROGSUFFIX"]: + webm_cpu_arm = True + else: + webm_cpu_x86 = True else: - is_android_x86 = (env["platform"] == 'android' and env["android_arch"] == 'x86') - if is_android_x86: - cpu_bits = '32' - if osx_fat: - webm_cpu_x86 = True - else: - webm_cpu_x86 = (cpu_bits == '32' or cpu_bits == '64') and (env["platform"] == 'windows' or env["platform"] == 'x11' or env["platform"] == 'osx' or env["platform"] == 'haiku' or is_android_x86) - webm_cpu_arm = env["platform"] == 'iphone' or env["platform"] == 'bb10' or (env["platform"] == 'android' and env["android_arch"] != 'x86') + is_android_x86 = (env["platform"] == 'android' and env["android_arch"] == 'x86') + if is_android_x86: + cpu_bits = '32' + if osx_fat: + webm_cpu_x86 = True + else: + webm_cpu_x86 = (cpu_bits == '32' or cpu_bits == '64') and (env["platform"] == 'windows' or env["platform"] == 'x11' or env["platform"] == 'osx' or env["platform"] == 'haiku' or is_android_x86) + webm_cpu_arm = env["platform"] == 'iphone' or env["platform"] == 'bb10' or (env["platform"] == 'android' and env["android_arch"] != 'x86') if webm_cpu_x86: - import subprocess - import os - - yasm_paths = [ - "yasm", - "../../../yasm", - ] - - yasm_found = False - - devnull = open(os.devnull) - for yasm_path in yasm_paths: - try: - yasm_found = True - subprocess.Popen([yasm_path, "--version"], stdout=devnull, stderr=devnull).communicate() - except: - yasm_found = False - if yasm_found: - break - - if not yasm_found: - webm_cpu_x86 = False - print "YASM is necessary for WebM SIMD optimizations." + import subprocess + import os + + yasm_paths = [ + "yasm", + "../../../yasm", + ] + + yasm_found = False + + devnull = open(os.devnull) + for yasm_path in yasm_paths: + try: + yasm_found = True + subprocess.Popen([yasm_path, "--version"], stdout=devnull, stderr=devnull).communicate() + except: + yasm_found = False + if yasm_found: + break + + if not yasm_found: + webm_cpu_x86 = False + print "YASM is necessary for WebM SIMD optimizations." webm_simd_optimizations = False if webm_cpu_x86: - if osx_fat: - #'osx' platform only: run python script which will compile using 'yasm' command and then merge 32-bit and 64-bit using 'lipo' command - env_libvpx["AS"] = 'python modules/webm/libvpx/yasm_osx_fat.py' - env_libvpx["ASFLAGS"] = '-I' + libvpx_dir[1:] - env_libvpx["ASCOM"] = '$AS $ASFLAGS $TARGET $SOURCES' - else: - if env["platform"] == 'windows' or env["platform"] == 'winrt': - env_libvpx["ASFORMAT"] = 'win' - elif env["platform"] == 'osx': - env_libvpx["ASFORMAT"] = 'macho' - else: - env_libvpx["ASFORMAT"] = 'elf' - env_libvpx["ASFORMAT"] += cpu_bits - - env_libvpx["AS"] = 'yasm' - env_libvpx["ASFLAGS"] = '-I' + libvpx_dir[1:] + ' -f $ASFORMAT -D $ASCPU' - env_libvpx["ASCOM"] = '$AS $ASFLAGS -o $TARGET $SOURCES' - - if cpu_bits == '32': - env_libvpx["ASCPU"] = 'X86_32' - elif cpu_bits == '64': - env_libvpx["ASCPU"] = 'X86_64' - - env_libvpx.Append(CCFLAGS=['-DWEBM_X86ASM']) - - webm_simd_optimizations = True + if osx_fat: + #'osx' platform only: run python script which will compile using 'yasm' command and then merge 32-bit and 64-bit using 'lipo' command + env_libvpx["AS"] = 'python modules/webm/libvpx/yasm_osx_fat.py' + env_libvpx["ASFLAGS"] = '-I' + libvpx_dir[1:] + env_libvpx["ASCOM"] = '$AS $ASFLAGS $TARGET $SOURCES' + else: + if env["platform"] == 'windows' or env["platform"] == 'winrt': + env_libvpx["ASFORMAT"] = 'win' + elif env["platform"] == 'osx': + env_libvpx["ASFORMAT"] = 'macho' + else: + env_libvpx["ASFORMAT"] = 'elf' + env_libvpx["ASFORMAT"] += cpu_bits + + env_libvpx["AS"] = 'yasm' + env_libvpx["ASFLAGS"] = '-I' + libvpx_dir[1:] + ' -f $ASFORMAT -D $ASCPU' + env_libvpx["ASCOM"] = '$AS $ASFLAGS -o $TARGET $SOURCES' + + if cpu_bits == '32': + env_libvpx["ASCPU"] = 'X86_32' + elif cpu_bits == '64': + env_libvpx["ASCPU"] = 'X86_64' + + env_libvpx.Append(CCFLAGS=['-DWEBM_X86ASM']) + + webm_simd_optimizations = True if webm_cpu_arm: - if env["platform"] == 'iphone': - env_libvpx["ASFLAGS"] = '-arch armv7' - elif env["platform"] == 'android': - env_libvpx["ASFLAGS"] = '-mfpu=neon' - elif env["platform"] == 'winrt': - env_libvpx["AS"] = 'armasm' - env_libvpx["ASFLAGS"] = '' - env_libvpx["ASCOM"] = '$AS $ASFLAGS -o $TARGET $SOURCES' + if env["platform"] == 'iphone': + env_libvpx["ASFLAGS"] = '-arch armv7' + elif env["platform"] == 'android': + env_libvpx["ASFLAGS"] = '-mfpu=neon' + elif env["platform"] == 'winrt': + env_libvpx["AS"] = 'armasm' + env_libvpx["ASFLAGS"] = '' + env_libvpx["ASCOM"] = '$AS $ASFLAGS -o $TARGET $SOURCES' - env_libvpx.Append(CCFLAGS=['-DWEBM_ARMASM']) + env_libvpx.Append(CCFLAGS=['-DWEBM_ARMASM']) - webm_simd_optimizations = True + webm_simd_optimizations = True if webm_simd_optimizations == False: - print "WebM SIMD optimizations are disabled. Check if your CPU architecture, CPU bits or platform are supported!" + print "WebM SIMD optimizations are disabled. Check if your CPU architecture, CPU bits or platform are supported!" env_libvpx.add_source_files(env.modules_sources, libvpx_sources) if webm_cpu_x86: - is_clang_or_gcc = ('gcc' in env["CC"]) or ('clang' in env["CC"]) + is_clang_or_gcc = ('gcc' in env["CC"]) or ('clang' in env["CC"]) - env_libvpx_mmx = env_libvpx.Clone() - if cpu_bits == '32' and is_clang_or_gcc: - env_libvpx_mmx.Append(CCFLAGS=['-mmmx']) - env_libvpx_mmx.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_mmx) + env_libvpx_mmx = env_libvpx.Clone() + if cpu_bits == '32' and is_clang_or_gcc: + env_libvpx_mmx.Append(CCFLAGS=['-mmmx']) + env_libvpx_mmx.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_mmx) - env_libvpx_sse2 = env_libvpx.Clone() - if cpu_bits == '32' and is_clang_or_gcc: - env_libvpx_sse2.Append(CCFLAGS=['-msse2']) - env_libvpx_sse2.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_sse2) + env_libvpx_sse2 = env_libvpx.Clone() + if cpu_bits == '32' and is_clang_or_gcc: + env_libvpx_sse2.Append(CCFLAGS=['-msse2']) + env_libvpx_sse2.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_sse2) - env_libvpx_ssse3 = env_libvpx.Clone() - if is_clang_or_gcc: - env_libvpx_ssse3.Append(CCFLAGS=['-mssse3']) - env_libvpx_ssse3.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_ssse3) + env_libvpx_ssse3 = env_libvpx.Clone() + if is_clang_or_gcc: + env_libvpx_ssse3.Append(CCFLAGS=['-mssse3']) + env_libvpx_ssse3.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_ssse3) - env_libvpx_avx2 = env_libvpx.Clone() - if is_clang_or_gcc: - env_libvpx_avx2.Append(CCFLAGS=['-mavx2']) - env_libvpx_avx2.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_avx2) + env_libvpx_avx2 = env_libvpx.Clone() + if is_clang_or_gcc: + env_libvpx_avx2.Append(CCFLAGS=['-mavx2']) + env_libvpx_avx2.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_avx2) - env_libvpx.add_source_files(env.modules_sources, libvpx_sources_intrin_x86) + env_libvpx.add_source_files(env.modules_sources, libvpx_sources_intrin_x86) - env_libvpx.add_source_files(env.modules_sources, libvpx_sources_x86asm) - if cpu_bits == '64' or osx_fat: - env_libvpx.add_source_files(env.modules_sources, libvpx_sources_x86_64asm) + env_libvpx.add_source_files(env.modules_sources, libvpx_sources_x86asm) + if cpu_bits == '64' or osx_fat: + env_libvpx.add_source_files(env.modules_sources, libvpx_sources_x86_64asm) elif webm_cpu_arm: - env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm) - - env_libvpx_neon = env_libvpx.Clone() - if env["platform"] == 'android' and env["android_arch"] == 'armv6': - env_libvpx_neon.Append(CCFLAGS=['-mfpu=neon']) - env_libvpx_neon.add_source_files(env.modules_sources, libvpx_sources_arm_neon) - - if env["platform"] == 'winrt': - env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_armasm_ms) - elif env["platform"] == 'iphone': - env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_gas_apple) - else: - env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_gas) + env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm) + + env_libvpx_neon = env_libvpx.Clone() + if env["platform"] == 'android' and env["android_arch"] == 'armv6': + env_libvpx_neon.Append(CCFLAGS=['-mfpu=neon']) + env_libvpx_neon.add_source_files(env.modules_sources, libvpx_sources_arm_neon) + + if env["platform"] == 'winrt': + env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_armasm_ms) + elif env["platform"] == 'iphone': + env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_gas_apple) + else: + env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_gas) diff --git a/modules/webm/libvpx/yasm_osx_fat.py b/modules/webm/libvpx/yasm_osx_fat.py index bcee50b389..0065e2766c 100644 --- a/modules/webm/libvpx/yasm_osx_fat.py +++ b/modules/webm/libvpx/yasm_osx_fat.py @@ -3,9 +3,9 @@ import sys import os -includes = sys.argv[1] +includes = sys.argv[1] output_file = sys.argv[2] -input_file = sys.argv[3] +input_file = sys.argv[3] can_remove = {} @@ -14,25 +14,25 @@ lipo_command = '' exit_code = 1 for arch in ['32', '64']: - if arch == '32' and input_file.endswith('x86_64.asm'): - can_remove[arch] = False - else: - command = 'yasm ' + includes + ' -f macho' + arch + ' -D X86_' + arch + ' -o ' + output_file + '.' + arch + ' ' + input_file - print(command) - if os.system(command) == 0: - lipo_command += output_file + '.' + arch + ' ' - can_remove[arch] = True - else: - can_remove[arch] = False + if arch == '32' and input_file.endswith('x86_64.asm'): + can_remove[arch] = False + else: + command = 'yasm ' + includes + ' -f macho' + arch + ' -D X86_' + arch + ' -o ' + output_file + '.' + arch + ' ' + input_file + print(command) + if os.system(command) == 0: + lipo_command += output_file + '.' + arch + ' ' + can_remove[arch] = True + else: + can_remove[arch] = False if lipo_command != '': - lipo_command = 'lipo -create ' + lipo_command + '-output ' + output_file - print(lipo_command) - if os.system(lipo_command) == 0: - exit_code = 0 + lipo_command = 'lipo -create ' + lipo_command + '-output ' + output_file + print(lipo_command) + if os.system(lipo_command) == 0: + exit_code = 0 for arch in ['32', '64']: - if can_remove[arch]: - os.remove(output_file + '.' + arch) + if can_remove[arch]: + os.remove(output_file + '.' + arch) sys.exit(exit_code) diff --git a/modules/webp/SCsub b/modules/webp/SCsub index 38585a1ff2..92f34c4da1 100644 --- a/modules/webp/SCsub +++ b/modules/webp/SCsub @@ -6,116 +6,116 @@ Import('env_modules') env_webp = env_modules.Clone() # Thirdparty source files -if (env["libwebp"] != "system"): # builtin - thirdparty_dir = "#thirdparty/libwebp/" - thirdparty_sources = [ - "enc/webpenc.c", - "enc/near_lossless.c", - "enc/frame.c", - "enc/alpha.c", - "enc/picture_csp.c", - "enc/vp8l.c", - "enc/picture_psnr.c", - "enc/delta_palettization.c", - "enc/syntax.c", - "enc/backward_references.c", - "enc/token.c", - "enc/analysis.c", - "enc/iterator.c", - "enc/picture_tools.c", - "enc/picture_rescale.c", - "enc/config.c", - "enc/tree.c", - "enc/cost.c", - "enc/picture.c", - "enc/quant.c", - "enc/filter.c", - "enc/histogram.c", - "utils/rescaler.c", - "utils/filters.c", - "utils/quant_levels_dec.c", - "utils/huffman.c", - "utils/thread.c", - "utils/quant_levels.c", - "utils/bit_writer.c", - "utils/bit_reader.c", - "utils/random.c", - "utils/utils.c", - "utils/huffman_encode.c", - "utils/color_cache.c", - "mux/muxinternal.c", - "mux/muxread.c", - "mux/anim_encode.c", - "mux/muxedit.c", - "dec/webp.c", - "dec/frame.c", - "dec/alpha.c", - "dec/vp8l.c", - "dec/io.c", - "dec/vp8.c", - "dec/idec.c", - "dec/tree.c", - "dec/buffer.c", - "dec/quant.c", - "demux/demux.c", - "demux/anim_decode.c", - "dsp/yuv.c", - "dsp/filters_sse2.c", - "dsp/dec_sse41.c", - "dsp/rescaler.c", - "dsp/lossless_sse2.c", - "dsp/alpha_processing_sse41.c", - "dsp/alpha_processing_sse2.c", - "dsp/filters.c", - "dsp/upsampling_mips_dsp_r2.c", - "dsp/dec_neon.c", - "dsp/enc_neon.c", - "dsp/lossless_enc_mips32.c", - "dsp/lossless_enc_sse2.c", - "dsp/upsampling.c", - "dsp/lossless_enc_neon.c", - "dsp/alpha_processing.c", - "dsp/cost_sse2.c", - "dsp/dec_mips32.c", - "dsp/enc_avx2.c", - "dsp/rescaler_mips32.c", - "dsp/enc.c", - "dsp/lossless_enc_sse41.c", - "dsp/cost_mips32.c", - "dsp/lossless_mips_dsp_r2.c", - "dsp/filters_mips_dsp_r2.c", - "dsp/upsampling_neon.c", - "dsp/alpha_processing_mips_dsp_r2.c", - "dsp/enc_mips_dsp_r2.c", - "dsp/lossless.c", - "dsp/yuv_mips_dsp_r2.c", - "dsp/cost_mips_dsp_r2.c", - "dsp/argb.c", - "dsp/dec_sse2.c", - "dsp/rescaler_sse2.c", - "dsp/enc_sse41.c", - "dsp/argb_mips_dsp_r2.c", - "dsp/lossless_enc_mips_dsp_r2.c", - "dsp/dec_clip_tables.c", - "dsp/yuv_mips32.c", - "dsp/cpu.c", - "dsp/dec.c", - "dsp/argb_sse2.c", - "dsp/lossless_neon.c", - "dsp/lossless_enc.c", - "dsp/enc_mips32.c", - "dsp/cost.c", - "dsp/rescaler_mips_dsp_r2.c", - "dsp/dec_mips_dsp_r2.c", - "dsp/rescaler_neon.c", - "dsp/yuv_sse2.c", - "dsp/enc_sse2.c", - "dsp/upsampling_sse2.c", - ] - thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] +if (env['builtin_libwebp'] != 'no'): + thirdparty_dir = "#thirdparty/libwebp/" + thirdparty_sources = [ + "enc/webpenc.c", + "enc/near_lossless.c", + "enc/frame.c", + "enc/alpha.c", + "enc/picture_csp.c", + "enc/vp8l.c", + "enc/picture_psnr.c", + "enc/delta_palettization.c", + "enc/syntax.c", + "enc/backward_references.c", + "enc/token.c", + "enc/analysis.c", + "enc/iterator.c", + "enc/picture_tools.c", + "enc/picture_rescale.c", + "enc/config.c", + "enc/tree.c", + "enc/cost.c", + "enc/picture.c", + "enc/quant.c", + "enc/filter.c", + "enc/histogram.c", + "utils/rescaler.c", + "utils/filters.c", + "utils/quant_levels_dec.c", + "utils/huffman.c", + "utils/thread.c", + "utils/quant_levels.c", + "utils/bit_writer.c", + "utils/bit_reader.c", + "utils/random.c", + "utils/utils.c", + "utils/huffman_encode.c", + "utils/color_cache.c", + "mux/muxinternal.c", + "mux/muxread.c", + "mux/anim_encode.c", + "mux/muxedit.c", + "dec/webp.c", + "dec/frame.c", + "dec/alpha.c", + "dec/vp8l.c", + "dec/io.c", + "dec/vp8.c", + "dec/idec.c", + "dec/tree.c", + "dec/buffer.c", + "dec/quant.c", + "demux/demux.c", + "demux/anim_decode.c", + "dsp/yuv.c", + "dsp/filters_sse2.c", + "dsp/dec_sse41.c", + "dsp/rescaler.c", + "dsp/lossless_sse2.c", + "dsp/alpha_processing_sse41.c", + "dsp/alpha_processing_sse2.c", + "dsp/filters.c", + "dsp/upsampling_mips_dsp_r2.c", + "dsp/dec_neon.c", + "dsp/enc_neon.c", + "dsp/lossless_enc_mips32.c", + "dsp/lossless_enc_sse2.c", + "dsp/upsampling.c", + "dsp/lossless_enc_neon.c", + "dsp/alpha_processing.c", + "dsp/cost_sse2.c", + "dsp/dec_mips32.c", + "dsp/enc_avx2.c", + "dsp/rescaler_mips32.c", + "dsp/enc.c", + "dsp/lossless_enc_sse41.c", + "dsp/cost_mips32.c", + "dsp/lossless_mips_dsp_r2.c", + "dsp/filters_mips_dsp_r2.c", + "dsp/upsampling_neon.c", + "dsp/alpha_processing_mips_dsp_r2.c", + "dsp/enc_mips_dsp_r2.c", + "dsp/lossless.c", + "dsp/yuv_mips_dsp_r2.c", + "dsp/cost_mips_dsp_r2.c", + "dsp/argb.c", + "dsp/dec_sse2.c", + "dsp/rescaler_sse2.c", + "dsp/enc_sse41.c", + "dsp/argb_mips_dsp_r2.c", + "dsp/lossless_enc_mips_dsp_r2.c", + "dsp/dec_clip_tables.c", + "dsp/yuv_mips32.c", + "dsp/cpu.c", + "dsp/dec.c", + "dsp/argb_sse2.c", + "dsp/lossless_neon.c", + "dsp/lossless_enc.c", + "dsp/enc_mips32.c", + "dsp/cost.c", + "dsp/rescaler_mips_dsp_r2.c", + "dsp/dec_mips_dsp_r2.c", + "dsp/rescaler_neon.c", + "dsp/yuv_sse2.c", + "dsp/enc_sse2.c", + "dsp/upsampling_sse2.c", + ] + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - env_webp.add_source_files(env.modules_sources, thirdparty_sources) - env_webp.Append(CPPPATH = [thirdparty_dir]) + env_webp.add_source_files(env.modules_sources, thirdparty_sources) + env_webp.Append(CPPPATH=[thirdparty_dir]) # Godot source files env_webp.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/webp/config.py b/modules/webp/config.py index 368e97e152..fb920482f5 100644 --- a/modules/webp/config.py +++ b/modules/webp/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True + return True + def configure(env): - pass + pass 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/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 59e5aa175d..5d5cd1590a 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -3,35 +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" ] 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=["--shell-file",'"platform/javascript/godot_shell.html"']) +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"']) -build = env.Program('#bin/godot',javascript_objects,PROGSUFFIX=env["PROGSUFFIX"]+".html") +build = env.Program('#bin/godot', javascript_objects, PROGSUFFIX=env["PROGSUFFIX"] + ".html") 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) + 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.AddPostAction(build, Action(make_html_shell, "Creating HTML shell file")) diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index b6a6a453b3..9bc204a94a 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -2,104 +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 [ - ['wasm','Compile to WebAssembly','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['ENV'] = os.environ + env.use_windows_spawn_fix('javascript') - env.Append(CPPPATH=['#platform/javascript']) + env.Append(CPPPATH=['#platform/javascript']) - em_path=os.environ["EMSCRIPTEN_ROOT"] + em_path = os.environ["EMSCRIPTEN_ROOT"] - 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['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','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['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['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['javascript_eval'] == 'yes': - env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED']) + if env['javascript_eval'] == 'yes': + env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED']) - 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/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/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/winrt/SCsub b/platform/winrt/SCsub index 91a179084d..5259e7dc22 100644 --- a/platform/winrt/SCsub +++ b/platform/winrt/SCsub @@ -3,21 +3,21 @@ 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', + '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)) + 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]) + env.Depends(prog, [cmd]) diff --git a/platform/winrt/detect.py b/platform/winrt/detect.py index a7bc62f685..6a1a06d8ab 100644 --- a/platform/winrt/detect.py +++ b/platform/winrt/detect.py @@ -6,161 +6,161 @@ import methods def is_active(): - return True + return True + def get_name(): - return "WinRT" + return "WinRT" + def can_build(): - if (os.name=="nt"): - #building natively on windows! - if (os.getenv("VSINSTALLDIR")): + if (os.name == "nt"): + # building natively on windows! + if (os.getenv("VSINSTALLDIR")): + + if (os.getenv("ANGLE_SRC_PATH") == None): + return False - if (os.getenv("ANGLE_SRC_PATH") == None): - return False + return True + return False - return True - return False def get_opts(): - return [] + return [] + def get_flags(): - return [ - ('tools', 'no'), - ('builtin_zlib', 'yes'), - ('openssl', 'builtin'), - ('xaudio2', 'yes'), - ] + 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=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(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() - if os.path.isfile(str(os.getenv("ANGLE_SRC_PATH")) + "/winrt/10/src/angle.sln"): - env["build_angle"] = True + arch = "" + env['ENV'] = os.environ - if os.getenv('Platform') == "ARM": + # 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=" - print "Compiled program architecture will be an ARM executable. (forcing bits=32)." + if os.path.isfile(str(os.getenv("ANGLE_SRC_PATH")) + "/winrt/10/src/angle.sln"): + env["build_angle"] = True - arch="arm" - env["bits"]="32" - env.Append(LINKFLAGS=['/MACHINE:ARM']) - env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/arm']) + if os.getenv('Platform') == "ARM": - angle_build_cmd += "ARM" + print "Compiled program architecture will be an ARM executable. (forcing bits=32)." - env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_ARM/lib']) + arch = "arm" + env["bits"] = "32" + env.Append(LINKFLAGS=['/MACHINE:ARM']) + env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/arm']) - else: + angle_build_cmd += "ARM" - compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV']) + env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_ARM/lib']) - 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" + else: - if (env["bits"] == "32"): - arch = "x86" + compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV']) - angle_build_cmd += "Win32" + 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" - 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']) + if (env["bits"] == "32"): + arch = "x86" - else: - arch = "x64" + angle_build_cmd += "Win32" - angle_build_cmd += "x64" + 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']) - 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']) + else: + arch = "x64" - 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']) + angle_build_cmd += "x64" - env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/references']) + 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']) - if (env["target"]=="release"): + 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(CPPFLAGS=['/O2', '/GL']) - env.Append(CPPFLAGS=['/MD']) - env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS', '/LTCG']) + env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/references']) - elif (env["target"]=="release_debug"): + if (env["target"] == "release"): - env.Append(CCFLAGS=['/O2','/Zi','/DDEBUG_ENABLED']) - env.Append(CPPFLAGS=['/MD']) - env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) + env.Append(CPPFLAGS=['/O2', '/GL']) + env.Append(CPPFLAGS=['/MD']) + env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS', '/LTCG']) - elif (env["target"]=="debug"): + elif (env["target"] == "release_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=['/O2', '/Zi', '/DDEBUG_ENABLED']) + env.Append(CPPFLAGS=['/MD']) + env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) + elif (env["target"] == "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.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["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=['/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']) + 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]) + 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 + # 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={'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') } ) + 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/scene/2d/SCsub b/scene/2d/SCsub index 9fa89edbf7..bf9125be7f 100644 --- a/scene/2d/SCsub +++ b/scene/2d/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.scene_sources,"*.cpp") +env.add_source_files(env.scene_sources, "*.cpp") Export('env') diff --git a/scene/3d/SCsub b/scene/3d/SCsub index 1205deb94a..90e78ba8d3 100644 --- a/scene/3d/SCsub +++ b/scene/3d/SCsub @@ -3,11 +3,11 @@ Import('env') -if (env["disable_3d"]=="yes"): +if (env["disable_3d"] == "yes"): - env.scene_sources.append("3d/spatial.cpp") - env.scene_sources.append("3d/skeleton.cpp") + env.scene_sources.append("3d/spatial.cpp") + env.scene_sources.append("3d/skeleton.cpp") else: - env.add_source_files(env.scene_sources,"*.cpp") + env.add_source_files(env.scene_sources, "*.cpp") Export('env') diff --git a/scene/SCsub b/scene/SCsub index 79da365192..bd2da1eab9 100644 --- a/scene/SCsub +++ b/scene/SCsub @@ -2,21 +2,21 @@ Import('env') -env.scene_sources=[] -env.add_source_files(env.scene_sources,"*.cpp") +env.scene_sources = [] +env.add_source_files(env.scene_sources, "*.cpp") Export('env') -SConscript('main/SCsub'); -SConscript('gui/SCsub'); -SConscript('3d/SCsub'); -SConscript('2d/SCsub'); -SConscript('animation/SCsub'); -SConscript('audio/SCsub'); -SConscript('resources/SCsub'); -SConscript('io/SCsub'); +SConscript('main/SCsub') +SConscript('gui/SCsub') +SConscript('3d/SCsub') +SConscript('2d/SCsub') +SConscript('animation/SCsub') +SConscript('audio/SCsub') +SConscript('resources/SCsub') +SConscript('io/SCsub') -lib = env.Library("scene",env.scene_sources) +lib = env.Library("scene", env.scene_sources) env.Prepend(LIBS=[lib]) diff --git a/scene/animation/SCsub b/scene/animation/SCsub index 9fa89edbf7..bf9125be7f 100644 --- a/scene/animation/SCsub +++ b/scene/animation/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.scene_sources,"*.cpp") +env.add_source_files(env.scene_sources, "*.cpp") Export('env') diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index 9488ae37a8..6ab1a3e5a1 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_player.cpp @@ -494,15 +494,8 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode case NODE_OUTPUT: { NodeOut *on = static_cast<NodeOut*>(nb); - - for(TrackMap::Element *E=track_map.front();E;E=E->next()) { - E->get().total_weight = 0; - } - HashMap<NodePath, float> weights; - - return _process_node(on->inputs[0].node,r_prev_anim,p_time,p_seek, p_fallback_weight, &weights); } break; @@ -544,15 +537,12 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode NodePath track_path = an->animation->track_get_path(E->get().local_track); if (an->filter.has(track_path) && an->filter[track_path]) { E->get().weight = 0; - E->get().track->total_weight += p_fallback_weight; } else { if (p_weights->has(track_path)) { float weight = (*p_weights)[track_path]; E->get().weight = weight; - E->get().track->total_weight += weight; } else { E->get().weight = p_fallback_weight; - E->get().track->total_weight += p_fallback_weight; } } if (E->get().weight>CMP_EPSILON) @@ -875,8 +865,6 @@ void AnimationTreePlayer::_process_animation(float p_delta) { if (tr.track==NULL || tr.local_track<0 || tr.weight < CMP_EPSILON) continue; - float blend=tr.weight / tr.track->total_weight; - switch(a->track_get_type(tr.local_track)) { case Animation::TYPE_TRANSFORM: { ///< Transform a node or a bone. @@ -885,14 +873,14 @@ void AnimationTreePlayer::_process_animation(float p_delta) { Vector3 scale; a->transform_track_interpolate(tr.local_track,anim_list->time,&loc,&rot,&scale); - tr.track->loc+=loc*blend; + tr.track->loc+=loc*tr.weight; scale.x-=1.0; scale.y-=1.0; scale.z-=1.0; - tr.track->scale+=scale*blend; + tr.track->scale+=scale*tr.weight; - tr.track->rot = tr.track->rot * empty_rot.slerp(rot,blend); + tr.track->rot = tr.track->rot * empty_rot.slerp(rot,tr.weight); } break; @@ -900,7 +888,7 @@ void AnimationTreePlayer::_process_animation(float p_delta) { if (a->value_track_get_update_mode(tr.local_track)==Animation::UPDATE_CONTINUOUS) { Variant value = a->value_track_interpolate(tr.local_track,anim_list->time); - Variant::blend(tr.track->value,value,blend,tr.track->value); + Variant::blend(tr.track->value,value,tr.weight,tr.track->value); } else { int index = a->track_find_key(tr.local_track,anim_list->time); tr.track->value = a->track_get_key_value(tr.local_track, index); diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h index 6b5350e9ee..909748924f 100644 --- a/scene/animation/animation_tree_player.h +++ b/scene/animation/animation_tree_player.h @@ -111,7 +111,6 @@ private: Variant value; bool skip; - float total_weight; }; diff --git a/scene/audio/SCsub b/scene/audio/SCsub index 9fa89edbf7..bf9125be7f 100644 --- a/scene/audio/SCsub +++ b/scene/audio/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.scene_sources,"*.cpp") +env.add_source_files(env.scene_sources, "*.cpp") Export('env') diff --git a/scene/gui/SCsub b/scene/gui/SCsub index 9fa89edbf7..bf9125be7f 100644 --- a/scene/gui/SCsub +++ b/scene/gui/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.scene_sources,"*.cpp") +env.add_source_files(env.scene_sources, "*.cpp") Export('env') diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index f69ad8fa7e..191627cadb 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -801,7 +801,10 @@ void ItemList::_notification(int p_what) { Size2 size = get_size(); float page = size.height-bg->get_minimum_size().height; - int width = size.width - mw - bg->get_minimum_size().width; + int width = size.width-bg->get_minimum_size().width; + if (!scroll_bar->is_hidden()){ + width-=mw+bg->get_margin(MARGIN_RIGHT); + } scroll_bar->set_page(page); draw_style_box(bg,Rect2(Point2(),size)); diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index ec89b7b690..3b15776c55 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -85,7 +85,7 @@ void Label::_notification(int p_what) { Ref<Font> font = get_font("font"); Color font_color = get_color("font_color"); Color font_color_shadow = get_color("font_color_shadow"); - bool use_outlinde = get_constant("shadow_as_outline"); + bool use_outline = get_constant("shadow_as_outline"); Point2 shadow_ofs(get_constant("shadow_offset_x"),get_constant("shadow_offset_y")); int line_spacing = get_constant("line_spacing"); @@ -247,7 +247,7 @@ void Label::_notification(int p_what) { } float move=font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+shadow_ofs, c, n,font_color_shadow ); - if (use_outlinde) { + if (use_outline) { font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(-shadow_ofs.x,shadow_ofs.y), c, n,font_color_shadow ); font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(shadow_ofs.x,-shadow_ofs.y), c, n,font_color_shadow ); font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(-shadow_ofs.x,-shadow_ofs.y), c, n,font_color_shadow ); diff --git a/scene/io/SCsub b/scene/io/SCsub index 9fa89edbf7..bf9125be7f 100644 --- a/scene/io/SCsub +++ b/scene/io/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.scene_sources,"*.cpp") +env.add_source_files(env.scene_sources, "*.cpp") Export('env') diff --git a/scene/main/SCsub b/scene/main/SCsub index 9fa89edbf7..bf9125be7f 100644 --- a/scene/main/SCsub +++ b/scene/main/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.scene_sources,"*.cpp") +env.add_source_files(env.scene_sources, "*.cpp") Export('env') diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 6e33dcb4c9..f4fb48682c 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2485,6 +2485,12 @@ void Node::replace_by(Node* p_node,bool p_keep_data) { rd.name=E->get().name; rd.value=get(rd.name); } + + List<GroupInfo> groups; + get_groups(&groups); + + for(List<GroupInfo>::Element *E=groups.front();E;E=E->next()) + p_node->add_to_group(E->get().name, E->get().persistent); } _replace_connections_target(p_node); diff --git a/scene/resources/SCsub b/scene/resources/SCsub index 702ed1a9bf..60b16cd0d4 100644 --- a/scene/resources/SCsub +++ b/scene/resources/SCsub @@ -2,9 +2,9 @@ Import('env') -env.add_source_files(env.scene_sources,"*.cpp") -env.add_source_files(env.scene_sources,"*.c") +env.add_source_files(env.scene_sources, "*.cpp") +env.add_source_files(env.scene_sources, "*.c") Export('env') -SConscript("default_theme/SCsub"); +SConscript("default_theme/SCsub") diff --git a/scene/resources/default_theme/SCsub b/scene/resources/default_theme/SCsub index 9fa89edbf7..bf9125be7f 100644 --- a/scene/resources/default_theme/SCsub +++ b/scene/resources/default_theme/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.scene_sources,"*.cpp") +env.add_source_files(env.scene_sources, "*.cpp") Export('env') diff --git a/scene/resources/default_theme/make_header.py b/scene/resources/default_theme/make_header.py index 2d3f989e01..68c9e92527 100644 --- a/scene/resources/default_theme/make_header.py +++ b/scene/resources/default_theme/make_header.py @@ -1,72 +1,71 @@ -import os; -import glob; -import string; +import os +import glob +import string -#Generate include files +# Generate include files -f=open("theme_data.h","wb") +f = open("theme_data.h", "wb") -f.write("// THIS FILE HAS BEEN AUTOGENERATED, DONT EDIT!!\n"); +f.write("// THIS FILE HAS BEEN AUTOGENERATED, DONT EDIT!!\n") -f.write("\n\n"); +f.write("\n\n") -#Generate png image block +# Generate png image block -pixmaps = glob.glob("*.png"); +pixmaps = glob.glob("*.png") -pixmaps.sort(); +pixmaps.sort() -f.write("\n\n\n"); +f.write("\n\n\n") for x in pixmaps: - var_str=x[:-4]+"_png"; + var_str = x[:-4] + "_png" - f.write("static const unsigned char "+ var_str +"[]={\n"); + f.write("static const unsigned char " + var_str + "[]={\n") - pngf=open(x,"rb"); + pngf = open(x, "rb") - b=pngf.read(1); - while(len(b)==1): - f.write(hex(ord(b))) - b=pngf.read(1); - if (len(b)==1): - f.write(",") + b = pngf.read(1) + while(len(b) == 1): + f.write(hex(ord(b))) + b = pngf.read(1) + if (len(b) == 1): + f.write(",") - f.write("\n};\n\n\n"); - pngf.close(); + f.write("\n};\n\n\n") + pngf.close() -#Generate shaders block +# Generate shaders block shaders = glob.glob("*.gsl") -shaders.sort(); +shaders.sort() -f.write("\n\n\n"); +f.write("\n\n\n") for x in shaders: - var_str=x[:-4]+"_shader_code"; + var_str = x[:-4] + "_shader_code" - f.write("static const char *"+ var_str +"=\n"); + f.write("static const char *" + var_str + "=\n") - sf=open(x,"rb"); + sf = open(x, "rb") + b = sf.readline() + while(b != ""): + if (b.endswith("\r\n")): + b = b[:-2] + if (b.endswith("\n")): + b = b[:-1] + f.write(" \"" + b) + b = sf.readline() + if (b != ""): + f.write("\"\n") - b=sf.readline(); - while(b!=""): - if (b.endswith("\r\n")): - b=b[:-2] - if (b.endswith("\n")): - b=b[:-1] - f.write(" \""+b) - b=sf.readline(); - if (b!=""): - f.write("\"\n") + f.write("\";\n\n\n") + sf.close() - f.write("\";\n\n\n"); - sf.close(); - -f.close(); +f.close() diff --git a/servers/SCsub b/servers/SCsub index 57b5b36758..eefa6278c4 100644 --- a/servers/SCsub +++ b/servers/SCsub @@ -2,18 +2,18 @@ Import('env') -env.servers_sources=[] -env.add_source_files(env.servers_sources,"*.cpp") +env.servers_sources = [] +env.add_source_files(env.servers_sources, "*.cpp") Export('env') -SConscript('physics/SCsub'); -SConscript('physics_2d/SCsub'); -SConscript('visual/SCsub'); -SConscript('audio/SCsub'); -SConscript('spatial_sound/SCsub'); -SConscript('spatial_sound_2d/SCsub'); +SConscript('physics/SCsub') +SConscript('physics_2d/SCsub') +SConscript('visual/SCsub') +SConscript('audio/SCsub') +SConscript('spatial_sound/SCsub') +SConscript('spatial_sound_2d/SCsub') -lib = env.Library("servers",env.servers_sources) +lib = env.Library("servers", env.servers_sources) env.Prepend(LIBS=[lib]) diff --git a/servers/audio/SCsub b/servers/audio/SCsub index 4684bd6cf3..ccc76e823f 100644 --- a/servers/audio/SCsub +++ b/servers/audio/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.servers_sources,"*.cpp") +env.add_source_files(env.servers_sources, "*.cpp") Export('env') diff --git a/servers/physics/SCsub b/servers/physics/SCsub index b527f38ceb..c0ee2cc739 100644 --- a/servers/physics/SCsub +++ b/servers/physics/SCsub @@ -2,7 +2,7 @@ Import('env') -env.add_source_files(env.servers_sources,"*.cpp") +env.add_source_files(env.servers_sources, "*.cpp") Export('env') diff --git a/servers/physics/joints/SCsub b/servers/physics/joints/SCsub index 4684bd6cf3..ccc76e823f 100644 --- a/servers/physics/joints/SCsub +++ b/servers/physics/joints/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.servers_sources,"*.cpp") +env.add_source_files(env.servers_sources, "*.cpp") Export('env') diff --git a/servers/physics_2d/SCsub b/servers/physics_2d/SCsub index 2114782faa..d730144861 100644 --- a/servers/physics_2d/SCsub +++ b/servers/physics_2d/SCsub @@ -2,4 +2,4 @@ Import('env') -env.add_source_files(env.servers_sources,"*.cpp") +env.add_source_files(env.servers_sources, "*.cpp") diff --git a/servers/spatial_sound/SCsub b/servers/spatial_sound/SCsub index 4684bd6cf3..ccc76e823f 100644 --- a/servers/spatial_sound/SCsub +++ b/servers/spatial_sound/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.servers_sources,"*.cpp") +env.add_source_files(env.servers_sources, "*.cpp") Export('env') diff --git a/servers/spatial_sound_2d/SCsub b/servers/spatial_sound_2d/SCsub index 4684bd6cf3..ccc76e823f 100644 --- a/servers/spatial_sound_2d/SCsub +++ b/servers/spatial_sound_2d/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.servers_sources,"*.cpp") +env.add_source_files(env.servers_sources, "*.cpp") Export('env') diff --git a/servers/visual/SCsub b/servers/visual/SCsub index 4684bd6cf3..ccc76e823f 100644 --- a/servers/visual/SCsub +++ b/servers/visual/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.servers_sources,"*.cpp") +env.add_source_files(env.servers_sources, "*.cpp") Export('env') diff --git a/thirdparty/README.md b/thirdparty/README.md index 0b0917c1e9..a1445a7a9a 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -84,7 +84,7 @@ Files extracted from upstream source: ## libpng - Upstream: http://libpng.org/pub/png/libpng.html -- Version: 1.6.23 +- Version: 1.6.26 - License: libpng/zlib Files extracted from upstream source: @@ -158,7 +158,7 @@ Files extracted from upstream source: - all .c and .h files in src/ (both opus and opusfile), except `opus_demo.c` -- all .h files in include/ (both opus and opusfile) +- all .h files in include/ (both opus and opusfile) as opus/ - COPYING diff --git a/thirdparty/libpng/arm/arm_init.c b/thirdparty/libpng/arm/arm_init.c index 52c3f31fed..02df812e77 100644 --- a/thirdparty/libpng/arm/arm_init.c +++ b/thirdparty/libpng/arm/arm_init.c @@ -3,7 +3,7 @@ * * Copyright (c) 2014,2016 Glenn Randers-Pehrson * Written by Mans Rullgard, 2011. - * Last changed in libpng 1.6.22 [June 9, 2016] + * Last changed in libpng 1.6.22 [May 26, 2016] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer diff --git a/thirdparty/libpng/arm/filter_neon_intrinsics.c b/thirdparty/libpng/arm/filter_neon_intrinsics.c index be5ccc7107..ea7e356bcc 100644 --- a/thirdparty/libpng/arm/filter_neon_intrinsics.c +++ b/thirdparty/libpng/arm/filter_neon_intrinsics.c @@ -5,7 +5,7 @@ * Written by James Yu <james.yu at linaro.org>, October 2013. * Based on filter_neon.S, written by Mans Rullgard, 2011. * - * Last changed in libpng 1.6.22 [June 9, 2016] + * Last changed in libpng 1.6.22 [May 26, 2016] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer diff --git a/thirdparty/libpng/png.c b/thirdparty/libpng/png.c index 1720ca0eae..6d5633cc09 100644 --- a/thirdparty/libpng/png.c +++ b/thirdparty/libpng/png.c @@ -1,8 +1,8 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.6.19 [November 12, 2015] - * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -14,7 +14,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_23 Your_png_h_is_not_version_1_6_23; +typedef png_libpng_version_1_6_26 Your_png_h_is_not_version_1_6_26; /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another @@ -85,7 +85,7 @@ png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED) if (items >= (~(png_alloc_size_t)0)/size) { png_warning (png_voidcast(png_structrp, png_ptr), - "Potential overflow in png_zalloc()"); + "Potential overflow in png_zalloc()"); return NULL; } @@ -172,10 +172,10 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length) int png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver) { - /* Libpng versions 1.0.0 and later are binary compatible if the version - * string matches through the second '.'; we must recompile any - * applications that use any older library version. - */ + /* Libpng versions 1.0.0 and later are binary compatible if the version + * string matches through the second '.'; we must recompile any + * applications that use any older library version. + */ if (user_png_ver != NULL) { @@ -297,7 +297,7 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr, if (png_user_version_check(&create_struct, user_png_ver) != 0) { png_structrp png_ptr = png_voidcast(png_structrp, - png_malloc_warn(&create_struct, (sizeof *png_ptr))); + png_malloc_warn(&create_struct, (sizeof *png_ptr))); if (png_ptr != NULL) { @@ -346,7 +346,7 @@ png_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED) * has always been done in 'example.c'. */ info_ptr = png_voidcast(png_inforp, png_malloc_base(png_ptr, - (sizeof *info_ptr))); + (sizeof *info_ptr))); if (info_ptr != NULL) memset(info_ptr, 0, (sizeof *info_ptr)); @@ -402,7 +402,7 @@ png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr) */ PNG_FUNCTION(void,PNGAPI png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size), - PNG_DEPRECATED) + PNG_DEPRECATED) { png_inforp info_ptr = *ptr_ptr; @@ -417,7 +417,7 @@ png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size), /* The following line is why this API should not be used: */ free(info_ptr); info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL, - (sizeof *info_ptr))); + (sizeof *info_ptr))); if (info_ptr == NULL) return; *ptr_ptr = info_ptr; @@ -430,7 +430,7 @@ png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size), /* The following API is not called internally */ void PNGAPI png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr, - int freer, png_uint_32 mask) + int freer, png_uint_32 mask) { png_debug(1, "in png_data_freer"); @@ -449,7 +449,7 @@ png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr, void PNGAPI png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, - int num) + int num) { png_debug(1, "in png_free_data"); @@ -458,7 +458,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #ifdef PNG_TEXT_SUPPORTED /* Free text item num or (if num == -1) all text items */ - if (info_ptr->text != 0 && + if (info_ptr->text != NULL && ((mask & PNG_FREE_TEXT) & info_ptr->free_me) != 0) { if (num != -1) @@ -541,7 +541,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #ifdef PNG_sPLT_SUPPORTED /* Free a given sPLT entry, or (if num == -1) all sPLT entries */ - if (info_ptr->splt_palettes != 0 && + if (info_ptr->splt_palettes != NULL && ((mask & PNG_FREE_SPLT) & info_ptr->free_me) != 0) { if (num != -1) @@ -571,7 +571,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #endif #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED - if (info_ptr->unknown_chunks != 0 && + if (info_ptr->unknown_chunks != NULL && ((mask & PNG_FREE_UNKN) & info_ptr->free_me) != 0) { if (num != -1) @@ -617,7 +617,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, /* Free any image bits attached to the info structure */ if (((mask & PNG_FREE_ROWS) & info_ptr->free_me) != 0) { - if (info_ptr->row_pointers != 0) + if (info_ptr->row_pointers != NULL) { png_uint_32 row; for (row = 0; row < info_ptr->height; row++) @@ -684,7 +684,7 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp) void PNGAPI png_save_int_32(png_bytep buf, png_int_32 i) { - png_save_uint_32(buf, i); + png_save_uint_32(buf, (png_uint_32)i); } # endif @@ -775,14 +775,14 @@ png_get_copyright(png_const_structrp png_ptr) #else # ifdef __STDC__ return PNG_STRING_NEWLINE \ - "libpng version 1.6.23 - June 9, 2016" PNG_STRING_NEWLINE \ + "libpng version 1.6.26 - October 20, 2016" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson" \ PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ PNG_STRING_NEWLINE; # else - return "libpng version 1.6.23 - June 9, 2016\ + return "libpng version 1.6.26 - October 20, 2016\ Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; @@ -1033,7 +1033,7 @@ png_zstream_error(png_structrp png_ptr, int ret) #ifdef PNG_GAMMA_SUPPORTED /* always set if COLORSPACE */ static int png_colorspace_check_gamma(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_fixed_point gAMA, int from) + png_colorspacerp colorspace, png_fixed_point gAMA, int from) /* This is called to check a new gamma value against an existing one. The * routine returns false if the new gamma value should not be written. * @@ -1047,7 +1047,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr, png_fixed_point gtest; if ((colorspace->flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && - (png_muldiv(>est, colorspace->gamma, PNG_FP_1, gAMA) == 0 || + (png_muldiv(>est, colorspace->gamma, PNG_FP_1, gAMA) == 0 || png_gamma_significant(gtest) != 0)) { /* Either this is an sRGB image, in which case the calculated gamma @@ -1059,7 +1059,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr, if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0 || from == 2) { png_chunk_report(png_ptr, "gamma value does not match sRGB", - PNG_CHUNK_ERROR); + PNG_CHUNK_ERROR); /* Do not overwrite an sRGB value */ return from == 2; } @@ -1067,7 +1067,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr, else /* sRGB tag not involved */ { png_chunk_report(png_ptr, "gamma value does not match libpng estimate", - PNG_CHUNK_WARNING); + PNG_CHUNK_WARNING); return from == 1; } } @@ -1077,7 +1077,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr, void /* PRIVATE */ png_colorspace_set_gamma(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_fixed_point gAMA) + png_colorspacerp colorspace, png_fixed_point gAMA) { /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't * occur. Since the fixed point representation is asymetrical it is @@ -1635,8 +1635,8 @@ static const png_xy sRGB_xy = /* From ITU-R BT.709-3 */ static int png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr, - png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ, - int preferred) + png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ, + int preferred) { if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0) return 0; @@ -1683,7 +1683,7 @@ png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr, int /* PRIVATE */ png_colorspace_set_chromaticities(png_const_structrp png_ptr, - png_colorspacerp colorspace, const png_xy *xy, int preferred) + png_colorspacerp colorspace, const png_xy *xy, int preferred) { /* We must check the end points to ensure they are reasonable - in the past * color management systems have crashed as a result of getting bogus @@ -1697,7 +1697,7 @@ png_colorspace_set_chromaticities(png_const_structrp png_ptr, { case 0: /* success */ return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, xy, &XYZ, - preferred); + preferred); case 1: /* We can't invert the chromaticities so we can't produce value XYZ @@ -1720,7 +1720,7 @@ png_colorspace_set_chromaticities(png_const_structrp png_ptr, int /* PRIVATE */ png_colorspace_set_endpoints(png_const_structrp png_ptr, - png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred) + png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred) { png_XYZ XYZ = *XYZ_in; png_xy xy; @@ -1729,7 +1729,7 @@ png_colorspace_set_endpoints(png_const_structrp png_ptr, { case 0: return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, &xy, &XYZ, - preferred); + preferred); case 1: /* End points are invalid. */ @@ -1786,7 +1786,7 @@ is_ICC_signature(png_alloc_size_t it) static int png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_alloc_size_t value, png_const_charp reason) + png_const_charp name, png_alloc_size_t value, png_const_charp reason) { size_t pos; char message[196]; /* see below for calculation */ @@ -1811,8 +1811,8 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114*/ pos = png_safecat(message, (sizeof message), pos, - png_format_number(number, number+(sizeof number), - PNG_NUMBER_FORMAT_x, value)); + png_format_number(number, number+(sizeof number), + PNG_NUMBER_FORMAT_x, value)); pos = png_safecat(message, (sizeof message), pos, "h: "); /*+2 = 116*/ } # endif @@ -1826,7 +1826,7 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, * application errors the PNG won't be written.) */ png_chunk_report(png_ptr, message, - (colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR); + (colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR); return 0; } @@ -1835,7 +1835,7 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, #ifdef PNG_sRGB_SUPPORTED int /* PRIVATE */ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, - int intent) + int intent) { /* sRGB sets known gamma, end points and (from the chunk) intent. */ /* IMPORTANT: these are not necessarily the values found in an ICC profile @@ -1872,10 +1872,10 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, */ if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST) return png_icc_profile_error(png_ptr, colorspace, "sRGB", - (unsigned)intent, "invalid sRGB rendering intent"); + (unsigned)intent, "invalid sRGB rendering intent"); if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 && - colorspace->rendering_intent != intent) + colorspace->rendering_intent != intent) return png_icc_profile_error(png_ptr, colorspace, "sRGB", (unsigned)intent, "inconsistent rendering intents"); @@ -1889,8 +1889,8 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, * warn but overwrite the value with the correct one. */ if ((colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0 && - !png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy, - 100)) + !png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy, + 100)) png_chunk_report(png_ptr, "cHRM chunk does not match sRGB", PNG_CHUNK_ERROR); @@ -1898,7 +1898,7 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, * returns true when the 'from' argument corresponds to sRGB (2). */ (void)png_colorspace_check_gamma(png_ptr, colorspace, PNG_GAMMA_sRGB_INVERSE, - 2/*from sRGB*/); + 2/*from sRGB*/); /* intent: bugs in GCC force 'int' to be used as the parameter type. */ colorspace->rendering_intent = (png_uint_16)intent; @@ -1931,21 +1931,55 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, static const png_byte D50_nCIEXYZ[12] = { 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d }; -int /* PRIVATE */ -png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length) +static int /* bool */ +icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_uint_32 profile_length) { if (profile_length < 132) return png_icc_profile_error(png_ptr, colorspace, name, profile_length, - "too short"); + "too short"); return 1; } +#ifdef PNG_READ_iCCP_SUPPORTED +int /* PRIVATE */ +png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_uint_32 profile_length) +{ + if (!icc_check_length(png_ptr, colorspace, name, profile_length)) + return 0; + + /* This needs to be here because the 'normal' check is in + * png_decompress_chunk, yet this happens after the attempt to + * png_malloc_base the required data. We only need this on read; on write + * the caller supplies the profile buffer so libpng doesn't allocate it. See + * the call to icc_check_length below (the write case). + */ +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + else if (png_ptr->user_chunk_malloc_max > 0 && + png_ptr->user_chunk_malloc_max < profile_length) + return png_icc_profile_error(png_ptr, colorspace, name, profile_length, + "exceeds application limits"); +# elif PNG_USER_CHUNK_MALLOC_MAX > 0 + else if (PNG_USER_CHUNK_MALLOC_MAX < profile_length) + return png_icc_profile_error(png_ptr, colorspace, name, profile_length, + "exceeds libpng limits"); +# else /* !SET_USER_LIMITS */ + /* This will get compiled out on all 32-bit and better systems. */ + else if (PNG_SIZE_MAX < profile_length) + return png_icc_profile_error(png_ptr, colorspace, name, profile_length, + "exceeds system limits"); +# endif /* !SET_USER_LIMITS */ + + return 1; +} +#endif /* READ_iCCP */ + int /* PRIVATE */ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length, - png_const_bytep profile/* first 132 bytes only */, int color_type) + png_const_charp name, png_uint_32 profile_length, + png_const_bytep profile/* first 132 bytes only */, int color_type) { png_uint_32 temp; @@ -1957,18 +1991,18 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, temp = png_get_uint_32(profile); if (temp != profile_length) return png_icc_profile_error(png_ptr, colorspace, name, temp, - "length does not match profile"); + "length does not match profile"); temp = (png_uint_32) (*(profile+8)); if (temp > 3 && (profile_length & 3)) return png_icc_profile_error(png_ptr, colorspace, name, profile_length, - "invalid length"); + "invalid length"); temp = png_get_uint_32(profile+128); /* tag count: 12 bytes/tag */ if (temp > 357913930 || /* (2^32-4-132)/12: maximum possible tag count */ profile_length < 132+12*temp) /* truncated tag table */ return png_icc_profile_error(png_ptr, colorspace, name, temp, - "tag count too large"); + "tag count too large"); /* The 'intent' must be valid or we can't store it, ICC limits the intent to * 16 bits. @@ -1976,14 +2010,14 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, temp = png_get_uint_32(profile+64); if (temp >= 0xffff) /* The ICC limit */ return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid rendering intent"); + "invalid rendering intent"); /* This is just a warning because the profile may be valid in future * versions. */ if (temp >= PNG_sRGB_INTENT_LAST) (void)png_icc_profile_error(png_ptr, NULL, name, temp, - "intent outside defined range"); + "intent outside defined range"); /* At this point the tag table can't be checked because it hasn't necessarily * been loaded; however, various header fields can be checked. These checks @@ -2000,7 +2034,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, temp = png_get_uint_32(profile+36); /* signature 'ascp' */ if (temp != 0x61637370) return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid signature"); + "invalid signature"); /* Currently the PCS illuminant/adopted white point (the computational * white point) are required to be D50, @@ -2011,7 +2045,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, */ if (memcmp(profile+68, D50_nCIEXYZ, 12) != 0) (void)png_icc_profile_error(png_ptr, NULL, name, 0/*no tag value*/, - "PCS illuminant is not D50"); + "PCS illuminant is not D50"); /* The PNG spec requires this: * "If the iCCP chunk is present, the image samples conform to the colour @@ -2039,18 +2073,18 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, case 0x52474220: /* 'RGB ' */ if ((color_type & PNG_COLOR_MASK_COLOR) == 0) return png_icc_profile_error(png_ptr, colorspace, name, temp, - "RGB color space not permitted on grayscale PNG"); + "RGB color space not permitted on grayscale PNG"); break; case 0x47524159: /* 'GRAY' */ if ((color_type & PNG_COLOR_MASK_COLOR) != 0) return png_icc_profile_error(png_ptr, colorspace, name, temp, - "Gray color space not permitted on RGB PNG"); + "Gray color space not permitted on RGB PNG"); break; default: return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid ICC profile color space"); + "invalid ICC profile color space"); } /* It is up to the application to check that the profile class matches the @@ -2075,7 +2109,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, case 0x61627374: /* 'abst' */ /* May not be embedded in an image */ return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid embedded Abstract ICC profile"); + "invalid embedded Abstract ICC profile"); case 0x6c696e6b: /* 'link' */ /* DeviceLink profiles cannot be interpreted in a non-device specific @@ -2085,7 +2119,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, * PNG. */ return png_icc_profile_error(png_ptr, colorspace, name, temp, - "unexpected DeviceLink ICC profile class"); + "unexpected DeviceLink ICC profile class"); case 0x6e6d636c: /* 'nmcl' */ /* A NamedColor profile is also device specific, however it doesn't @@ -2093,7 +2127,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, * certainly it will fail the tests below. */ (void)png_icc_profile_error(png_ptr, NULL, name, temp, - "unexpected NamedColor ICC profile class"); + "unexpected NamedColor ICC profile class"); break; default: @@ -2103,7 +2137,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, * understood profiles. */ (void)png_icc_profile_error(png_ptr, NULL, name, temp, - "unrecognized ICC profile class"); + "unrecognized ICC profile class"); break; } @@ -2119,7 +2153,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, default: return png_icc_profile_error(png_ptr, colorspace, name, temp, - "unexpected ICC PCS encoding"); + "unexpected ICC PCS encoding"); } return 1; @@ -2127,8 +2161,8 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, int /* PRIVATE */ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length, - png_const_bytep profile /* header plus whole tag table */) + png_const_charp name, png_uint_32 profile_length, + png_const_bytep profile /* header plus whole tag table */) { png_uint_32 tag_count = png_get_uint_32(profile+128); png_uint_32 itag; @@ -2156,7 +2190,7 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace, * alignment. */ (void)png_icc_profile_error(png_ptr, NULL, name, tag_id, - "ICC profile tag start not a multiple of 4"); + "ICC profile tag start not a multiple of 4"); } /* This is a hard error; potentially it can cause read outside the @@ -2164,7 +2198,7 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace, */ if (tag_start > profile_length || tag_length > profile_length - tag_start) return png_icc_profile_error(png_ptr, colorspace, name, tag_id, - "ICC profile tag outside profile"); + "ICC profile tag outside profile"); } return 1; /* success, maybe with warnings */ @@ -2192,22 +2226,22 @@ static const struct */ /* adler32, crc32, MD5[4], intent, date, length, file-name */ PNG_ICC_CHECKSUM(0x0a3fd9f6, 0x3b8772b9, - PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0, - "2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc") + PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0, + "2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc") /* ICC sRGB v2 perceptual no black-compensation: */ PNG_ICC_CHECKSUM(0x4909e5e1, 0x427ebb21, - PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0, - "2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc") + PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0, + "2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc") PNG_ICC_CHECKSUM(0xfd2144a1, 0x306fd8ae, - PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0, - "2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc") + PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0, + "2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc") /* ICC sRGB v4 perceptual */ PNG_ICC_CHECKSUM(0x209c35d2, 0xbbef7812, - PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0, - "2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc") + PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0, + "2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc") /* The following profiles have no known MD5 checksum. If there is a match * on the (empty) MD5 the other fields are used to attempt a match and @@ -2215,8 +2249,8 @@ static const struct * which suggests that they were also made by Hewlett Packard. */ PNG_ICC_CHECKSUM(0xa054d762, 0x5d5129ce, - PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0, - "2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc") + PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0, + "2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc") /* This is a 'mntr' (display) profile with a mediaWhitePointTag that does not * match the D50 PCS illuminant in the header (it is in fact the D65 values, @@ -2226,17 +2260,17 @@ static const struct * chromaticAdaptationTag. */ PNG_ICC_CHECKSUM(0xf784f3fb, 0x182ea552, - PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/, - "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual") + PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/, + "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual") PNG_ICC_CHECKSUM(0x0398f3fc, 0xf29e526d, - PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/, - "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative") + PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/, + "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative") }; static int png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, - png_const_bytep profile, uLong adler) + png_const_bytep profile, uLong adler) { /* The quick check is to verify just the MD5 signature and trust the * rest of the data. Because the profile has already been verified for @@ -2320,7 +2354,7 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, * which is made irrelevant by this error. */ png_chunk_report(png_ptr, "known incorrect sRGB profile", - PNG_CHUNK_ERROR); + PNG_CHUNK_ERROR); } /* Warn that this being done; this isn't even an error since @@ -2330,8 +2364,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, else if (png_sRGB_checks[i].have_md5 == 0) { png_chunk_report(png_ptr, - "out-of-date sRGB profile with no signature", - PNG_CHUNK_WARNING); + "out-of-date sRGB profile with no signature", + PNG_CHUNK_WARNING); } return 1+png_sRGB_checks[i].is_broken; @@ -2354,38 +2388,36 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, return 0; /* no match */ } -#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */ void /* PRIVATE */ png_icc_set_sRGB(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_const_bytep profile, uLong adler) + png_colorspacerp colorspace, png_const_bytep profile, uLong adler) { /* Is this profile one of the known ICC sRGB profiles? If it is, just set * the sRGB information. */ -#if PNG_sRGB_PROFILE_CHECKS >= 0 if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler) != 0) -#endif (void)png_colorspace_set_sRGB(png_ptr, colorspace, (int)/*already checked*/png_get_uint_32(profile+64)); } +#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */ #endif /* sRGB */ int /* PRIVATE */ png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length, png_const_bytep profile, - int color_type) + png_const_charp name, png_uint_32 profile_length, png_const_bytep profile, + int color_type) { if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0) return 0; - if (png_icc_check_length(png_ptr, colorspace, name, profile_length) != 0 && + if (icc_check_length(png_ptr, colorspace, name, profile_length) != 0 && png_icc_check_header(png_ptr, colorspace, name, profile_length, profile, - color_type) != 0 && + color_type) != 0 && png_icc_check_tag_table(png_ptr, colorspace, name, profile_length, - profile) != 0) + profile) != 0) { -# ifdef PNG_sRGB_SUPPORTED +# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0 /* If no sRGB support, don't try storing sRGB information */ png_icc_set_sRGB(png_ptr, colorspace, profile, 0); # endif @@ -2444,7 +2476,7 @@ png_colorspace_set_rgb_coefficients(png_structrp png_ptr) /* Check for an internal error. */ if (r+g+b != 32768) png_error(png_ptr, - "internal error handling cHRM coefficients"); + "internal error handling cHRM coefficients"); else { @@ -2470,7 +2502,7 @@ png_colorspace_set_rgb_coefficients(png_structrp png_ptr) static int /* PRIVATE */ png_gt(size_t a, size_t b) { - return a > b; + return a > b; } #else # define png_gt(a,b) ((a) > (b)) @@ -2478,9 +2510,9 @@ png_gt(size_t a, size_t b) void /* PRIVATE */ png_check_IHDR(png_const_structrp png_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_type, int compression_type, - int filter_type) + png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_type, int compression_type, + int filter_type) { int error = 0; @@ -2497,7 +2529,7 @@ png_check_IHDR(png_const_structrp png_ptr, error = 1; } - if (png_gt(((width + 7) & (~7)), + if (png_gt(((width + 7) & (~7U)), ((PNG_SIZE_MAX - 48 /* big_row_buf hack */ - 1) /* filter byte */ @@ -2643,7 +2675,7 @@ png_check_IHDR(png_const_structrp png_ptr, int /* PRIVATE */ png_check_fp_number(png_const_charp string, png_size_t size, int *statep, - png_size_tp whereami) + png_size_tp whereami) { int state = *statep; png_size_t i = *whereami; @@ -2908,7 +2940,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size, */ if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */ { - czero = -exp_b10; /* PLUS 2 digits: TOTAL 3 */ + czero = (unsigned int)(-exp_b10); /* PLUS 2 digits: TOTAL 3 */ exp_b10 = 0; /* Dot added below before first output. */ } else @@ -3086,11 +3118,11 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size, if (exp_b10 < 0) { *ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */ - uexp_b10 = -exp_b10; + uexp_b10 = (unsigned int)(-exp_b10); } else - uexp_b10 = exp_b10; + uexp_b10 = (unsigned int)exp_b10; cdigits = 0; @@ -3152,9 +3184,9 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii, /* Avoid overflow here on the minimum integer. */ if (fp < 0) - *ascii++ = 45, num = -fp; + *ascii++ = 45, num = (png_uint_32)(-fp); else - num = fp; + num = (png_uint_32)fp; if (num <= 0x80000000) /* else overflowed */ { @@ -3806,25 +3838,25 @@ png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val) { if (value > 0 && value < 65535) { -# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - /* The same (unsigned int)->(double) constraints apply here as above, - * however in this case the (unsigned int) to (int) conversion can - * overflow on an ANSI-C90 compliant system so the cast needs to ensure - * that this is not possible. - */ - double r = floor(65535*pow((png_int_32)value/65535., - gamma_val*.00001)+.5); - return (png_uint_16)r; -# else - png_int_32 lg2 = png_log16bit(value); - png_fixed_point res; - - if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1) != 0) - return png_exp16bit(res); - - /* Overflow. */ - value = 0; -# endif +# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + /* The same (unsigned int)->(double) constraints apply here as above, + * however in this case the (unsigned int) to (int) conversion can + * overflow on an ANSI-C90 compliant system so the cast needs to ensure + * that this is not possible. + */ + double r = floor(65535*pow((png_int_32)value/65535., + gamma_val*.00001)+.5); + return (png_uint_16)r; +# else + png_int_32 lg2 = png_log16bit(value); + png_fixed_point res; + + if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1) != 0) + return png_exp16bit(res); + + /* Overflow. */ + value = 0; +# endif } return (png_uint_16)value; @@ -3863,7 +3895,7 @@ png_gamma_correct(png_structrp png_ptr, unsigned int value, */ static void png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, - PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) + PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) { /* Various values derived from 'shift': */ PNG_CONST unsigned int num = 1U << (8U - shift); @@ -3940,7 +3972,7 @@ png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, */ static void png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, - PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) + PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) { PNG_CONST unsigned int num = 1U << (8U - shift); PNG_CONST unsigned int max = (1U << (16U - shift))-1U; @@ -4008,7 +4040,7 @@ png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, */ static void png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable, - PNG_CONST png_fixed_point gamma_val) + PNG_CONST png_fixed_point gamma_val) { unsigned int i; png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256); @@ -4088,131 +4120,133 @@ png_destroy_gamma_table(png_structrp png_ptr) void /* PRIVATE */ png_build_gamma_table(png_structrp png_ptr, int bit_depth) { - png_debug(1, "in png_build_gamma_table"); - - /* Remove any existing table; this copes with multiple calls to - * png_read_update_info. The warning is because building the gamma tables - * multiple times is a performance hit - it's harmless but the ability to call - * png_read_update_info() multiple times is new in 1.5.6 so it seems sensible - * to warn if the app introduces such a hit. - */ - if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL) - { - png_warning(png_ptr, "gamma table being rebuilt"); - png_destroy_gamma_table(png_ptr); - } - - if (bit_depth <= 8) - { - png_build_8bit_table(png_ptr, &png_ptr->gamma_table, - png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma) : PNG_FP_1); + png_debug(1, "in png_build_gamma_table"); + + /* Remove any existing table; this copes with multiple calls to + * png_read_update_info. The warning is because building the gamma tables + * multiple times is a performance hit - it's harmless but the ability to + * call png_read_update_info() multiple times is new in 1.5.6 so it seems + * sensible to warn if the app introduces such a hit. + */ + if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL) + { + png_warning(png_ptr, "gamma table being rebuilt"); + png_destroy_gamma_table(png_ptr); + } + + if (bit_depth <= 8) + { + png_build_8bit_table(png_ptr, &png_ptr->gamma_table, + png_ptr->screen_gamma > 0 ? + png_reciprocal2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma) : PNG_FP_1); #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0) - { - png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1, - png_reciprocal(png_ptr->colorspace.gamma)); - - png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1, - png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : - png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); - } + if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0) + { + png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1, + png_reciprocal(png_ptr->colorspace.gamma)); + + png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1, + png_ptr->screen_gamma > 0 ? + png_reciprocal(png_ptr->screen_gamma) : + png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); + } #endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ - } + } #ifdef PNG_16BIT_SUPPORTED - else - { - png_byte shift, sig_bit; - - if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) - { - sig_bit = png_ptr->sig_bit.red; - - if (png_ptr->sig_bit.green > sig_bit) - sig_bit = png_ptr->sig_bit.green; - - if (png_ptr->sig_bit.blue > sig_bit) - sig_bit = png_ptr->sig_bit.blue; - } - else - sig_bit = png_ptr->sig_bit.gray; - - /* 16-bit gamma code uses this equation: - * - * ov = table[(iv & 0xff) >> gamma_shift][iv >> 8] - * - * Where 'iv' is the input color value and 'ov' is the output value - - * pow(iv, gamma). - * - * Thus the gamma table consists of up to 256 256-entry tables. The table - * is selected by the (8-gamma_shift) most significant of the low 8 bits of - * the color value then indexed by the upper 8 bits: - * - * table[low bits][high 8 bits] - * - * So the table 'n' corresponds to all those 'iv' of: - * - * <all high 8-bit values><n << gamma_shift>..<(n+1 << gamma_shift)-1> - * - */ - if (sig_bit > 0 && sig_bit < 16U) - /* shift == insignificant bits */ - shift = (png_byte)((16U - sig_bit) & 0xff); - - else - shift = 0; /* keep all 16 bits */ - - if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0) - { - /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively - * the significant bits in the *input* when the output will - * eventually be 8 bits. By default it is 11. - */ - if (shift < (16U - PNG_MAX_GAMMA_8)) - shift = (16U - PNG_MAX_GAMMA_8); - } - - if (shift > 8U) - shift = 8U; /* Guarantees at least one table! */ - - png_ptr->gamma_shift = shift; - - /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now - * PNG_COMPOSE). This effectively smashed the background calculation for - * 16-bit output because the 8-bit table assumes the result will be reduced - * to 8 bits. - */ - if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0) - png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift, - png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma) : PNG_FP_1); - - else - png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift, - png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma) : PNG_FP_1); + else + { + png_byte shift, sig_bit; + + if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) + { + sig_bit = png_ptr->sig_bit.red; + + if (png_ptr->sig_bit.green > sig_bit) + sig_bit = png_ptr->sig_bit.green; + + if (png_ptr->sig_bit.blue > sig_bit) + sig_bit = png_ptr->sig_bit.blue; + } + else + sig_bit = png_ptr->sig_bit.gray; + + /* 16-bit gamma code uses this equation: + * + * ov = table[(iv & 0xff) >> gamma_shift][iv >> 8] + * + * Where 'iv' is the input color value and 'ov' is the output value - + * pow(iv, gamma). + * + * Thus the gamma table consists of up to 256 256-entry tables. The table + * is selected by the (8-gamma_shift) most significant of the low 8 bits + * of the color value then indexed by the upper 8 bits: + * + * table[low bits][high 8 bits] + * + * So the table 'n' corresponds to all those 'iv' of: + * + * <all high 8-bit values><n << gamma_shift>..<(n+1 << gamma_shift)-1> + * + */ + if (sig_bit > 0 && sig_bit < 16U) + /* shift == insignificant bits */ + shift = (png_byte)((16U - sig_bit) & 0xff); + + else + shift = 0; /* keep all 16 bits */ + + if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0) + { + /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively + * the significant bits in the *input* when the output will + * eventually be 8 bits. By default it is 11. + */ + if (shift < (16U - PNG_MAX_GAMMA_8)) + shift = (16U - PNG_MAX_GAMMA_8); + } + + if (shift > 8U) + shift = 8U; /* Guarantees at least one table! */ + + png_ptr->gamma_shift = shift; + + /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now + * PNG_COMPOSE). This effectively smashed the background calculation for + * 16-bit output because the 8-bit table assumes the result will be + * reduced to 8 bits. + */ + if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0) + png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift, + png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma) : PNG_FP_1); + + else + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift, + png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma) : PNG_FP_1); #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0) - { - png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift, - png_reciprocal(png_ptr->colorspace.gamma)); - - /* Notice that the '16 from 1' table should be full precision, however - * the lookup on this table still uses gamma_shift, so it can't be. - * TODO: fix this. - */ - png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift, - png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : - png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); - } + if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0) + { + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift, + png_reciprocal(png_ptr->colorspace.gamma)); + + /* Notice that the '16 from 1' table should be full precision, however + * the lookup on this table still uses gamma_shift, so it can't be. + * TODO: fix this. + */ + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift, + png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : + png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); + } #endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ - } + } #endif /* 16BIT */ } #endif /* READ_GAMMA */ diff --git a/thirdparty/libpng/png.h b/thirdparty/libpng/png.h index 1efb0b02a9..f0944631e0 100644 --- a/thirdparty/libpng/png.h +++ b/thirdparty/libpng/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.6.23, June 9, 2016 + * libpng version 1.6.26, October 20, 2016 * * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -12,7 +12,7 @@ * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.6.23, June 9, 2016: + * libpng versions 0.97, January 1998, through 1.6.26, October 20, 2016: * Glenn Randers-Pehrson. * See also "Contributing Authors", below. */ @@ -29,7 +29,7 @@ * files that are distributed with libpng have other copyright owners and * are released under other open source licenses. * - * libpng versions 1.0.7, July 1, 2000 through 1.6.23, June 9, 2016 are + * libpng versions 1.0.7, July 1, 2000 through 1.6.26, October 20, 2016 are * Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are * derived from libpng-1.0.6, and are distributed according to the same * disclaimer and license as libpng-1.0.6 with the following individuals @@ -41,6 +41,7 @@ * Cosmin Truta * Gilles Vollant * James Yu + * Mandar Sahastrabuddhe * * and with the following additions to the disclaimer: * @@ -217,7 +218,7 @@ * ... * 1.5.27 15 10527 15.so.15.27[.0] * ... - * 1.6.23 16 10623 16.so.16.23[.0] + * 1.6.26 16 10626 16.so.16.26[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -245,13 +246,13 @@ * Y2K compliance in libpng: * ========================= * - * June 9, 2016 + * October 20, 2016 * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. * * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.6.23 are Y2K compliant. It is my belief that + * upward through 1.6.26 are Y2K compliant. It is my belief that * earlier versions were also Y2K compliant. * * Libpng only has two year fields. One is a 2-byte unsigned integer @@ -313,9 +314,8 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.23" -#define PNG_HEADER_VERSION_STRING \ - " libpng version 1.6.23 - June 9, 2016\n" +#define PNG_LIBPNG_VER_STRING "1.6.26" +#define PNG_HEADER_VERSION_STRING " libpng version 1.6.26 - October 20, 2016\n" #define PNG_LIBPNG_VER_SONUM 16 #define PNG_LIBPNG_VER_DLLNUM 16 @@ -323,7 +323,7 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 6 -#define PNG_LIBPNG_VER_RELEASE 23 +#define PNG_LIBPNG_VER_RELEASE 26 /* This should match the numeric part of the final component of * PNG_LIBPNG_VER_STRING, omitting any leading zero: @@ -354,20 +354,20 @@ * version 1.0.0 was mis-numbered 100 instead of 10000). From * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10623 /* 1.6.23 */ +#define PNG_LIBPNG_VER 10626 /* 1.6.26 */ /* Library configuration: these options cannot be changed after * the library has been built. */ #ifndef PNGLCONF_H - /* If pnglibconf.h is missing, you can - * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h - */ +/* If pnglibconf.h is missing, you can + * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h + */ # include "pnglibconf.h" #endif #ifndef PNG_VERSION_INFO_ONLY - /* Machine specific configuration. */ +/* Machine specific configuration. */ # include "pngconf.h" #endif @@ -464,7 +464,7 @@ extern "C" { /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef char* png_libpng_version_1_6_23; +typedef char* png_libpng_version_1_6_26; /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. * @@ -657,17 +657,17 @@ typedef png_time * * png_timepp; */ typedef struct png_unknown_chunk_t { - png_byte name[5]; /* Textual chunk name with '\0' terminator */ - png_byte *data; /* Data, should not be modified on read! */ - png_size_t size; - - /* On write 'location' must be set using the flag values listed below. - * Notice that on read it is set by libpng however the values stored have - * more bits set than are listed below. Always treat the value as a - * bitmask. On write set only one bit - setting multiple bits may cause the - * chunk to be written in multiple places. - */ - png_byte location; /* mode of operation at read time */ + png_byte name[5]; /* Textual chunk name with '\0' terminator */ + png_byte *data; /* Data, should not be modified on read! */ + png_size_t size; + + /* On write 'location' must be set using the flag values listed below. + * Notice that on read it is set by libpng however the values stored have + * more bits set than are listed below. Always treat the value as a + * bitmask. On write set only one bit - setting multiple bits may cause the + * chunk to be written in multiple places. + */ + png_byte location; /* mode of operation at read time */ } png_unknown_chunk; @@ -2300,8 +2300,10 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to * be processed by libpng. */ +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, int keep, png_const_bytep chunk_list, int num_chunks)); +#endif /* HANDLE_AS_UNKNOWN */ /* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned; * the result is therefore true (non-zero) if special handling is required, @@ -2309,7 +2311,7 @@ PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, */ PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr, png_const_bytep chunk_name)); -#endif +#endif /* SET_UNKNOWN_CHUNKS */ #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr, @@ -2530,33 +2532,37 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ -# define png_composite(composite, fg, alpha, bg) \ - { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ - * (png_uint_16)(alpha) \ - + (png_uint_16)(bg)*(png_uint_16)(255 \ - - (png_uint_16)(alpha)) + 128); \ - (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); } - -# define png_composite_16(composite, fg, alpha, bg) \ - { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ - * (png_uint_32)(alpha) \ - + (png_uint_32)(bg)*(65535 \ - - (png_uint_32)(alpha)) + 32768); \ - (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); } +# define png_composite(composite, fg, alpha, bg) \ + { \ + png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ + * (png_uint_16)(alpha) \ + + (png_uint_16)(bg)*(png_uint_16)(255 \ + - (png_uint_16)(alpha)) + 128); \ + (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); \ + } + +# define png_composite_16(composite, fg, alpha, bg) \ + { \ + png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ + * (png_uint_32)(alpha) \ + + (png_uint_32)(bg)*(65535 \ + - (png_uint_32)(alpha)) + 32768); \ + (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); \ + } #else /* Standard method using integer division */ -# define png_composite(composite, fg, alpha, bg) \ - (composite) = \ - (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \ - (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ - 127) / 255)) - -# define png_composite_16(composite, fg, alpha, bg) \ - (composite) = \ - (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \ - (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ - 32767) / 65535)) +# define png_composite(composite, fg, alpha, bg) \ + (composite) = \ + (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \ + (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ + 127) / 255)) + +# define png_composite_16(composite, fg, alpha, bg) \ + (composite) = \ + (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \ + (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ + 32767) / 65535)) #endif /* READ_COMPOSITE_NODIV */ #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED @@ -2592,38 +2598,38 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); * format for negative values, which is almost certainly true. */ # define PNG_get_uint_32(buf) \ - (((png_uint_32)(*(buf)) << 24) + \ - ((png_uint_32)(*((buf) + 1)) << 16) + \ - ((png_uint_32)(*((buf) + 2)) << 8) + \ - ((png_uint_32)(*((buf) + 3)))) + (((png_uint_32)(*(buf)) << 24) + \ + ((png_uint_32)(*((buf) + 1)) << 16) + \ + ((png_uint_32)(*((buf) + 2)) << 8) + \ + ((png_uint_32)(*((buf) + 3)))) /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the * function) incorrectly returned a value of type png_uint_32. */ # define PNG_get_uint_16(buf) \ - ((png_uint_16) \ - (((unsigned int)(*(buf)) << 8) + \ - ((unsigned int)(*((buf) + 1))))) + ((png_uint_16) \ + (((unsigned int)(*(buf)) << 8) + \ + ((unsigned int)(*((buf) + 1))))) # define PNG_get_int_32(buf) \ - ((png_int_32)((*(buf) & 0x80) \ - ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \ - : (png_int_32)png_get_uint_32(buf))) + ((png_int_32)((*(buf) & 0x80) \ + ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \ + : (png_int_32)png_get_uint_32(buf))) - /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h, - * but defining a macro name prefixed with PNG_PREFIX. - */ +/* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h, + * but defining a macro name prefixed with PNG_PREFIX. + */ # ifndef PNG_PREFIX -# define png_get_uint_32(buf) PNG_get_uint_32(buf) -# define png_get_uint_16(buf) PNG_get_uint_16(buf) -# define png_get_int_32(buf) PNG_get_int_32(buf) +# define png_get_uint_32(buf) PNG_get_uint_32(buf) +# define png_get_uint_16(buf) PNG_get_uint_16(buf) +# define png_get_int_32(buf) PNG_get_int_32(buf) # endif #else # ifdef PNG_PREFIX - /* No macros; revert to the (redefined) function */ -# define PNG_get_uint_32 (png_get_uint_32) -# define PNG_get_uint_16 (png_get_uint_16) -# define PNG_get_int_32 (png_get_int_32) + /* No macros; revert to the (redefined) function */ +# define PNG_get_uint_32 (png_get_uint_32) +# define PNG_get_uint_16 (png_get_uint_16) +# define PNG_get_int_32 (png_get_int_32) # endif #endif @@ -3171,9 +3177,9 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory, #define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\ ((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\ (((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\ - 12U+3U*(image).colormap_entries/*PLTE data*/+\ - (((image).format&PNG_FORMAT_FLAG_ALPHA)?\ - 12U/*tRNS*/+(image).colormap_entries:0U):0U)+\ + 12U+3U*(image).colormap_entries/*PLTE data*/+\ + (((image).format&PNG_FORMAT_FLAG_ALPHA)?\ + 12U/*tRNS*/+(image).colormap_entries:0U):0U)+\ 12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size)) /* A helper for the following macro; if your compiler cannot handle the * following macro use this one with the result of @@ -3221,7 +3227,10 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory, #endif #define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */ #define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */ -#define PNG_OPTION_NEXT 6 /* Next option - numbers must be even */ +#ifdef PNG_MIPS_MSA_API_SUPPORTED +# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */ +#endif +#define PNG_OPTION_NEXT 8 /* Next option - numbers must be even */ /* Return values: NOTE: there are four values and 'off' is *not* zero */ #define PNG_OPTION_UNSET 0 /* Unset - defaults to off */ diff --git a/thirdparty/libpng/pngconf.h b/thirdparty/libpng/pngconf.h index b0ccc8c25e..5c891eb8b8 100644 --- a/thirdparty/libpng/pngconf.h +++ b/thirdparty/libpng/pngconf.h @@ -1,9 +1,9 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.6.23, June 9, 2016 + * libpng version 1.6.26, October 20, 2016 * - * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -188,27 +188,27 @@ * compatible with GCC or Visual C because of different calling conventions. */ # if PNG_API_RULE == 2 - /* If this line results in an error, either because __watcall is not - * understood or because of a redefine just below you cannot use *this* - * build of the library with the compiler you are using. *This* build was - * build using Watcom and applications must also be built using Watcom! - */ + /* If this line results in an error, either because __watcall is not + * understood or because of a redefine just below you cannot use *this* + * build of the library with the compiler you are using. *This* build was + * build using Watcom and applications must also be built using Watcom! + */ # define PNGCAPI __watcall # endif # if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800)) # define PNGCAPI __cdecl # if PNG_API_RULE == 1 - /* If this line results in an error __stdcall is not understood and - * PNG_API_RULE should not have been set to '1'. - */ + /* If this line results in an error __stdcall is not understood and + * PNG_API_RULE should not have been set to '1'. + */ # define PNGAPI __stdcall # endif # else - /* An older compiler, or one not detected (erroneously) above, - * if necessary override on the command line to get the correct - * variants for the compiler. - */ + /* An older compiler, or one not detected (erroneously) above, + * if necessary override on the command line to get the correct + * variants for the compiler. + */ # ifndef PNGCAPI # define PNGCAPI _cdecl # endif @@ -225,10 +225,10 @@ # if (defined(_MSC_VER) && _MSC_VER < 800) ||\ (defined(__BORLANDC__) && __BORLANDC__ < 0x500) - /* older Borland and MSC - * compilers used '__export' and required this to be after - * the type. - */ + /* older Borland and MSC + * compilers used '__export' and required this to be after + * the type. + */ # ifndef PNG_EXPORT_TYPE # define PNG_EXPORT_TYPE(type) type PNG_IMPEXP # endif @@ -244,9 +244,9 @@ # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) # define PNGAPI _System # else /* !Windows/x86 && !OS/2 */ - /* Use the defaults, or define PNG*API on the command line (but - * this will have to be done for every compile!) - */ + /* Use the defaults, or define PNG*API on the command line (but + * this will have to be done for every compile!) + */ # endif /* other system, !OS/2 */ #endif /* !Windows/x86 */ @@ -267,7 +267,7 @@ */ #ifndef PNG_IMPEXP # if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) - /* This forces use of a DLL, disallowing static linking */ + /* This forces use of a DLL, disallowing static linking */ # define PNG_IMPEXP PNG_DLL_IMPORT # endif @@ -340,7 +340,7 @@ * less efficient code. */ # if defined(__clang__) && defined(__has_attribute) - /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */ + /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */ # if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__) # define PNG_USE_RESULT __attribute__((__warn_unused_result__)) # endif @@ -507,9 +507,9 @@ # error "libpng requires a signed 32-bit (or more) type" #endif -#if UINT_MAX > 4294967294 +#if UINT_MAX > 4294967294U typedef unsigned int png_uint_32; -#elif ULONG_MAX > 4294967294 +#elif ULONG_MAX > 4294967294U typedef unsigned long int png_uint_32; #else # error "libpng requires an unsigned 32-bit (or more) type" diff --git a/thirdparty/libpng/pngerror.c b/thirdparty/libpng/pngerror.c index 3fc8092fa6..00d76f7c05 100644 --- a/thirdparty/libpng/pngerror.c +++ b/thirdparty/libpng/pngerror.c @@ -1,8 +1,8 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.6.15 [November 20, 2014] - * Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -26,7 +26,7 @@ static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr, #ifdef PNG_WARNINGS_SUPPORTED static void /* PRIVATE */ png_default_warning PNGARG((png_const_structrp png_ptr, - png_const_charp warning_message)); + png_const_charp warning_message)); #endif /* WARNINGS */ /* This function is called whenever there is a fatal error. This function @@ -37,7 +37,7 @@ png_default_warning PNGARG((png_const_structrp png_ptr, #ifdef PNG_ERROR_TEXT_SUPPORTED PNG_FUNCTION(void,PNGAPI png_error,(png_const_structrp png_ptr, png_const_charp error_message), - PNG_NORETURN) + PNG_NORETURN) { #ifdef PNG_ERROR_NUMBERS_SUPPORTED char msg[16]; @@ -65,18 +65,18 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message), else error_message += offset; - } + } - else - { - if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0) + else { - msg[0] = '0'; - msg[1] = '\0'; - error_message = msg; + if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0) + { + msg[0] = '0'; + msg[1] = '\0'; + error_message = msg; + } } - } - } + } } #endif if (png_ptr != NULL && png_ptr->error_fn != NULL) @@ -110,7 +110,7 @@ png_err,(png_const_structrp png_ptr),PNG_NORETURN) */ size_t png_safecat(png_charp buffer, size_t bufsize, size_t pos, - png_const_charp string) + png_const_charp string) { if (buffer != NULL && pos < bufsize) { @@ -131,7 +131,7 @@ png_safecat(png_charp buffer, size_t bufsize, size_t pos, */ png_charp png_format_number(png_const_charp start, png_charp end, int format, - png_alloc_size_t number) + png_alloc_size_t number) { int count = 0; /* number of digits output */ int mincount = 1; /* minimum number required */ @@ -233,7 +233,7 @@ png_warning(png_const_structrp png_ptr, png_const_charp warning_message) } if (png_ptr != NULL && png_ptr->warning_fn != NULL) (*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr), - warning_message + offset); + warning_message + offset); else png_default_warning(png_ptr, warning_message + offset); } @@ -245,7 +245,7 @@ png_warning(png_const_structrp png_ptr, png_const_charp warning_message) */ void png_warning_parameter(png_warning_parameters p, int number, - png_const_charp string) + png_const_charp string) { if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT) (void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string); @@ -253,7 +253,7 @@ png_warning_parameter(png_warning_parameters p, int number, void png_warning_parameter_unsigned(png_warning_parameters p, int number, int format, - png_alloc_size_t value) + png_alloc_size_t value) { char buffer[PNG_NUMBER_BUFFER_SIZE]; png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value)); @@ -261,7 +261,7 @@ png_warning_parameter_unsigned(png_warning_parameters p, int number, int format, void png_warning_parameter_signed(png_warning_parameters p, int number, int format, - png_int_32 value) + png_int_32 value) { png_alloc_size_t u; png_charp str; @@ -282,7 +282,7 @@ png_warning_parameter_signed(png_warning_parameters p, int number, int format, void png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p, - png_const_charp message) + png_const_charp message) { /* The internal buffer is just 192 bytes - enough for all our messages, * overflow doesn't happen because this code checks! If someone figures @@ -391,10 +391,10 @@ png_benign_error(png_const_structrp png_ptr, png_const_charp error_message) void /* PRIVATE */ png_app_warning(png_const_structrp png_ptr, png_const_charp error_message) { - if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0) - png_warning(png_ptr, error_message); - else - png_error(png_ptr, error_message); + if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0) + png_warning(png_ptr, error_message); + else + png_error(png_ptr, error_message); # ifndef PNG_ERROR_TEXT_SUPPORTED PNG_UNUSED(error_message) @@ -404,10 +404,10 @@ png_app_warning(png_const_structrp png_ptr, png_const_charp error_message) void /* PRIVATE */ png_app_error(png_const_structrp png_ptr, png_const_charp error_message) { - if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0) - png_warning(png_ptr, error_message); - else - png_error(png_ptr, error_message); + if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0) + png_warning(png_ptr, error_message); + else + png_error(png_ptr, error_message); # ifndef PNG_ERROR_TEXT_SUPPORTED PNG_UNUSED(error_message) @@ -478,7 +478,7 @@ png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp #if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED) PNG_FUNCTION(void,PNGAPI png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message), - PNG_NORETURN) + PNG_NORETURN) { char msg[18+PNG_MAX_ERROR_TEXT]; if (png_ptr == NULL) @@ -573,7 +573,7 @@ png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN) { # define fixed_message "fixed point overflow in " # define fixed_message_ln ((sizeof fixed_message)-1) - int iin; + unsigned int iin; char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT]; memcpy(msg, fixed_message, fixed_message_ln); iin = 0; @@ -620,7 +620,7 @@ png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn, else { png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *, - png_malloc_warn(png_ptr, jmp_buf_size)); + png_malloc_warn(png_ptr, jmp_buf_size)); if (png_ptr->jmp_buf_ptr == NULL) return NULL; /* new NULL return on OOM */ @@ -709,7 +709,7 @@ png_free_jmpbuf(png_structrp png_ptr) */ static PNG_FUNCTION(void /* PRIVATE */, png_default_error,(png_const_structrp png_ptr, png_const_charp error_message), - PNG_NORETURN) + PNG_NORETURN) { #ifdef PNG_CONSOLE_IO_SUPPORTED #ifdef PNG_ERROR_NUMBERS_SUPPORTED @@ -883,7 +883,7 @@ png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode) */ PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message), - PNG_NORETURN) + PNG_NORETURN) { const png_const_structrp png_ptr = png_nonconst_ptr; png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr); @@ -906,7 +906,7 @@ png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message), /* Missing longjmp buffer, the following is to help debugging: */ { size_t pos = png_safecat(image->message, (sizeof image->message), 0, - "bad longjmp: "); + "bad longjmp: "); png_safecat(image->message, (sizeof image->message), pos, error_message); } diff --git a/thirdparty/libpng/pngget.c b/thirdparty/libpng/pngget.c index 14fc7be520..141c393330 100644 --- a/thirdparty/libpng/pngget.c +++ b/thirdparty/libpng/pngget.c @@ -1,8 +1,8 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.6.17 [March 26, 2015] - * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -338,7 +338,7 @@ ppi_from_ppm(png_uint_32 ppm) png_fixed_point result; if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127, 5000) != 0) - return result; + return (png_uint_32)result; /* Overflow. */ return 0; @@ -486,7 +486,7 @@ png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr) #ifdef PNG_bKGD_SUPPORTED png_uint_32 PNGAPI png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, - png_color_16p *background) + png_color_16p *background) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0 && @@ -526,28 +526,28 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr, if (white_x != NULL) *white_x = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.whitex, "cHRM white X"); + info_ptr->colorspace.end_points_xy.whitex, "cHRM white X"); if (white_y != NULL) *white_y = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y"); + info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y"); if (red_x != NULL) *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx, - "cHRM red X"); + "cHRM red X"); if (red_y != NULL) *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy, - "cHRM red Y"); + "cHRM red Y"); if (green_x != NULL) *green_x = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.greenx, "cHRM green X"); + info_ptr->colorspace.end_points_xy.greenx, "cHRM green X"); if (green_y != NULL) *green_y = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y"); + info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y"); if (blue_x != NULL) *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex, - "cHRM blue X"); + "cHRM blue X"); if (blue_y != NULL) *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey, - "cHRM blue Y"); + "cHRM blue Y"); return (PNG_INFO_cHRM); } @@ -556,42 +556,42 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 PNGAPI png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr, - double *red_X, double *red_Y, double *red_Z, double *green_X, - double *green_Y, double *green_Z, double *blue_X, double *blue_Y, - double *blue_Z) + double *red_X, double *red_Y, double *red_Z, double *green_X, + double *green_Y, double *green_Z, double *blue_X, double *blue_Y, + double *blue_Z) { if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) { png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)"); if (red_X != NULL) *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X, - "cHRM red X"); + "cHRM red X"); if (red_Y != NULL) *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y, - "cHRM red Y"); + "cHRM red Y"); if (red_Z != NULL) *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z, - "cHRM red Z"); + "cHRM red Z"); if (green_X != NULL) *green_X = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X"); + info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X"); if (green_Y != NULL) *green_Y = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y"); + info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y"); if (green_Z != NULL) *green_Z = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z"); + info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z"); if (blue_X != NULL) *blue_X = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X"); + info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X"); if (blue_Y != NULL) *blue_Y = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y"); + info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y"); if (blue_Z != NULL) *blue_Z = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z"); + info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z"); return (PNG_INFO_cHRM); } @@ -681,8 +681,8 @@ png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, png_debug1(1, "in %s retrieval function", "gAMA"); if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && - file_gamma != NULL) + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && + file_gamma != NULL) { *file_gamma = info_ptr->colorspace.gamma; return (PNG_INFO_gAMA); @@ -704,7 +704,7 @@ png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr, file_gamma != NULL) { *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma, - "png_get_gAMA"); + "png_get_gAMA"); return (PNG_INFO_gAMA); } @@ -901,7 +901,7 @@ png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, */ *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width"); *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height), - "sCAL height"); + "sCAL height"); return (PNG_INFO_sCAL); } diff --git a/thirdparty/libpng/pnglibconf.h b/thirdparty/libpng/pnglibconf.h index 3e70aa1170..ba7805ff59 100644 --- a/thirdparty/libpng/pnglibconf.h +++ b/thirdparty/libpng/pnglibconf.h @@ -1,8 +1,8 @@ -/* libpng 1.6.23 STANDARD API DEFINITION */ +/* libpng 1.6.26 STANDARD API DEFINITION */ /* pnglibconf.h - library build configuration */ -/* Libpng version 1.6.23 - June 9, 2016 */ +/* Libpng version 1.6.26 - October 20, 2016 */ /* Copyright (c) 1998-2015 Glenn Randers-Pehrson */ diff --git a/thirdparty/libpng/pngmem.c b/thirdparty/libpng/pngmem.c index 7bcfd00507..ff3ef7e88c 100644 --- a/thirdparty/libpng/pngmem.c +++ b/thirdparty/libpng/pngmem.c @@ -1,8 +1,8 @@ /* pngmem.c - stub functions for memory allocation * - * Last changed in libpng 1.6.15 [November 20, 2014] - * Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -66,7 +66,7 @@ png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) */ PNG_FUNCTION(png_voidp /* PRIVATE */, png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size), - PNG_ALLOCATED) + PNG_ALLOCATED) { /* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS * allocators have also been removed in 1.6.0, so any 16-bit system now has @@ -107,9 +107,9 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size), */ static png_voidp png_malloc_array_checked(png_const_structrp png_ptr, int nelements, - size_t element_size) + size_t element_size) { - png_alloc_size_t req = nelements; /* known to be > 0 */ + png_alloc_size_t req = (png_alloc_size_t)nelements; /* known to be > 0 */ if (req <= PNG_SIZE_MAX/element_size) return png_malloc_base(png_ptr, req * element_size); @@ -120,7 +120,7 @@ png_malloc_array_checked(png_const_structrp png_ptr, int nelements, PNG_FUNCTION(png_voidp /* PRIVATE */, png_malloc_array,(png_const_structrp png_ptr, int nelements, - size_t element_size),PNG_ALLOCATED) + size_t element_size),PNG_ALLOCATED) { if (nelements <= 0 || element_size == 0) png_error(png_ptr, "internal error: array alloc"); @@ -130,7 +130,7 @@ png_malloc_array,(png_const_structrp png_ptr, int nelements, PNG_FUNCTION(png_voidp /* PRIVATE */, png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array, - int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED) + int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED) { /* These are internal errors: */ if (add_elements <= 0 || element_size == 0 || old_elements < 0 || @@ -143,7 +143,7 @@ png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array, if (add_elements <= INT_MAX - old_elements) { png_voidp new_array = png_malloc_array_checked(png_ptr, - old_elements+add_elements, element_size); + old_elements+add_elements, element_size); if (new_array != NULL) { @@ -154,7 +154,7 @@ png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array, memcpy(new_array, old_array, element_size*(unsigned)old_elements); memset((char*)new_array + element_size*(unsigned)old_elements, 0, - element_size*(unsigned)add_elements); + element_size*(unsigned)add_elements); return new_array; } @@ -187,7 +187,7 @@ png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) #ifdef PNG_USER_MEM_SUPPORTED PNG_FUNCTION(png_voidp,PNGAPI png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size), - PNG_ALLOCATED PNG_DEPRECATED) + PNG_ALLOCATED PNG_DEPRECATED) { png_voidp ret; @@ -210,7 +210,7 @@ png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size), */ PNG_FUNCTION(png_voidp,PNGAPI png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size), - PNG_ALLOCATED) + PNG_ALLOCATED) { if (png_ptr != NULL) { diff --git a/thirdparty/libpng/pngpread.c b/thirdparty/libpng/pngpread.c index ca300e7f16..650ba1e232 100644 --- a/thirdparty/libpng/pngpread.c +++ b/thirdparty/libpng/pngpread.c @@ -1,7 +1,7 @@ /* pngpread.c - read a png file in push mode * - * Last changed in libpng 1.6.23 [June 9, 2016] + * Last changed in libpng 1.6.24 [August 4, 2016] * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -77,11 +77,11 @@ png_process_data_pause(png_structrp png_ptr, int save) png_uint_32 PNGAPI png_process_data_skip(png_structrp png_ptr) { - /* TODO: Deprecate and remove this API. - * Somewhere the implementation of this seems to have been lost, - * or abandoned. It was only to support some internal back-door access - * to png_struct) in libpng-1.4.x. - */ +/* TODO: Deprecate and remove this API. + * Somewhere the implementation of this seems to have been lost, + * or abandoned. It was only to support some internal back-door access + * to png_struct) in libpng-1.4.x. + */ png_app_warning(png_ptr, "png_process_data_skip is not implemented in any current version of libpng"); return 0; @@ -410,7 +410,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) { PNG_PUSH_SAVE_BUFFER_IF_FULL png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, - PNG_HANDLE_CHUNK_AS_DEFAULT); + PNG_HANDLE_CHUNK_AS_DEFAULT); } png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; @@ -521,7 +521,7 @@ png_push_save_buffer(png_structrp png_ptr) void /* PRIVATE */ png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer, - png_size_t buffer_length) + png_size_t buffer_length) { png_ptr->current_buffer = buffer; png_ptr->current_buffer_size = buffer_length; @@ -624,7 +624,7 @@ png_push_read_IDAT(png_structrp png_ptr) void /* PRIVATE */ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer, - png_size_t buffer_length) + png_size_t buffer_length) { /* The caller checks for a non-zero buffer length. */ if (!(buffer_length > 0) || buffer == NULL) @@ -684,7 +684,12 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer, png_warning(png_ptr, "Truncated compressed data in IDAT"); else - png_error(png_ptr, "Decompression error in IDAT"); + { + if (ret == Z_DATA_ERROR) + png_benign_error(png_ptr, "IDAT: ADLER32 checksum mismatch"); + else + png_error(png_ptr, "Decompression error in IDAT"); + } /* Skip the check on unprocessed input */ return; @@ -782,7 +787,7 @@ png_push_process_row(png_structrp png_ptr) { if (png_ptr->pass < 6) png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, - png_ptr->transformations); + png_ptr->transformations); switch (png_ptr->pass) { @@ -1044,7 +1049,7 @@ png_push_have_row(png_structrp png_ptr, png_bytep row) { if (png_ptr->row_fn != NULL) (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number, - (int)png_ptr->pass); + (int)png_ptr->pass); } #ifdef PNG_READ_INTERLACING_SUPPORTED diff --git a/thirdparty/libpng/pngpriv.h b/thirdparty/libpng/pngpriv.h index 9338df3144..ed61165b2d 100644 --- a/thirdparty/libpng/pngpriv.h +++ b/thirdparty/libpng/pngpriv.h @@ -1,7 +1,7 @@ /* pngpriv.h - private declarations for use inside libpng * - * Last changed in libpng 1.6.22 [May 26, 2016] + * Last changed in libpng 1.6.26 [October 20, 2016] * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -182,6 +182,35 @@ # endif #endif /* PNG_ARM_NEON_OPT > 0 */ +#ifndef PNG_MIPS_MSA_OPT +# if defined(__mips_msa) && (__mips_isa_rev >= 5) && defined(PNG_ALIGNED_MEMORY_SUPPORTED) +# define PNG_MIPS_MSA_OPT 2 +# else +# define PNG_MIPS_MSA_OPT 0 +# endif +#endif + +#if PNG_MIPS_MSA_OPT > 0 +# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_msa +# ifndef PNG_MIPS_MSA_IMPLEMENTATION +# if defined(__mips_msa) +# if defined(__clang__) +# elif defined(__GNUC__) +# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) +# define PNG_MIPS_MSA_IMPLEMENTATION 2 +# endif /* no GNUC support */ +# endif /* __GNUC__ */ +# else /* !defined __mips_msa */ +# define PNG_MIPS_MSA_IMPLEMENTATION 2 +# endif /* __mips_msa */ +# endif /* !PNG_MIPS_MSA_IMPLEMENTATION */ + +# ifndef PNG_MIPS_MSA_IMPLEMENTATION +# define PNG_MIPS_MSA_IMPLEMENTATION 1 +# endif +#endif /* PNG_MIPS_MSA_OPT > 0 */ + + /* Is this a build of a DLL where compilation of the object modules requires * different preprocessor settings to those required for a simple library? If * so PNG_BUILD_DLL must be set. @@ -420,10 +449,10 @@ # if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) - /* We need to check that <math.h> hasn't already been included earlier - * as it seems it doesn't agree with <fp.h>, yet we should really use - * <fp.h> if possible. - */ + /* We need to check that <math.h> hasn't already been included earlier + * as it seems it doesn't agree with <fp.h>, yet we should really use + * <fp.h> if possible. + */ # if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) # include <fp.h> # endif @@ -431,9 +460,9 @@ # include <math.h> # endif # if defined(_AMIGA) && defined(__SASC) && defined(_M68881) - /* Amiga SAS/C: We must include builtin FPU functions when compiling using - * MATH=68881 - */ + /* Amiga SAS/C: We must include builtin FPU functions when compiling using + * MATH=68881 + */ # include <m68881.h> # endif #endif @@ -504,7 +533,8 @@ /* This implicitly assumes alignment is always to a power of 2. */ #ifdef png_alignof # define png_isaligned(ptr, type)\ - ((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0) + (((type)((const char*)ptr-(const char*)0) & \ + (type)(png_alignof(type)-1)) == 0) #else # define png_isaligned(ptr, type) 0 #endif @@ -521,92 +551,92 @@ * are defined in png.h because they need to be visible to applications * that call png_set_unknown_chunk(). */ -/* #define PNG_HAVE_IHDR 0x01 (defined in png.h) */ -/* #define PNG_HAVE_PLTE 0x02 (defined in png.h) */ -#define PNG_HAVE_IDAT 0x04 -/* #define PNG_AFTER_IDAT 0x08 (defined in png.h) */ -#define PNG_HAVE_IEND 0x10 - /* 0x20 (unused) */ - /* 0x40 (unused) */ - /* 0x80 (unused) */ -#define PNG_HAVE_CHUNK_HEADER 0x100 -#define PNG_WROTE_tIME 0x200 -#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 -#define PNG_BACKGROUND_IS_GRAY 0x800 -#define PNG_HAVE_PNG_SIGNATURE 0x1000 -#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ - /* 0x4000 (unused) */ -#define PNG_IS_READ_STRUCT 0x8000 /* Else is a write struct */ +/* #define PNG_HAVE_IHDR 0x01U (defined in png.h) */ +/* #define PNG_HAVE_PLTE 0x02U (defined in png.h) */ +#define PNG_HAVE_IDAT 0x04U +/* #define PNG_AFTER_IDAT 0x08U (defined in png.h) */ +#define PNG_HAVE_IEND 0x10U + /* 0x20U (unused) */ + /* 0x40U (unused) */ + /* 0x80U (unused) */ +#define PNG_HAVE_CHUNK_HEADER 0x100U +#define PNG_WROTE_tIME 0x200U +#define PNG_WROTE_INFO_BEFORE_PLTE 0x400U +#define PNG_BACKGROUND_IS_GRAY 0x800U +#define PNG_HAVE_PNG_SIGNATURE 0x1000U +#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */ + /* 0x4000U (unused) */ +#define PNG_IS_READ_STRUCT 0x8000U /* Else is a write struct */ /* Flags for the transformations the PNG library does on the image data */ -#define PNG_BGR 0x0001 -#define PNG_INTERLACE 0x0002 -#define PNG_PACK 0x0004 -#define PNG_SHIFT 0x0008 -#define PNG_SWAP_BYTES 0x0010 -#define PNG_INVERT_MONO 0x0020 -#define PNG_QUANTIZE 0x0040 -#define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */ -#define PNG_BACKGROUND_EXPAND 0x0100 -#define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */ -#define PNG_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */ -#define PNG_RGBA 0x0800 -#define PNG_EXPAND 0x1000 -#define PNG_GAMMA 0x2000 -#define PNG_GRAY_TO_RGB 0x4000 -#define PNG_FILLER 0x8000 -#define PNG_PACKSWAP 0x10000 -#define PNG_SWAP_ALPHA 0x20000 -#define PNG_STRIP_ALPHA 0x40000 -#define PNG_INVERT_ALPHA 0x80000 -#define PNG_USER_TRANSFORM 0x100000 -#define PNG_RGB_TO_GRAY_ERR 0x200000 -#define PNG_RGB_TO_GRAY_WARN 0x400000 -#define PNG_RGB_TO_GRAY 0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */ -#define PNG_ENCODE_ALPHA 0x800000 /* Added to libpng-1.5.4 */ -#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */ -#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */ -#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */ - /* 0x8000000 unused */ - /* 0x10000000 unused */ - /* 0x20000000 unused */ - /* 0x40000000 unused */ +#define PNG_BGR 0x0001U +#define PNG_INTERLACE 0x0002U +#define PNG_PACK 0x0004U +#define PNG_SHIFT 0x0008U +#define PNG_SWAP_BYTES 0x0010U +#define PNG_INVERT_MONO 0x0020U +#define PNG_QUANTIZE 0x0040U +#define PNG_COMPOSE 0x0080U /* Was PNG_BACKGROUND */ +#define PNG_BACKGROUND_EXPAND 0x0100U +#define PNG_EXPAND_16 0x0200U /* Added to libpng 1.5.2 */ +#define PNG_16_TO_8 0x0400U /* Becomes 'chop' in 1.5.4 */ +#define PNG_RGBA 0x0800U +#define PNG_EXPAND 0x1000U +#define PNG_GAMMA 0x2000U +#define PNG_GRAY_TO_RGB 0x4000U +#define PNG_FILLER 0x8000U +#define PNG_PACKSWAP 0x10000U +#define PNG_SWAP_ALPHA 0x20000U +#define PNG_STRIP_ALPHA 0x40000U +#define PNG_INVERT_ALPHA 0x80000U +#define PNG_USER_TRANSFORM 0x100000U +#define PNG_RGB_TO_GRAY_ERR 0x200000U +#define PNG_RGB_TO_GRAY_WARN 0x400000U +#define PNG_RGB_TO_GRAY 0x600000U /* two bits, RGB_TO_GRAY_ERR|WARN */ +#define PNG_ENCODE_ALPHA 0x800000U /* Added to libpng-1.5.4 */ +#define PNG_ADD_ALPHA 0x1000000U /* Added to libpng-1.2.7 */ +#define PNG_EXPAND_tRNS 0x2000000U /* Added to libpng-1.2.9 */ +#define PNG_SCALE_16_TO_8 0x4000000U /* Added to libpng-1.5.4 */ + /* 0x8000000U unused */ + /* 0x10000000U unused */ + /* 0x20000000U unused */ + /* 0x40000000U unused */ /* Flags for png_create_struct */ -#define PNG_STRUCT_PNG 0x0001 -#define PNG_STRUCT_INFO 0x0002 +#define PNG_STRUCT_PNG 0x0001U +#define PNG_STRUCT_INFO 0x0002U /* Flags for the png_ptr->flags rather than declaring a byte for each one */ -#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 -#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002 /* Added to libpng-1.6.0 */ - /* 0x0004 unused */ -#define PNG_FLAG_ZSTREAM_ENDED 0x0008 /* Added to libpng-1.6.0 */ - /* 0x0010 unused */ - /* 0x0020 unused */ -#define PNG_FLAG_ROW_INIT 0x0040 -#define PNG_FLAG_FILLER_AFTER 0x0080 -#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 -#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 -#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 -#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 -#define PNG_FLAG_ASSUME_sRGB 0x1000 /* Added to libpng-1.5.4 */ -#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000 /* Added to libpng-1.5.4 */ -#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000 /* Added to libpng-1.5.4 */ -/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000 */ -/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000 */ -#define PNG_FLAG_LIBRARY_MISMATCH 0x20000 -#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000 -#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000 -#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000 /* Added to libpng-1.4.0 */ -#define PNG_FLAG_APP_WARNINGS_WARN 0x200000 /* Added to libpng-1.6.0 */ -#define PNG_FLAG_APP_ERRORS_WARN 0x400000 /* Added to libpng-1.6.0 */ - /* 0x800000 unused */ - /* 0x1000000 unused */ - /* 0x2000000 unused */ - /* 0x4000000 unused */ - /* 0x8000000 unused */ - /* 0x10000000 unused */ - /* 0x20000000 unused */ - /* 0x40000000 unused */ +#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001U +#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002U /* Added to libpng-1.6.0 */ + /* 0x0004U unused */ +#define PNG_FLAG_ZSTREAM_ENDED 0x0008U /* Added to libpng-1.6.0 */ + /* 0x0010U unused */ + /* 0x0020U unused */ +#define PNG_FLAG_ROW_INIT 0x0040U +#define PNG_FLAG_FILLER_AFTER 0x0080U +#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100U +#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200U +#define PNG_FLAG_CRC_CRITICAL_USE 0x0400U +#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800U +#define PNG_FLAG_ASSUME_sRGB 0x1000U /* Added to libpng-1.5.4 */ +#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000U /* Added to libpng-1.5.4 */ +#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000U /* Added to libpng-1.5.4 */ +/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000U */ +/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000U */ +#define PNG_FLAG_LIBRARY_MISMATCH 0x20000U +#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000U +#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000U +#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000U /* Added to libpng-1.4.0 */ +#define PNG_FLAG_APP_WARNINGS_WARN 0x200000U /* Added to libpng-1.6.0 */ +#define PNG_FLAG_APP_ERRORS_WARN 0x400000U /* Added to libpng-1.6.0 */ + /* 0x800000U unused */ + /* 0x1000000U unused */ + /* 0x2000000U unused */ + /* 0x4000000U unused */ + /* 0x8000000U unused */ + /* 0x10000000U unused */ + /* 0x20000000U unused */ + /* 0x40000000U unused */ #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ PNG_FLAG_CRC_ANCILLARY_NOWARN) @@ -640,6 +670,24 @@ ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \ (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) ) +/* This returns the number of trailing bits in the last byte of a row, 0 if the + * last byte is completely full of pixels. It is, in principle, (pixel_bits x + * width) % 8, but that would overflow for large 'width'. The second macro is + * the same except that it returns the number of unused bits in the last byte; + * (8-TRAILBITS), but 0 when TRAILBITS is 0. + * + * NOTE: these macros are intended to be self-evidently correct and never + * overflow on the assumption that pixel_bits is in the range 0..255. The + * arguments are evaluated only once and they can be signed (e.g. as a result of + * the integral promotions). The result of the expression always has type + * (png_uint_32), however the compiler always knows it is in the range 0..7. + */ +#define PNG_TRAILBITS(pixel_bits, width) \ + (((pixel_bits) * ((width) % (png_uint_32)8)) % 8) + +#define PNG_PADBITS(pixel_bits, width) \ + ((8 - PNG_TRAILBITS(pixel_bits, width)) % 8) + /* PNG_OUT_OF_RANGE returns true if value is outside the range * ideal-delta..ideal+delta. Each argument is evaluated twice. * "ideal" and "delta" should be constants, normally simple @@ -1025,7 +1073,7 @@ PNG_INTERNAL_FUNCTION(void,png_write_sBIT,(png_structrp png_ptr, #ifdef PNG_WRITE_cHRM_SUPPORTED PNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr, const png_xy *xy), PNG_EMPTY); - /* The xy value must have been previously validated */ + /* The xy value must have been previously validated */ #endif #ifdef PNG_WRITE_sRGB_SUPPORTED @@ -1174,6 +1222,7 @@ PNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info, PNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY); +#if PNG_ARM_NEON_OPT > 0 PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop @@ -1188,6 +1237,24 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +#endif + +#if PNG_MIPS_MSA_OPT > 0 +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_msa,(png_row_infop row_info, + png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +#endif /* Choose the best filter to use and filter the row data */ PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr, @@ -1215,7 +1282,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr), /* Initialize the row buffers, etc. */ PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY); -#if PNG_ZLIB_VERNUM >= 0x1240 +#if ZLIB_VERNUM >= 0x1240 PNG_INTERNAL_FUNCTION(int,png_zlib_inflate,(png_structrp png_ptr, int flush), PNG_EMPTY); # define PNG_INFLATE(pp, flush) png_zlib_inflate(pp, flush) @@ -1413,7 +1480,7 @@ PNG_INTERNAL_FUNCTION(void,png_push_have_info,(png_structrp png_ptr, PNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr, png_inforp info_ptr),PNG_EMPTY); PNG_INTERNAL_FUNCTION(void,png_push_have_row,(png_structrp png_ptr, - png_bytep row),PNG_EMPTY); + png_bytep row),PNG_EMPTY); PNG_INTERNAL_FUNCTION(void,png_push_read_end,(png_structrp png_ptr, png_inforp info_ptr),PNG_EMPTY); PNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr, @@ -1452,13 +1519,13 @@ PNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr, PNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr, png_inforp info_ptr), PNG_EMPTY); - /* Synchronize the info 'valid' flags with the colorspace */ + /* Synchronize the info 'valid' flags with the colorspace */ PNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr, png_inforp info_ptr), PNG_EMPTY); - /* Copy the png_struct colorspace to the info_struct and call the above to - * synchronize the flags. Checks for NULL info_ptr and does nothing. - */ + /* Copy the png_struct colorspace to the info_struct and call the above to + * synchronize the flags. Checks for NULL info_ptr and does nothing. + */ #endif /* Added at libpng version 1.4.0 */ @@ -1492,9 +1559,11 @@ PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr, /* The 'name' is used for information only */ /* Routines for checking parts of an ICC profile. */ +#ifdef PNG_READ_iCCP_SUPPORTED PNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr, png_colorspacerp colorspace, png_const_charp name, png_uint_32 profile_length), PNG_EMPTY); +#endif /* READ_iCCP */ PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr, png_colorspacerp colorspace, png_const_charp name, png_uint_32 profile_length, @@ -1913,10 +1982,17 @@ PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr, * the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in * CFLAGS in place of CPPFLAGS *and* uses symbol prefixing. */ +# if PNG_ARM_NEON_OPT > 0 PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon, (png_structp png_ptr, unsigned int bpp), PNG_EMPTY); #endif +#if PNG_MIPS_MSA_OPT > 0 +PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa, + (png_structp png_ptr, unsigned int bpp), PNG_EMPTY); +#endif +#endif + PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr, png_const_charp key, png_bytep new_key), PNG_EMPTY); diff --git a/thirdparty/libpng/pngread.c b/thirdparty/libpng/pngread.c index 0ff6238023..106a80588c 100644 --- a/thirdparty/libpng/pngread.c +++ b/thirdparty/libpng/pngread.c @@ -1,7 +1,7 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.6.23 [June 9, 2016] + * Last changed in libpng 1.6.26 [October 20, 2016] * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -28,10 +28,10 @@ png_create_read_struct,(png_const_charp user_png_ver, png_voidp error_ptr, { #ifndef PNG_USER_MEM_SUPPORTED png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr, - error_fn, warn_fn, NULL, NULL, NULL); + error_fn, warn_fn, NULL, NULL, NULL); #else return png_create_read_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, NULL, NULL, NULL); + warn_fn, NULL, NULL, NULL); } /* Alternate create PNG structure for reading, and allocate any memory @@ -43,7 +43,7 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) { png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr, - error_fn, warn_fn, mem_ptr, malloc_fn, free_fn); + error_fn, warn_fn, mem_ptr, malloc_fn, free_fn); #endif /* USER_MEM */ if (png_ptr != NULL) @@ -252,7 +252,7 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr) else png_handle_unknown(png_ptr, info_ptr, length, - PNG_HANDLE_CHUNK_AS_DEFAULT); + PNG_HANDLE_CHUNK_AS_DEFAULT); } } #endif /* SEQUENTIAL_READ */ @@ -279,7 +279,7 @@ png_read_update_info(png_structrp png_ptr, png_inforp info_ptr) /* New in 1.6.0 this avoids the bug of doing the initializations twice */ else png_app_error(png_ptr, - "png_read_update_info/png_start_read_image: duplicate call"); + "png_read_update_info/png_start_read_image: duplicate call"); } } @@ -302,7 +302,7 @@ png_start_read_image(png_structrp png_ptr) /* New in 1.6.0 this avoids the bug of doing the initializations twice */ else png_app_error(png_ptr, - "png_start_read_image/png_read_update_info: duplicate call"); + "png_start_read_image/png_read_update_info: duplicate call"); } } #endif /* SEQUENTIAL_READ */ @@ -359,9 +359,9 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1); - png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3); - png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5); + png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1); + png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3); + png_uint_32 s2 = (png_uint_32)(*(rp + 4) << 8) | *(rp + 5); png_uint_32 red = (s0 + s1 + 65536) & 0xffff; png_uint_32 blue = (s2 + s1 + 65536) & 0xffff; *(rp ) = (png_byte)((red >> 8) & 0xff); @@ -540,7 +540,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) { if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST) png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1, - png_ptr->prev_row + 1, png_ptr->row_buf[0]); + png_ptr->prev_row + 1, png_ptr->row_buf[0]); else png_error(png_ptr, "bad adaptive filter value"); } @@ -584,7 +584,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) { if (png_ptr->pass < 6) png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, - png_ptr->transformations); + png_ptr->transformations); if (dsp_row != NULL) png_combine_row(png_ptr, dsp_row, 1/*display*/); @@ -719,7 +719,7 @@ png_read_image(png_structrp png_ptr, png_bytepp image) * but the caller should do it! */ png_warning(png_ptr, "Interlace handling should be turned on when " - "using png_read_image"); + "using png_read_image"); /* Make sure this is set correctly */ png_ptr->num_rows = png_ptr->height; } @@ -779,8 +779,8 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED /* Report invalid palette index; added at libng-1.5.10 */ if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - png_ptr->num_palette_max > png_ptr->num_palette) - png_benign_error(png_ptr, "Read palette index exceeding num_palette"); + png_ptr->num_palette_max > png_ptr->num_palette) + png_benign_error(png_ptr, "Read palette index exceeding num_palette"); #endif do @@ -919,7 +919,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) else png_handle_unknown(png_ptr, info_ptr, length, - PNG_HANDLE_CHUNK_AS_DEFAULT); + PNG_HANDLE_CHUNK_AS_DEFAULT); } while ((png_ptr->mode & PNG_HAVE_IEND) == 0); } #endif /* SEQUENTIAL_READ */ @@ -1030,8 +1030,7 @@ png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn) #ifdef PNG_INFO_IMAGE_SUPPORTED void PNGAPI png_read_png(png_structrp png_ptr, png_inforp info_ptr, - int transforms, - voidp params) + int transforms, voidp params) { if (png_ptr == NULL || info_ptr == NULL) return; @@ -1307,7 +1306,7 @@ png_image_read_init(png_imagep image) if (info_ptr != NULL) { png_controlp control = png_voidcast(png_controlp, - png_malloc_warn(png_ptr, (sizeof *control))); + png_malloc_warn(png_ptr, (sizeof *control))); if (control != NULL) { @@ -1394,7 +1393,9 @@ png_image_read_header(png_voidp argument) png_structrp png_ptr = image->opaque->png_ptr; png_inforp info_ptr = image->opaque->info_ptr; +#ifdef PNG_BENIGN_ERRORS_SUPPORTED png_set_benign_errors(png_ptr, 1/*warn*/); +#endif png_read_info(png_ptr, info_ptr); /* Do this the fast way; just read directly out of png_struct. */ @@ -1432,7 +1433,7 @@ png_image_read_header(png_voidp argument) break; case PNG_COLOR_TYPE_PALETTE: - cmap_entries = png_ptr->num_palette; + cmap_entries = (png_uint_32)png_ptr->num_palette; break; default: @@ -1470,12 +1471,12 @@ png_image_begin_read_from_stdio(png_imagep image, FILE* file) else return png_image_error(image, - "png_image_begin_read_from_stdio: invalid argument"); + "png_image_begin_read_from_stdio: invalid argument"); } else if (image != NULL) return png_image_error(image, - "png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION"); + "png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION"); return 0; } @@ -1508,12 +1509,12 @@ png_image_begin_read_from_file(png_imagep image, const char *file_name) else return png_image_error(image, - "png_image_begin_read_from_file: invalid argument"); + "png_image_begin_read_from_file: invalid argument"); } else if (image != NULL) return png_image_error(image, - "png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION"); + "png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION"); return 0; } @@ -1550,7 +1551,7 @@ png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need) } int PNGAPI png_image_begin_read_from_memory(png_imagep image, - png_const_voidp memory, png_size_t size) + png_const_voidp memory, png_size_t size) { if (image != NULL && image->version == PNG_IMAGE_VERSION) { @@ -1573,12 +1574,12 @@ int PNGAPI png_image_begin_read_from_memory(png_imagep image, else return png_image_error(image, - "png_image_begin_read_from_memory: invalid argument"); + "png_image_begin_read_from_memory: invalid argument"); } else if (image != NULL) return png_image_error(image, - "png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION"); + "png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION"); return 0; } @@ -1624,12 +1625,12 @@ png_image_skip_unused_chunks(png_structrp png_ptr) * IHDR, PLTE, tRNS, IDAT, and IEND chunks. */ png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_NEVER, - NULL, -1); + NULL, -1); /* But do not ignore image data handling chunks */ png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT, - chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5); - } + chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5); + } } # define PNG_SKIP_CHUNKS(p) png_image_skip_unused_chunks(p) @@ -1696,7 +1697,7 @@ decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding) #ifdef __GNUC__ default: png_error(display->image->opaque->png_ptr, - "unexpected encoding (internal error)"); + "unexpected encoding (internal error)"); #endif } @@ -1705,8 +1706,8 @@ decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding) static png_uint_32 png_colormap_compose(png_image_read_control *display, - png_uint_32 foreground, int foreground_encoding, png_uint_32 alpha, - png_uint_32 background, int encoding) + png_uint_32 foreground, int foreground_encoding, png_uint_32 alpha, + png_uint_32 background, int encoding) { /* The file value is composed on the background, the background has the given * encoding and so does the result, the file is encoded with P_FILE and the @@ -1742,14 +1743,14 @@ png_colormap_compose(png_image_read_control *display, */ static void png_create_colormap_entry(png_image_read_control *display, - png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue, - png_uint_32 alpha, int encoding) + png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue, + png_uint_32 alpha, int encoding) { png_imagep image = display->image; const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ? - P_LINEAR : P_sRGB; + P_LINEAR : P_sRGB; const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 && - (red != green || green != blue); + (red != green || green != blue); if (ip > 255) png_error(image->opaque->png_ptr, "color-map index out of range"); @@ -1967,7 +1968,7 @@ make_gray_file_colormap(png_image_read_control *display) for (i=0; i<256; ++i) png_create_colormap_entry(display, i, i, i, i, 255, P_FILE); - return i; + return (int)i; } static int @@ -1978,7 +1979,7 @@ make_gray_colormap(png_image_read_control *display) for (i=0; i<256; ++i) png_create_colormap_entry(display, i, i, i, i, 255, P_sRGB); - return i; + return (int)i; } #define PNG_GRAY_COLORMAP_ENTRIES 256 @@ -2029,10 +2030,10 @@ make_ga_colormap(png_image_read_control *display) for (g=0; g<6; ++g) png_create_colormap_entry(display, i++, g*51, g*51, g*51, a*51, - P_sRGB); + P_sRGB); } - return i; + return (int)i; } #define PNG_GA_COLORMAP_ENTRIES 256 @@ -2053,11 +2054,11 @@ make_rgb_colormap(png_image_read_control *display) for (b=0; b<6; ++b) png_create_colormap_entry(display, i++, r*51, g*51, b*51, 255, - P_sRGB); + P_sRGB); } } - return i; + return (int)i; } #define PNG_RGB_COLORMAP_ENTRIES 216 @@ -2105,7 +2106,7 @@ png_image_read_colormap(png_voidp argument) else if (display->background == NULL /* no way to remove it */) png_error(png_ptr, - "a background color must be supplied to remove alpha/transparency"); + "background color must be supplied to remove alpha/transparency"); /* Get a copy of the background color (this avoids repeating the checks * below.) The encoding is 8-bit sRGB or 16-bit linear, depending on the @@ -2200,7 +2201,7 @@ png_image_read_colormap(png_voidp argument) */ if (i != trans) png_create_colormap_entry(display, i, val, val, val, 255, - P_FILE/*8-bit with file gamma*/); + P_FILE/*8-bit with file gamma*/); /* Else this entry is transparent. The colors don't matter if * there is an alpha channel (back_alpha == 0), but it does no @@ -2212,7 +2213,7 @@ png_image_read_colormap(png_voidp argument) */ else png_create_colormap_entry(display, i, back_r, back_g, back_b, - back_alpha, output_encoding); + back_alpha, output_encoding); } /* We need libpng to preserve the original encoding. */ @@ -2250,7 +2251,7 @@ png_image_read_colormap(png_voidp argument) if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) png_error(png_ptr, "gray[16] color-map: too few entries"); - cmap_entries = make_gray_colormap(display); + cmap_entries = (unsigned int)make_gray_colormap(display); if (png_ptr->num_trans > 0) { @@ -2277,7 +2278,7 @@ png_image_read_colormap(png_voidp argument) * matches. */ png_create_colormap_entry(display, gray, back_g, back_g, - back_g, 65535, P_LINEAR); + back_g, 65535, P_LINEAR); } /* The background passed to libpng, however, must be the @@ -2291,8 +2292,8 @@ png_image_read_colormap(png_voidp argument) * doesn't. */ png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); output_processing = PNG_CMAP_NONE; break; @@ -2322,7 +2323,7 @@ png_image_read_colormap(png_voidp argument) * background color at full precision. */ png_create_colormap_entry(display, 254, back_r, back_g, back_b, - back_alpha, output_encoding); + back_alpha, output_encoding); } else @@ -2348,7 +2349,7 @@ png_image_read_colormap(png_voidp argument) if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) png_error(png_ptr, "gray+alpha color-map: too few entries"); - cmap_entries = make_ga_colormap(display); + cmap_entries = (unsigned int)make_ga_colormap(display); background_index = PNG_CMAP_GA_BACKGROUND; output_processing = PNG_CMAP_GA; @@ -2382,7 +2383,7 @@ png_image_read_colormap(png_voidp argument) if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) png_error(png_ptr, "gray-alpha color-map: too few entries"); - cmap_entries = make_gray_colormap(display); + cmap_entries = (unsigned int)make_gray_colormap(display); if (output_encoding == P_LINEAR) { @@ -2390,7 +2391,7 @@ png_image_read_colormap(png_voidp argument) /* And make sure the corresponding palette entry matches. */ png_create_colormap_entry(display, gray, back_g, back_g, - back_g, 65535, P_LINEAR); + back_g, 65535, P_LINEAR); } /* The background passed to libpng, however, must be the sRGB @@ -2400,8 +2401,8 @@ png_image_read_colormap(png_voidp argument) c.gray = c.red = c.green = c.blue = (png_uint_16)gray; png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); output_processing = PNG_CMAP_NONE; } @@ -2421,7 +2422,7 @@ png_image_read_colormap(png_voidp argument) { png_uint_32 gray = (i * 256 + 115) / 231; png_create_colormap_entry(display, i++, gray, gray, gray, - 255, P_sRGB); + 255, P_sRGB); } /* NOTE: this preserves the full precision of the application @@ -2430,13 +2431,13 @@ png_image_read_colormap(png_voidp argument) background_index = i; png_create_colormap_entry(display, i++, back_r, back_g, back_b, #ifdef __COVERITY__ - /* Coverity claims that output_encoding cannot be 2 (P_LINEAR) - * here. - */ 255U, + /* Coverity claims that output_encoding + * cannot be 2 (P_LINEAR) here. + */ 255U, #else - output_encoding == P_LINEAR ? 65535U : 255U, + output_encoding == P_LINEAR ? 65535U : 255U, #endif - output_encoding); + output_encoding); /* For non-opaque input composite on the sRGB background - this * requires inverting the encoding for each component. The input @@ -2474,9 +2475,9 @@ png_image_read_colormap(png_voidp argument) png_uint_32 gray = png_sRGB_table[g*51] * alpha; png_create_colormap_entry(display, i++, - PNG_sRGB_FROM_LINEAR(gray + back_rx), - PNG_sRGB_FROM_LINEAR(gray + back_gx), - PNG_sRGB_FROM_LINEAR(gray + back_bx), 255, P_sRGB); + PNG_sRGB_FROM_LINEAR(gray + back_rx), + PNG_sRGB_FROM_LINEAR(gray + back_gx), + PNG_sRGB_FROM_LINEAR(gray + back_bx), 255, P_sRGB); } } @@ -2502,7 +2503,7 @@ png_image_read_colormap(png_voidp argument) * png_set_tRNS_to_alpha before png_set_background_fixed. */ png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, -1, - -1); + -1); data_encoding = P_sRGB; /* The output will now be one or two 8-bit gray or gray+alpha @@ -2521,7 +2522,7 @@ png_image_read_colormap(png_voidp argument) if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) png_error(png_ptr, "rgb[ga] color-map: too few entries"); - cmap_entries = make_ga_colormap(display); + cmap_entries = (unsigned int)make_ga_colormap(display); background_index = PNG_CMAP_GA_BACKGROUND; output_processing = PNG_CMAP_GA; } @@ -2547,12 +2548,12 @@ png_image_read_colormap(png_voidp argument) png_ptr->num_trans > 0) && png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0) { - cmap_entries = make_gray_file_colormap(display); + cmap_entries = (unsigned int)make_gray_file_colormap(display); data_encoding = P_FILE; } else - cmap_entries = make_gray_colormap(display); + cmap_entries = (unsigned int)make_gray_colormap(display); /* But if the input has alpha or transparency it must be removed */ @@ -2578,13 +2579,13 @@ png_image_read_colormap(png_voidp argument) gray = png_sRGB_table[gray]; /* now P_LINEAR */ gray = PNG_DIV257(png_gamma_16bit_correct(gray, - png_ptr->colorspace.gamma)); /* now P_FILE */ + png_ptr->colorspace.gamma)); /* now P_FILE */ /* And make sure the corresponding palette entry contains * exactly the required sRGB value. */ png_create_colormap_entry(display, gray, back_g, back_g, - back_g, 0/*unused*/, output_encoding); + back_g, 0/*unused*/, output_encoding); } else if (output_encoding == P_LINEAR) @@ -2609,8 +2610,8 @@ png_image_read_colormap(png_voidp argument) */ expand_tRNS = 1; png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); } output_processing = PNG_CMAP_NONE; @@ -2640,11 +2641,11 @@ png_image_read_colormap(png_voidp argument) if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries) png_error(png_ptr, "rgb+alpha color-map: too few entries"); - cmap_entries = make_rgb_colormap(display); + cmap_entries = (unsigned int)make_rgb_colormap(display); /* Add a transparent entry. */ png_create_colormap_entry(display, cmap_entries, 255, 255, - 255, 0, P_sRGB); + 255, 0, P_sRGB); /* This is stored as the background index for the processing * algorithm. @@ -2665,7 +2666,7 @@ png_image_read_colormap(png_voidp argument) */ for (b=0; b<256; b = (b << 1) | 0x7f) png_create_colormap_entry(display, cmap_entries++, - r, g, b, 128, P_sRGB); + r, g, b, 128, P_sRGB); } } @@ -2689,10 +2690,10 @@ png_image_read_colormap(png_voidp argument) if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries) png_error(png_ptr, "rgb-alpha color-map: too few entries"); - cmap_entries = make_rgb_colormap(display); + cmap_entries = (unsigned int)make_rgb_colormap(display); png_create_colormap_entry(display, cmap_entries, back_r, - back_g, back_b, 0/*unused*/, output_encoding); + back_g, back_b, 0/*unused*/, output_encoding); if (output_encoding == P_LINEAR) { @@ -2714,9 +2715,9 @@ png_image_read_colormap(png_voidp argument) * index. */ if (memcmp((png_const_bytep)display->colormap + - sample_size * cmap_entries, - (png_const_bytep)display->colormap + - sample_size * PNG_RGB_INDEX(r,g,b), + sample_size * cmap_entries, + (png_const_bytep)display->colormap + + sample_size * PNG_RGB_INDEX(r,g,b), sample_size) != 0) { /* The background color must be added. */ @@ -2734,13 +2735,13 @@ png_image_read_colormap(png_voidp argument) */ for (b=0; b<256; b = (b << 1) | 0x7f) png_create_colormap_entry(display, cmap_entries++, - png_colormap_compose(display, r, P_sRGB, 128, - back_r, output_encoding), - png_colormap_compose(display, g, P_sRGB, 128, - back_g, output_encoding), - png_colormap_compose(display, b, P_sRGB, 128, - back_b, output_encoding), - 0/*unused*/, output_encoding); + png_colormap_compose(display, r, P_sRGB, 128, + back_r, output_encoding), + png_colormap_compose(display, g, P_sRGB, 128, + back_g, output_encoding), + png_colormap_compose(display, b, P_sRGB, 128, + back_b, output_encoding), + 0/*unused*/, output_encoding); } } @@ -2758,8 +2759,8 @@ png_image_read_colormap(png_voidp argument) c.blue = (png_uint_16)back_b; png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); output_processing = PNG_CMAP_RGB; } @@ -2774,7 +2775,7 @@ png_image_read_colormap(png_voidp argument) if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries) png_error(png_ptr, "rgb color-map: too few entries"); - cmap_entries = make_rgb_colormap(display); + cmap_entries = (unsigned int)make_rgb_colormap(display); output_processing = PNG_CMAP_RGB; } } @@ -2798,11 +2799,11 @@ png_image_read_colormap(png_voidp argument) output_processing = PNG_CMAP_NONE; data_encoding = P_FILE; /* Don't change from color-map indices */ - cmap_entries = png_ptr->num_palette; + cmap_entries = (unsigned int)png_ptr->num_palette; if (cmap_entries > 256) cmap_entries = 256; - if (cmap_entries > image->colormap_entries) + if (cmap_entries > (unsigned int)image->colormap_entries) png_error(png_ptr, "palette color-map: too few entries"); for (i=0; i < cmap_entries; ++i) @@ -2811,7 +2812,7 @@ png_image_read_colormap(png_voidp argument) { if (trans[i] == 0) png_create_colormap_entry(display, i, back_r, back_g, - back_b, 0, output_encoding); + back_b, 0, output_encoding); else { @@ -2819,22 +2820,22 @@ png_image_read_colormap(png_voidp argument) * on the sRGB color in 'back'. */ png_create_colormap_entry(display, i, - png_colormap_compose(display, colormap[i].red, P_FILE, - trans[i], back_r, output_encoding), - png_colormap_compose(display, colormap[i].green, P_FILE, - trans[i], back_g, output_encoding), - png_colormap_compose(display, colormap[i].blue, P_FILE, - trans[i], back_b, output_encoding), - output_encoding == P_LINEAR ? trans[i] * 257U : - trans[i], - output_encoding); + png_colormap_compose(display, colormap[i].red, + P_FILE, trans[i], back_r, output_encoding), + png_colormap_compose(display, colormap[i].green, + P_FILE, trans[i], back_g, output_encoding), + png_colormap_compose(display, colormap[i].blue, + P_FILE, trans[i], back_b, output_encoding), + output_encoding == P_LINEAR ? trans[i] * 257U : + trans[i], + output_encoding); } } else png_create_colormap_entry(display, i, colormap[i].red, - colormap[i].green, colormap[i].blue, - i < num_trans ? trans[i] : 255U, P_FILE/*8-bit*/); + colormap[i].green, colormap[i].blue, + i < num_trans ? trans[i] : 255U, P_FILE/*8-bit*/); } /* The PNG data may have indices packed in fewer than 8 bits, it @@ -2914,7 +2915,7 @@ png_image_read_colormap(png_voidp argument) png_error(png_ptr, "bad background index (internal error)"); } - display->colormap_processing = output_processing; + display->colormap_processing = (int)output_processing; return 1/*ok*/; } @@ -2924,7 +2925,7 @@ static int png_image_read_and_map(png_voidp argument) { png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); + argument); png_imagep image = display->image; png_structrp png_ptr = image->opaque->png_ptr; int passes; @@ -3061,7 +3062,7 @@ png_image_read_and_map(png_voidp argument) if (alpha >= 196) *outrow = PNG_RGB_INDEX(inrow[0], inrow[1], - inrow[2]); + inrow[2]); else if (alpha < 64) *outrow = PNG_CMAP_RGB_ALPHA_BACKGROUND; @@ -3113,7 +3114,7 @@ static int png_image_read_colormapped(png_voidp argument) { png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); + argument); png_imagep image = display->image; png_controlp control = image->opaque; png_structrp png_ptr = control->png_ptr; @@ -3223,14 +3224,14 @@ png_image_read_colormapped(png_voidp argument) else { - png_alloc_size_t row_bytes = display->row_bytes; + png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes; while (--passes >= 0) { png_uint_32 y = image->height; png_bytep row = png_voidcast(png_bytep, display->first_row); - while (y-- > 0) + for (; y > 0; --y) { png_read_row(png_ptr, row, NULL); row += row_bytes; @@ -3246,7 +3247,7 @@ static int png_image_read_composite(png_voidp argument) { png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); + argument); png_imagep image = display->image; png_structrp png_ptr = image->opaque->png_ptr; int passes; @@ -3373,7 +3374,7 @@ static int png_image_read_background(png_voidp argument) { png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); + argument); png_imagep image = display->image; png_structrp png_ptr = image->opaque->png_ptr; png_inforp info_ptr = image->opaque->info_ptr; @@ -3433,8 +3434,7 @@ png_image_read_background(png_voidp argument) for (pass = 0; pass < passes; ++pass) { - png_bytep row = png_voidcast(png_bytep, - display->first_row); + png_bytep row = png_voidcast(png_bytep, display->first_row); unsigned int startx, stepx, stepy; png_uint_32 y; @@ -3462,7 +3462,7 @@ png_image_read_background(png_voidp argument) for (; y<height; y += stepy) { png_bytep inrow = png_voidcast(png_bytep, - display->local_row); + display->local_row); png_bytep outrow = first_row + y * step_row; png_const_bytep end_row = outrow + width; @@ -3507,7 +3507,7 @@ png_image_read_background(png_voidp argument) for (; y<height; y += stepy) { png_bytep inrow = png_voidcast(png_bytep, - display->local_row); + display->local_row); png_bytep outrow = first_row + y * step_row; png_const_bytep end_row = outrow + width; @@ -3554,13 +3554,14 @@ png_image_read_background(png_voidp argument) */ { png_uint_16p first_row = png_voidcast(png_uint_16p, - display->first_row); + display->first_row); /* The division by two is safe because the caller passed in a * stride which was multiplied by 2 (below) to get row_bytes. */ ptrdiff_t step_row = display->row_bytes / 2; - int preserve_alpha = (image->format & PNG_FORMAT_FLAG_ALPHA) != 0; - unsigned int outchannels = 1+preserve_alpha; + unsigned int preserve_alpha = (image->format & + PNG_FORMAT_FLAG_ALPHA) != 0; + unsigned int outchannels = 1U+preserve_alpha; int swap_alpha = 0; # ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED @@ -3604,7 +3605,7 @@ png_image_read_background(png_voidp argument) /* Read the row, which is packed: */ png_read_row(png_ptr, png_voidcast(png_bytep, - display->local_row), NULL); + display->local_row), NULL); inrow = png_voidcast(png_const_uint_16p, display->local_row); /* Now do the pre-multiplication on each pixel in this row. @@ -3653,7 +3654,7 @@ static int png_image_read_direct(png_voidp argument) { png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); + argument); png_imagep image = display->image; png_structrp png_ptr = image->opaque->png_ptr; png_inforp info_ptr = image->opaque->info_ptr; @@ -3704,7 +3705,7 @@ png_image_read_direct(png_voidp argument) do_local_background = 1/*maybe*/; png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, - PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT); + PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT); } change &= ~PNG_FORMAT_FLAG_COLOR; @@ -3763,7 +3764,7 @@ png_image_read_direct(png_voidp argument) * final value. */ if (png_muldiv(>est, output_gamma, png_ptr->colorspace.gamma, - PNG_FP_1) != 0 && png_gamma_significant(gtest) == 0) + PNG_FP_1) != 0 && png_gamma_significant(gtest) == 0) do_local_background = 0; else if (mode == PNG_ALPHA_STANDARD) @@ -3826,8 +3827,8 @@ png_image_read_direct(png_voidp argument) * pixels. */ png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); } else /* compose on row: implemented below. */ @@ -4057,14 +4058,14 @@ png_image_read_direct(png_voidp argument) else { - png_alloc_size_t row_bytes = display->row_bytes; + png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes; while (--passes >= 0) { png_uint_32 y = image->height; png_bytep row = png_voidcast(png_bytep, display->first_row); - while (y-- > 0) + for (; y > 0; --y) { png_read_row(png_ptr, row, NULL); row += row_bytes; @@ -4077,7 +4078,7 @@ png_image_read_direct(png_voidp argument) int PNGAPI png_image_finish_read(png_imagep image, png_const_colorp background, - void *buffer, png_int_32 row_stride, void *colormap) + void *buffer, png_int_32 row_stride, void *colormap) { if (image != NULL && image->version == PNG_IMAGE_VERSION) { @@ -4087,7 +4088,13 @@ png_image_finish_read(png_imagep image, png_const_colorp background, */ const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format); - if (image->width <= 0x7FFFFFFFU/channels) /* no overflow */ + /* The following checks just the 'row_stride' calculation to ensure it + * fits in a signed 32-bit value. Because channels/components can be + * either 1 or 2 bytes in size the length of a row can still overflow 32 + * bits; this is just to verify that the 'row_stride' argument can be + * represented. + */ + if (image->width <= 0x7fffffffU/channels) /* no overflow */ { png_uint_32 check; const png_uint_32 png_row_stride = image->width * channels; @@ -4096,18 +4103,35 @@ png_image_finish_read(png_imagep image, png_const_colorp background, row_stride = (png_int_32)/*SAFE*/png_row_stride; if (row_stride < 0) - check = -row_stride; + check = (png_uint_32)(-row_stride); else - check = row_stride; + check = (png_uint_32)row_stride; + /* This verifies 'check', the absolute value of the actual stride + * passed in and detects overflow in the application calculation (i.e. + * if the app did actually pass in a non-zero 'row_stride'. + */ if (image->opaque != NULL && buffer != NULL && check >= png_row_stride) { /* Now check for overflow of the image buffer calculation; this * limits the whole image size to 32 bits for API compatibility with * the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro. + * + * The PNG_IMAGE_BUFFER_SIZE macro is: + * + * (PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)*height*(row_stride)) + * + * And the component size is always 1 or 2, so make sure that the + * number of *bytes* that the application is saying are available + * does actually fit into a 32-bit number. + * + * NOTE: this will be changed in 1.7 because PNG_IMAGE_BUFFER_SIZE + * will be changed to use png_alloc_size_t; bigger images can be + * accomodated on 64-bit systems. */ - if (image->height <= 0xFFFFFFFF/png_row_stride) + if (image->height <= + 0xffffffffU/PNG_IMAGE_PIXEL_COMPONENT_SIZE(image->format)/check) { if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 || (image->colormap_entries > 0 && colormap != NULL)) @@ -4127,15 +4151,16 @@ png_image_finish_read(png_imagep image, png_const_colorp background, * all the setup has already been done. */ if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0) - result = png_safe_execute(image, - png_image_read_colormap, &display) && - png_safe_execute(image, - png_image_read_colormapped, &display); + result = + png_safe_execute(image, + png_image_read_colormap, &display) && + png_safe_execute(image, + png_image_read_colormapped, &display); else result = png_safe_execute(image, - png_image_read_direct, &display); + png_image_read_direct, &display); png_image_free(image); return result; @@ -4143,27 +4168,27 @@ png_image_finish_read(png_imagep image, png_const_colorp background, else return png_image_error(image, - "png_image_finish_read[color-map]: no color-map"); + "png_image_finish_read[color-map]: no color-map"); } else return png_image_error(image, - "png_image_finish_read: image too large"); + "png_image_finish_read: image too large"); } else return png_image_error(image, - "png_image_finish_read: invalid argument"); + "png_image_finish_read: invalid argument"); } else return png_image_error(image, - "png_image_finish_read: row_stride too large"); + "png_image_finish_read: row_stride too large"); } else if (image != NULL) return png_image_error(image, - "png_image_finish_read: damaged PNG_IMAGE_VERSION"); + "png_image_finish_read: damaged PNG_IMAGE_VERSION"); return 0; } diff --git a/thirdparty/libpng/pngrio.c b/thirdparty/libpng/pngrio.c index 5101d54a62..7e26e855ca 100644 --- a/thirdparty/libpng/pngrio.c +++ b/thirdparty/libpng/pngrio.c @@ -1,8 +1,8 @@ /* pngrio.c - functions for data input * - * Last changed in libpng 1.6.17 [March 26, 2015] - * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.24 [August 4, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -85,7 +85,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) */ void PNGAPI png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr, - png_rw_ptr read_data_fn) + png_rw_ptr read_data_fn) { if (png_ptr == NULL) return; diff --git a/thirdparty/libpng/pngrtran.c b/thirdparty/libpng/pngrtran.c index 3138147aff..0b4f4f9068 100644 --- a/thirdparty/libpng/pngrtran.c +++ b/thirdparty/libpng/pngrtran.c @@ -1,7 +1,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.6.22 [May 26, 2016] + * Last changed in libpng 1.6.24 [August 4, 2016] * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -48,7 +48,7 @@ png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action) case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */ png_warning(png_ptr, - "Can't discard critical data on CRC error"); + "Can't discard critical data on CRC error"); case PNG_CRC_ERROR_QUIT: /* Error/quit */ case PNG_CRC_DEFAULT: @@ -101,7 +101,7 @@ png_rtran_ok(png_structrp png_ptr, int need_IHDR) { if ((png_ptr->flags & PNG_FLAG_ROW_INIT) != 0) png_app_error(png_ptr, - "invalid after png_start_read_image or png_read_update_info"); + "invalid after png_start_read_image or png_read_update_info"); else if (need_IHDR && (png_ptr->mode & PNG_HAVE_IHDR) == 0) png_app_error(png_ptr, "invalid before the PNG header has been read"); @@ -209,7 +209,7 @@ png_set_strip_alpha(png_structrp png_ptr) #if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED) static png_fixed_point translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma, - int is_screen) + int is_screen) { /* Check for flag values. The main reason for having the old Mac value as a * flag is that it is pretty near impossible to work out what the correct @@ -273,7 +273,7 @@ convert_gamma_value(png_structrp png_ptr, double output_gamma) #ifdef PNG_READ_ALPHA_MODE_SUPPORTED void PNGFAPI png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, - png_fixed_point output_gamma) + png_fixed_point output_gamma) { int compose = 0; png_fixed_point file_gamma; @@ -377,7 +377,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, if ((png_ptr->transformations & PNG_COMPOSE) != 0) png_error(png_ptr, - "conflicting calls to set alpha mode and background"); + "conflicting calls to set alpha mode and background"); png_ptr->transformations |= PNG_COMPOSE; } @@ -388,7 +388,7 @@ void PNGAPI png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma) { png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr, - output_gamma)); + output_gamma)); } # endif #endif @@ -429,7 +429,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, int i; png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * (sizeof (png_byte)))); + (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte)))); for (i = 0; i < num_palette; i++) png_ptr->quantize_index[i] = (png_byte)i; } @@ -446,7 +446,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, /* Initialize an array to sort colors */ png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * (sizeof (png_byte)))); + (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte)))); /* Initialize the quantize_sort array */ for (i = 0; i < num_palette; i++) @@ -580,9 +580,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, /* Initialize palette index arrays */ png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * (sizeof (png_byte)))); + (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte)))); png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * (sizeof (png_byte)))); + (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte)))); /* Initialize the sort array */ for (i = 0; i < num_palette; i++) @@ -802,7 +802,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, #ifdef PNG_READ_GAMMA_SUPPORTED void PNGFAPI png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma, - png_fixed_point file_gamma) + png_fixed_point file_gamma) { png_debug(1, "in png_set_gamma_fixed"); @@ -844,7 +844,7 @@ void PNGAPI png_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma) { png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma), - convert_gamma_value(png_ptr, file_gamma)); + convert_gamma_value(png_ptr, file_gamma)); } # endif /* FLOATING_POINT */ #endif /* READ_GAMMA */ @@ -990,7 +990,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, * that it just worked and get a memory overwrite. */ png_error(png_ptr, - "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED"); + "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED"); /* png_ptr->transformations &= ~PNG_RGB_TO_GRAY; */ } @@ -1017,7 +1017,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, { if (red >= 0 && green >= 0) png_app_warning(png_ptr, - "ignoring out of range rgb_to_gray coefficients"); + "ignoring out of range rgb_to_gray coefficients"); /* Use the defaults, from the cHRM chunk if set, else the historical * values which are close to the sRGB/HDTV/ITU-Rec 709 values. See @@ -1026,7 +1026,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, * something has already provided a default. */ if (png_ptr->rgb_to_gray_red_coeff == 0 && - png_ptr->rgb_to_gray_green_coeff == 0) + png_ptr->rgb_to_gray_green_coeff == 0) { png_ptr->rgb_to_gray_red_coeff = 6968; png_ptr->rgb_to_gray_green_coeff = 23434; @@ -1043,10 +1043,10 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, void PNGAPI png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red, - double green) + double green) { png_set_rgb_to_gray_fixed(png_ptr, error_action, - png_fixed(png_ptr, red, "rgb to gray red coefficient"), + png_fixed(png_ptr, red, "rgb to gray red coefficient"), png_fixed(png_ptr, green, "rgb to gray green coefficient")); } #endif /* FLOATING POINT */ @@ -1303,7 +1303,7 @@ png_init_read_transformations(png_structrp png_ptr) { if (png_ptr->screen_gamma != 0) /* screen set too */ gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma, - png_ptr->screen_gamma); + png_ptr->screen_gamma); else /* Assume the output matches the input; a long time default behavior @@ -1584,7 +1584,7 @@ png_init_read_transformations(png_structrp png_ptr) */ if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0) png_warning(png_ptr, - "libpng does not support gamma+background+rgb_to_gray"); + "libpng does not support gamma+background+rgb_to_gray"); if ((png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) != 0) { @@ -1620,13 +1620,13 @@ png_init_read_transformations(png_structrp png_ptr) case PNG_BACKGROUND_GAMMA_FILE: g = png_reciprocal(png_ptr->colorspace.gamma); gs = png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma); + png_ptr->screen_gamma); break; case PNG_BACKGROUND_GAMMA_UNIQUE: g = png_reciprocal(png_ptr->background_gamma); gs = png_reciprocal2(png_ptr->background_gamma, - png_ptr->screen_gamma); + png_ptr->screen_gamma); break; default: g = PNG_FP_1; /* back_1 */ @@ -1654,11 +1654,11 @@ png_init_read_transformations(png_structrp png_ptr) if (png_gamma_significant(g) != 0) { back_1.red = png_gamma_8bit_correct(png_ptr->background.red, - g); + g); back_1.green = png_gamma_8bit_correct( - png_ptr->background.green, g); + png_ptr->background.green, g); back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue, - g); + g); } else @@ -1729,7 +1729,7 @@ png_init_read_transformations(png_structrp png_ptr) case PNG_BACKGROUND_GAMMA_FILE: g = png_reciprocal(png_ptr->colorspace.gamma); gs = png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma); + png_ptr->screen_gamma); break; case PNG_BACKGROUND_GAMMA_UNIQUE: @@ -2150,7 +2150,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row) { png_bytep sp = row + (png_size_t)((row_width - 1) >> 3); png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07); + png_uint_32 shift = 7U - ((row_width + 7U) & 0x07); for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x01); @@ -2174,7 +2174,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row) png_bytep sp = row + (png_size_t)((row_width - 1) >> 2); png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); + png_uint_32 shift = ((3U - ((row_width + 3U) & 0x03)) << 1); for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x03); @@ -2197,7 +2197,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row) { png_bytep sp = row + (png_size_t)((row_width - 1) >> 1); png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); + png_uint_32 shift = ((1U - ((row_width + 1U) & 0x01)) << 2); for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x0f); @@ -3223,7 +3223,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) == png_ptr->trans_color.gray) { unsigned int tmp = *sp & (0x7f7f >> (7 - shift)); - tmp |= png_ptr->background.gray << shift; + tmp |= + (unsigned int)(png_ptr->background.gray << shift); *sp = (png_byte)(tmp & 0xff); } @@ -3252,7 +3253,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) == png_ptr->trans_color.gray) { unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); - tmp |= png_ptr->background.gray << shift; + tmp |= + (unsigned int)png_ptr->background.gray << shift; *sp = (png_byte)(tmp & 0xff); } @@ -3262,7 +3264,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) unsigned int g = (gamma_table [p | (p << 2) | (p << 4) | (p << 6)] >> 6) & 0x03; unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); - tmp |= g << shift; + tmp |= (unsigned int)(g << shift); *sp = (png_byte)(tmp & 0xff); } @@ -3288,7 +3290,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) == png_ptr->trans_color.gray) { unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); - tmp |= png_ptr->background.gray << shift; + tmp |= + (unsigned int)png_ptr->background.gray << shift; *sp = (png_byte)(tmp & 0xff); } @@ -3318,7 +3321,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) == png_ptr->trans_color.gray) { unsigned int tmp = *sp & (0x0f0f >> (4 - shift)); - tmp |= png_ptr->background.gray << shift; + tmp |= + (unsigned int)(png_ptr->background.gray << shift); *sp = (png_byte)(tmp & 0xff); } @@ -3328,7 +3332,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) unsigned int g = (gamma_table[p | (p << 4)] >> 4) & 0x0f; unsigned int tmp = *sp & (0x0f0f >> (4 - shift)); - tmp |= g << shift; + tmp |= (unsigned int)(g << shift); *sp = (png_byte)(tmp & 0xff); } @@ -3354,7 +3358,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) == png_ptr->trans_color.gray) { unsigned int tmp = *sp & (0x0f0f >> (4 - shift)); - tmp |= png_ptr->background.gray << shift; + tmp |= + (unsigned int)(png_ptr->background.gray << shift); *sp = (png_byte)(tmp & 0xff); } @@ -4195,7 +4200,7 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr) */ static void png_do_expand_palette(png_row_infop row_info, png_bytep row, - png_const_colorp palette, png_const_bytep trans_alpha, int num_trans) + png_const_colorp palette, png_const_bytep trans_alpha, int num_trans) { int shift, value; png_bytep sp, dp; @@ -4502,7 +4507,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, row_info->channels = 2; row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_width); + row_width); } } else if (row_info->color_type == PNG_COLOR_TYPE_RGB && @@ -4762,7 +4767,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA || row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) png_do_strip_channel(row_info, png_ptr->row_buf + 1, - 0 /* at_start == false, because SWAP_ALPHA happens later */); + 0 /* at_start == false, because SWAP_ALPHA happens later */); #endif #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED diff --git a/thirdparty/libpng/pngrutil.c b/thirdparty/libpng/pngrutil.c index c9747fc27d..fb5f5f083d 100644 --- a/thirdparty/libpng/pngrutil.c +++ b/thirdparty/libpng/pngrutil.c @@ -1,8 +1,8 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.6.20 [December 3, 2014] - * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -86,11 +86,11 @@ png_get_int_32)(png_const_bytep buf) { png_uint_32 uval = png_get_uint_32(buf); if ((uval & 0x80000000) == 0) /* non-negative */ - return uval; + return (png_int_32)uval; uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */ if ((uval & 0x80000000) == 0) /* no overflow */ - return -(png_int_32)uval; + return -(png_int_32)uval; /* The following has to be safe; this function only gets called on PNG data * and if we get here that data is invalid. 0 is the most safe value and * if not then an attacker would surely just generate a PNG with 0 instead. @@ -370,11 +370,10 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) */ { int ret; /* zlib return code */ -#if PNG_ZLIB_VERNUM >= 0x1240 +#if ZLIB_VERNUM >= 0x1240 + int window_bits = 0; # if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW) - int window_bits; - if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) == PNG_OPTION_ON) { @@ -384,13 +383,11 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) else { - window_bits = 0; png_ptr->zstream_start = 1; } -# else -# define window_bits 0 # endif -#endif + +#endif /* ZLIB_VERNUM >= 0x1240 */ /* Set this for safety, just in case the previous owner left pointers to * memory allocations. @@ -402,25 +399,31 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0) { -#if PNG_ZLIB_VERNUM < 0x1240 - ret = inflateReset(&png_ptr->zstream); -#else +#if ZLIB_VERNUM >= 0x1240 ret = inflateReset2(&png_ptr->zstream, window_bits); +#else + ret = inflateReset(&png_ptr->zstream); #endif } else { -#if PNG_ZLIB_VERNUM < 0x1240 - ret = inflateInit(&png_ptr->zstream); -#else +#if ZLIB_VERNUM >= 0x1240 ret = inflateInit2(&png_ptr->zstream, window_bits); +#else + ret = inflateInit(&png_ptr->zstream); #endif if (ret == Z_OK) png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; } +#if ZLIB_VERNUM >= 0x1281 + /* Turn off validation of the ADLER32 checksum */ + if ((png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) != 0) + ret = inflateValidate(&png_ptr->zstream, 0); +#endif + if (ret == Z_OK) png_ptr->zowner = owner; @@ -435,7 +438,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) #endif } -#if PNG_ZLIB_VERNUM >= 0x1240 +#if ZLIB_VERNUM >= 0x1240 /* Handle the start of the inflate stream if we called inflateInit2(strm,0); * in this case some zlib versions skip validation of the CINFO field and, in * certain circumstances, libpng may end up displaying an invalid image, in @@ -461,6 +464,7 @@ png_zlib_inflate(png_structrp png_ptr, int flush) #endif /* Zlib >= 1.2.4 */ #ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED +#if defined(PNG_READ_zTXt_SUPPORTED) || defined (PNG_READ_iTXt_SUPPORTED) /* png_inflate now returns zlib error codes including Z_OK and Z_STREAM_END to * allow the caller to do multiple calls if required. If the 'finish' flag is * set Z_FINISH will be passed to the final inflate() call and Z_STREAM_END must @@ -599,9 +603,9 @@ png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish, */ static int png_decompress_chunk(png_structrp png_ptr, - png_uint_32 chunklength, png_uint_32 prefix_size, - png_alloc_size_t *newlength /* must be initialized to the maximum! */, - int terminate /*add a '\0' to the end of the uncompressed data*/) + png_uint_32 chunklength, png_uint_32 prefix_size, + png_alloc_size_t *newlength /* must be initialized to the maximum! */, + int terminate /*add a '\0' to the end of the uncompressed data*/) { /* TODO: implement different limits for different types of chunk. * @@ -638,8 +642,8 @@ png_decompress_chunk(png_structrp png_ptr, png_uint_32 lzsize = chunklength - prefix_size; ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/, - /* input: */ png_ptr->read_buffer + prefix_size, &lzsize, - /* output: */ NULL, newlength); + /* input: */ png_ptr->read_buffer + prefix_size, &lzsize, + /* output: */ NULL, newlength); if (ret == Z_STREAM_END) { @@ -659,15 +663,15 @@ png_decompress_chunk(png_structrp png_ptr, */ png_alloc_size_t new_size = *newlength; png_alloc_size_t buffer_size = prefix_size + new_size + - (terminate != 0); + (terminate != 0); png_bytep text = png_voidcast(png_bytep, png_malloc_base(png_ptr, - buffer_size)); + buffer_size)); if (text != NULL) { ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/, - png_ptr->read_buffer + prefix_size, &lzsize, - text + prefix_size, newlength); + png_ptr->read_buffer + prefix_size, &lzsize, + text + prefix_size, newlength); if (ret == Z_STREAM_END) { @@ -754,6 +758,7 @@ png_decompress_chunk(png_structrp png_ptr, return Z_MEM_ERROR; } } +#endif /* READ_zTXt || READ_iTXt */ #endif /* READ_COMPRESSED_TEXT */ #ifdef PNG_READ_iCCP_SUPPORTED @@ -762,8 +767,8 @@ png_decompress_chunk(png_structrp png_ptr, */ static int png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size, - png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size, - int finish) + png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size, + int finish) { if (png_ptr->zowner == png_ptr->chunk_name) { @@ -802,8 +807,8 @@ png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size, * the available output is produced; this allows reading of truncated * streams. */ - ret = PNG_INFLATE(png_ptr, - *chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH)); + ret = PNG_INFLATE(png_ptr, *chunk_bytes > 0 ? + Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH)); } while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0)); @@ -1009,7 +1014,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) #endif { - png_crc_finish(png_ptr, (int) length - num * 3); + png_crc_finish(png_ptr, (png_uint_32) (length - (unsigned int)num * 3)); } #ifndef PNG_READ_OPT_PLTE_SUPPORTED @@ -1292,7 +1297,7 @@ png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM; (void)png_colorspace_set_chromaticities(png_ptr, &png_ptr->colorspace, &xy, - 1/*prefer cHRM values*/); + 1/*prefer cHRM values*/); png_colorspace_sync(png_ptr, info_ptr); } #endif @@ -1432,8 +1437,8 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_ptr->zstream.next_in = (Bytef*)keyword + (keyword_length+2); png_ptr->zstream.avail_in = read_length; (void)png_inflate_read(png_ptr, local_buffer, - (sizeof local_buffer), &length, profile_header, &size, - 0/*finish: don't, because the output is too small*/); + (sizeof local_buffer), &length, profile_header, &size, + 0/*finish: don't, because the output is too small*/); if (size == 0) { @@ -1443,14 +1448,14 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_get_uint_32(profile_header); if (png_icc_check_length(png_ptr, &png_ptr->colorspace, - keyword, profile_length) != 0) + keyword, profile_length) != 0) { /* The length is apparently ok, so we can check the 132 * byte header. */ if (png_icc_check_header(png_ptr, &png_ptr->colorspace, - keyword, profile_length, profile_header, - png_ptr->color_type) != 0) + keyword, profile_length, profile_header, + png_ptr->color_type) != 0) { /* Now read the tag table; a variable size buffer is * needed at this point, allocate one for the whole @@ -1458,20 +1463,20 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) * that none of these stuff will overflow. */ const png_uint_32 tag_count = png_get_uint_32( - profile_header+128); + profile_header+128); png_bytep profile = png_read_buffer(png_ptr, - profile_length, 2/*silent*/); + profile_length, 2/*silent*/); if (profile != NULL) { memcpy(profile, profile_header, - (sizeof profile_header)); + (sizeof profile_header)); size = 12 * tag_count; (void)png_inflate_read(png_ptr, local_buffer, - (sizeof local_buffer), &length, - profile + (sizeof profile_header), &size, 0); + (sizeof local_buffer), &length, + profile + (sizeof profile_header), &size, 0); /* Still expect a buffer error because we expect * there to be some tag data! @@ -1479,22 +1484,22 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (size == 0) { if (png_icc_check_tag_table(png_ptr, - &png_ptr->colorspace, keyword, profile_length, - profile) != 0) + &png_ptr->colorspace, keyword, profile_length, + profile) != 0) { /* The profile has been validated for basic * security issues, so read the whole thing in. */ size = profile_length - (sizeof profile_header) - - 12 * tag_count; + - 12 * tag_count; (void)png_inflate_read(png_ptr, local_buffer, - (sizeof local_buffer), &length, - profile + (sizeof profile_header) + - 12 * tag_count, &size, 1/*finish*/); + (sizeof local_buffer), &length, + profile + (sizeof profile_header) + + 12 * tag_count, &size, 1/*finish*/); if (length > 0 && !(png_ptr->flags & - PNG_FLAG_BENIGN_ERRORS_WARN)) + PNG_FLAG_BENIGN_ERRORS_WARN)) errmsg = "extra compressed data"; /* But otherwise allow extra data: */ @@ -1506,34 +1511,34 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) * keep going. */ png_chunk_warning(png_ptr, - "extra compressed data"); + "extra compressed data"); } png_crc_finish(png_ptr, length); finished = 1; -# ifdef PNG_sRGB_SUPPORTED +# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0 /* Check for a match against sRGB */ png_icc_set_sRGB(png_ptr, - &png_ptr->colorspace, profile, - png_ptr->zstream.adler); -# endif + &png_ptr->colorspace, profile, + png_ptr->zstream.adler); +# endif /* Steal the profile for info_ptr. */ if (info_ptr != NULL) { png_free_data(png_ptr, info_ptr, - PNG_FREE_ICCP, 0); + PNG_FREE_ICCP, 0); info_ptr->iccp_name = png_voidcast(char*, - png_malloc_base(png_ptr, - keyword_length+1)); + png_malloc_base(png_ptr, + keyword_length+1)); if (info_ptr->iccp_name != NULL) { memcpy(info_ptr->iccp_name, keyword, - keyword_length+1); + keyword_length+1); info_ptr->iccp_proflen = - profile_length; + profile_length; info_ptr->iccp_profile = profile; png_ptr->read_buffer = NULL; /*steal*/ info_ptr->free_me |= PNG_FREE_ICCP; @@ -1715,13 +1720,13 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) data_length = length - (png_uint_32)(entry_start - buffer); /* Integrity-check the data length */ - if ((data_length % entry_size) != 0) + if ((data_length % (unsigned int)entry_size) != 0) { png_warning(png_ptr, "sPLT chunk has bad length"); return; } - dl = (png_int_32)(data_length / entry_size); + dl = (png_uint_32)(data_length / (unsigned int)entry_size); max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry)); if (dl > max_dl) @@ -1730,10 +1735,10 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) return; } - new_palette.nentries = (png_int_32)(data_length / entry_size); + new_palette.nentries = (png_int_32)(data_length / (unsigned int)entry_size); - new_palette.entries = (png_sPLT_entryp)png_malloc_warn( - png_ptr, new_palette.nentries * (sizeof (png_sPLT_entry))); + new_palette.entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, + (png_alloc_size_t) new_palette.nentries * (sizeof (png_sPLT_entry))); if (new_palette.entries == NULL) { @@ -2270,7 +2275,7 @@ png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) } png_set_pCAL(png_ptr, info_ptr, (png_charp)buffer, X0, X1, type, nparams, - (png_charp)units, params); + (png_charp)units, params); png_free(png_ptr, params); } @@ -2313,7 +2318,7 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) } png_debug1(2, "Allocating and reading sCAL chunk data (%u bytes)", - length + 1); + length + 1); buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/); @@ -2365,7 +2370,7 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) else /* This is the (only) success case. */ png_set_sCAL_s(png_ptr, info_ptr, buffer[0], - (png_charp)buffer+1, (png_charp)buffer+heighti); + (png_charp)buffer+1, (png_charp)buffer+heighti); } } #endif @@ -2465,8 +2470,8 @@ png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (buffer == NULL) { - png_chunk_benign_error(png_ptr, "out of memory"); - return; + png_chunk_benign_error(png_ptr, "out of memory"); + return; } png_crc_read(png_ptr, buffer, length); @@ -2573,7 +2578,7 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) * and text chunks. */ if (png_decompress_chunk(png_ptr, length, keyword_length+2, - &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) + &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) { png_text text; @@ -2713,7 +2718,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) * iCCP and text chunks. */ if (png_decompress_chunk(png_ptr, length, prefix_length, - &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) + &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) buffer = png_ptr->read_buffer; else @@ -2793,7 +2798,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length) { /* Do a 'warn' here - it is handled below. */ png_ptr->unknown_chunk.data = png_voidcast(png_bytep, - png_malloc_warn(png_ptr, length)); + png_malloc_warn(png_ptr, length)); } } @@ -2818,7 +2823,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length) /* Handle an unknown, or known but disabled, chunk */ void /* PRIVATE */ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, - png_uint_32 length, int keep) + png_uint_32 length, int keep) { int handled = 0; /* the chunk was handled */ @@ -2856,7 +2861,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, { /* Callback to user unknown chunk handler */ int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr, - &png_ptr->unknown_chunk); + &png_ptr->unknown_chunk); /* ret is: * negative: An error occurred; png_chunk_error will be called. @@ -2890,9 +2895,9 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, { png_chunk_warning(png_ptr, "Saving unknown chunk:"); png_app_warning(png_ptr, - "forcing save of an unhandled chunk;" - " please call png_set_keep_unknown_chunks"); - /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */ + "forcing save of an unhandled chunk;" + " please call png_set_keep_unknown_chunks"); + /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */ } # endif keep = PNG_HANDLE_CHUNK_IF_SAFE; @@ -2985,7 +2990,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, * out; store the chunk. */ png_set_unknown_chunks(png_ptr, info_ptr, - &png_ptr->unknown_chunk, 1); + &png_ptr->unknown_chunk, 1); handled = 1; # ifdef PNG_USER_LIMITS_SUPPORTED break; @@ -3097,7 +3102,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) # ifdef PNG_READ_PACKSWAP_SUPPORTED if ((png_ptr->transformations & PNG_PACKSWAP) != 0) /* little-endian byte */ - end_mask = 0xff << end_mask; + end_mask = (unsigned int)(0xff << end_mask); else /* big-endian byte */ # endif @@ -3418,8 +3423,8 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) /* Everything is aligned for png_uint_16 copies, but try for * png_uint_32 first. */ - if (png_isaligned(dp, png_uint_32) != 0 && - png_isaligned(sp, png_uint_32) != 0 && + if (png_isaligned(dp, png_uint_32) && + png_isaligned(sp, png_uint_32) && bytes_to_copy % (sizeof (png_uint_32)) == 0 && bytes_to_jump % (sizeof (png_uint_32)) == 0) { @@ -3539,11 +3544,11 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) #ifdef PNG_READ_INTERLACING_SUPPORTED void /* PRIVATE */ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, - png_uint_32 transformations /* Because these may affect the byte layout */) + png_uint_32 transformations /* Because these may affect the byte layout */) { /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Offset to next interlace block */ - static PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + static PNG_CONST unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; png_debug(1, "in png_do_read_interlace"); if (row != NULL && row_info != NULL) @@ -3558,9 +3563,10 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, { png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3); png_bytep dp = row + (png_size_t)((final_width - 1) >> 3); - int sshift, dshift; - int s_start, s_end, s_inc; - int jstop = png_pass_inc[pass]; + unsigned int sshift, dshift; + unsigned int s_start, s_end; + int s_inc; + int jstop = (int)png_pass_inc[pass]; png_byte v; png_uint_32 i; int j; @@ -3568,8 +3574,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, #ifdef PNG_READ_PACKSWAP_SUPPORTED if ((transformations & PNG_PACKSWAP) != 0) { - sshift = (int)((row_info->width + 7) & 0x07); - dshift = (int)((final_width + 7) & 0x07); + sshift = ((row_info->width + 7) & 0x07); + dshift = ((final_width + 7) & 0x07); s_start = 7; s_end = 0; s_inc = -1; @@ -3578,8 +3584,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, else #endif { - sshift = 7 - (int)((row_info->width + 7) & 0x07); - dshift = 7 - (int)((final_width + 7) & 0x07); + sshift = 7 - ((row_info->width + 7) & 0x07); + dshift = 7 - ((final_width + 7) & 0x07); s_start = 0; s_end = 7; s_inc = 1; @@ -3591,7 +3597,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, for (j = 0; j < jstop; j++) { unsigned int tmp = *dp & (0x7f7f >> (7 - dshift)); - tmp |= v << dshift; + tmp |= (unsigned int)(v << dshift); *dp = (png_byte)(tmp & 0xff); if (dshift == s_end) @@ -3601,7 +3607,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, } else - dshift += s_inc; + dshift = (unsigned int)((int)dshift + s_inc); } if (sshift == s_end) @@ -3611,7 +3617,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, } else - sshift += s_inc; + sshift = (unsigned int)((int)sshift + s_inc); } break; } @@ -3620,16 +3626,17 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, { png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2); - int sshift, dshift; - int s_start, s_end, s_inc; - int jstop = png_pass_inc[pass]; + unsigned int sshift, dshift; + unsigned int s_start, s_end; + int s_inc; + int jstop = (int)png_pass_inc[pass]; png_uint_32 i; #ifdef PNG_READ_PACKSWAP_SUPPORTED if ((transformations & PNG_PACKSWAP) != 0) { - sshift = (int)(((row_info->width + 3) & 0x03) << 1); - dshift = (int)(((final_width + 3) & 0x03) << 1); + sshift = (((row_info->width + 3) & 0x03) << 1); + dshift = (((final_width + 3) & 0x03) << 1); s_start = 6; s_end = 0; s_inc = -2; @@ -3638,8 +3645,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, else #endif { - sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1); - dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1); + sshift = ((3 - ((row_info->width + 3) & 0x03)) << 1); + dshift = ((3 - ((final_width + 3) & 0x03)) << 1); s_start = 0; s_end = 6; s_inc = 2; @@ -3654,7 +3661,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, for (j = 0; j < jstop; j++) { unsigned int tmp = *dp & (0x3f3f >> (6 - dshift)); - tmp |= v << dshift; + tmp |= (unsigned int)(v << dshift); *dp = (png_byte)(tmp & 0xff); if (dshift == s_end) @@ -3664,7 +3671,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, } else - dshift += s_inc; + dshift = (unsigned int)((int)dshift + s_inc); } if (sshift == s_end) @@ -3674,7 +3681,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, } else - sshift += s_inc; + sshift = (unsigned int)((int)sshift + s_inc); } break; } @@ -3683,16 +3690,17 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, { png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1); png_bytep dp = row + (png_size_t)((final_width - 1) >> 1); - int sshift, dshift; - int s_start, s_end, s_inc; + unsigned int sshift, dshift; + unsigned int s_start, s_end; + int s_inc; png_uint_32 i; - int jstop = png_pass_inc[pass]; + int jstop = (int)png_pass_inc[pass]; #ifdef PNG_READ_PACKSWAP_SUPPORTED if ((transformations & PNG_PACKSWAP) != 0) { - sshift = (int)(((row_info->width + 1) & 0x01) << 2); - dshift = (int)(((final_width + 1) & 0x01) << 2); + sshift = (((row_info->width + 1) & 0x01) << 2); + dshift = (((final_width + 1) & 0x01) << 2); s_start = 4; s_end = 0; s_inc = -4; @@ -3701,8 +3709,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, else #endif { - sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2); - dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2); + sshift = ((1 - ((row_info->width + 1) & 0x01)) << 2); + dshift = ((1 - ((final_width + 1) & 0x01)) << 2); s_start = 0; s_end = 4; s_inc = 4; @@ -3716,7 +3724,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, for (j = 0; j < jstop; j++) { unsigned int tmp = *dp & (0xf0f >> (4 - dshift)); - tmp |= v << dshift; + tmp |= (unsigned int)(v << dshift); *dp = (png_byte)(tmp & 0xff); if (dshift == s_end) @@ -3726,7 +3734,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, } else - dshift += s_inc; + dshift = (unsigned int)((int)dshift + s_inc); } if (sshift == s_end) @@ -3736,7 +3744,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, } else - sshift += s_inc; + sshift = (unsigned int)((int)sshift + s_inc); } break; } @@ -3750,7 +3758,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes; - int jstop = png_pass_inc[pass]; + int jstop = (int)png_pass_inc[pass]; png_uint_32 i; for (i = 0; i < row_info->width; i++) @@ -3783,7 +3791,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, static void png_read_filter_row_sub(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) + png_const_bytep prev_row) { png_size_t i; png_size_t istop = row_info->rowbytes; @@ -3801,7 +3809,7 @@ png_read_filter_row_sub(png_row_infop row_info, png_bytep row, static void png_read_filter_row_up(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) + png_const_bytep prev_row) { png_size_t i; png_size_t istop = row_info->rowbytes; @@ -3817,7 +3825,7 @@ png_read_filter_row_up(png_row_infop row_info, png_bytep row, static void png_read_filter_row_avg(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) + png_const_bytep prev_row) { png_size_t i; png_bytep rp = row; @@ -3844,7 +3852,7 @@ png_read_filter_row_avg(png_row_infop row_info, png_bytep row, static void png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) + png_const_bytep prev_row) { png_bytep rp_end = row + row_info->rowbytes; int a, c; @@ -3892,9 +3900,9 @@ png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row, static void png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) + png_const_bytep prev_row) { - int bpp = (row_info->pixel_depth + 7) >> 3; + unsigned int bpp = (row_info->pixel_depth + 7) >> 3; png_bytep rp_end = row + bpp; /* Process the first pixel in the row completely (this is the same as 'up' @@ -3907,7 +3915,7 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row, } /* Remainder */ - rp_end += row_info->rowbytes - bpp; + rp_end = rp_end + (row_info->rowbytes - bpp); while (row < rp_end) { @@ -3977,7 +3985,7 @@ png_init_filter_functions(png_structrp pp) void /* PRIVATE */ png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row, - png_const_bytep prev_row, int filter) + png_const_bytep prev_row, int filter) { /* OPTIMIZATION: DO NOT MODIFY THIS FUNCTION, instead #define * PNG_FILTER_OPTIMIZATIONS to a function that overrides the generic @@ -3995,7 +4003,7 @@ png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row, #ifdef PNG_SEQUENTIAL_READ_SUPPORTED void /* PRIVATE */ png_read_IDAT_data(png_structrp png_ptr, png_bytep output, - png_alloc_size_t avail_out) + png_alloc_size_t avail_out) { /* Loop reading IDATs and decompressing the result into output[avail_out] */ png_ptr->zstream.next_out = output; @@ -4099,7 +4107,15 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output, png_zstream_error(png_ptr, ret); if (output != NULL) - png_chunk_error(png_ptr, png_ptr->zstream.msg); + { + if(!strncmp(png_ptr->zstream.msg,"incorrect data check",20)) + { + png_chunk_benign_error(png_ptr, "ADLER32 checksum mismatch"); + continue; + } + else + png_chunk_error(png_ptr, png_ptr->zstream.msg); + } else /* checking */ { @@ -4252,7 +4268,7 @@ png_read_start_row(png_structrp png_ptr) /* Offset to next interlace block in the y direction */ static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; - int max_pixel_depth; + unsigned int max_pixel_depth; png_size_t row_bytes; png_debug(1, "in png_read_start_row"); @@ -4281,7 +4297,7 @@ png_read_start_row(png_structrp png_ptr) png_ptr->iwidth = png_ptr->width; } - max_pixel_depth = png_ptr->pixel_depth; + max_pixel_depth = (unsigned int)png_ptr->pixel_depth; /* WARNING: * png_read_transform_info (pngrtran.c) performs a simpler set of * calculations to calculate the final pixel depth, then @@ -4416,7 +4432,7 @@ png_read_start_row(png_structrp png_ptr) defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0) { - int user_pixel_depth = png_ptr->user_transform_depth * + unsigned int user_pixel_depth = png_ptr->user_transform_depth * png_ptr->user_transform_channels; if (user_pixel_depth > max_pixel_depth) @@ -4438,7 +4454,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) * for safety's sake */ row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) + - 1 + ((max_pixel_depth + 7) >> 3); + 1 + ((max_pixel_depth + 7) >> 3U); #ifdef PNG_MAX_MALLOC_64K if (row_bytes > (png_uint_32)65536L) @@ -4447,42 +4463,42 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) if (row_bytes + 48 > png_ptr->old_big_row_buf_size) { - png_free(png_ptr, png_ptr->big_row_buf); - png_free(png_ptr, png_ptr->big_prev_row); + png_free(png_ptr, png_ptr->big_row_buf); + png_free(png_ptr, png_ptr->big_prev_row); - if (png_ptr->interlaced != 0) - png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr, - row_bytes + 48); + if (png_ptr->interlaced != 0) + png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr, + row_bytes + 48); - else - png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 48); + else + png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 48); - png_ptr->big_prev_row = (png_bytep)png_malloc(png_ptr, row_bytes + 48); + png_ptr->big_prev_row = (png_bytep)png_malloc(png_ptr, row_bytes + 48); #ifdef PNG_ALIGNED_MEMORY_SUPPORTED - /* Use 16-byte aligned memory for row_buf with at least 16 bytes - * of padding before and after row_buf; treat prev_row similarly. - * NOTE: the alignment is to the start of the pixels, one beyond the start - * of the buffer, because of the filter byte. Prior to libpng 1.5.6 this - * was incorrect; the filter byte was aligned, which had the exact - * opposite effect of that intended. - */ - { - png_bytep temp = png_ptr->big_row_buf + 32; - int extra = (int)((temp - (png_bytep)0) & 0x0f); - png_ptr->row_buf = temp - extra - 1/*filter byte*/; - - temp = png_ptr->big_prev_row + 32; - extra = (int)((temp - (png_bytep)0) & 0x0f); - png_ptr->prev_row = temp - extra - 1/*filter byte*/; - } + /* Use 16-byte aligned memory for row_buf with at least 16 bytes + * of padding before and after row_buf; treat prev_row similarly. + * NOTE: the alignment is to the start of the pixels, one beyond the start + * of the buffer, because of the filter byte. Prior to libpng 1.5.6 this + * was incorrect; the filter byte was aligned, which had the exact + * opposite effect of that intended. + */ + { + png_bytep temp = png_ptr->big_row_buf + 32; + int extra = (int)((temp - (png_bytep)0) & 0x0f); + png_ptr->row_buf = temp - extra - 1/*filter byte*/; + + temp = png_ptr->big_prev_row + 32; + extra = (int)((temp - (png_bytep)0) & 0x0f); + png_ptr->prev_row = temp - extra - 1/*filter byte*/; + } #else - /* Use 31 bytes of padding before and 17 bytes after row_buf. */ - png_ptr->row_buf = png_ptr->big_row_buf + 31; - png_ptr->prev_row = png_ptr->big_prev_row + 31; + /* Use 31 bytes of padding before and 17 bytes after row_buf. */ + png_ptr->row_buf = png_ptr->big_row_buf + 31; + png_ptr->prev_row = png_ptr->big_prev_row + 31; #endif - png_ptr->old_big_row_buf_size = row_bytes + 48; + png_ptr->old_big_row_buf_size = row_bytes + 48; } #ifdef PNG_MAX_MALLOC_64K @@ -4507,7 +4523,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) * does not, so free the read buffer now regardless; the sequential reader * reallocates it on demand. */ - if (png_ptr->read_buffer != 0) + if (png_ptr->read_buffer != NULL) { png_bytep buffer = png_ptr->read_buffer; diff --git a/thirdparty/libpng/pngset.c b/thirdparty/libpng/pngset.c index 43456b729d..28ff3a064d 100644 --- a/thirdparty/libpng/pngset.c +++ b/thirdparty/libpng/pngset.c @@ -1,7 +1,7 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.6.23 [June 9, 2016] + * Last changed in libpng 1.6.26 [October 20, 2016] * Copyright (c) 1998-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -104,14 +104,14 @@ png_set_cHRM(png_const_structrp png_ptr, png_inforp info_ptr, double green_x, double green_y, double blue_x, double blue_y) { png_set_cHRM_fixed(png_ptr, info_ptr, - png_fixed(png_ptr, white_x, "cHRM White X"), - png_fixed(png_ptr, white_y, "cHRM White Y"), - png_fixed(png_ptr, red_x, "cHRM Red X"), - png_fixed(png_ptr, red_y, "cHRM Red Y"), - png_fixed(png_ptr, green_x, "cHRM Green X"), - png_fixed(png_ptr, green_y, "cHRM Green Y"), - png_fixed(png_ptr, blue_x, "cHRM Blue X"), - png_fixed(png_ptr, blue_y, "cHRM Blue Y")); + png_fixed(png_ptr, white_x, "cHRM White X"), + png_fixed(png_ptr, white_y, "cHRM White Y"), + png_fixed(png_ptr, red_x, "cHRM Red X"), + png_fixed(png_ptr, red_y, "cHRM Red Y"), + png_fixed(png_ptr, green_x, "cHRM Green X"), + png_fixed(png_ptr, green_y, "cHRM Green Y"), + png_fixed(png_ptr, blue_x, "cHRM Blue X"), + png_fixed(png_ptr, blue_y, "cHRM Blue Y")); } void PNGAPI @@ -120,15 +120,15 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X, double blue_X, double blue_Y, double blue_Z) { png_set_cHRM_XYZ_fixed(png_ptr, info_ptr, - png_fixed(png_ptr, red_X, "cHRM Red X"), - png_fixed(png_ptr, red_Y, "cHRM Red Y"), - png_fixed(png_ptr, red_Z, "cHRM Red Z"), - png_fixed(png_ptr, green_X, "cHRM Green X"), - png_fixed(png_ptr, green_Y, "cHRM Green Y"), - png_fixed(png_ptr, green_Z, "cHRM Green Z"), - png_fixed(png_ptr, blue_X, "cHRM Blue X"), - png_fixed(png_ptr, blue_Y, "cHRM Blue Y"), - png_fixed(png_ptr, blue_Z, "cHRM Blue Z")); + png_fixed(png_ptr, red_X, "cHRM Red X"), + png_fixed(png_ptr, red_Y, "cHRM Red Y"), + png_fixed(png_ptr, red_Z, "cHRM Red Z"), + png_fixed(png_ptr, green_X, "cHRM Green X"), + png_fixed(png_ptr, green_Y, "cHRM Green Y"), + png_fixed(png_ptr, green_Z, "cHRM Green Z"), + png_fixed(png_ptr, blue_X, "cHRM Blue X"), + png_fixed(png_ptr, blue_Y, "cHRM Blue Y"), + png_fixed(png_ptr, blue_Z, "cHRM Blue Z")); } # endif /* FLOATING_POINT */ @@ -283,17 +283,29 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, /* Check that the type matches the specification. */ if (type < 0 || type > 3) - png_error(png_ptr, "Invalid pCAL equation type"); + { + png_chunk_report(png_ptr, "Invalid pCAL equation type", + PNG_CHUNK_WRITE_ERROR); + return; + } if (nparams < 0 || nparams > 255) - png_error(png_ptr, "Invalid pCAL parameter count"); + { + png_chunk_report(png_ptr, "Invalid pCAL parameter count", + PNG_CHUNK_WRITE_ERROR); + return; + } /* Validate params[nparams] */ for (i=0; i<nparams; ++i) { if (params[i] == NULL || !png_check_fp_string(params[i], strlen(params[i]))) - png_error(png_ptr, "Invalid format for pCAL parameter"); + { + png_chunk_report(png_ptr, "Invalid format for pCAL parameter", + PNG_CHUNK_WRITE_ERROR); + return; + } } info_ptr->pcal_purpose = png_voidcast(png_charp, @@ -301,8 +313,8 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, if (info_ptr->pcal_purpose == NULL) { - png_warning(png_ptr, "Insufficient memory for pCAL purpose"); - + png_chunk_report(png_ptr, "Insufficient memory for pCAL purpose", + PNG_CHUNK_WRITE_ERROR); return; } @@ -316,10 +328,10 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, length = strlen(units) + 1; png_debug1(3, "allocating units for info (%lu bytes)", - (unsigned long)length); + (unsigned long)length); info_ptr->pcal_units = png_voidcast(png_charp, - png_malloc_warn(png_ptr, length)); + png_malloc_warn(png_ptr, length)); if (info_ptr->pcal_units == NULL) { @@ -331,7 +343,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, memcpy(info_ptr->pcal_units, units, length); info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr, - (png_size_t)((nparams + 1) * (sizeof (png_charp))))); + (png_size_t)(((unsigned int)nparams + 1) * (sizeof (png_charp))))); if (info_ptr->pcal_params == NULL) { @@ -340,7 +352,8 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, return; } - memset(info_ptr->pcal_params, 0, (nparams + 1) * (sizeof (png_charp))); + memset(info_ptr->pcal_params, 0, ((unsigned int)nparams + 1) * + (sizeof (png_charp))); for (i = 0; i < nparams; i++) { @@ -398,7 +411,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr, png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw); info_ptr->scal_s_width = png_voidcast(png_charp, - png_malloc_warn(png_ptr, lengthw)); + png_malloc_warn(png_ptr, lengthw)); if (info_ptr->scal_s_width == NULL) { @@ -414,7 +427,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr, png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh); info_ptr->scal_s_height = png_voidcast(png_charp, - png_malloc_warn(png_ptr, lengthh)); + png_malloc_warn(png_ptr, lengthh)); if (info_ptr->scal_s_height == NULL) { @@ -453,9 +466,9 @@ png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit, char sheight[PNG_sCAL_MAX_DIGITS+1]; png_ascii_from_fp(png_ptr, swidth, (sizeof swidth), width, - PNG_sCAL_PRECISION); + PNG_sCAL_PRECISION); png_ascii_from_fp(png_ptr, sheight, (sizeof sheight), height, - PNG_sCAL_PRECISION); + PNG_sCAL_PRECISION); png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); } @@ -563,7 +576,8 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, PNG_MAX_PALETTE_LENGTH * (sizeof (png_color)))); if (num_palette > 0) - memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color))); + memcpy(png_ptr->palette, palette, (unsigned int)num_palette * + (sizeof (png_color))); info_ptr->palette = png_ptr->palette; info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; @@ -648,7 +662,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, */ { int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name, - proflen, profile, info_ptr->color_type); + proflen, profile, info_ptr->color_type); png_colorspace_sync_info(png_ptr, info_ptr); @@ -673,7 +687,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, memcpy(new_iccp_name, name, length); new_iccp_profile = png_voidcast(png_bytep, - png_malloc_warn(png_ptr, proflen)); + png_malloc_warn(png_ptr, proflen)); if (new_iccp_profile == NULL) { @@ -748,14 +762,14 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, * the overflow checks. */ new_text = png_voidcast(png_textp,png_realloc_array(png_ptr, - info_ptr->text, old_num_text, max_text-old_num_text, - sizeof *new_text)); + info_ptr->text, old_num_text, max_text-old_num_text, + sizeof *new_text)); } if (new_text == NULL) { png_chunk_report(png_ptr, "too many text chunks", - PNG_CHUNK_WRITE_ERROR); + PNG_CHUNK_WRITE_ERROR); return 1; } @@ -783,7 +797,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST) { png_chunk_report(png_ptr, "text compression mode is out of range", - PNG_CHUNK_WRITE_ERROR); + PNG_CHUNK_WRITE_ERROR); continue; } @@ -815,7 +829,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, # else /* iTXt */ { png_chunk_report(png_ptr, "iTXt chunk not supported", - PNG_CHUNK_WRITE_ERROR); + PNG_CHUNK_WRITE_ERROR); continue; } # endif @@ -844,7 +858,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, if (textp->key == NULL) { png_chunk_report(png_ptr, "text chunk: out of memory", - PNG_CHUNK_WRITE_ERROR); + PNG_CHUNK_WRITE_ERROR); return 1; } @@ -956,7 +970,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, { /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ info_ptr->trans_alpha = png_voidcast(png_bytep, - png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH)); + png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH)); memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans); } png_ptr->trans_alpha = info_ptr->trans_alpha; @@ -976,7 +990,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, trans_color->green > sample_max || trans_color->blue > sample_max))) png_warning(png_ptr, - "tRNS chunk has out-of-range samples for bit_depth"); + "tRNS chunk has out-of-range samples for bit_depth"); } #endif @@ -1018,8 +1032,8 @@ png_set_sPLT(png_const_structrp png_ptr, * overflows. Notice that the parameters are (int) and (size_t) */ np = png_voidcast(png_sPLT_tp,png_realloc_array(png_ptr, - info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries, - sizeof *np)); + info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries, + sizeof *np)); if (np == NULL) { @@ -1080,7 +1094,7 @@ png_set_sPLT(png_const_structrp png_ptr, * checked it when doing the allocation. */ memcpy(np->entries, entries->entries, - entries->nentries * sizeof (png_sPLT_entry)); + (unsigned int)entries->nentries * sizeof (png_sPLT_entry)); /* Note that 'continue' skips the advance of the out pointer and out * count, so an invalid entry is not added. @@ -1110,10 +1124,10 @@ check_location(png_const_structrp png_ptr, int location) { /* Write struct, so unknown chunks come from the app */ png_app_warning(png_ptr, - "png_set_unknown_chunks now expects a valid location"); + "png_set_unknown_chunks now expects a valid location"); /* Use the old behavior */ location = (png_byte)(png_ptr->mode & - (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)); + (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)); } /* This need not be an internal error - if the app calls @@ -1136,7 +1150,7 @@ check_location(png_const_structrp png_ptr, int location) void PNGAPI png_set_unknown_chunks(png_const_structrp png_ptr, - png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns) + png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns) { png_unknown_chunkp np; @@ -1175,13 +1189,13 @@ png_set_unknown_chunks(png_const_structrp png_ptr, * appropriate to read or write. */ np = png_voidcast(png_unknown_chunkp, png_realloc_array(png_ptr, - info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns, - sizeof *np)); + info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns, + sizeof *np)); if (np == NULL) { png_chunk_report(png_ptr, "too many unknown chunks", - PNG_CHUNK_WRITE_ERROR); + PNG_CHUNK_WRITE_ERROR); return; } @@ -1210,12 +1224,12 @@ png_set_unknown_chunks(png_const_structrp png_ptr, else { np->data = png_voidcast(png_bytep, - png_malloc_base(png_ptr, unknowns->size)); + png_malloc_base(png_ptr, unknowns->size)); if (np->data == NULL) { png_chunk_report(png_ptr, "unknown chunk: out of memory", - PNG_CHUNK_WRITE_ERROR); + PNG_CHUNK_WRITE_ERROR); /* But just skip storing the unknown chunk */ continue; } @@ -1249,7 +1263,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr, { png_app_error(png_ptr, "invalid unknown chunk location"); /* Fake out the pre 1.6.0 behavior: */ - if ((location & PNG_HAVE_IDAT) != 0) /* undocumented! */ + if (((unsigned int)location & PNG_HAVE_IDAT) != 0) /* undocumented! */ location = PNG_AFTER_IDAT; else @@ -1373,7 +1387,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, return; } - num_chunks = num_chunks_in; + num_chunks = (unsigned int)num_chunks_in; } old_num_chunks = png_ptr->num_chunk_list; @@ -1422,7 +1436,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, for (i=0; i<num_chunks; ++i) { old_num_chunks = add_one_chunk(new_list, old_num_chunks, - chunk_list+5*i, keep); + chunk_list+5*i, keep); } /* Now remove any spurious 'default' entries. */ @@ -1502,60 +1516,60 @@ png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr, void PNGAPI png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size) { - if (png_ptr == NULL) - return; + if (png_ptr == NULL) + return; - if (size == 0 || size > PNG_UINT_31_MAX) - png_error(png_ptr, "invalid compression buffer size"); + if (size == 0 || size > PNG_UINT_31_MAX) + png_error(png_ptr, "invalid compression buffer size"); # ifdef PNG_SEQUENTIAL_READ_SUPPORTED - if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) - { - png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */ - return; - } + if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) + { + png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */ + return; + } # endif # ifdef PNG_WRITE_SUPPORTED - if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0) + if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0) + { + if (png_ptr->zowner != 0) { - if (png_ptr->zowner != 0) - { - png_warning(png_ptr, - "Compression buffer size cannot be changed because it is in use"); + png_warning(png_ptr, + "Compression buffer size cannot be changed because it is in use"); - return; - } + return; + } #ifndef __COVERITY__ - /* Some compilers complain that this is always false. However, it - * can be true when integer overflow happens. - */ - if (size > ZLIB_IO_MAX) - { - png_warning(png_ptr, - "Compression buffer size limited to system maximum"); - size = ZLIB_IO_MAX; /* must fit */ - } + /* Some compilers complain that this is always false. However, it + * can be true when integer overflow happens. + */ + if (size > ZLIB_IO_MAX) + { + png_warning(png_ptr, + "Compression buffer size limited to system maximum"); + size = ZLIB_IO_MAX; /* must fit */ + } #endif - if (size < 6) - { - /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH - * if this is permitted. - */ - png_warning(png_ptr, - "Compression buffer size cannot be reduced below 6"); + if (size < 6) + { + /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH + * if this is permitted. + */ + png_warning(png_ptr, + "Compression buffer size cannot be reduced below 6"); - return; - } + return; + } - if (png_ptr->zbuffer_size != size) - { - png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list); - png_ptr->zbuffer_size = (uInt)size; - } + if (png_ptr->zbuffer_size != size) + { + png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list); + png_ptr->zbuffer_size = (uInt)size; } + } # endif } @@ -1563,7 +1577,7 @@ void PNGAPI png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask) { if (png_ptr != NULL && info_ptr != NULL) - info_ptr->valid &= ~mask; + info_ptr->valid &= (unsigned int)(~mask); } @@ -1662,7 +1676,9 @@ png_set_check_for_invalid_index(png_structrp png_ptr, int allowed) png_uint_32 /* PRIVATE */ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key) { +#ifdef PNG_WARNINGS_SUPPORTED png_const_charp orig_key = key; +#endif png_uint_32 key_len = 0; int bad_character = 0; int space = 1; @@ -1725,7 +1741,9 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key) png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'"); } -#endif /* WARNINGS */ +#else /* !WARNINGS */ + PNG_UNUSED(png_ptr) +#endif /* !WARNINGS */ return key_len; } diff --git a/thirdparty/libpng/pngstruct.h b/thirdparty/libpng/pngstruct.h index c1f35edef5..55516eaaa1 100644 --- a/thirdparty/libpng/pngstruct.h +++ b/thirdparty/libpng/pngstruct.h @@ -1,8 +1,8 @@ /* pngstruct.h - header file for PNG reference library * - * Last changed in libpng 1.6.18 [July 23, 2015] - * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.24 [August 4, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -249,7 +249,7 @@ struct png_struct_def png_byte filter; /* file filter type (always 0) */ png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ png_byte pass; /* current interlace pass (0 - 6) */ - png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ + png_byte do_filter; /* row filter flags (see PNG_FILTER_ in png.h ) */ png_byte color_type; /* color type of file */ png_byte bit_depth; /* bit depth of file */ png_byte usr_bit_depth; /* bit depth of users row: write only */ @@ -263,7 +263,7 @@ struct png_struct_def /* pixel depth used for the row buffers */ png_byte transformed_pixel_depth; /* pixel depth after read/write transforms */ -#if PNG_ZLIB_VERNUM >= 0x1240 +#if ZLIB_VERNUM >= 0x1240 png_byte zstream_start; /* at start of an input zlib stream */ #endif /* Zlib >= 1.2.4 */ #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) diff --git a/thirdparty/libpng/pngtrans.c b/thirdparty/libpng/pngtrans.c index 7f8cc455d3..da7413fb80 100644 --- a/thirdparty/libpng/pngtrans.c +++ b/thirdparty/libpng/pngtrans.c @@ -1,8 +1,8 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * Last changed in libpng 1.6.18 [July 23, 2015] - * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -172,13 +172,14 @@ png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc) * size! */ png_app_error(png_ptr, - "png_set_filler is invalid for low bit depth gray output"); + "png_set_filler is invalid for" + " low bit depth gray output"); return; } default: png_app_error(png_ptr, - "png_set_filler: inappropriate color type"); + "png_set_filler: inappropriate color type"); return; } # else @@ -594,7 +595,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) return; /* The filler channel has gone already */ /* Fix the rowbytes value. */ - row_info->rowbytes = dp-row; + row_info->rowbytes = (unsigned int)(dp-row); } #endif @@ -692,7 +693,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info) * and this calculation is used because it avoids warnings that other * forms produced on either GCC or MSVC. */ - int padding = (-row_info->pixel_depth * row_info->width) & 7; + int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width); png_bytep rp = png_ptr->row_buf + row_info->rowbytes; switch (row_info->bit_depth) @@ -797,7 +798,7 @@ png_set_user_transform_info(png_structrp png_ptr, png_voidp (png_ptr->flags & PNG_FLAG_ROW_INIT) != 0) { png_app_error(png_ptr, - "info change after png_start_read_image or png_read_update_info"); + "info change after png_start_read_image or png_read_update_info"); return; } #endif diff --git a/thirdparty/libpng/pngwio.c b/thirdparty/libpng/pngwio.c index 586c03b721..37c7c3a7f0 100644 --- a/thirdparty/libpng/pngwio.c +++ b/thirdparty/libpng/pngwio.c @@ -1,8 +1,8 @@ /* pngwio.c - functions for data output * - * Last changed in libpng 1.6.15 [November 20, 2014] - * Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson + * Last changed in libpng 1.6.24 [August 4, 2016] + * Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -35,7 +35,7 @@ png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length) /* NOTE: write_data_fn must not change the buffer! */ if (png_ptr->write_data_fn != NULL ) (*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data), - length); + length); else png_error(png_ptr, "Call to NULL write function"); diff --git a/thirdparty/libpng/pngwrite.c b/thirdparty/libpng/pngwrite.c index 181a899438..07088ee75e 100644 --- a/thirdparty/libpng/pngwrite.c +++ b/thirdparty/libpng/pngwrite.c @@ -1,8 +1,8 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.6.19 [November 12, 2015] - * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -22,7 +22,7 @@ /* Write out all the unknown chunks for the current given location */ static void write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr, - unsigned int where) + unsigned int where) { if (info_ptr->unknown_chunks_num != 0) { @@ -148,11 +148,11 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) # ifdef PNG_WRITE_sRGB_SUPPORTED if ((info_ptr->valid & PNG_INFO_sRGB) != 0) png_app_warning(png_ptr, - "profile matches sRGB but writing iCCP instead"); + "profile matches sRGB but writing iCCP instead"); # endif png_write_iCCP(png_ptr, info_ptr->iccp_name, - info_ptr->iccp_profile); + info_ptr->iccp_profile); } # ifdef PNG_WRITE_sRGB_SUPPORTED else @@ -383,7 +383,7 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr) for (i = 0; i < info_ptr->num_text; i++) { png_debug2(2, "Writing trailer text chunk %d, type %d", i, - info_ptr->text[i].compression); + info_ptr->text[i].compression); /* An internationalized chunk? */ if (info_ptr->text[i].compression > 0) { @@ -666,9 +666,9 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1); - png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3); - png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5); + png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1); + png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3); + png_uint_32 s2 = (png_uint_32)(*(rp + 4) << 8) | *(rp + 5); png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL); png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL); *(rp ) = (png_byte)(red >> 8); @@ -693,7 +693,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) return; png_debug2(1, "in png_write_row (row %u, pass %d)", - png_ptr->row_number, png_ptr->pass); + png_ptr->row_number, png_ptr->pass); /* Initialize transformations and other stuff if first time */ if (png_ptr->row_number == 0 && png_ptr->pass == 0) @@ -901,7 +901,7 @@ png_set_flush(png_structrp png_ptr, int nrows) if (png_ptr == NULL) return; - png_ptr->flush_dist = (nrows < 0 ? 0 : nrows); + png_ptr->flush_dist = (nrows < 0 ? 0 : (png_uint_32)nrows); } /* Flush the current output buffers now */ @@ -1069,7 +1069,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters) * is not available so the filter can't be used. Just warn here. */ png_app_warning(png_ptr, - "png_set_filter: UP/AVG/PAETH cannot be added after start"); + "png_set_filter: UP/AVG/PAETH cannot be added after start"); filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH); } @@ -1095,13 +1095,13 @@ png_set_filter(png_structrp png_ptr, int method, int filters) if (png_ptr->try_row == NULL) png_ptr->try_row = png_voidcast(png_bytep, - png_malloc(png_ptr, buf_size)); + png_malloc(png_ptr, buf_size)); if (num_filters > 1) { if (png_ptr->tst_row == NULL) png_ptr->tst_row = png_voidcast(png_bytep, - png_malloc(png_ptr, buf_size)); + png_malloc(png_ptr, buf_size)); } } png_ptr->do_filter = (png_byte)filters; @@ -1525,7 +1525,8 @@ png_write_image_16bit(png_voidp argument) display->first_row); png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row); png_uint_16p row_end; - const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1; + const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? + 3 : 1; int aindex = 0; png_uint_32 y = image->height; @@ -1539,9 +1540,9 @@ png_write_image_16bit(png_voidp argument) ++output_row; } else - aindex = channels; + aindex = (int)channels; # else - aindex = channels; + aindex = (int)channels; # endif } @@ -1554,7 +1555,7 @@ png_write_image_16bit(png_voidp argument) */ row_end = output_row + image->width * (channels+1); - while (y-- > 0) + for (; y > 0; --y) { png_const_uint_16p in_ptr = input_row; png_uint_16p out_ptr = output_row; @@ -1575,7 +1576,7 @@ png_write_image_16bit(png_voidp argument) if (alpha > 0 && alpha < 65535) reciprocal = ((0xffff<<15)+(alpha>>1))/alpha; - c = channels; + c = (int)channels; do /* always at least one channel */ { png_uint_16 component = *in_ptr++; @@ -1610,7 +1611,7 @@ png_write_image_16bit(png_voidp argument) } png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row)); - input_row += display->row_bytes/(sizeof (png_uint_16)); + input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); } return 1; @@ -1628,7 +1629,7 @@ png_write_image_16bit(png_voidp argument) static png_byte png_unpremultiply(png_uint_32 component, png_uint_32 alpha, - png_uint_32 reciprocal/*from the above macro*/) + png_uint_32 reciprocal/*from the above macro*/) { /* The following gives 1.0 for an alpha of 0, which is fine, otherwise if 0/0 * is represented as some other value there is more likely to be a @@ -1683,7 +1684,8 @@ png_write_image_8bit(png_voidp argument) display->first_row); png_bytep output_row = png_voidcast(png_bytep, display->local_row); png_uint_32 y = image->height; - const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1; + const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? + 3 : 1; if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0) { @@ -1700,12 +1702,12 @@ png_write_image_8bit(png_voidp argument) else # endif - aindex = channels; + aindex = (int)channels; /* Use row_end in place of a loop counter: */ row_end = output_row + image->width * (channels+1); - while (y-- > 0) + for (; y > 0; --y) { png_const_uint_16p in_ptr = input_row; png_bytep out_ptr = output_row; @@ -1723,7 +1725,7 @@ png_write_image_8bit(png_voidp argument) if (alphabyte > 0 && alphabyte < 255) reciprocal = UNP_RECIPROCAL(alpha); - c = channels; + c = (int)channels; do /* always at least one channel */ *out_ptr++ = png_unpremultiply(*in_ptr++, alpha, reciprocal); while (--c > 0); @@ -1735,7 +1737,7 @@ png_write_image_8bit(png_voidp argument) png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row)); - input_row += display->row_bytes/(sizeof (png_uint_16)); + input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); } /* while y */ } @@ -1746,7 +1748,7 @@ png_write_image_8bit(png_voidp argument) */ png_bytep row_end = output_row + image->width * channels; - while (y-- > 0) + for (; y > 0; --y) { png_const_uint_16p in_ptr = input_row; png_bytep out_ptr = output_row; @@ -1760,7 +1762,7 @@ png_write_image_8bit(png_voidp argument) } png_write_row(png_ptr, output_row); - input_row += display->row_bytes/(sizeof (png_uint_16)); + input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); } } @@ -1777,7 +1779,7 @@ png_image_set_PLTE(png_image_write_control *display) /* NOTE: the caller must check for cmap != NULL and entries != 0 */ const png_uint_32 format = image->format; - const int channels = PNG_IMAGE_SAMPLE_CHANNELS(format); + const unsigned int channels = PNG_IMAGE_SAMPLE_CHANNELS(format); # if defined(PNG_FORMAT_BGR_SUPPORTED) &&\ defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED) @@ -1809,7 +1811,7 @@ png_image_set_PLTE(png_image_write_control *display) { png_const_uint_16p entry = png_voidcast(png_const_uint_16p, cmap); - entry += i * channels; + entry += (unsigned int)i * channels; if ((channels & 1) != 0) /* no alpha */ { @@ -1848,16 +1850,16 @@ png_image_set_PLTE(png_image_write_control *display) if (channels >= 3) /* RGB */ { palette[i].blue = png_unpremultiply(entry[afirst + (2 ^ bgr)], - alpha, reciprocal); + alpha, reciprocal); palette[i].green = png_unpremultiply(entry[afirst + 1], alpha, - reciprocal); + reciprocal); palette[i].red = png_unpremultiply(entry[afirst + bgr], alpha, - reciprocal); + reciprocal); } else /* gray */ palette[i].blue = palette[i].red = palette[i].green = - png_unpremultiply(entry[afirst], alpha, reciprocal); + png_unpremultiply(entry[afirst], alpha, reciprocal); } } @@ -1865,7 +1867,7 @@ png_image_set_PLTE(png_image_write_control *display) { png_const_bytep entry = png_voidcast(png_const_bytep, cmap); - entry += i * channels; + entry += (unsigned int)i * channels; switch (channels) { @@ -1904,20 +1906,20 @@ png_image_set_PLTE(png_image_write_control *display) # endif png_set_PLTE(image->opaque->png_ptr, image->opaque->info_ptr, palette, - entries); + entries); if (num_trans > 0) png_set_tRNS(image->opaque->png_ptr, image->opaque->info_ptr, tRNS, - num_trans, NULL); + num_trans, NULL); - image->colormap_entries = entries; + image->colormap_entries = (png_uint_32)entries; } static int png_image_write_main(png_voidp argument) { png_image_write_control *display = png_voidcast(png_image_write_control*, - argument); + argument); png_imagep image = display->image; png_structrp png_ptr = image->opaque->png_ptr; png_inforp info_ptr = image->opaque->info_ptr; @@ -1940,7 +1942,7 @@ png_image_write_main(png_voidp argument) { const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format); - if (image->width <= 0x7FFFFFFFU/channels) /* no overflow */ + if (image->width <= 0x7fffffffU/channels) /* no overflow */ { png_uint_32 check; const png_uint_32 png_row_stride = image->width * channels; @@ -1949,10 +1951,10 @@ png_image_write_main(png_voidp argument) display->row_stride = (png_int_32)/*SAFE*/png_row_stride; if (display->row_stride < 0) - check = -display->row_stride; + check = (png_uint_32)(-display->row_stride); else - check = display->row_stride; + check = (png_uint_32)display->row_stride; if (check >= png_row_stride) { @@ -1960,7 +1962,7 @@ png_image_write_main(png_voidp argument) * limits the whole image size to 32 bits for API compatibility with * the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro. */ - if (image->height > 0xFFFFFFFF/png_row_stride) + if (image->height > 0xffffffffU/png_row_stride) png_error(image->opaque->png_ptr, "memory image too large"); } @@ -1980,24 +1982,24 @@ png_image_write_main(png_voidp argument) png_uint_32 entries = image->colormap_entries; png_set_IHDR(png_ptr, info_ptr, image->width, image->height, - entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)), - PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)), + PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); png_image_set_PLTE(display); } else png_error(image->opaque->png_ptr, - "no color-map for color-mapped image"); + "no color-map for color-mapped image"); } else png_set_IHDR(png_ptr, info_ptr, image->width, image->height, - write_16bit ? 16 : 8, - ((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) + - ((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0), - PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + write_16bit ? 16 : 8, + ((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) + + ((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0), + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); /* Counter-intuitively the data transformations must be called *after* * png_write_info, not before as in the read code, but the 'set' functions @@ -2012,11 +2014,11 @@ png_image_write_main(png_voidp argument) if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0) png_set_cHRM_fixed(png_ptr, info_ptr, - /* color x y */ - /* white */ 31270, 32900, - /* red */ 64000, 33000, - /* green */ 30000, 60000, - /* blue */ 15000, 6000 + /* color x y */ + /* white */ 31270, 32900, + /* red */ 64000, 33000, + /* green */ 30000, 60000, + /* blue */ 15000, 6000 ); } @@ -2110,7 +2112,7 @@ png_image_write_main(png_voidp argument) (colormap == 0 && display->convert_to_8bit != 0)) { png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr, - png_get_rowbytes(png_ptr, info_ptr))); + png_get_rowbytes(png_ptr, info_ptr))); int result; display->local_row = row; @@ -2136,7 +2138,7 @@ png_image_write_main(png_voidp argument) ptrdiff_t row_bytes = display->row_bytes; png_uint_32 y = image->height; - while (y-- > 0) + for (; y > 0; --y) { png_write_row(png_ptr, row); row += row_bytes; @@ -2150,10 +2152,10 @@ png_image_write_main(png_voidp argument) static void (PNGCBAPI image_memory_write)(png_structp png_ptr, png_bytep/*const*/ data, - png_size_t size) + png_size_t size) { png_image_write_control *display = png_voidcast(png_image_write_control*, - png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/); + png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/); const png_alloc_size_t ob = display->output_bytes; /* Check for overflow; this should never happen: */ @@ -2184,22 +2186,22 @@ static int png_image_write_memory(png_voidp argument) { png_image_write_control *display = png_voidcast(png_image_write_control*, - argument); + argument); /* The rest of the memory-specific init and write_main in an error protected * environment. This case needs to use callbacks for the write operations * since libpng has no built in support for writing to memory. */ png_set_write_fn(display->image->opaque->png_ptr, display/*io_ptr*/, - image_memory_write, image_memory_flush); + image_memory_write, image_memory_flush); return png_image_write_main(display); } int PNGAPI png_image_write_to_memory(png_imagep image, void *memory, - png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8bit, - const void *buffer, png_int_32 row_stride, const void *colormap) + png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8bit, + const void *buffer, png_int_32 row_stride, const void *colormap) { /* Write the image to the given buffer, or count the bytes if it is NULL */ if (image != NULL && image->version == PNG_IMAGE_VERSION) @@ -2251,12 +2253,12 @@ png_image_write_to_memory(png_imagep image, void *memory, else return png_image_error(image, - "png_image_write_to_memory: invalid argument"); + "png_image_write_to_memory: invalid argument"); } else if (image != NULL) return png_image_error(image, - "png_image_write_to_memory: incorrect PNG_IMAGE_VERSION"); + "png_image_write_to_memory: incorrect PNG_IMAGE_VERSION"); else return 0; @@ -2265,7 +2267,7 @@ png_image_write_to_memory(png_imagep image, void *memory, #ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED int PNGAPI png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit, - const void *buffer, png_int_32 row_stride, const void *colormap) + const void *buffer, png_int_32 row_stride, const void *colormap) { /* Write the image to the given (FILE*). */ if (image != NULL && image->version == PNG_IMAGE_VERSION) @@ -2301,12 +2303,12 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit, else return png_image_error(image, - "png_image_write_to_stdio: invalid argument"); + "png_image_write_to_stdio: invalid argument"); } else if (image != NULL) return png_image_error(image, - "png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION"); + "png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION"); else return 0; @@ -2314,8 +2316,8 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit, int PNGAPI png_image_write_to_file(png_imagep image, const char *file_name, - int convert_to_8bit, const void *buffer, png_int_32 row_stride, - const void *colormap) + int convert_to_8bit, const void *buffer, png_int_32 row_stride, + const void *colormap) { /* Write the image to the named file. */ if (image != NULL && image->version == PNG_IMAGE_VERSION) @@ -2327,7 +2329,7 @@ png_image_write_to_file(png_imagep image, const char *file_name, if (fp != NULL) { if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer, - row_stride, colormap) != 0) + row_stride, colormap) != 0) { int error; /* from fflush/fclose */ @@ -2368,12 +2370,12 @@ png_image_write_to_file(png_imagep image, const char *file_name, else return png_image_error(image, - "png_image_write_to_file: invalid argument"); + "png_image_write_to_file: invalid argument"); } else if (image != NULL) return png_image_error(image, - "png_image_write_to_file: incorrect PNG_IMAGE_VERSION"); + "png_image_write_to_file: incorrect PNG_IMAGE_VERSION"); else return 0; diff --git a/thirdparty/libpng/pngwtran.c b/thirdparty/libpng/pngwtran.c index 038a2ef5dc..377b43e5ca 100644 --- a/thirdparty/libpng/pngwtran.c +++ b/thirdparty/libpng/pngwtran.c @@ -1,8 +1,8 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * Last changed in libpng 1.6.18 [July 23, 2015] - * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -177,7 +177,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, if (row_info->color_type != PNG_COLOR_TYPE_PALETTE) { int shift_start[4], shift_dec[4]; - int channels = 0; + unsigned int channels = 0; if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) { @@ -525,7 +525,7 @@ png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info) #ifdef PNG_WRITE_FILLER_SUPPORTED if ((png_ptr->transformations & PNG_FILLER) != 0) png_do_strip_channel(row_info, png_ptr->row_buf + 1, - !(png_ptr->flags & PNG_FLAG_FILLER_AFTER)); + !(png_ptr->flags & PNG_FLAG_FILLER_AFTER)); #endif #ifdef PNG_WRITE_PACKSWAP_SUPPORTED @@ -549,7 +549,7 @@ png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info) #ifdef PNG_WRITE_SHIFT_SUPPORTED if ((png_ptr->transformations & PNG_SHIFT) != 0) png_do_shift(row_info, png_ptr->row_buf + 1, - &(png_ptr->shift)); + &(png_ptr->shift)); #endif #ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED diff --git a/thirdparty/libpng/pngwutil.c b/thirdparty/libpng/pngwutil.c index b47f119d22..d1a82d45e1 100644 --- a/thirdparty/libpng/pngwutil.c +++ b/thirdparty/libpng/pngwutil.c @@ -1,7 +1,7 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.6.22 [May 26, 2016] + * Last changed in libpng 1.6.26 [October 20, 2016] * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -59,7 +59,7 @@ png_write_sig(png_structrp png_ptr) /* Write the rest of the 8 byte signature */ png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], - (png_size_t)(8 - png_ptr->sig_bytes)); + (png_size_t)(8 - png_ptr->sig_bytes)); if (png_ptr->sig_bytes < 3) png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; @@ -174,7 +174,7 @@ png_write_chunk_end(png_structrp png_ptr) */ static void png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name, - png_const_bytep data, png_size_t length) + png_const_bytep data, png_size_t length) { if (png_ptr == NULL) return; @@ -191,10 +191,10 @@ png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name, /* This is the API that calls the internal function above. */ void PNGAPI png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string, - png_const_bytep data, png_size_t length) + png_const_bytep data, png_size_t length) { png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data, - length); + length); } /* This is used below to find the size of an image to pass to png_deflate_claim, @@ -291,7 +291,7 @@ optimize_cmf(png_bytep data, png_alloc_size_t data_size) /* Initialize the compressor for the appropriate type of compression. */ static int png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, - png_alloc_size_t data_size) + png_alloc_size_t data_size) { if (png_ptr->zowner != 0) { @@ -408,7 +408,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, png_ptr->zstream.avail_out = 0; /* Now initialize if required, setting the new parameters, otherwise just - * to a simple reset to the previous parameters. + * do a simple reset to the previous parameters. */ if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0) ret = deflateReset(&png_ptr->zstream); @@ -416,7 +416,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, else { ret = deflateInit2(&png_ptr->zstream, level, method, windowBits, - memLevel, strategy); + memLevel, strategy); if (ret == Z_OK) png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; @@ -477,7 +477,7 @@ typedef struct static void png_text_compress_init(compression_state *comp, png_const_bytep input, - png_alloc_size_t input_len) + png_alloc_size_t input_len) { comp->input = input; comp->input_len = input_len; @@ -487,7 +487,7 @@ png_text_compress_init(compression_state *comp, png_const_bytep input, /* Compress the data in the compression state input */ static int png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name, - compression_state *comp, png_uint_32 prefix_len) + compression_state *comp, png_uint_32 prefix_len) { int ret; @@ -579,7 +579,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name, /* Compress the data */ ret = deflate(&png_ptr->zstream, - input_len > 0 ? Z_NO_FLUSH : Z_FINISH); + input_len > 0 ? Z_NO_FLUSH : Z_FINISH); /* Claw back input data that was not consumed (because avail_in is * reset above every time round the loop). @@ -925,7 +925,7 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette, */ void /* PRIVATE */ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input, - png_alloc_size_t input_len, int flush) + png_alloc_size_t input_len, int flush) { if (png_ptr->zowner != png_IDAT) { @@ -937,7 +937,7 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input, if (png_ptr->zbuffer_list == NULL) { png_ptr->zbuffer_list = png_voidcast(png_compression_bufferp, - png_malloc(png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr))); + png_malloc(png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr))); png_ptr->zbuffer_list->next = NULL; } @@ -1176,7 +1176,7 @@ png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette) png_byte new_name[80]; png_byte entrybuf[10]; png_size_t entry_size = (spalette->depth == 8 ? 6 : 10); - png_size_t palette_size = entry_size * spalette->nentries; + png_size_t palette_size = entry_size * (png_size_t)spalette->nentries; png_sPLT_entryp ep; #ifndef PNG_POINTER_INDEXING_SUPPORTED int i; @@ -1358,7 +1358,7 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha, /* Write the chunk out as it is */ png_write_complete_chunk(png_ptr, png_tRNS, trans_alpha, - (png_size_t)num_trans); + (png_size_t)num_trans); } else if (color_type == PNG_COLOR_TYPE_GRAY) @@ -1389,7 +1389,7 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha, #endif { png_app_warning(png_ptr, - "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); + "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); return; } @@ -1441,7 +1441,8 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type) #endif { png_warning(png_ptr, - "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); + "Ignoring attempt to write 16-bit bKGD chunk " + "when bit_depth is 8"); return; } @@ -1571,7 +1572,7 @@ png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, /* Compute the compressed data; do it now for the length */ png_text_compress_init(&comp, (png_const_bytep)text, - text == NULL ? 0 : strlen(text)); + text == NULL ? 0 : strlen(text)); if (png_text_compress(png_ptr, png_zTXt, &comp, key_len) != Z_OK) png_error(png_ptr, png_ptr->zstream.msg); @@ -1742,7 +1743,7 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0, total_len = purpose_len + units_len + 10; params_len = (png_size_tp)png_malloc(png_ptr, - (png_alloc_size_t)(nparams * (sizeof (png_size_t)))); + (png_alloc_size_t)((png_alloc_size_t)nparams * (sizeof (png_size_t)))); /* Find the length of each parameter, making sure we don't count the * null terminator for the last parameter. @@ -1941,7 +1942,7 @@ png_write_start_row(png_structrp png_ptr) */ if ((filters & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) != 0) png_ptr->prev_row = png_voidcast(png_bytep, - png_calloc(png_ptr, buf_size)); + png_calloc(png_ptr, buf_size)); #endif /* WRITE_FILTER */ #ifdef PNG_WRITE_INTERLACING_SUPPORTED @@ -2244,7 +2245,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) */ static void /* PRIVATE */ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, - png_size_t row_bytes); + png_size_t row_bytes); #ifdef PNG_WRITE_FILTER_SUPPORTED static png_size_t /* PRIVATE */ @@ -2254,7 +2255,7 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp, png_bytep rp, dp, lp; png_size_t i; png_size_t sum = 0; - int v; + unsigned int v; png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB; @@ -2262,14 +2263,22 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp, i++, rp++, dp++) { v = *dp = *rp; +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif } for (lp = png_ptr->row_buf + 1; i < row_bytes; i++, rp++, lp++, dp++) { v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif if (sum > lmins) /* We are already worse, don't continue. */ break; @@ -2278,6 +2287,28 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp, return (sum); } +static void /* PRIVATE */ +png_setup_sub_row_only(png_structrp png_ptr, const png_uint_32 bpp, + const png_size_t row_bytes) +{ + png_bytep rp, dp, lp; + png_size_t i; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp; + i++, rp++, dp++) + { + *dp = *rp; + } + + for (lp = png_ptr->row_buf + 1; i < row_bytes; + i++, rp++, lp++, dp++) + { + *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); + } +} + static png_size_t /* PRIVATE */ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes, const png_size_t lmins) @@ -2285,7 +2316,7 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes, png_bytep rp, dp, pp; png_size_t i; png_size_t sum = 0; - int v; + unsigned int v; png_ptr->try_row[0] = PNG_FILTER_VALUE_UP; @@ -2294,7 +2325,11 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes, i++, rp++, pp++, dp++) { v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif if (sum > lmins) /* We are already worse, don't continue. */ break; @@ -2302,24 +2337,43 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes, return (sum); } +static void /* PRIVATE */ +png_setup_up_row_only(png_structrp png_ptr, const png_size_t row_bytes) +{ + png_bytep rp, dp, pp; + png_size_t i; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_UP; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, + pp = png_ptr->prev_row + 1; i < row_bytes; + i++, rp++, pp++, dp++) + { + *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); + } +} static png_size_t /* PRIVATE */ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp, - const png_size_t row_bytes, const png_size_t lmins) + const png_size_t row_bytes, const png_size_t lmins) { png_bytep rp, dp, pp, lp; png_uint_32 i; png_size_t sum = 0; - int v; + unsigned int v; png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG; for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, - pp = png_ptr->prev_row + 1; i < bpp; i++) + pp = png_ptr->prev_row + 1; i < bpp; i++) { v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif } for (lp = png_ptr->row_buf + 1; i < row_bytes; i++) @@ -2327,7 +2381,11 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp, v = *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff); +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif if (sum > lmins) /* We are already worse, don't continue. */ break; @@ -2335,6 +2393,27 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp, return (sum); } +static void /* PRIVATE */ +png_setup_avg_row_only(png_structrp png_ptr, const png_uint_32 bpp, + const png_size_t row_bytes) +{ + png_bytep rp, dp, pp, lp; + png_uint_32 i; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, + pp = png_ptr->prev_row + 1; i < bpp; i++) + { + *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); + } + + for (lp = png_ptr->row_buf + 1; i < row_bytes; i++) + { + *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) + & 0xff); + } +} static png_size_t /* PRIVATE */ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp, @@ -2343,7 +2422,7 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp, png_bytep rp, dp, pp, cp, lp; png_size_t i; png_size_t sum = 0; - int v; + unsigned int v; png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH; @@ -2352,7 +2431,11 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp, { v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif } for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes; @@ -2381,7 +2464,11 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp, v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif if (sum > lmins) /* We are already worse, don't continue. */ break; @@ -2389,6 +2476,48 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp, return (sum); } +static void /* PRIVATE */ +png_setup_paeth_row_only(png_structrp png_ptr, const png_uint_32 bpp, + const png_size_t row_bytes) +{ + png_bytep rp, dp, pp, cp, lp; + png_size_t i; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, + pp = png_ptr->prev_row + 1; i < bpp; i++) + { + *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); + } + + for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes; + i++) + { + int a, b, c, pa, pb, pc, p; + + b = *pp++; + c = *cp++; + a = *lp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; + + *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); + } +} #endif /* WRITE_FILTER */ void /* PRIVATE */ @@ -2397,7 +2526,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) #ifndef PNG_WRITE_FILTER_SUPPORTED png_write_filtered_row(png_ptr, png_ptr->row_buf, row_info->rowbytes+1); #else - png_byte filter_to_do = png_ptr->do_filter; + unsigned int filter_to_do = png_ptr->do_filter; png_bytep row_buf; png_bytep best_row; png_uint_32 bpp; @@ -2443,32 +2572,33 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) */ best_row = png_ptr->row_buf; - - if ((filter_to_do & PNG_FILTER_NONE) != 0 && filter_to_do != PNG_FILTER_NONE) + if (PNG_SIZE_MAX/128 <= row_bytes) { + /* Overflow can occur in the calculation, just select the lowest set + * filter. + */ + filter_to_do &= 0U-filter_to_do; + } + else if ((filter_to_do & PNG_FILTER_NONE) != 0 && + filter_to_do != PNG_FILTER_NONE) + { + /* Overflow not possible and multiple filters in the list, including the + * 'none' filter. + */ png_bytep rp; png_size_t sum = 0; png_size_t i; - int v; + unsigned int v; - if (PNG_SIZE_MAX/128 <= row_bytes) - { - for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) - { - /* Check for overflow */ - if (sum > PNG_SIZE_MAX/128 - 256) - break; - - v = *rp; - sum += (v < 128) ? v : 256 - v; - } - } - else /* Overflow is not possible */ { for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) { v = *rp; +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif } } @@ -2479,7 +2609,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) if (filter_to_do == PNG_FILTER_SUB) /* It's the only filter so no testing is needed */ { - (void) png_setup_sub_row(png_ptr, bpp, row_bytes, mins); + png_setup_sub_row_only(png_ptr, bpp, row_bytes); best_row = png_ptr->try_row; } @@ -2505,7 +2635,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Up filter */ if (filter_to_do == PNG_FILTER_UP) { - (void) png_setup_up_row(png_ptr, row_bytes, mins); + png_setup_up_row_only(png_ptr, row_bytes); best_row = png_ptr->try_row; } @@ -2531,7 +2661,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Avg filter */ if (filter_to_do == PNG_FILTER_AVG) { - (void) png_setup_avg_row(png_ptr, bpp, row_bytes, mins); + png_setup_avg_row_only(png_ptr, bpp, row_bytes); best_row = png_ptr->try_row; } @@ -2555,9 +2685,9 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) } /* Paeth filter */ - if ((filter_to_do == PNG_FILTER_PAETH) != 0) + if (filter_to_do == PNG_FILTER_PAETH) { - (void) png_setup_paeth_row(png_ptr, bpp, row_bytes, mins); + png_setup_paeth_row_only(png_ptr, bpp, row_bytes); best_row = png_ptr->try_row; } @@ -2589,7 +2719,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Do the actual writing of a previously filtered row. */ static void png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, - png_size_t full_row_length/*includes filter byte*/) + png_size_t full_row_length/*includes filter byte*/) { png_debug(1, "in png_write_filtered_row"); diff --git a/thirdparty/opus/opus.h b/thirdparty/opus/opus/opus.h index b0bdf6f2df..b0bdf6f2df 100644 --- a/thirdparty/opus/opus.h +++ b/thirdparty/opus/opus/opus.h diff --git a/thirdparty/opus/opus_custom.h b/thirdparty/opus/opus/opus_custom.h index 41f36bf2fb..41f36bf2fb 100644 --- a/thirdparty/opus/opus_custom.h +++ b/thirdparty/opus/opus/opus_custom.h diff --git a/thirdparty/opus/opus_defines.h b/thirdparty/opus/opus/opus_defines.h index 647ed5d6f2..647ed5d6f2 100644 --- a/thirdparty/opus/opus_defines.h +++ b/thirdparty/opus/opus/opus_defines.h diff --git a/thirdparty/opus/opus_multistream.h b/thirdparty/opus/opus/opus_multistream.h index 47e03900bd..47e03900bd 100644 --- a/thirdparty/opus/opus_multistream.h +++ b/thirdparty/opus/opus/opus_multistream.h diff --git a/thirdparty/opus/opus_types.h b/thirdparty/opus/opus/opus_types.h index b28e03aea2..b28e03aea2 100644 --- a/thirdparty/opus/opus_types.h +++ b/thirdparty/opus/opus/opus_types.h diff --git a/thirdparty/opus/opusfile.h b/thirdparty/opus/opus/opusfile.h index 3604115c31..3604115c31 100644 --- a/thirdparty/opus/opusfile.h +++ b/thirdparty/opus/opus/opusfile.h diff --git a/tools/SCsub b/tools/SCsub index b0b33d4f01..43cad794d4 100644 --- a/tools/SCsub +++ b/tools/SCsub @@ -2,124 +2,120 @@ Import('env') -env.tool_sources=[] -env.add_source_files(env.tool_sources,"*.cpp") +env.tool_sources = [] +env.add_source_files(env.tool_sources, "*.cpp") Export('env') -def make_translations_header(target,source,env): +def make_translations_header(target, source, env): + dst = target[0].srcnode().abspath - dst = target[0].srcnode().abspath + g = open(dst, "wb") - g = open(dst,"wb") - - - """" + """" """ - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _EDITOR_TRANSLATIONS_H\n") - g.write("#define _EDITOR_TRANSLATIONS_H\n") - - import zlib - import os.path + g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + g.write("#ifndef _EDITOR_TRANSLATIONS_H\n") + g.write("#define _EDITOR_TRANSLATIONS_H\n") - paths = [node.srcnode().abspath for node in source] - sorted_paths = sorted(paths, key=lambda path: os.path.splitext(os.path.basename(path))[0]) + import zlib + import os.path - xl_names=[] - for i in range(len(sorted_paths)): - print("Appending translation: "+sorted_paths[i]) - f = open(sorted_paths[i],"rb") - buf = f.read() - decomp_size = len(buf) - buf = zlib.compress(buf) - name = os.path.splitext(os.path.basename(sorted_paths[i]))[0] + paths = [node.srcnode().abspath for node in source] + sorted_paths = sorted(paths, key=lambda path: os.path.splitext(os.path.basename(path))[0]) - #g.write("static const int _translation_"+name+"_compressed_size="+str(len(buf))+";\n") - #g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n") - g.write("static const unsigned char _translation_"+name+"_compressed[]={\n") - for i in range(len(buf)): - g.write(str(ord(buf[i]))+",\n") + xl_names = [] + for i in range(len(sorted_paths)): + print("Appending translation: " + sorted_paths[i]) + f = open(sorted_paths[i], "rb") + buf = f.read() + decomp_size = len(buf) + buf = zlib.compress(buf) + name = os.path.splitext(os.path.basename(sorted_paths[i]))[0] - g.write("};\n") + #g.write("static const int _translation_"+name+"_compressed_size="+str(len(buf))+";\n") + #g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n") + g.write("static const unsigned char _translation_" + name + "_compressed[]={\n") + for i in range(len(buf)): + g.write(str(ord(buf[i])) + ",\n") - xl_names.append([name,len(buf),str(decomp_size)]) + g.write("};\n") - g.write("struct EditorTranslationList {\n") - g.write("\tconst char* lang;\n"); - g.write("\tint comp_size;\n"); - g.write("\tint uncomp_size;\n"); - g.write("\tconst unsigned char* data;\n"); - g.write("};\n\n"); - g.write("static EditorTranslationList _editor_translations[]={\n") - for x in xl_names: - g.write("\t{ \""+x[0]+"\", "+str(x[1])+", "+str(x[2])+",_translation_"+x[0]+"_compressed},\n") - g.write("\t{NULL,0,0,NULL}\n") - g.write("};\n") + xl_names.append([name, len(buf), str(decomp_size)]) - g.write("#endif") + g.write("struct EditorTranslationList {\n") + g.write("\tconst char* lang;\n") + g.write("\tint comp_size;\n") + g.write("\tint uncomp_size;\n") + g.write("\tconst unsigned char* data;\n") + g.write("};\n\n") + g.write("static EditorTranslationList _editor_translations[]={\n") + for x in xl_names: + g.write("\t{ \"" + x[0] + "\", " + str(x[1]) + ", " + str(x[2]) + ",_translation_" + x[0] + "_compressed},\n") + g.write("\t{NULL,0,0,NULL}\n") + g.write("};\n") + g.write("#endif") -def make_fonts_header(target,source,env): +def make_fonts_header(target, source, env): - dst = target[0].srcnode().abspath + dst = target[0].srcnode().abspath - g = open(dst,"wb") + g = open(dst, "wb") - - """" + """" """ - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _EDITOR_FONTS_H\n") - g.write("#define _EDITOR_FONTS_H\n") + g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + g.write("#ifndef _EDITOR_FONTS_H\n") + g.write("#define _EDITOR_FONTS_H\n") + + # saving uncompressed, since freetype will reference from memory pointer + xl_names = [] + for i in range(len(source)): + print("Appending font: " + source[i].srcnode().abspath) + f = open(source[i].srcnode().abspath, "rb") + buf = f.read() + import os.path + + name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0] + + g.write("static const int _font_" + name + "_size=" + str(len(buf)) + ";\n") + g.write("static const unsigned char _font_" + name + "[]={\n") + for i in range(len(buf)): + g.write(str(ord(buf[i])) + ",\n") + + g.write("};\n") - #saving uncompressed, since freetype will reference from memory pointer - xl_names=[] - for i in range(len(source)): - print("Appending font: "+source[i].srcnode().abspath) - f = open(source[i].srcnode().abspath,"rb") - buf = f.read() - import os.path - - name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0] + g.write("#endif") - g.write("static const int _font_"+name+"_size="+str(len(buf))+";\n") - g.write("static const unsigned char _font_"+name+"[]={\n") - for i in range(len(buf)): - g.write(str(ord(buf[i]))+",\n") - g.write("};\n") - - g.write("#endif") - - -if (env["tools"]!="no"): +if (env["tools"] != "no"): - import glob + import glob - dir = env.Dir('.').abspath - tlist = glob.glob(dir + "/translations/*.po") + dir = env.Dir('.').abspath + tlist = glob.glob(dir + "/translations/*.po") - print("translations: ",tlist) - env.Depends('#tools/editor/translations.h',tlist) - env.Command('#tools/editor/translations.h',tlist,make_translations_header) + print("translations: ", tlist) + env.Depends('#tools/editor/translations.h', tlist) + env.Command('#tools/editor/translations.h', tlist, make_translations_header) - flist = glob.glob(dir + "/editor_fonts/*.ttf") - flist.append( glob.glob(dir + "/editor_fonts/*.otf") ) + flist = glob.glob(dir + "/editor_fonts/*.ttf") + flist.append(glob.glob(dir + "/editor_fonts/*.otf")) - print("fonts: ",flist) - env.Depends('#tools/editor/builtin_fonts.h',flist) - env.Command('#tools/editor/builtin_fonts.h',flist,make_fonts_header) + print("fonts: ", flist) + env.Depends('#tools/editor/builtin_fonts.h', flist) + env.Command('#tools/editor/builtin_fonts.h', flist, make_fonts_header) - SConscript('editor/SCsub'); - SConscript('collada/SCsub'); - SConscript('doc/SCsub') + SConscript('editor/SCsub') + SConscript('collada/SCsub') + SConscript('doc/SCsub') - lib = env.Library("tool",env.tool_sources) + lib = env.Library("tool", env.tool_sources) - env.Prepend(LIBS=[lib]) + env.Prepend(LIBS=[lib]) diff --git a/tools/collada/SCsub b/tools/collada/SCsub index 473474201a..4bc64ffdc2 100644 --- a/tools/collada/SCsub +++ b/tools/collada/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.tool_sources,"*.cpp") +env.add_source_files(env.tool_sources, "*.cpp") Export('env') diff --git a/tools/doc/SCsub b/tools/doc/SCsub index 473474201a..4bc64ffdc2 100644 --- a/tools/doc/SCsub +++ b/tools/doc/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.tool_sources,"*.cpp") +env.add_source_files(env.tool_sources, "*.cpp") Export('env') diff --git a/tools/editor/SCsub b/tools/editor/SCsub index f6cb16dc24..caf45d25be 100644 --- a/tools/editor/SCsub +++ b/tools/editor/SCsub @@ -3,86 +3,78 @@ Import('env') -def make_doc_header(target,source,env): - - src = source[0].srcnode().abspath - dst = target[0].srcnode().abspath - f = open(src,"rb") - g = open(dst,"wb") - buf = f.read() - decomp_size = len(buf) - import zlib - buf = zlib.compress(buf) - - - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _DOC_DATA_RAW_H\n") - g.write("#define _DOC_DATA_RAW_H\n") - g.write("static const int _doc_data_compressed_size="+str(len(buf))+";\n") - g.write("static const int _doc_data_uncompressed_size="+str(decomp_size)+";\n") - g.write("static const unsigned char _doc_data_compressed[]={\n") - for i in range(len(buf)): - g.write(str(ord(buf[i]))+",\n") - g.write("};\n") - g.write("#endif") - - - -def make_certs_header(target,source,env): - - src = source[0].srcnode().abspath - dst = target[0].srcnode().abspath - f = open(src,"rb") - g = open(dst,"wb") - buf = f.read() - decomp_size = len(buf) - import zlib - buf = zlib.compress(buf) - - - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _CERTS_RAW_H\n") - g.write("#define _CERTS_RAW_H\n") - g.write("static const int _certs_compressed_size="+str(len(buf))+";\n") - g.write("static const int _certs_uncompressed_size="+str(decomp_size)+";\n") - g.write("static const unsigned char _certs_compressed[]={\n") - for i in range(len(buf)): - g.write(str(ord(buf[i]))+",\n") - g.write("};\n") - g.write("#endif") - - - - - - - -if (env["tools"]=="yes"): - - reg_exporters_inc='#include "register_exporters.h"\n' - reg_exporters='void register_exporters() {\n' - for e in env.platform_exporters: - env.tool_sources.append("#platform/"+e+"/export/export.cpp") - reg_exporters+='\tregister_'+e+'_exporter();\n' - reg_exporters_inc+='#include "platform/'+e+'/export/export.h"\n' - reg_exporters+='}\n' - f = open("register_exporters.cpp","wb") - f.write(reg_exporters_inc) - f.write(reg_exporters) - f.close() - - env.Depends("#tools/editor/doc_data_compressed.h","#doc/base/classes.xml") - env.Command("#tools/editor/doc_data_compressed.h","#doc/base/classes.xml",make_doc_header) - - env.Depends("#tools/editor/certs_compressed.h","#tools/certs/ca-certificates.crt") - env.Command("#tools/editor/certs_compressed.h","#tools/certs/ca-certificates.crt",make_certs_header) - - #make_doc_header(env.File("#tools/editor/doc_data_raw.h").srcnode().abspath,env.File("#doc/base/classes.xml").srcnode().abspath,env) - - env.add_source_files(env.tool_sources,"*.cpp") - - Export('env') - SConscript('icons/SCsub'); - SConscript('plugins/SCsub'); - SConscript('fileserver/SCsub'); - SConscript('io_plugins/SCsub'); +def make_doc_header(target, source, env): + + src = source[0].srcnode().abspath + dst = target[0].srcnode().abspath + f = open(src, "rb") + g = open(dst, "wb") + buf = f.read() + decomp_size = len(buf) + import zlib + buf = zlib.compress(buf) + + g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + g.write("#ifndef _DOC_DATA_RAW_H\n") + g.write("#define _DOC_DATA_RAW_H\n") + g.write("static const int _doc_data_compressed_size=" + str(len(buf)) + ";\n") + g.write("static const int _doc_data_uncompressed_size=" + str(decomp_size) + ";\n") + g.write("static const unsigned char _doc_data_compressed[]={\n") + for i in range(len(buf)): + g.write(str(ord(buf[i])) + ",\n") + g.write("};\n") + g.write("#endif") + + +def make_certs_header(target, source, env): + + src = source[0].srcnode().abspath + dst = target[0].srcnode().abspath + f = open(src, "rb") + g = open(dst, "wb") + buf = f.read() + decomp_size = len(buf) + import zlib + buf = zlib.compress(buf) + + g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + g.write("#ifndef _CERTS_RAW_H\n") + g.write("#define _CERTS_RAW_H\n") + g.write("static const int _certs_compressed_size=" + str(len(buf)) + ";\n") + g.write("static const int _certs_uncompressed_size=" + str(decomp_size) + ";\n") + g.write("static const unsigned char _certs_compressed[]={\n") + for i in range(len(buf)): + g.write(str(ord(buf[i])) + ",\n") + g.write("};\n") + g.write("#endif") + + +if (env["tools"] == "yes"): + + reg_exporters_inc = '#include "register_exporters.h"\n' + reg_exporters = 'void register_exporters() {\n' + for e in env.platform_exporters: + env.tool_sources.append("#platform/" + e + "/export/export.cpp") + reg_exporters += '\tregister_' + e + '_exporter();\n' + reg_exporters_inc += '#include "platform/' + e + '/export/export.h"\n' + reg_exporters += '}\n' + f = open("register_exporters.cpp", "wb") + f.write(reg_exporters_inc) + f.write(reg_exporters) + f.close() + + env.Depends("#tools/editor/doc_data_compressed.h", "#doc/base/classes.xml") + env.Command("#tools/editor/doc_data_compressed.h", "#doc/base/classes.xml", make_doc_header) + + env.Depends("#tools/editor/certs_compressed.h", "#tools/certs/ca-certificates.crt") + env.Command("#tools/editor/certs_compressed.h", "#tools/certs/ca-certificates.crt", make_certs_header) + + # make_doc_header(env.File("#tools/editor/doc_data_raw.h").srcnode().abspath,env.File("#doc/base/classes.xml").srcnode().abspath,env) + + env.add_source_files(env.tool_sources, "*.cpp") + + Export('env') + SConscript('icons/SCsub') + SConscript('plugins/SCsub') + SConscript('fileserver/SCsub') + SConscript('io_plugins/SCsub') diff --git a/tools/editor/fileserver/SCsub b/tools/editor/fileserver/SCsub index 6299fd416c..4bf55189cc 100644 --- a/tools/editor/fileserver/SCsub +++ b/tools/editor/fileserver/SCsub @@ -2,4 +2,4 @@ Import('env') Export('env') -env.add_source_files(env.tool_sources,"*.cpp") +env.add_source_files(env.tool_sources, "*.cpp") diff --git a/tools/editor/icons/2x/icon_script_create.png b/tools/editor/icons/2x/icon_script_create.png Binary files differnew file mode 100644 index 0000000000..67f80e8760 --- /dev/null +++ b/tools/editor/icons/2x/icon_script_create.png diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub index 9e05d8f391..af6ebd67fd 100644 --- a/tools/editor/icons/SCsub +++ b/tools/editor/icons/SCsub @@ -2,97 +2,95 @@ Import('env') -def make_editor_icons_action(target, source, env): - - import os - import cStringIO - dst = target[0].srcnode().abspath - pixmaps = source - - s = cStringIO.StringIO() +def make_editor_icons_action(target, source, env): - s.write("#include \"editor_icons.h\"\n\n") - s.write("#include \"editor_scale.h\"\n\n") - s.write("#include \"scene/resources/theme.h\"\n\n") + import os + import cStringIO - hidpi_list=[] + dst = target[0].srcnode().abspath + pixmaps = source - for x in pixmaps: + s = cStringIO.StringIO() - x=str(x) - var_str=os.path.basename(x)[:-4]+"_png"; - #print(var_str) + s.write("#include \"editor_icons.h\"\n\n") + s.write("#include \"editor_scale.h\"\n\n") + s.write("#include \"scene/resources/theme.h\"\n\n") - s.write("static const unsigned char "+ var_str +"[]={\n"); + hidpi_list = [] - pngf=open(x,"rb"); + for x in pixmaps: - b=pngf.read(1); - while(len(b)==1): - s.write(hex(ord(b))) - b=pngf.read(1); - if (len(b)==1): - s.write(",") + x = str(x) + var_str = os.path.basename(x)[:-4] + "_png" + # print(var_str) - s.write("\n};\n\n"); + s.write("static const unsigned char " + var_str + "[]={\n") - pngf.close(); - var_str=os.path.basename(x)[:-4]+"_hidpi_png"; - try: + pngf = open(x, "rb") - pngf = open(os.path.dirname(x)+"/2x/"+os.path.basename(x), "rb") + b = pngf.read(1) + while(len(b) == 1): + s.write(hex(ord(b))) + b = pngf.read(1) + if (len(b) == 1): + s.write(",") - s.write("static const unsigned char "+ var_str +"[]={\n"); + s.write("\n};\n\n") - b=pngf.read(1); - while(len(b)==1): - s.write(hex(ord(b))) - b=pngf.read(1); - if (len(b)==1): - s.write(",") + pngf.close() + var_str = os.path.basename(x)[:-4] + "_hidpi_png" + try: - s.write("\n};\n\n\n"); - hidpi_list.append(x) + pngf = open(os.path.dirname(x) + "/2x/" + os.path.basename(x), "rb") - except: - s.write("static const unsigned char* "+ var_str +"=NULL;\n\n\n"); + s.write("static const unsigned char " + var_str + "[]={\n") + b = pngf.read(1) + while(len(b) == 1): + s.write(hex(ord(b))) + b = pngf.read(1) + if (len(b) == 1): + s.write(",") + s.write("\n};\n\n\n") + hidpi_list.append(x) + except: + s.write("static const unsigned char* " + var_str + "=NULL;\n\n\n") - s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n") - s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n") - s.write("\tbool use_hidpi_image=(editor_get_scale()>1.0&&p_hidpi_png);\n") - s.write("\tImage img(use_hidpi_image?p_hidpi_png:p_png);\n") - s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); use_hidpi_image=true;}\n") - s.write("\timg.resize(img.get_width()*EDSCALE/(use_hidpi_image?2:1),img.get_height()*EDSCALE/(use_hidpi_image?2:1));\n") - s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n") - s.write("\treturn texture;\n") - s.write("}\n\n") + s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n") + s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n") + s.write("\tbool use_hidpi_image=(editor_get_scale()>1.0&&p_hidpi_png);\n") + s.write("\tImage img(use_hidpi_image?p_hidpi_png:p_png);\n") + s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); use_hidpi_image=true;}\n") + s.write("\timg.resize(img.get_width()*EDSCALE/(use_hidpi_image?2:1),img.get_height()*EDSCALE/(use_hidpi_image?2:1));\n") + s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n") + s.write("\treturn texture;\n") + s.write("}\n\n") - s.write("void editor_register_icons(Ref<Theme> p_theme) {\n\n") + s.write("void editor_register_icons(Ref<Theme> p_theme) {\n\n") - for x in pixmaps: + for x in pixmaps: - x=os.path.basename(str(x)) - type=x[5:-4].title().replace("_",""); - var_str=x[:-4]+"_png"; - var_str_hidpi=x[:-4]+"_hidpi_png"; - s.write("\tp_theme->set_icon(\""+type+"\",\"EditorIcons\",make_icon("+var_str+","+var_str_hidpi+"));\n"); + x = os.path.basename(str(x)) + type = x[5:-4].title().replace("_", "") + var_str = x[:-4] + "_png" + var_str_hidpi = x[:-4] + "_hidpi_png" + s.write("\tp_theme->set_icon(\"" + type + "\",\"EditorIcons\",make_icon(" + var_str + "," + var_str_hidpi + "));\n") - s.write("\n\n}\n\n"); + s.write("\n\n}\n\n") - f = open(dst,"wb") - f.write(s.getvalue()) - f.close() - s.close() + f = open(dst, "wb") + f.write(s.getvalue()) + f.close() + s.close() make_editor_icons_builder = Builder(action=make_editor_icons_action, - suffix = '.cpp', - src_suffix = '.png') -env['BUILDERS']['MakeEditorIconsBuilder']=make_editor_icons_builder -env.Alias('editor_icons',[env.MakeEditorIconsBuilder('#tools/editor/editor_icons.cpp',Glob("*.png"))]) + suffix='.cpp', + src_suffix='.png') +env['BUILDERS']['MakeEditorIconsBuilder'] = make_editor_icons_builder +env.Alias('editor_icons', [env.MakeEditorIconsBuilder('#tools/editor/editor_icons.cpp', Glob("*.png"))]) env.tool_sources.append("#tools/editor/editor_icons.cpp") Export('env') diff --git a/tools/editor/icons/icon_script_create.png b/tools/editor/icons/icon_script_create.png Binary files differnew file mode 100644 index 0000000000..f5d8b0cfd6 --- /dev/null +++ b/tools/editor/icons/icon_script_create.png diff --git a/tools/editor/icons/source/icon_script_create.svg b/tools/editor/icons/source/icon_script_create.svg new file mode 100644 index 0000000000..c3f69c4601 --- /dev/null +++ b/tools/editor/icons/source/icon_script_create.svg @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="16" + height="16" + viewBox="0 0 16 16" + id="svg2" + version="1.1" + inkscape:version="0.91 r13725" + inkscape:export-filename="/home/godotengine/godot/tools/editor/icons/con_script_create.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" + sodipodi:docname="icon_script_create.svg"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="29.966667" + inkscape:cx="5.495872" + inkscape:cy="2.1206692" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="true" + units="px" + inkscape:snap-bbox="true" + inkscape:bbox-paths="true" + inkscape:bbox-nodes="true" + inkscape:snap-bbox-edge-midpoints="true" + inkscape:snap-bbox-midpoints="true" + inkscape:snap-object-midpoints="true" + inkscape:snap-center="true" + inkscape:window-width="1920" + inkscape:window-height="1119" + inkscape:window-x="0" + inkscape:window-y="26" + inkscape:window-maximized="1" + showguides="false"> + <inkscape:grid + type="xygrid" + id="grid3336" + empspacing="4" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1036.3622)"> + <path + style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" + d="M 6 1 L 6 2 A 1 1 0 0 0 5 3 L 5 13 L 4 13 L 4 11 L 2 11 L 2 13 A 1 1 0 0 0 2.5 13.865234 A 1 1 0 0 0 3 14 L 3 15 L 10 15 L 10 14 L 7 14 L 7 10 L 10 10 L 10 7 L 12 7 L 12 5 L 15 5 L 15 3 A 2 2 0 0 0 13 1 L 6 1 z M 11 8 L 11 11 L 8 11 L 8 13 L 11 13 L 11 14.730469 A 2 2 0 0 0 12 13 L 12 8 L 11 8 z " + transform="translate(0,1036.3622)" + id="rect4255" /> + <path + style="opacity:1;fill:#b4b4b4;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" + d="M 6 1 C 4.8954305 1 4 1.8954305 4 3 L 4 10 L 2 10 L 1 10 L 1 11 L 1 13 C 1 14.104569 1.8954305 15 3 15 C 4.1045695 15 5 14.104569 5 13 L 5 3 C 5 2.4477153 5.4477153 2 6 2 C 6.5522847 2 7 2.4477153 7 3 L 7 4 L 7 5 L 7 6 L 8 6 L 12 6 L 12 5 L 8 5 L 8 4 L 8 3 C 8 1.8954305 7.1045695 1 6 1 z M 2 11 L 4 11 L 4 13 C 4 13.552285 3.5522847 14 3 14 C 2.4477153 14 2 13.552285 2 13 L 2 11 z " + transform="translate(0,1036.3622)" + id="path4265" /> + <circle + cy="1048.3622" + cx="3" + id="ellipse4234" + style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" + ry="1.0000174" + rx="1" /> + <path + style="fill:#e0e0e0;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1" + d="m 13,1049.3622 3,0 0,-2 -3,0 0,-3 -2,0 0,3 -3,0 0,2 3,0 0,3 2,0 z" + id="path8069" + inkscape:connector-curvature="0" /> + </g> +</svg> diff --git a/tools/editor/io_plugins/SCsub b/tools/editor/io_plugins/SCsub index 6299fd416c..4bf55189cc 100644 --- a/tools/editor/io_plugins/SCsub +++ b/tools/editor/io_plugins/SCsub @@ -2,4 +2,4 @@ Import('env') Export('env') -env.add_source_files(env.tool_sources,"*.cpp") +env.add_source_files(env.tool_sources, "*.cpp") diff --git a/tools/editor/plugins/SCsub b/tools/editor/plugins/SCsub index 6299fd416c..4bf55189cc 100644 --- a/tools/editor/plugins/SCsub +++ b/tools/editor/plugins/SCsub @@ -2,4 +2,4 @@ Import('env') Export('env') -env.add_source_files(env.tool_sources,"*.cpp") +env.add_source_files(env.tool_sources, "*.cpp") diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 49db321d4d..e7d8776f1f 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -86,6 +86,9 @@ void SceneTreeDock::_unhandled_key_input(InputEvent p_event) { else if (ED_IS_SHORTCUT("scene_tree/load_script", p_event)) { _tool_selected(TOOL_LOAD_SCRIPT); } + else if(ED_IS_SHORTCUT("scene_tree/clear_script", p_event)) { + _tool_selected(TOOL_CLEAR_SCRIPT); + } else if (ED_IS_SHORTCUT("scene_tree/move_up", p_event)) { _tool_selected(TOOL_MOVE_UP); } @@ -415,6 +418,18 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } break; + case TOOL_CLEAR_SCRIPT: { + Node *selected = scene_tree->get_selected(); + if(!selected) + break; + + Ref<Script> existing = selected->get_script(); + if(existing.is_valid()) { + const RefPtr empty; + selected->set_script(empty); + } + + } break; case TOOL_MOVE_UP: case TOOL_MOVE_DOWN: { @@ -707,8 +722,9 @@ void SceneTreeDock::_notification(int p_what) { } button_add->set_icon(get_icon("Add","EditorIcons")); button_instance->set_icon(get_icon("Instance","EditorIcons")); - button_create_script->set_icon(get_icon("Script","EditorIcons")); + button_create_script->set_icon(get_icon("ScriptCreate","EditorIcons")); button_load_script->set_icon(get_icon("Script", "EditorIcons")); + button_clear_script->set_icon(get_icon("Remove", "EditorIcons")); filter_icon->set_texture(get_icon("Zoom","EditorIcons")); @@ -1338,12 +1354,21 @@ void SceneTreeDock::_selection_changed() { _tool_selected(TOOL_MULTI_EDIT); } - if (selection_size==1 && EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) { - button_create_script->show(); - button_load_script->show(); + if (selection_size==1) { + if(EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) { + button_create_script->show(); + button_load_script->show(); + button_clear_script->hide(); + } + else { + button_create_script->hide(); + button_load_script->hide(); + button_clear_script->show(); + } } else { button_create_script->hide(); button_load_script->hide(); + button_clear_script->hide(); } //tool_buttons[TOOL_MULTI_EDIT]->set_disabled(EditorNode::get_singleton()->get_editor_selection()->get_selection().size()<2); @@ -1823,8 +1848,9 @@ void SceneTreeDock::_tree_rmb(const Vector2& p_menu_pos) { //menu->add_icon_item(get_icon("Groups","EditorIcons"),TTR("Edit Groups"),TOOL_GROUP); //menu->add_icon_item(get_icon("Connect","EditorIcons"),TTR("Edit Connections"),TOOL_CONNECT); menu->add_separator(); - menu->add_icon_shortcut(get_icon("Script", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_script"), TOOL_CREATE_SCRIPT); + menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_script"), TOOL_CREATE_SCRIPT); menu->add_icon_shortcut(get_icon("Script", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/load_script"), TOOL_LOAD_SCRIPT); + menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT); menu->add_separator(); } @@ -1938,6 +1964,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec ED_SHORTCUT("scene_tree/change_node_type", TTR("Change Type")); ED_SHORTCUT("scene_tree/add_script", TTR("Add Script")); ED_SHORTCUT("scene_tree/load_script", TTR("Load Script")); + ED_SHORTCUT("scene_tree/clear_script", TTR("Clear Script")); ED_SHORTCUT("scene_tree/move_up", TTR("Move Up"), KEY_MASK_CMD | KEY_UP); ED_SHORTCUT("scene_tree/move_down", TTR("Move Down"), KEY_MASK_CMD | KEY_DOWN); ED_SHORTCUT("scene_tree/duplicate", TTR("Duplicate"),KEY_MASK_CMD | KEY_D); @@ -1987,6 +2014,13 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec filter_hbc->add_child(tb); button_load_script = tb; + tb = memnew(ToolButton); + tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_CLEAR_SCRIPT, false)); + tb->set_tooltip(TTR("Clear a script for the selected node.")); + tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/clear_script")); + filter_hbc->add_child(tb); + button_clear_script = tb; + scene_tree = memnew( SceneTreeEditor(false,true,true )); vbc->add_child(scene_tree); diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h index 36d4a6d208..86fe3bb136 100644 --- a/tools/editor/scene_tree_dock.h +++ b/tools/editor/scene_tree_dock.h @@ -60,6 +60,7 @@ class SceneTreeDock : public VBoxContainer { TOOL_GROUP, TOOL_CREATE_SCRIPT, TOOL_LOAD_SCRIPT, + TOOL_CLEAR_SCRIPT, TOOL_MOVE_UP, TOOL_MOVE_DOWN, TOOL_DUPLICATE, @@ -82,6 +83,7 @@ class SceneTreeDock : public VBoxContainer { ToolButton *button_instance; ToolButton *button_create_script; ToolButton *button_load_script; + ToolButton *button_clear_script; SceneTreeEditor *scene_tree; diff --git a/tools/scripts/addheader.py b/tools/scripts/addheader.py index d040d8b5d6..7838e16ae0 100644 --- a/tools/scripts/addheader.py +++ b/tools/scripts/addheader.py @@ -1,4 +1,4 @@ -header="""\ +header = """\ /*************************************************************************/ /* $filename */ /*************************************************************************/ @@ -29,44 +29,42 @@ header="""\ /*************************************************************************/ """ -f = open("files","rb") +f = open("files", "rb") fname = f.readline() -while (fname!=""): +while (fname != ""): - fr = open(fname.strip(),"rb") - l = fr.readline() - bc=False - fsingle = fname.strip() + fr = open(fname.strip(), "rb") + l = fr.readline() + bc = False + fsingle = fname.strip() - if (fsingle.find("/")!=-1): - fsingle=fsingle[fsingle.rfind("/")+1:] - rep_fl="$filename" - rep_fi=fsingle - len_fl=len(rep_fl) - len_fi=len(rep_fi) - if (len_fi<len_fl): - for x in range(len_fl-len_fi): - rep_fi+=" " - elif (len_fl<len_fi): - for x in range(len_fi-len_fl): - rep_fl+=" " - if (header.find(rep_fl)!=-1): - text=header.replace(rep_fl,rep_fi) - else: - text=header.replace("$filename",fsingle) + if (fsingle.find("/") != -1): + fsingle = fsingle[fsingle.rfind("/") + 1:] + rep_fl = "$filename" + rep_fi = fsingle + len_fl = len(rep_fl) + len_fi = len(rep_fi) + if (len_fi < len_fl): + for x in range(len_fl - len_fi): + rep_fi += " " + elif (len_fl < len_fi): + for x in range(len_fi - len_fl): + rep_fl += " " + if (header.find(rep_fl) != -1): + text = header.replace(rep_fl, rep_fi) + else: + text = header.replace("$filename", fsingle) + while (l != ""): + if ((l.find("//") != 0 and l.find("/*") != 0 and l.strip() != "") or bc): + text += l + bc = True + l = fr.readline() - while (l!=""): - if ((l.find("//")!=0 and l.find("/*")!=0 and l.strip()!="") or bc): - text+=l - bc=True - l=fr.readline() - - fr.close() - fr=open(fname.strip(),"wb") - fr.write(text) - fr.close() - #print(text) - fname=f.readline() - + fr.close() + fr = open(fname.strip(), "wb") + fr.write(text) + fr.close() + # print(text) + fname = f.readline() diff --git a/tools/scripts/file-hex-array.py b/tools/scripts/file-hex-array.py index 05352396f1..a6cdfe541f 100755 --- a/tools/scripts/file-hex-array.py +++ b/tools/scripts/file-hex-array.py @@ -2,34 +2,38 @@ import binascii import os.path import sys + def tof(filepath): - with open(filepath, 'r') as f: - content = f.read() - content = content.replace("0x","") - content = content.split(',') - for i in range(len(content)): - if len(content[i]) == 1: content[i] = "0" + content[i] - content = "".join(content) - with open(filepath+".file", 'wb') as f: - content = f.write(content.decode("hex")) - print(os.path.basename(filepath)+".file created.") - exit(0) + with open(filepath, 'r') as f: + content = f.read() + content = content.replace("0x", "") + content = content.split(',') + for i in range(len(content)): + if len(content[i]) == 1: + content[i] = "0" + content[i] + content = "".join(content) + with open(filepath + ".file", 'wb') as f: + content = f.write(content.decode("hex")) + print(os.path.basename(filepath) + ".file created.") + exit(0) + def toa(filepath): - with open(filepath, 'rb') as f: - content = f.read() - content = binascii.hexlify(content) - content = [content[i:i+2] for i in range(0, len(content), 2)] - content = ",0x".join(content) - content = "0x" + content - content = content.replace("0x00","0x0") - with open(filepath+".array", 'w') as f: - content = f.write(content) - print(os.path.basename(filepath)+".array created.") - exit(0) + with open(filepath, 'rb') as f: + content = f.read() + content = binascii.hexlify(content) + content = [content[i:i + 2] for i in range(0, len(content), 2)] + content = ",0x".join(content) + content = "0x" + content + content = content.replace("0x00", "0x0") + with open(filepath + ".array", 'w') as f: + content = f.write(content) + print(os.path.basename(filepath) + ".array created.") + exit(0) + def usage(): - print("========================================================\n\ + print("========================================================\n\ #\n\ # Usage: python file-hex-array.py [action] [option]\n\ #\n\ @@ -40,13 +44,13 @@ def usage(): # Example : python file-hex-array.py toa 1.png\n\ #\n\ ========================================================") - exit(1) + exit(1) if len(sys.argv) != 3: - usage() + usage() if sys.argv[1] == "toa" and os.path.isfile(sys.argv[2]): - toa(sys.argv[2]) + toa(sys.argv[2]) elif sys.argv[1] == "tof" and os.path.isfile(sys.argv[2]): - tof(sys.argv[2]) + tof(sys.argv[2]) else: - usage()
\ No newline at end of file + usage() diff --git a/tools/scripts/make_bmfhdr.py b/tools/scripts/make_bmfhdr.py index 0f6f453004..1d3c40f9c6 100644 --- a/tools/scripts/make_bmfhdr.py +++ b/tools/scripts/make_bmfhdr.py @@ -2,69 +2,66 @@ import sys -if (len(sys.argv)!=2): - print("Pass me a .fnt argument!") +if (len(sys.argv) != 2): + print("Pass me a .fnt argument!") -f = open(sys.argv[1],"rb") +f = open(sys.argv[1], "rb") -name = sys.argv[1].lower().replace(".fnt","") +name = sys.argv[1].lower().replace(".fnt", "") l = f.readline() -font_height=0 -font_ascent=0 -font_charcount=0 -font_chars=[] -font_cc=0 - -while(l!=""): - - fs = l.strip().find(" ") - if (fs==-1): - l=f.readline() - continue - t = l[0:fs] - - dv = l[fs+1:].split(" ") - d = {} - for x in dv: - if (x.find("=")==-1): - continue - s = x.split("=") - d[ s[0] ] = s[1] - - - if (t=="common"): - font_height=d["lineHeight"] - font_ascent=d["base"] - - if (t=="char"): - font_chars.append(d["id"]) - font_chars.append(d["x"]) - font_chars.append(d["y"]) - font_chars.append(d["width"]) - font_chars.append(d["height"]) - font_chars.append(d["xoffset"]) - font_chars.append(d["yoffset"]) - font_chars.append(d["xadvance"]) - font_cc+=1 - - - - l = f.readline() - - -print("static const int _bi_font_"+name+"_height="+str(font_height)+";") -print("static const int _bi_font_"+name+"_ascent="+str(font_ascent)+";") -print("static const int _bi_font_"+name+"_charcount="+str(font_cc)+";") -cstr="static const int _bi_font_"+name+"_characters={" +font_height = 0 +font_ascent = 0 +font_charcount = 0 +font_chars = [] +font_cc = 0 + +while(l != ""): + + fs = l.strip().find(" ") + if (fs == -1): + l = f.readline() + continue + t = l[0:fs] + + dv = l[fs + 1:].split(" ") + d = {} + for x in dv: + if (x.find("=") == -1): + continue + s = x.split("=") + d[s[0]] = s[1] + + if (t == "common"): + font_height = d["lineHeight"] + font_ascent = d["base"] + + if (t == "char"): + font_chars.append(d["id"]) + font_chars.append(d["x"]) + font_chars.append(d["y"]) + font_chars.append(d["width"]) + font_chars.append(d["height"]) + font_chars.append(d["xoffset"]) + font_chars.append(d["yoffset"]) + font_chars.append(d["xadvance"]) + font_cc += 1 + + l = f.readline() + + +print("static const int _bi_font_" + name + "_height=" + str(font_height) + ";") +print("static const int _bi_font_" + name + "_ascent=" + str(font_ascent) + ";") +print("static const int _bi_font_" + name + "_charcount=" + str(font_cc) + ";") +cstr = "static const int _bi_font_" + name + "_characters={" for i in range(len(font_chars)): - c=font_chars[i] - if (i>0): - cstr+=", " - cstr+=c + c = font_chars[i] + if (i > 0): + cstr += ", " + cstr += c -cstr+=("};") +cstr += ("};") -print(cstr)
\ No newline at end of file +print(cstr) diff --git a/tools/scripts/make_glwrapper.py b/tools/scripts/make_glwrapper.py index b4c582f1eb..5694d2327e 100644 --- a/tools/scripts/make_glwrapper.py +++ b/tools/scripts/make_glwrapper.py @@ -1,32 +1,32 @@ #! /usr/bin/env python import sys -if (len(sys.argv)<2): - print("usage: make_glwrapper.py <headers>") - sys.exit(255) +if (len(sys.argv) < 2): + print("usage: make_glwrapper.py <headers>") + sys.exit(255) -functions=[] -types=[] -constants=[] +functions = [] +types = [] +constants = [] -READ_FUNCTIONS=0 -READ_TYPES=1 -READ_CONSTANTS=2 +READ_FUNCTIONS = 0 +READ_TYPES = 1 +READ_CONSTANTS = 2 -read_what=READ_TYPES +read_what = READ_TYPES -for x in (range(len(sys.argv)-1)): - f=open(sys.argv[x+1],"r") +for x in (range(len(sys.argv) - 1)): + f = open(sys.argv[x + 1], "r") - while(True): + while(True): - line=f.readline() - if (line==""): - break + line = f.readline() + if (line == ""): + break - line=line.replace("\n","").strip() - """ + line = line.replace("\n", "").strip() + """ if (line.find("[types]")!=-1): read_what=READ_TYPES continue @@ -38,67 +38,66 @@ for x in (range(len(sys.argv)-1)): continue """ - if (line.find("#define")!=-1): - if (line.find("0x")==-1 and line.find("GL_VERSION")==-1): - continue - constants.append(line) - elif (line.find("typedef")!=-1): - if (line.find("(")!=-1 or line.find(")")!=-1 or line.find("ARB")!=-1 or line.find("EXT")!=-1 or line.find("GL")==-1): - continue - types.append(line) - elif (line.find("APIENTRY")!=-1 and line.find("GLAPI")!=-1): + if (line.find("#define") != -1): + if (line.find("0x") == -1 and line.find("GL_VERSION") == -1): + continue + constants.append(line) + elif (line.find("typedef") != -1): + if (line.find("(") != -1 or line.find(")") != -1 or line.find("ARB") != -1 or line.find("EXT") != -1 or line.find("GL") == -1): + continue + types.append(line) + elif (line.find("APIENTRY") != -1 and line.find("GLAPI") != -1): - if (line.find("ARB")!=-1 or line.find("EXT")!=-1 or line.find("NV")!=-1): - continue + if (line.find("ARB") != -1 or line.find("EXT") != -1 or line.find("NV") != -1): + continue - line=line.replace("APIENTRY","") - line=line.replace("GLAPI","") + line = line.replace("APIENTRY", "") + line = line.replace("GLAPI", "") - glpos=line.find(" gl") - if (glpos==-1): + glpos = line.find(" gl") + if (glpos == -1): - glpos=line.find("\tgl") - if (glpos==-1): - continue + glpos = line.find("\tgl") + if (glpos == -1): + continue - ret=line[:glpos].strip(); + ret = line[:glpos].strip() - line=line[glpos:].strip() - namepos=line.find("(") + line = line[glpos:].strip() + namepos = line.find("(") - if (namepos==-1): - continue + if (namepos == -1): + continue - name=line[:namepos].strip() - line=line[namepos:] + name = line[:namepos].strip() + line = line[namepos:] - argpos=line.rfind(")") - if (argpos==-1): - continue + argpos = line.rfind(")") + if (argpos == -1): + continue - args=line[1:argpos] + args = line[1:argpos] - funcdata={} - funcdata["ret"]=ret - funcdata["name"]=name - funcdata["args"]=args + funcdata = {} + funcdata["ret"] = ret + funcdata["name"] = name + funcdata["args"] = args - functions.append(funcdata) - print(funcdata) + functions.append(funcdata) + print(funcdata) +# print(types) +# print(constants) +# print(functions) -#print(types) -#print(constants) -#print(functions) - -f=open("glwrapper.h","w") +f = open("glwrapper.h", "w") f.write("#ifndef GL_WRAPPER\n") f.write("#define GL_WRAPPER\n\n\n") -header_code="""\ +header_code = """\ #if defined(__gl_h_) || defined(__GL_H__) #error gl.h included before glwrapper.h #endif @@ -128,56 +127,52 @@ header_code="""\ f.write("#include <stddef.h>\n\n\n") -f.write(header_code); +f.write(header_code) f.write("#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n") f.write("#if defined(_WIN32) && !defined(__CYGWIN__)\n") f.write("#define GLWRP_APIENTRY __stdcall\n") -f.write("#else\n"); +f.write("#else\n") f.write("#define GLWRP_APIENTRY \n") -f.write("#endif\n\n"); +f.write("#endif\n\n") for x in types: - f.write(x+"\n") + f.write(x + "\n") f.write("\n\n") for x in constants: - f.write(x+"\n") + f.write(x + "\n") f.write("\n\n") for x in functions: - f.write("extern "+x["ret"]+" GLWRP_APIENTRY (*__wrapper_"+x["name"]+")("+x["args"]+");\n") - f.write("#define "+x["name"]+" __wrapper_"+x["name"]+"\n") + f.write("extern " + x["ret"] + " GLWRP_APIENTRY (*__wrapper_" + x["name"] + ")(" + x["args"] + ");\n") + f.write("#define " + x["name"] + " __wrapper_" + x["name"] + "\n") f.write("\n\n") -f.write("typedef void (*GLWrapperFuncPtr)(void);\n\n"); +f.write("typedef void (*GLWrapperFuncPtr)(void);\n\n") f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) );\n") f.write("#ifdef __cplusplus\n}\n#endif\n") f.write("#endif\n\n") -f=open("glwrapper.c","w") +f = open("glwrapper.c", "w") f.write("\n\n") f.write("#include \"glwrapper.h\"\n") f.write("\n\n") for x in functions: - f.write(x["ret"]+" GLWRP_APIENTRY (*__wrapper_"+x["name"]+")("+x["args"]+")=NULL;\n") + f.write(x["ret"] + " GLWRP_APIENTRY (*__wrapper_" + x["name"] + ")(" + x["args"] + ")=NULL;\n") f.write("\n\n") f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) ) {\n") f.write("\n") for x in functions: - f.write("\t__wrapper_"+x["name"]+"=("+x["ret"]+" GLWRP_APIENTRY (*)("+x["args"]+"))wrapperFunc(\""+x["name"]+"\");\n") + f.write("\t__wrapper_" + x["name"] + "=(" + x["ret"] + " GLWRP_APIENTRY (*)(" + x["args"] + "))wrapperFunc(\"" + x["name"] + "\");\n") f.write("\n\n") f.write("}\n") f.write("\n\n") - - - - diff --git a/tools/scripts/makeargs.py b/tools/scripts/makeargs.py index 8c5539c5fe..2cd47ae087 100644 --- a/tools/scripts/makeargs.py +++ b/tools/scripts/makeargs.py @@ -1,5 +1,5 @@ -text=""" +text = """ #define FUNC$numR(m_r,m_func,$argt)\\ virtual m_r m_func($argtp) { \\ if (Thread::get_caller_ID()!=server_thread) {\\ @@ -64,25 +64,19 @@ text=""" """ +for i in range(1, 8): -for i in range(1,8): - - tp="" - p="" - t="" - for j in range(i): - if (j>0): - tp+=", " - p+=", " - t+=", " - tp +=("m_arg"+str(j+1)+" p"+str(j+1)) - p+=("p"+str(j+1)) - t+=("m_arg"+str(j+1)) - - t = text.replace("$argtp",tp).replace("$argp",p).replace("$argt",t).replace("$num",str(i)) - print(t) - - - - + tp = "" + p = "" + t = "" + for j in range(i): + if (j > 0): + tp += ", " + p += ", " + t += ", " + tp += ("m_arg" + str(j + 1) + " p" + str(j + 1)) + p += ("p" + str(j + 1)) + t += ("m_arg" + str(j + 1)) + t = text.replace("$argtp", tp).replace("$argp", p).replace("$argt", t).replace("$num", str(i)) + print(t) diff --git a/tools/scripts/memsort.py b/tools/scripts/memsort.py index d2e4fe0226..fb636b0f78 100644 --- a/tools/scripts/memsort.py +++ b/tools/scripts/memsort.py @@ -1,35 +1,35 @@ import sys -arg="memdump.txt" +arg = "memdump.txt" -if (len(sys.argv)>1): - arg=sys.argv[1] +if (len(sys.argv) > 1): + arg = sys.argv[1] -f = open(arg,"rb") +f = open(arg, "rb") -l=f.readline() +l = f.readline() sum = {} -cnt={} +cnt = {} -while(l!=""): +while(l != ""): - s=l.split("-") - amount = int(s[1]) - what=s[2] - if (what in sum): - sum[what]+=amount - cnt[what]+=1 - else: - sum[what]=amount - cnt[what]=1 + s = l.split("-") + amount = int(s[1]) + what = s[2] + if (what in sum): + sum[what] += amount + cnt[what] += 1 + else: + sum[what] = amount + cnt[what] = 1 - l=f.readline() + l = f.readline() for x in sum: - print(x.strip()+"("+str(cnt[x])+"):\n: "+str(sum[x])) + print(x.strip() + "(" + str(cnt[x]) + "):\n: " + str(sum[x])) diff --git a/tools/scripts/svgs_2_pngs.py b/tools/scripts/svgs_2_pngs.py index 879926ab42..b24324dcd7 100644 --- a/tools/scripts/svgs_2_pngs.py +++ b/tools/scripts/svgs_2_pngs.py @@ -51,7 +51,7 @@ def export_icons(): # name without extensions name_only = file_name.replace('.svg', '') - out_icon_names = [name_only] # export to a png with the same file name + out_icon_names = [name_only] # export to a png with the same file name theme_out_icon_names = [] # special cases if special_icons.has_key(name_only): @@ -73,7 +73,6 @@ def export_icons(): svg_to_png(source_path, theme_dir_base + theme_out_icon_name, 90) - def export_theme(): svgs_path = theme_dir_source file_names = [f for f in listdir(svgs_path) if isfile(join(svgs_path, f))] @@ -82,7 +81,7 @@ def export_theme(): # name without extensions name_only = file_name.replace('.svg', '') - out_icon_names = [name_only] # export to a png with the same file name + out_icon_names = [name_only] # export to a png with the same file name # special cases if theme_icons.has_key(name_only): special_icon = theme_icons[name_only] @@ -102,36 +101,36 @@ special_icons = { output_names=['icon_add'], theme_output_names=['icon_add', 'icon_zoom_more'] ), - 'icon_new': dict( output_names=['icon_file'] ), - 'icon_animation_tree_player': dict( output_names=['icon_animation_tree'] ), + 'icon_new': dict(output_names=['icon_file']), + 'icon_animation_tree_player': dict(output_names=['icon_animation_tree']), 'icon_tool_rotate': dict( output_names=['icon_reload'], - theme_output_names= ['icon_reload'] + theme_output_names=['icon_reload'] ), - 'icon_multi_edit': dict( output_names=['icon_multi_node_edit'] ), + 'icon_multi_edit': dict(output_names=['icon_multi_node_edit']), 'icon_folder': dict( output_names=['icon_load', 'icon_open'], - theme_output_names= ['icon_folder'] + theme_output_names=['icon_folder'] ), - 'icon_file_list': dict( output_names=['icon_enum'] ), - 'icon_collision_2d': dict( output_names=['icon_collision_polygon_2d', 'icon_polygon_2d'] ), - 'icon_class_list': dict( output_names=['icon_filesystem'] ), - 'icon_color_ramp': dict( output_names=['icon_graph_color_ramp'] ), - 'icon_translation': dict( output_names=['icon_p_hash_translation'] ), - 'icon_shader': dict( output_names=['icon_shader_material', 'icon_material_shader'] ), - 'icon_canvas_item_shader_graph': dict( output_names=['icon_material_shader_graph'] ), - - 'icon_color_pick': dict( theme_output_names= ['icon_color_pick'], avoid_self=True ), - 'icon_play': dict( theme_output_names= ['icon_play'] ), - 'icon_stop': dict( theme_output_names= ['icon_stop'] ), - 'icon_zoom_less': dict( theme_output_names= ['icon_zoom_less'], avoid_self=True ), - 'icon_zoom_reset': dict( theme_output_names= ['icon_zoom_reset'], avoid_self=True ), + 'icon_file_list': dict(output_names=['icon_enum']), + 'icon_collision_2d': dict(output_names=['icon_collision_polygon_2d', 'icon_polygon_2d']), + 'icon_class_list': dict(output_names=['icon_filesystem']), + 'icon_color_ramp': dict(output_names=['icon_graph_color_ramp']), + 'icon_translation': dict(output_names=['icon_p_hash_translation']), + 'icon_shader': dict(output_names=['icon_shader_material', 'icon_material_shader']), + 'icon_canvas_item_shader_graph': dict(output_names=['icon_material_shader_graph']), + + 'icon_color_pick': dict(theme_output_names=['icon_color_pick'], avoid_self=True), + 'icon_play': dict(theme_output_names=['icon_play']), + 'icon_stop': dict(theme_output_names=['icon_stop']), + 'icon_zoom_less': dict(theme_output_names=['icon_zoom_less'], avoid_self=True), + 'icon_zoom_reset': dict(theme_output_names=['icon_zoom_reset'], avoid_self=True), 'icon_snap': dict(theme_output_names=['icon_snap']) } theme_icons = { - 'icon_close': dict(output_names=['close', 'close_hl']), - 'tab_menu': dict(output_names=['tab_menu_hl']) + 'icon_close': dict(output_names=['close', 'close_hl']), + 'tab_menu': dict(output_names=['tab_menu_hl']) } export_icons() diff --git a/tools/translations/extract.py b/tools/translations/extract.py index 61b07b5799..bd6f03237b 100755 --- a/tools/translations/extract.py +++ b/tools/translations/extract.py @@ -10,27 +10,27 @@ import sys line_nb = False for arg in sys.argv[1:]: - if (arg == "--with-line-nb"): - print("Enabling line numbers in the context locations.") - line_nb = True - else: - os.sys.exit("Non supported argument '" + arg + "'. Aborting.") + if (arg == "--with-line-nb"): + print("Enabling line numbers in the context locations.") + line_nb = True + else: + os.sys.exit("Non supported argument '" + arg + "'. Aborting.") if (not os.path.exists("tools")): - os.sys.exit("ERROR: This script should be started from the root of the git repo.") + os.sys.exit("ERROR: This script should be started from the root of the git repo.") matches = [] for root, dirnames, filenames in os.walk('.'): - for filename in fnmatch.filter(filenames, '*.cpp'): - if (filename.find("collada") != -1): - continue - matches.append(os.path.join(root, filename)) - for filename in fnmatch.filter(filenames, '*.h'): - if (filename.find("collada") != -1): - continue - matches.append(os.path.join(root, filename)) + for filename in fnmatch.filter(filenames, '*.cpp'): + if (filename.find("collada") != -1): + continue + matches.append(os.path.join(root, filename)) + for filename in fnmatch.filter(filenames, '*.h'): + if (filename.find("collada") != -1): + continue + matches.append(os.path.join(root, filename)) matches.sort() @@ -55,51 +55,51 @@ print("Updating the tools.pot template...") for fname in matches: - f = open(fname, "rb") - - l = f.readline() - lc = 1 - while (l): - - patterns = ['RTR(\"', 'TTR(\"'] - idx = 0 - pos = 0 - while (pos >= 0): - pos = l.find(patterns[idx], pos) - if (pos == -1): - if (idx < len(patterns) - 1): - idx += 1 - pos = 0 - continue - pos += 5 - - msg = "" - while (pos < len(l) and (l[pos] != '"' or l[pos - 1] == '\\')): - msg += l[pos] - pos += 1 - - location = os.path.relpath(fname).replace('\\','/') - if (line_nb): - location += ":" + str(lc) - - if (not msg in unique_str): - main_po += "\n#: " + location + "\n" - main_po += 'msgid "' + msg + '"\n' - main_po += 'msgstr ""\n' - unique_str.append(msg) - unique_loc[msg] = [location] - elif (not location in unique_loc[msg]): - # Add additional location to previous occurence too - msg_pos = main_po.find('\nmsgid "' + msg + '"') - if (msg_pos == -1): - print("Someone apparently thought writing Python was as easy as GDScript. Ping Akien.") - main_po = main_po[:msg_pos] + ' ' + location + main_po[msg_pos:] - unique_loc[msg].append(location) - - l = f.readline() - lc += 1 - - f.close() + f = open(fname, "rb") + + l = f.readline() + lc = 1 + while (l): + + patterns = ['RTR(\"', 'TTR(\"'] + idx = 0 + pos = 0 + while (pos >= 0): + pos = l.find(patterns[idx], pos) + if (pos == -1): + if (idx < len(patterns) - 1): + idx += 1 + pos = 0 + continue + pos += 5 + + msg = "" + while (pos < len(l) and (l[pos] != '"' or l[pos - 1] == '\\')): + msg += l[pos] + pos += 1 + + location = os.path.relpath(fname).replace('\\', '/') + if (line_nb): + location += ":" + str(lc) + + if (not msg in unique_str): + main_po += "\n#: " + location + "\n" + main_po += 'msgid "' + msg + '"\n' + main_po += 'msgstr ""\n' + unique_str.append(msg) + unique_loc[msg] = [location] + elif (not location in unique_loc[msg]): + # Add additional location to previous occurence too + msg_pos = main_po.find('\nmsgid "' + msg + '"') + if (msg_pos == -1): + print("Someone apparently thought writing Python was as easy as GDScript. Ping Akien.") + main_po = main_po[:msg_pos] + ' ' + location + main_po[msg_pos:] + unique_loc[msg].append(location) + + l = f.readline() + lc += 1 + + f.close() f = open("tools.pot", "wb") @@ -107,15 +107,15 @@ f.write(main_po) f.close() if (os.name == "posix"): - print("Wrapping template at 79 characters for compatibility with Weblate.") - os.system("msgmerge -w79 tools.pot tools.pot > tools.pot.wrap") - shutil.move("tools.pot.wrap", "tools.pot") + print("Wrapping template at 79 characters for compatibility with Weblate.") + os.system("msgmerge -w79 tools.pot tools.pot > tools.pot.wrap") + shutil.move("tools.pot.wrap", "tools.pot") shutil.move("tools.pot", "tools/translations/tools.pot") # TODO: Make that in a portable way, if we care; if not, kudos to Unix users if (os.name == "posix"): - added = subprocess.check_output("git diff tools/translations/tools.pot | grep \+msgid | wc -l", shell = True) - removed = subprocess.check_output("git diff tools/translations/tools.pot | grep \\\-msgid | wc -l", shell = True) - print("\n# Template changes compared to the staged status:") - print("# Additions: %s msgids.\n# Deletions: %s msgids." % (int(added), int(removed))) + added = subprocess.check_output("git diff tools/translations/tools.pot | grep \+msgid | wc -l", shell=True) + removed = subprocess.check_output("git diff tools/translations/tools.pot | grep \\\-msgid | wc -l", shell=True) + print("\n# Template changes compared to the staged status:") + print("# Additions: %s msgids.\n# Deletions: %s msgids." % (int(added), int(removed))) diff --git a/version.py b/version.py index bf1d33c1cf..d014a538c9 100644 --- a/version.py +++ b/version.py @@ -1,5 +1,5 @@ -short_name="godot" -name="Godot Engine" -major=2 -minor=2 -status="alpha" +short_name = "godot" +name = "Godot Engine" +major = 2 +minor = 2 +status = "alpha" |