diff options
Diffstat (limited to 'methods.py')
-rw-r--r-- | methods.py | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/methods.py b/methods.py index bec1b803e9..7ede2592ff 100644 --- a/methods.py +++ b/methods.py @@ -7,15 +7,6 @@ from collections import OrderedDict from collections.abc import Mapping from typing import Iterator -# We need to define our own `Action` method to control the verbosity of output -# and whenever we need to run those commands in a subprocess on some platforms. -from SCons import Node -from SCons.Script import Action -from SCons.Script import ARGUMENTS -from SCons.Script import Glob -from SCons.Variables.BoolVariable import _text2bool -from platform_methods import run_in_subprocess - def add_source_files(self, sources, files): # Convert string to list of absolute paths (including expanding wildcard) @@ -120,6 +111,10 @@ def get_version_info(module_version_string="", silent=False): head = open(os.path.join(gitfolder, "HEAD"), "r", encoding="utf8").readline().strip() if head.startswith("ref: "): ref = head[5:] + # If this directory is a Git worktree instead of a root clone. + parts = gitfolder.split("/") + if len(parts) > 2 and parts[-2] == "worktrees": + gitfolder = "/".join(parts[0:-2]) head = os.path.join(gitfolder, ref) packedrefs = os.path.join(gitfolder, "packed-refs") if os.path.isfile(head): @@ -220,6 +215,9 @@ def get_cmdline_bool(option, default): """We use `ARGUMENTS.get()` to check if options were manually overridden on the command line, and SCons' _text2bool helper to convert them to booleans, otherwise they're handled as strings. """ + from SCons.Script import ARGUMENTS + from SCons.Variables.BoolVariable import _text2bool + cmdline_val = ARGUMENTS.get(option) if cmdline_val is not None: return _text2bool(cmdline_val) @@ -490,29 +488,29 @@ def use_windows_spawn_fix(self, platform=None): def save_active_platforms(apnames, ap): for x in ap: - names = ["logo"] - if os.path.isfile(x + "/run_icon.png"): - names.append("run_icon") - - for name in names: - pngf = open(x + "/" + name + ".png", "rb") - b = pngf.read(1) - str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n" - str += " static const unsigned char _" + x[9:] + "_" + name + "[]={" + svg_names = [] + if os.path.isfile(x + "/logo.svg"): + svg_names.append("logo") + if os.path.isfile(x + "/run_icon.svg"): + svg_names.append("run_icon") + + for name in svg_names: + svgf = open(x + "/" + name + ".svg", "rb") + b = svgf.read(1) + svg_str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n" + svg_str += " static const char *_" + x[9:] + "_" + name + '_svg = "' while len(b) == 1: - str += hex(ord(b)) - b = pngf.read(1) - if len(b) == 1: - str += "," + svg_str += "\\" + hex(ord(b))[1:] + b = svgf.read(1) - str += "};\n" + svg_str += '";\n' - pngf.close() + svgf.close() # NOTE: It is safe to generate this file here, since this is still executed serially - wf = x + "/" + name + ".gen.h" - with open(wf, "w") as pngw: - pngw.write(str) + wf = x + "/" + name + "_svg.gen.h" + with open(wf, "w") as svgw: + svgw.write(svg_str) def no_verbose(sys, env): @@ -703,6 +701,9 @@ def generate_cpp_hint_file(filename): def glob_recursive(pattern, node="."): + from SCons import Node + from SCons.Script import Glob + results = [] for f in Glob(str(node) + "/*", source=True): if type(f) is Node.FS.Dir: @@ -777,7 +778,7 @@ def generate_vs_project(env, num_jobs): for platform in ModuleConfigs.PLATFORMS ] self.arg_dict["runfile"] += [ - f'bin\\godot.windows.{config}{ModuleConfigs.DEV_SUFFIX}.{plat_id}{f".{name}" if name else ""}.exe' + f'bin\\godot.windows.{config}{ModuleConfigs.DEV_SUFFIX}{".double" if env["precision"] == "double" else ""}.{plat_id}{f".{name}" if name else ""}.exe' for config in ModuleConfigs.CONFIGURATIONS for plat_id in ModuleConfigs.PLATFORM_IDS ] @@ -814,12 +815,18 @@ def generate_vs_project(env, num_jobs): if env["dev_build"]: common_build_postfix.append("dev_build=yes") - if env["tests"]: + if env["dev_mode"]: + common_build_postfix.append("dev_mode=yes") + + elif env["tests"]: common_build_postfix.append("tests=yes") if env["custom_modules"]: common_build_postfix.append("custom_modules=%s" % env["custom_modules"]) + if env["precision"] == "double": + common_build_postfix.append("precision=double") + result = " ^& ".join(common_build_prefix + [" ".join([commands] + common_build_postfix)]) return result @@ -907,6 +914,9 @@ def CommandNoCache(env, target, sources, command, **args): def Run(env, function, short_message, subprocess=True): + from SCons.Script import Action + from platform_methods import run_in_subprocess + output_print = short_message if not env["verbose"] else "" if not subprocess: return Action(function, output_print) |