summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-03-30 08:28:32 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-03-30 09:05:53 +0200
commitcd4e46ee65dab6baa6a143bf3b3f64244be36712 (patch)
tree689e53265691e782ae35a961445c975219e1155d /core
parent0168709978154a89f137b44f33647e5d28a46250 (diff)
SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters. psf/black is very opinionated and purposely doesn't leave much room for configuration. The output is mostly OK so that should be fine for us, but some things worth noting: - Manually wrapped strings will be reflowed, so by using a line length of 120 for the sake of preserving readability for our long command calls, it also means that some manually wrapped strings are back on the same line and should be manually merged again. - Code generators using string concatenation extensively look awful, since black puts each operand on a single line. We need to refactor these generators to use more pythonic string formatting, for which many options are available (`%`, `format` or f-strings). - CI checks and a pre-commit hook will be added to ensure that future buildsystem changes are well-formatted.
Diffstat (limited to 'core')
-rw-r--r--core/SCsub111
-rw-r--r--core/bind/SCsub2
-rw-r--r--core/core_builders.py139
-rw-r--r--core/crypto/SCsub8
-rw-r--r--core/debugger/SCsub2
-rw-r--r--core/input/SCsub16
-rw-r--r--core/input/input_builders.py20
-rw-r--r--core/io/SCsub2
-rw-r--r--core/make_binders.py48
-rw-r--r--core/math/SCsub2
-rw-r--r--core/os/SCsub2
11 files changed, 215 insertions, 137 deletions
diff --git a/core/SCsub b/core/SCsub
index ca003ce931..0ab4f11d87 100644
--- a/core/SCsub
+++ b/core/SCsub
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-Import('env')
+Import("env")
import core_builders
import make_binders
@@ -11,31 +11,32 @@ env.core_sources = []
# Generate AES256 script encryption key
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):
+if "SCRIPT_AES256_ENCRYPTION_KEY" in os.environ:
e = os.environ["SCRIPT_AES256_ENCRYPTION_KEY"]
txt = ""
ec_valid = True
- if (len(e) != 64):
+ if len(e) != 64:
ec_valid = False
else:
for i in range(len(e) >> 1):
- if (i > 0):
+ if i > 0:
txt += ","
- txts = "0x" + e[i * 2:i * 2 + 2]
+ txts = "0x" + e[i * 2 : i * 2 + 2]
try:
int(txts, 16)
except:
ec_valid = False
txt += txts
- if (not ec_valid):
+ 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)
# NOTE: It is safe to generate this file here, since this is still executed serially
with open("script_encryption_key.gen.cpp", "w") as f:
- f.write("#include \"core/project_settings.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
+ f.write('#include "core/project_settings.h"\nuint8_t script_encryption_key[32]={' + txt + "};\n")
# Add required thirdparty code.
@@ -49,7 +50,6 @@ thirdparty_misc_sources = [
# C sources
"fastlz.c",
"smaz.c",
-
# C++ sources
"hq2x.cpp",
"pcg.cpp",
@@ -60,30 +60,30 @@ thirdparty_misc_sources = [thirdparty_misc_dir + file for file in thirdparty_mis
env_thirdparty.add_source_files(env.core_sources, thirdparty_misc_sources)
# Zlib library, can be unbundled
-if env['builtin_zlib']:
- thirdparty_zlib_dir = "#thirdparty/zlib/"
- thirdparty_zlib_sources = [
- "adler32.c",
- "compress.c",
- "crc32.c",
- "deflate.c",
- "infback.c",
- "inffast.c",
- "inflate.c",
- "inftrees.c",
- "trees.c",
- "uncompr.c",
- "zutil.c",
- ]
- thirdparty_zlib_sources = [thirdparty_zlib_dir + file for file in thirdparty_zlib_sources]
-
- env_thirdparty.Prepend(CPPPATH=[thirdparty_zlib_dir])
- # Needs to be available in main env too
- env.Prepend(CPPPATH=[thirdparty_zlib_dir])
- if (env['target'] == 'debug'):
- env_thirdparty.Append(CPPDEFINES=['ZLIB_DEBUG'])
-
- env_thirdparty.add_source_files(env.core_sources, thirdparty_zlib_sources)
+if env["builtin_zlib"]:
+ thirdparty_zlib_dir = "#thirdparty/zlib/"
+ thirdparty_zlib_sources = [
+ "adler32.c",
+ "compress.c",
+ "crc32.c",
+ "deflate.c",
+ "infback.c",
+ "inffast.c",
+ "inflate.c",
+ "inftrees.c",
+ "trees.c",
+ "uncompr.c",
+ "zutil.c",
+ ]
+ thirdparty_zlib_sources = [thirdparty_zlib_dir + file for file in thirdparty_zlib_sources]
+
+ env_thirdparty.Prepend(CPPPATH=[thirdparty_zlib_dir])
+ # Needs to be available in main env too
+ env.Prepend(CPPPATH=[thirdparty_zlib_dir])
+ if env["target"] == "debug":
+ env_thirdparty.Append(CPPDEFINES=["ZLIB_DEBUG"])
+
+ env_thirdparty.add_source_files(env.core_sources, thirdparty_zlib_sources)
# Minizip library, could be unbundled in theory
# However, our version has some custom modifications, so it won't compile with the system one
@@ -99,7 +99,7 @@ env_thirdparty.add_source_files(env.core_sources, thirdparty_minizip_sources)
# Zstd library, can be unbundled in theory
# though we currently use some private symbols
# https://github.com/godotengine/godot/issues/17374
-if env['builtin_zstd']:
+if env["builtin_zstd"]:
thirdparty_zstd_dir = "#thirdparty/zstd/"
thirdparty_zstd_sources = [
"common/debug.c",
@@ -142,32 +142,45 @@ if env['builtin_zstd']:
env.add_source_files(env.core_sources, "*.cpp")
# Certificates
-env.Depends("#core/io/certs_compressed.gen.h", ["#thirdparty/certs/ca-certificates.crt", env.Value(env['builtin_certs']), env.Value(env['system_certs_path'])])
-env.CommandNoCache("#core/io/certs_compressed.gen.h", "#thirdparty/certs/ca-certificates.crt", run_in_subprocess(core_builders.make_certs_header))
+env.Depends(
+ "#core/io/certs_compressed.gen.h",
+ ["#thirdparty/certs/ca-certificates.crt", env.Value(env["builtin_certs"]), env.Value(env["system_certs_path"])],
+)
+env.CommandNoCache(
+ "#core/io/certs_compressed.gen.h",
+ "#thirdparty/certs/ca-certificates.crt",
+ run_in_subprocess(core_builders.make_certs_header),
+)
# Make binders
-env.CommandNoCache(['method_bind.gen.inc', 'method_bind_ext.gen.inc', 'method_bind_free_func.gen.inc'], 'make_binders.py', run_in_subprocess(make_binders.run))
+env.CommandNoCache(
+ ["method_bind.gen.inc", "method_bind_ext.gen.inc", "method_bind_free_func.gen.inc"],
+ "make_binders.py",
+ run_in_subprocess(make_binders.run),
+)
# Authors
-env.Depends('#core/authors.gen.h', "../AUTHORS.md")
-env.CommandNoCache('#core/authors.gen.h', "../AUTHORS.md", run_in_subprocess(core_builders.make_authors_header))
+env.Depends("#core/authors.gen.h", "../AUTHORS.md")
+env.CommandNoCache("#core/authors.gen.h", "../AUTHORS.md", run_in_subprocess(core_builders.make_authors_header))
# Donors
-env.Depends('#core/donors.gen.h', "../DONORS.md")
-env.CommandNoCache('#core/donors.gen.h', "../DONORS.md", run_in_subprocess(core_builders.make_donors_header))
+env.Depends("#core/donors.gen.h", "../DONORS.md")
+env.CommandNoCache("#core/donors.gen.h", "../DONORS.md", run_in_subprocess(core_builders.make_donors_header))
# License
-env.Depends('#core/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"])
-env.CommandNoCache('#core/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"], run_in_subprocess(core_builders.make_license_header))
+env.Depends("#core/license.gen.h", ["../COPYRIGHT.txt", "../LICENSE.txt"])
+env.CommandNoCache(
+ "#core/license.gen.h", ["../COPYRIGHT.txt", "../LICENSE.txt"], run_in_subprocess(core_builders.make_license_header)
+)
# Chain load SCsubs
-SConscript('os/SCsub')
-SConscript('math/SCsub')
-SConscript('crypto/SCsub')
-SConscript('io/SCsub')
-SConscript('debugger/SCsub')
-SConscript('input/SCsub')
-SConscript('bind/SCsub')
+SConscript("os/SCsub")
+SConscript("math/SCsub")
+SConscript("crypto/SCsub")
+SConscript("io/SCsub")
+SConscript("debugger/SCsub")
+SConscript("input/SCsub")
+SConscript("bind/SCsub")
# Build it all as a library
diff --git a/core/bind/SCsub b/core/bind/SCsub
index 1c5f954470..19a6549225 100644
--- a/core/bind/SCsub
+++ b/core/bind/SCsub
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-Import('env')
+Import("env")
env.add_source_files(env.core_sources, "*.cpp")
diff --git a/core/core_builders.py b/core/core_builders.py
index a06b61cb9b..d03874608e 100644
--- a/core/core_builders.py
+++ b/core/core_builders.py
@@ -11,15 +11,15 @@ def escape_string(s):
rev_result = []
while c >= 256:
c, low = (c // 256, c % 256)
- rev_result.append('\\%03o' % low)
- rev_result.append('\\%03o' % c)
- return ''.join(reversed(rev_result))
+ rev_result.append("\\%03o" % low)
+ rev_result.append("\\%03o" % c)
+ return "".join(reversed(rev_result))
- result = ''
+ result = ""
if isinstance(s, str):
- s = s.encode('utf-8')
+ s = s.encode("utf-8")
for c in s:
- if not(32 <= c < 127) or c in (ord('\\'), ord('"')):
+ if not (32 <= c < 127) or c in (ord("\\"), ord('"')):
result += charcode_to_c_escapes(c)
else:
result += chr(c)
@@ -34,6 +34,7 @@ def make_certs_header(target, source, env):
buf = f.read()
decomp_size = len(buf)
import zlib
+
buf = zlib.compress(buf)
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
@@ -41,9 +42,9 @@ def make_certs_header(target, source, env):
g.write("#define CERTS_COMPRESSED_GEN_H\n")
# System certs path. Editor will use them if defined. (for package maintainers)
- path = env['system_certs_path']
- g.write("#define _SYSTEM_CERTS_PATH \"%s\"\n" % str(path))
- if env['builtin_certs']:
+ path = env["system_certs_path"]
+ g.write('#define _SYSTEM_CERTS_PATH "%s"\n' % str(path))
+ if env["builtin_certs"]:
# Defined here and not in env so changing it does not trigger a full rebuild.
g.write("#define BUILTIN_CERTS_ENABLED\n")
g.write("static const int _certs_compressed_size = " + str(len(buf)) + ";\n")
@@ -59,8 +60,18 @@ def make_certs_header(target, source, env):
def make_authors_header(target, source, env):
- sections = ["Project Founders", "Lead Developer", "Project Manager", "Developers"]
- sections_id = ["AUTHORS_FOUNDERS", "AUTHORS_LEAD_DEVELOPERS", "AUTHORS_PROJECT_MANAGERS", "AUTHORS_DEVELOPERS"]
+ sections = [
+ "Project Founders",
+ "Lead Developer",
+ "Project Manager",
+ "Developers",
+ ]
+ sections_id = [
+ "AUTHORS_FOUNDERS",
+ "AUTHORS_LEAD_DEVELOPERS",
+ "AUTHORS_PROJECT_MANAGERS",
+ "AUTHORS_DEVELOPERS",
+ ]
src = source[0]
dst = target[0]
@@ -80,7 +91,7 @@ def make_authors_header(target, source, env):
for line in f:
if reading:
if line.startswith(" "):
- g.write("\t\"" + escape_string(line.strip()) + "\",\n")
+ g.write('\t"' + escape_string(line.strip()) + '",\n')
continue
if line.startswith("## "):
if reading:
@@ -103,10 +114,22 @@ def make_authors_header(target, source, env):
def make_donors_header(target, source, env):
- sections = ["Platinum sponsors", "Gold sponsors", "Mini sponsors",
- "Gold donors", "Silver donors", "Bronze donors"]
- sections_id = ["DONORS_SPONSOR_PLAT", "DONORS_SPONSOR_GOLD", "DONORS_SPONSOR_MINI",
- "DONORS_GOLD", "DONORS_SILVER", "DONORS_BRONZE"]
+ sections = [
+ "Platinum sponsors",
+ "Gold sponsors",
+ "Mini sponsors",
+ "Gold donors",
+ "Silver donors",
+ "Bronze donors",
+ ]
+ sections_id = [
+ "DONORS_SPONSOR_PLAT",
+ "DONORS_SPONSOR_GOLD",
+ "DONORS_SPONSOR_MINI",
+ "DONORS_GOLD",
+ "DONORS_SILVER",
+ "DONORS_BRONZE",
+ ]
src = source[0]
dst = target[0]
@@ -126,7 +149,7 @@ def make_donors_header(target, source, env):
for line in f:
if reading >= 0:
if line.startswith(" "):
- g.write("\t\"" + escape_string(line.strip()) + "\",\n")
+ g.write('\t"' + escape_string(line.strip()) + '",\n')
continue
if line.startswith("## "):
if reading:
@@ -169,8 +192,8 @@ def make_license_header(target, source, env):
return line
def next_tag(self):
- if not ':' in self.current:
- return ('', [])
+ if not ":" in self.current:
+ return ("", [])
tag, line = self.current.split(":", 1)
lines = [line.strip()]
while self.next_line() and self.current.startswith(" "):
@@ -178,6 +201,7 @@ def make_license_header(target, source, env):
return (tag, lines)
from collections import OrderedDict
+
projects = OrderedDict()
license_list = []
@@ -218,26 +242,30 @@ def make_license_header(target, source, env):
with open(src_license, "r", encoding="utf-8") as license_file:
for line in license_file:
escaped_string = escape_string(line.strip())
- f.write("\n\t\t\"" + escaped_string + "\\n\"")
+ f.write('\n\t\t"' + escaped_string + '\\n"')
f.write(";\n\n")
- f.write("struct ComponentCopyrightPart {\n"
- "\tconst char *license;\n"
- "\tconst char *const *files;\n"
- "\tconst char *const *copyright_statements;\n"
- "\tint file_count;\n"
- "\tint copyright_count;\n"
- "};\n\n")
-
- f.write("struct ComponentCopyright {\n"
- "\tconst char *name;\n"
- "\tconst ComponentCopyrightPart *parts;\n"
- "\tint part_count;\n"
- "};\n\n")
+ f.write(
+ "struct ComponentCopyrightPart {\n"
+ "\tconst char *license;\n"
+ "\tconst char *const *files;\n"
+ "\tconst char *const *copyright_statements;\n"
+ "\tint file_count;\n"
+ "\tint copyright_count;\n"
+ "};\n\n"
+ )
+
+ f.write(
+ "struct ComponentCopyright {\n"
+ "\tconst char *name;\n"
+ "\tconst ComponentCopyrightPart *parts;\n"
+ "\tint part_count;\n"
+ "};\n\n"
+ )
f.write("const char *const COPYRIGHT_INFO_DATA[] = {\n")
for line in data_list:
- f.write("\t\"" + escape_string(line) + "\",\n")
+ f.write('\t"' + escape_string(line) + '",\n')
f.write("};\n\n")
f.write("const ComponentCopyrightPart COPYRIGHT_PROJECT_PARTS[] = {\n")
@@ -246,11 +274,21 @@ def make_license_header(target, source, env):
for project_name, project in iter(projects.items()):
part_indexes[project_name] = part_index
for part in project:
- f.write("\t{ \"" + escape_string(part["License"][0]) + "\", "
- + "&COPYRIGHT_INFO_DATA[" + str(part["file_index"]) + "], "
- + "&COPYRIGHT_INFO_DATA[" + str(part["copyright_index"]) + "], "
- + str(len(part["Files"])) + ", "
- + str(len(part["Copyright"])) + " },\n")
+ f.write(
+ '\t{ "'
+ + escape_string(part["License"][0])
+ + '", '
+ + "&COPYRIGHT_INFO_DATA["
+ + str(part["file_index"])
+ + "], "
+ + "&COPYRIGHT_INFO_DATA["
+ + str(part["copyright_index"])
+ + "], "
+ + str(len(part["Files"]))
+ + ", "
+ + str(len(part["Copyright"]))
+ + " },\n"
+ )
part_index += 1
f.write("};\n\n")
@@ -258,30 +296,37 @@ def make_license_header(target, source, env):
f.write("const ComponentCopyright COPYRIGHT_INFO[] = {\n")
for project_name, project in iter(projects.items()):
- f.write("\t{ \"" + escape_string(project_name) + "\", "
- + "&COPYRIGHT_PROJECT_PARTS[" + str(part_indexes[project_name]) + "], "
- + str(len(project)) + " },\n")
+ f.write(
+ '\t{ "'
+ + escape_string(project_name)
+ + '", '
+ + "&COPYRIGHT_PROJECT_PARTS["
+ + str(part_indexes[project_name])
+ + "], "
+ + str(len(project))
+ + " },\n"
+ )
f.write("};\n\n")
f.write("const int LICENSE_COUNT = " + str(len(license_list)) + ";\n")
f.write("const char *const LICENSE_NAMES[] = {\n")
for l in license_list:
- f.write("\t\"" + escape_string(l[0]) + "\",\n")
+ f.write('\t"' + escape_string(l[0]) + '",\n')
f.write("};\n\n")
f.write("const char *const LICENSE_BODIES[] = {\n\n")
for l in license_list:
for line in l[1:]:
if line == ".":
- f.write("\t\"\\n\"\n")
+ f.write('\t"\\n"\n')
else:
- f.write("\t\"" + escape_string(line) + "\\n\"\n")
- f.write("\t\"\",\n\n")
+ f.write('\t"' + escape_string(line) + '\\n"\n')
+ f.write('\t"",\n\n')
f.write("};\n\n")
f.write("#endif // LICENSE_GEN_H\n")
-if __name__ == '__main__':
+if __name__ == "__main__":
subprocess_main(globals())
diff --git a/core/crypto/SCsub b/core/crypto/SCsub
index 0a3f05d87a..da4a9c9381 100644
--- a/core/crypto/SCsub
+++ b/core/crypto/SCsub
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-Import('env')
+Import("env")
env_crypto = env.Clone()
@@ -22,7 +22,9 @@ if not has_module:
env_thirdparty = env_crypto.Clone()
env_thirdparty.disable_warnings()
# Custom config file
- env_thirdparty.Append(CPPDEFINES=[('MBEDTLS_CONFIG_FILE', '\\"thirdparty/mbedtls/include/godot_core_mbedtls_config.h\\"')])
+ env_thirdparty.Append(
+ CPPDEFINES=[("MBEDTLS_CONFIG_FILE", '\\"thirdparty/mbedtls/include/godot_core_mbedtls_config.h\\"')]
+ )
thirdparty_mbedtls_dir = "#thirdparty/mbedtls/library/"
thirdparty_mbedtls_sources = [
"aes.c",
@@ -30,7 +32,7 @@ if not has_module:
"md5.c",
"sha1.c",
"sha256.c",
- "godot_core_mbedtls_platform.c"
+ "godot_core_mbedtls_platform.c",
]
thirdparty_mbedtls_sources = [thirdparty_mbedtls_dir + file for file in thirdparty_mbedtls_sources]
env_thirdparty.add_source_files(env.core_sources, thirdparty_mbedtls_sources)
diff --git a/core/debugger/SCsub b/core/debugger/SCsub
index 1c5f954470..19a6549225 100644
--- a/core/debugger/SCsub
+++ b/core/debugger/SCsub
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-Import('env')
+Import("env")
env.add_source_files(env.core_sources, "*.cpp")
diff --git a/core/input/SCsub b/core/input/SCsub
index f1660932e5..d46e52a347 100644
--- a/core/input/SCsub
+++ b/core/input/SCsub
@@ -1,20 +1,28 @@
#!/usr/bin/env python
-Import('env')
+Import("env")
from platform_methods import run_in_subprocess
import input_builders
# Order matters here. Higher index controller database files write on top of lower index database files.
-controller_databases = ["#core/input/gamecontrollerdb_204.txt", "#core/input/gamecontrollerdb_205.txt", "#core/input/gamecontrollerdb.txt", "#core/input/godotcontrollerdb.txt"]
+controller_databases = [
+ "#core/input/gamecontrollerdb_204.txt",
+ "#core/input/gamecontrollerdb_205.txt",
+ "#core/input/gamecontrollerdb.txt",
+ "#core/input/godotcontrollerdb.txt",
+]
env.Depends("#core/input/default_controller_mappings.gen.cpp", controller_databases)
-env.CommandNoCache("#core/input/default_controller_mappings.gen.cpp", controller_databases, run_in_subprocess(input_builders.make_default_controller_mappings))
+env.CommandNoCache(
+ "#core/input/default_controller_mappings.gen.cpp",
+ controller_databases,
+ run_in_subprocess(input_builders.make_default_controller_mappings),
+)
env.add_source_files(env.core_sources, "*.cpp")
# Don't warn about duplicate entry here, we need it registered manually for first build,
# even if later builds will pick it up twice due to above *.cpp globbing.
env.add_source_files(env.core_sources, "#core/input/default_controller_mappings.gen.cpp", warn_duplicates=False)
-
diff --git a/core/input/input_builders.py b/core/input/input_builders.py
index ca142c0c80..6184c5debb 100644
--- a/core/input/input_builders.py
+++ b/core/input/input_builders.py
@@ -12,8 +12,8 @@ def make_default_controller_mappings(target, source, env):
g = open(dst, "w")
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#include \"core/typedefs.h\"\n")
- g.write("#include \"core/input/default_controller_mappings.h\"\n")
+ g.write('#include "core/typedefs.h"\n')
+ g.write('#include "core/input/default_controller_mappings.h"\n')
# ensure mappings have a consistent order
platform_mappings = OrderedDict()
@@ -37,11 +37,19 @@ def make_default_controller_mappings(target, source, env):
line_parts = line.split(",")
guid = line_parts[0]
if guid in platform_mappings[current_platform]:
- g.write("// WARNING - DATABASE {} OVERWROTE PRIOR MAPPING: {} {}\n".format(src_path, current_platform, platform_mappings[current_platform][guid]))
+ g.write(
+ "// WARNING - DATABASE {} OVERWROTE PRIOR MAPPING: {} {}\n".format(
+ src_path, current_platform, platform_mappings[current_platform][guid]
+ )
+ )
valid_mapping = True
for input_map in line_parts[2:]:
if "+" in input_map or "-" in input_map or "~" in input_map:
- g.write("// WARNING - DISCARDED UNSUPPORTED MAPPING TYPE FROM DATABASE {}: {} {}\n".format(src_path, current_platform, line))
+ g.write(
+ "// WARNING - DISCARDED UNSUPPORTED MAPPING TYPE FROM DATABASE {}: {} {}\n".format(
+ src_path, current_platform, line
+ )
+ )
valid_mapping = False
break
if valid_mapping:
@@ -62,12 +70,12 @@ def make_default_controller_mappings(target, source, env):
variable = platform_variables[platform]
g.write("{}\n".format(variable))
for mapping in mappings.values():
- g.write("\t\"{}\",\n".format(mapping))
+ g.write('\t"{}",\n'.format(mapping))
g.write("#endif\n")
g.write("\tNULL\n};\n")
g.close()
-if __name__ == '__main__':
+if __name__ == "__main__":
subprocess_main(globals())
diff --git a/core/io/SCsub b/core/io/SCsub
index 1c5f954470..19a6549225 100644
--- a/core/io/SCsub
+++ b/core/io/SCsub
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-Import('env')
+Import("env")
env.add_source_files(env.core_sources, "*.cpp")
diff --git a/core/make_binders.py b/core/make_binders.py
index c42b91fbe5..94bee95bfb 100644
--- a/core/make_binders.py
+++ b/core/make_binders.py
@@ -280,58 +280,57 @@ MethodBind* create_method_bind($ifret R$ $ifnoret void$ (*p_method)($ifconst con
"""
-
def make_version(template, nargs, argmax, const, ret):
intext = template
from_pos = 0
outtext = ""
- while(True):
+ while True:
to_pos = intext.find("$", from_pos)
- if (to_pos == -1):
+ 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):
+ if end == -1:
break # ignore
- macro = intext[to_pos + 1:end]
+ macro = intext[to_pos + 1 : end]
cmd = ""
data = ""
- if (macro.find(" ") != -1):
- cmd = macro[0:macro.find(" ")]
- data = macro[macro.find(" ") + 1:]
+ if macro.find(" ") != -1:
+ cmd = macro[0 : macro.find(" ")]
+ data = macro[macro.find(" ") + 1 :]
else:
cmd = macro
- if (cmd == "argc"):
+ if cmd == "argc":
outtext += str(nargs)
- if (cmd == "ifret" and ret):
+ if cmd == "ifret" and ret:
outtext += data
- if (cmd == "ifargs" and nargs):
+ if cmd == "ifargs" and nargs:
outtext += data
- if (cmd == "ifretargs" and nargs and ret):
+ if cmd == "ifretargs" and nargs and ret:
outtext += data
- if (cmd == "ifconst" and const):
+ if cmd == "ifconst" and const:
outtext += data
- elif (cmd == "ifnoconst" and not const):
+ elif cmd == "ifnoconst" and not const:
outtext += data
- elif (cmd == "ifnoret" and not ret):
+ elif cmd == "ifnoret" and not ret:
outtext += data
- elif (cmd == "iftempl" and (nargs > 0 or ret)):
+ elif cmd == "iftempl" and (nargs > 0 or ret):
outtext += data
- elif (cmd == "arg,"):
+ elif cmd == "arg,":
for i in range(1, nargs + 1):
- if (i > 1):
+ if i > 1:
outtext += ", "
outtext += data.replace("@", str(i))
- elif (cmd == "arg"):
+ elif cmd == "arg":
for i in range(1, nargs + 1):
outtext += data.replace("@", str(i))
- elif (cmd == "noarg"):
+ elif cmd == "noarg":
for i in range(nargs + 1, argmax + 1):
outtext += data.replace("@", str(i))
@@ -348,7 +347,9 @@ def run(target, source, env):
text_ext = ""
text_free_func = "#ifndef METHOD_BIND_FREE_FUNC_H\n#define METHOD_BIND_FREE_FUNC_H\n"
text_free_func += "\n//including this header file allows method binding to use free functions\n"
- text_free_func += "//note that the free function must have a pointer to an instance of the class as its first parameter\n"
+ text_free_func += (
+ "//note that the free function must have a pointer to an instance of the class as its first parameter\n"
+ )
for i in range(0, versions + 1):
@@ -361,7 +362,7 @@ def run(target, source, env):
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):
+ if i >= versions_ext:
text_ext += t
else:
text += t
@@ -383,6 +384,7 @@ def run(target, source, env):
f.write(text_free_func)
-if __name__ == '__main__':
+if __name__ == "__main__":
from platform_methods import subprocess_main
+
subprocess_main(globals())
diff --git a/core/math/SCsub b/core/math/SCsub
index be438fcfbe..c8fdac207e 100644
--- a/core/math/SCsub
+++ b/core/math/SCsub
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-Import('env')
+Import("env")
env_math = env.Clone()
diff --git a/core/os/SCsub b/core/os/SCsub
index 1c5f954470..19a6549225 100644
--- a/core/os/SCsub
+++ b/core/os/SCsub
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-Import('env')
+Import("env")
env.add_source_files(env.core_sources, "*.cpp")