From a68e96b8c2d88e01ff910b6e05631b50871ef0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 3 Jan 2025 22:38:38 +0100 Subject: [PATCH 1/5] SCons: Set explicit standards to C++98 and C11 Godot 1.0 was developed at a time where compilers defaulted to C++98. Also disable `-Wall` on debug builds, there are now hundreds of warnings from newer compilers that would need to be fixed. This would best be done by adding a new `warnings` SCons option, which would also affect non-debug builds, but I have no intention to fix warnings in the 1.0 branch, the goal here is just to get it to compile for archival and game preservation. --- SConstruct | 15 +++++++++++++++ platform/android/detect.py | 2 +- platform/flash/detect.py | 2 +- platform/iphone/detect.py | 8 ++++---- platform/isim/detect.py | 4 ++-- platform/javascript/detect.py | 2 +- platform/nacl/detect.py | 2 +- platform/osx/detect.py | 2 +- platform/server/detect.py | 2 +- platform/windows/detect.py | 2 +- 10 files changed, 28 insertions(+), 13 deletions(-) diff --git a/SConstruct b/SConstruct index 42e90851714..4a94cd8c3fe 100644 --- a/SConstruct +++ b/SConstruct @@ -189,6 +189,21 @@ if selected_platform in platform_list: detect.configure(env) + # Set our C and C++ standard requirements. + # Prepending to make it possible to override. + # This MSVC "detection" is an extreme hack. + is_msvc = (os.name=="nt") and (os.getenv("VSINSTALLDIR")!=None or os.getenv("VCINSTALLDIR")!=None) and (selected_platform in ["windows", "winrt"]) + if (not is_msvc): + # Specifying GNU extensions support explicitly, which are supported by both GCC and Clang. + # We don't support C++17 so stick to earlier standards. + # Godot 1.0 definitely started as a C++98 codebase. + env.Prepend(CFLAGS=["-std=gnu11"]) + env.Prepend(CXXFLAGS=["-std=gnu++98"]) + # Disable these auto-enabled warnings which are treated as errors by modern compilers. + env.Prepend(CCFLAGS=["-Wno-error=implicit-function-declaration", "-Wno-error=incompatible-pointer-types"]) + else: + # MSVC doesn't support setting C++ to pre-C++14 standards, so do nothing and hope it works. + pass flag_list = platform_flags[selected_platform] for f in flag_list: diff --git a/platform/android/detect.py b/platform/android/detect.py index 417f3e68ab1..bb21d0c3e2f 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -150,7 +150,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-D_DEBUG', '-g1', '-Wall', '-O0', '-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-D_DEBUG', '-g1', '-O0', '-DDEBUG_ENABLED']) env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) if env["armv6"] == "no" and env['x86'] != 'yes': diff --git a/platform/flash/detect.py b/platform/flash/detect.py index 5507ce5177d..48be88738bc 100644 --- a/platform/flash/detect.py +++ b/platform/flash/detect.py @@ -98,7 +98,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-D_DEBUG', '-g0', '-Wall', '-O0', '-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-D_DEBUG', '-g0', '-O0', '-DDEBUG_ENABLED']) env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) env.Append(CPPFLAGS=['-DFLASH_ENABLED', '-DGLES1_ENABLED', '-DNO_FCNTL', '-DUNIX_ENABLED']) diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index 93345be7302..3b4f0c89e47 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -54,7 +54,7 @@ def configure(env): env['AR'] = 'ar' import string - #env['CCFLAGS'] = string.split('-arch armv7 -Wall -fno-strict-aliasing -fno-common -D__IPHONE_OS_VERSION_MIN_REQUIRED=20000 -isysroot $IPHONESDK -fvisibility=hidden -mmacosx-version-min=10.5 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\" -DNO_THUMB') + #env['CCFLAGS'] = string.split('-arch armv7 -fno-strict-aliasing -fno-common -D__IPHONE_OS_VERSION_MIN_REQUIRED=20000 -isysroot $IPHONESDK -fvisibility=hidden -mmacosx-version-min=10.5 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\" -DNO_THUMB') 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 -gdwarf-2 -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=4.3 -MMD -MT dependencies -isysroot $IPHONESDK') @@ -95,17 +95,17 @@ def configure(env): if (env["target"]=="release"): - env.Append(CCFLAGS=['-O3', '-ffast-math', '-DNS_BLOCK_ASSERTIONS=1','-Wall']) + env.Append(CCFLAGS=['-O3', '-ffast-math', '-DNS_BLOCK_ASSERTIONS=1']) env.Append(LINKFLAGS=['-O3', '-ffast-math']) elif env["target"] == "release_debug": - env.Append(CCFLAGS=['-Os', '-ffast-math', '-DNS_BLOCK_ASSERTIONS=1','-Wall','-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-Os', '-ffast-math', '-DNS_BLOCK_ASSERTIONS=1','-DDEBUG_ENABLED']) env.Append(LINKFLAGS=['-Os', '-ffast-math']) 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(CCFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-O0', '-DDEBUG_ENABLED']) env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED']) elif (env["target"]=="profile"): diff --git a/platform/isim/detect.py b/platform/isim/detect.py index 8d60e30d256..f1b8dae1199 100644 --- a/platform/isim/detect.py +++ b/platform/isim/detect.py @@ -51,7 +51,7 @@ def configure(env): env['AR'] = 'ar' import string - 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 $ISIMSDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"') + env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $ISIMSDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"') env.Append(LINKFLAGS=['-arch', 'i386', '-mios-simulator-version-min=4.3', @@ -84,7 +84,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-DDEBUG', '-D_DEBUG', '-gdwarf-2', '-Wall', '-O0', '-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-DDEBUG', '-D_DEBUG', '-gdwarf-2', '-O0', '-DDEBUG_ENABLED']) env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) elif (env["target"]=="profile"): diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 845b2e3395a..621330d803a 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -70,7 +70,7 @@ def configure(env): env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED']) elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-O2', '-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-D_DEBUG', '-O2', '-DDEBUG_ENABLED']) env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) env.Append(CPPFLAGS=["-fno-exceptions",'-DNO_SAFE_CAST','-fno-rtti']) diff --git a/platform/nacl/detect.py b/platform/nacl/detect.py index f8849cfd259..2acb59bb599 100644 --- a/platform/nacl/detect.py +++ b/platform/nacl/detect.py @@ -54,7 +54,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-g', '-O0', '-Wall','-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-g', '-O0', '-DDEBUG_ENABLED']) elif (env["target"]=="profile"): diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 1b32838525e..a8836d8f460 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -51,7 +51,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-g3', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-g3', '-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) if (env["freetype"]!="no"): diff --git a/platform/server/detect.py b/platform/server/detect.py index 24b36d31885..ebfc2a674f2 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -66,7 +66,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) env.Append(CPPFLAGS=['-DSERVER_ENABLED','-DUNIX_ENABLED']) env.Append(LIBS=['pthread','z']) #TODO detect linux/BSD! diff --git a/platform/windows/detect.py b/platform/windows/detect.py index be92ee8f6da..0b8e4b421a1 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -188,7 +188,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-g', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-g', '-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) if (env["freetype"]!="no"): env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) From 9eebaed89f3d2720e3aca1eabc6368a922d1b8bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 3 Jan 2025 22:40:37 +0100 Subject: [PATCH 2/5] Windows: Fix support for modern mingw-w64 --- platform/windows/detect.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 0b8e4b421a1..f0d6c75c15e 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -26,8 +26,8 @@ def can_build(): if (os.name=="posix"): - mingw = "i586-mingw32msvc-" - mingw64 = "i686-w64-mingw32-" + mingw = "i686-w64-mingw32-" + mingw64 = "x86_64-w64-mingw32-" if (os.getenv("MINGW32_PREFIX")): mingw=os.getenv("MINGW32_PREFIX") if (os.getenv("MINGW64_PREFIX")): @@ -45,8 +45,8 @@ def get_opts(): mingw="" mingw64="" if (os.name!="nt"): - mingw = "i586-mingw32msvc-" - mingw64 = "i686-w64-mingw32-" + mingw = "i686-w64-mingw32-" + mingw64 = "x86_64-w64-mingw32-" if (os.getenv("MINGW32_PREFIX")): mingw=os.getenv("MINGW32_PREFIX") if (os.getenv("MINGW64_PREFIX")): From abf6a0919b5d18a82248bb460331f0f4ba25ec2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 3 Jan 2025 22:43:12 +0100 Subject: [PATCH 3/5] Linux: Default to builtin openssl, freetype, and zlib Fix support for cross-compilation, and fix handling of builtin libraries, which would still attempt to link system libs and use system headers. Also patch out GLU includes from GLEW, we don't need it, so that removes another mandatory dependency. --- .../glew-remove-glu-dependency.patch | 22 +++++++++++++ drivers/gl_context/glew.h | 5 +++ platform/server/detect.py | 22 +++++++++++-- platform/x11/detect.py | 33 ++++++++++--------- 4 files changed, 64 insertions(+), 18 deletions(-) create mode 100644 drivers/gl_context/glew-remove-glu-dependency.patch diff --git a/drivers/gl_context/glew-remove-glu-dependency.patch b/drivers/gl_context/glew-remove-glu-dependency.patch new file mode 100644 index 00000000000..4ef9565a709 --- /dev/null +++ b/drivers/gl_context/glew-remove-glu-dependency.patch @@ -0,0 +1,22 @@ +diff --git a/drivers/gl_context/glew.h b/drivers/gl_context/glew.h +index 4eed47708f..5f937862bf 100644 +--- a/drivers/gl_context/glew.h ++++ b/drivers/gl_context/glew.h +@@ -1168,12 +1168,17 @@ GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei heigh + + /* ---------------------------------- GLU ---------------------------------- */ + ++// -- GODOT start -- ++// We don't use GLU, so remove a dependency. ++#if 0 + /* this is where we can safely include GLU */ + #if defined(__APPLE__) && defined(__MACH__) + #include + #else + #include + #endif ++#endif ++// -- GODOT end -- + + /* ----------------------------- GL_VERSION_1_2 ---------------------------- */ + diff --git a/drivers/gl_context/glew.h b/drivers/gl_context/glew.h index 4eed47708f4..5f937862bf3 100644 --- a/drivers/gl_context/glew.h +++ b/drivers/gl_context/glew.h @@ -1168,12 +1168,17 @@ GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei heigh /* ---------------------------------- GLU ---------------------------------- */ +// -- GODOT start -- +// We don't use GLU, so remove a dependency. +#if 0 /* this is where we can safely include GLU */ #if defined(__APPLE__) && defined(__MACH__) #include #else #include #endif +#endif +// -- GODOT end -- /* ----------------------------- GL_VERSION_1_2 ---------------------------- */ diff --git a/platform/server/detect.py b/platform/server/detect.py index ebfc2a674f2..d80c296b12c 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -27,8 +27,10 @@ def get_opts(): def get_flags(): return [ - ('builtin_zlib', 'no'), - ('theora','no'), #use builtin openssl + ('builtin_zlib', 'yes'), + ('openssl', 'builtin'), + ("freetype", "builtin"), + ('theora','no'), ] @@ -68,8 +70,22 @@ def configure(env): env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + + if (env["openssl"]=="yes"): + env.ParseConfig('pkg-config openssl --cflags --libs') + + if (env["freetype"]!="no"): + env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) + if (env["freetype"]=="builtin"): + env.Append(CPPPATH=['#tools/freetype']) + env.Append(CPPPATH=['#tools/freetype/freetype/include']) + else: + env.ParseConfig('pkg-config freetype2 --cflags --libs') + env.Append(CPPFLAGS=['-DSERVER_ENABLED','-DUNIX_ENABLED']) - env.Append(LIBS=['pthread','z']) #TODO detect linux/BSD! + env.Append(LIBS=['pthread']) #TODO detect linux/BSD! + if (env["builtin_zlib"]=="no"): + env.Append(LIBS=['z']) if (env["CXX"]=="clang++"): env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 1c8d231d4a1..93619f9fb10 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -29,11 +29,6 @@ def can_build(): 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 - x11_error=os.system("pkg-config xcursor --modversion > /dev/null ") if (x11_error): print("xcursor not found.. x11 disabled.") @@ -52,8 +47,9 @@ def get_opts(): def get_flags(): return [ - ('builtin_zlib', 'no'), - ("openssl", "yes"), + ('builtin_zlib', 'yes'), + ("openssl", "builtin"), + ("freetype", "builtin"), ("theora","no"), ] @@ -101,31 +97,38 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) env.ParseConfig('pkg-config x11 --cflags --libs') env.ParseConfig('pkg-config xcursor --cflags --libs') - env.ParseConfig('pkg-config openssl --cflags --libs') + if (env["openssl"]=="yes"): + env.ParseConfig('pkg-config openssl --cflags --libs') - env.ParseConfig('pkg-config freetype2 --cflags --libs') - env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) + if (env["freetype"]!="no"): + env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) + if (env["freetype"]=="builtin"): + env.Append(CPPPATH=['#tools/freetype']) + env.Append(CPPPATH=['#tools/freetype/freetype/include']) + else: + env.ParseConfig('pkg-config freetype2 --cflags --libs') - env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED']) env.Append(CPPFLAGS=["-DALSA_ENABLED"]) env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES1_ENABLED','-DGLES_OVER_GL']) - env.Append(LIBS=['GL', 'GLU', 'pthread','asound','z']) #TODO detect linux/BSD! + env.Append(LIBS=['GL', 'pthread', 'asound']) #TODO detect linux/BSD! + if (env["builtin_zlib"]=="no"): + env.Append(LIBS=['z']) #env.Append(CPPFLAGS=['-DMPC_FIXED_POINT']) #host compiler is default.. if (is64 and env["bits"]=="32"): env.Append(CPPFLAGS=['-m32']) - env.Append(LINKFLAGS=['-m32','-L/usr/lib/i386-linux-gnu']) + env.Append(LINKFLAGS=['-m32']) elif (not is64 and env["bits"]=="64"): env.Append(CPPFLAGS=['-m64']) - env.Append(LINKFLAGS=['-m64','-L/usr/lib/i686-linux-gnu']) + env.Append(LINKFLAGS=['-m64']) if (env["CXX"]=="clang++"): From eb111c1d39119c92baed00dd69ec6a85820102bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 3 Jan 2025 22:43:51 +0100 Subject: [PATCH 4/5] OSX: Add support for building with osxcross --- platform/osx/detect.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/platform/osx/detect.py b/platform/osx/detect.py index a8836d8f460..8d8c077a74e 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -11,16 +11,16 @@ def get_name(): def can_build(): - if (sys.platform != "darwin"): - return False + if (sys.platform == "darwin" or ("OSXCROSS_ROOT" in os.environ)): + return True - return True # osx enabled + return False def get_opts(): return [ ('force_64_bits','Force 64 bits binary','no'), - + ('osxcross_sdk', 'OSXCross SDK version', 'darwin14'), ] def get_flags(): @@ -59,12 +59,25 @@ def configure(env): env.Append(CPPPATH=['#tools/freetype']) env.Append(CPPPATH=['#tools/freetype/freetype/include']) - if (env["bits"]=="64"): - env.Append(CCFLAGS=['-arch', 'x86_64']) - env.Append(LINKFLAGS=['-arch', 'x86_64']) + if ("OSXCROSS_ROOT" not in os.environ): + # regular native build + if (env["bits"]=="64"): + env.Append(CCFLAGS=['-arch', 'x86_64']) + env.Append(LINKFLAGS=['-arch', 'x86_64']) + else: + env.Append(CCFLAGS=['-arch', 'i386']) + env.Append(LINKFLAGS=['-arch', 'i386']) else: - env.Append(CCFLAGS=['-arch', 'i386']) - env.Append(LINKFLAGS=['-arch', 'i386']) + # osxcross build + root = os.environ.get("OSXCROSS_ROOT", 0) + arch = "i686" if env["bits"]=="32" else "x86_64" + basecmd = root + "/target/bin/" + arch + "-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(CPPPATH=['#platform/osx/include/freetype2', '#platform/osx/include']) # env.Append(LIBPATH=['#platform/osx/lib']) From ad2fb7d93bf0fc0d1266dc7267a074f2293d48d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 3 Jan 2025 22:44:20 +0100 Subject: [PATCH 5/5] SCons: Ensure written files are properly flushed/closed Also add `core/method_bind_ext.inc` to `.gitignore`. --- .gitignore | 1 + methods.py | 6 +++++- platform/android/SCsub | 1 + tools/docdump/doc_merge.py | 2 +- tools/docdump/makedoku.py | 10 +++++----- tools/docdump/makemd.py | 2 ++ tools/editor/SCsub | 1 + tools/export/blender25/io_scene_dae/export_dae.py | 1 + tools/glwrapper/makewrapper.py | 6 +++--- 9 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 45bf5313117..4aee83c13f3 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ drivers/gles2/shaders/*.h modules/register_module_types.cpp core/version.h core/method_bind.inc +core/method_bind_ext.inc core/script_encryption_key.cpp core/global_defaults.cpp tools/editor/register_exporters.cpp diff --git a/methods.py b/methods.py index 0c0c5a05e33..fb92f8a07ba 100755 --- a/methods.py +++ b/methods.py @@ -42,6 +42,7 @@ def build_shader_header( target, source, env ): line=fs.readline() fd.write(";\n") + fd.close() return 0 @@ -1098,6 +1099,7 @@ def update_version(): f.write("#define VERSION_MINOR "+str(version.minor)+"\n") f.write("#define VERSION_REVISION "+str(rev)+"\n") f.write("#define VERSION_STATUS "+str(version.status)+"\n") + f.close() def parse_cg_file(fname, uniforms, sizes, conditionals): @@ -1167,8 +1169,8 @@ def build_cg_shader(sname): fd.write('\t\tVP_%s,\n' % vp_uniforms[i].upper()) fd.write("\t};\n"); + fd.close() - import glob def detect_modules(): @@ -1219,6 +1221,7 @@ void unregister_module_types() { f=open("modules/register_module_types.cpp","wb") f.write(modules_cpp) + f.close() return module_list @@ -1315,4 +1318,5 @@ def save_active_platforms(apnames,ap): wf = x+"/logo.h" logow = open(wf,"wb") logow.write(str) + logow.close() diff --git a/platform/android/SCsub b/platform/android/SCsub index cffec5ae952..fba7d0b6108 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -57,6 +57,7 @@ pp_baseout = open(abspath+"/java/AndroidManifest.xml","wb") manifest = pp_basein.read() manifest = manifest.replace("$$ADD_APPLICATION_CHUNKS$$",env.android_manifest_chunk) pp_baseout.write( manifest ) +pp_baseout.close() for x in env.android_source_files: diff --git a/tools/docdump/doc_merge.py b/tools/docdump/doc_merge.py index 872f38ed870..a90588b4d04 100644 --- a/tools/docdump/doc_merge.py +++ b/tools/docdump/doc_merge.py @@ -205,4 +205,4 @@ for c in list(new_doc): write_class(c) write_string(f,'\n') - +f.close() diff --git a/tools/docdump/makedoku.py b/tools/docdump/makedoku.py index e8207715fe7..36a7cbb98f8 100644 --- a/tools/docdump/makedoku.py +++ b/tools/docdump/makedoku.py @@ -75,8 +75,9 @@ def make_class_list(class_list,columns): s+="\n" f.write(s) - - + f.close() + + def dokuize_text(txt): return txt @@ -220,7 +221,7 @@ def make_method(f,name,m,declare,event=False): s+=" "+m.attrib["qualifiers"] f.write(s+"\n") - + f.close() def make_doku_class(node): @@ -302,8 +303,7 @@ def make_doku_class(node): f.write(dokuize_text(d.text.strip())) f.write("\n") - - + f.close() """ diff --git a/tools/docdump/makemd.py b/tools/docdump/makemd.py index f85d145d5e5..5ab345d6d23 100644 --- a/tools/docdump/makemd.py +++ b/tools/docdump/makemd.py @@ -85,6 +85,7 @@ def make_class_list(class_list, columns): s += '\n' f.write(s) + f.close() def dokuize_text(txt): @@ -317,6 +318,7 @@ def make_doku_class(node): f.write('\n') f.write(dokuize_text(d.text.strip())) f.write('\n') + f.close() for file in input_list: diff --git a/tools/editor/SCsub b/tools/editor/SCsub index 73ec5301774..39719540559 100644 --- a/tools/editor/SCsub +++ b/tools/editor/SCsub @@ -23,6 +23,7 @@ def make_doc_header(target,source,env): g.write(str(ord(buf[i]))+",\n") g.write("};\n") g.write("#endif") + g.close() diff --git a/tools/export/blender25/io_scene_dae/export_dae.py b/tools/export/blender25/io_scene_dae/export_dae.py index 4e1635429b9..97d749d99cb 100644 --- a/tools/export/blender25/io_scene_dae/export_dae.py +++ b/tools/export/blender25/io_scene_dae/export_dae.py @@ -1588,6 +1588,7 @@ class DaeExporter: f.write(bytes('\t\n',"UTF-8")) f.write(bytes('\n',"UTF-8")) f.write(bytes('\n',"UTF-8")) + f.close() return True def __init__(self,path,kwargs): diff --git a/tools/glwrapper/makewrapper.py b/tools/glwrapper/makewrapper.py index cde976d5f93..537487275a1 100644 --- a/tools/glwrapper/makewrapper.py +++ b/tools/glwrapper/makewrapper.py @@ -157,6 +157,7 @@ f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) );\n") f.write("#ifdef __cplusplus\n}\n#endif\n") f.write("#endif\n\n") +f.close() f=open("glwrapper.c","w") @@ -177,8 +178,7 @@ for x in functions: f.write("\n\n") f.write("}\n") f.write("\n\n") - - +f.close() - \ No newline at end of file +