From 4ec54f32b8d5c567ad616e27a0b2a893a7a8d2e9 Mon Sep 17 00:00:00 2001 From: Lukas Tenbrink Date: Wed, 20 Nov 2024 00:19:39 +0100 Subject: [PATCH] Move tools to site_scons/site_tools, which is the canonical scons tools directory. Pass toolpath down the tool chain in godotcpp.py. --- SConstruct | 11 ++++++++++- {tools => site_scons/site_tools}/android.py | 0 .../site_tools}/common_compiler_flags.py | 0 {tools => site_scons/site_tools}/godotcpp.py | 18 +++++++++--------- {tools => site_scons/site_tools}/ios.py | 0 {tools => site_scons/site_tools}/linux.py | 0 {tools => site_scons/site_tools}/macos.py | 0 {tools => site_scons/site_tools}/my_spawn.py | 0 {tools => site_scons/site_tools}/web.py | 0 {tools => site_scons/site_tools}/windows.py | 0 10 files changed, 19 insertions(+), 10 deletions(-) rename {tools => site_scons/site_tools}/android.py (100%) rename {tools => site_scons/site_tools}/common_compiler_flags.py (100%) rename {tools => site_scons/site_tools}/godotcpp.py (98%) rename {tools => site_scons/site_tools}/ios.py (100%) rename {tools => site_scons/site_tools}/linux.py (100%) rename {tools => site_scons/site_tools}/macos.py (100%) rename {tools => site_scons/site_tools}/my_spawn.py (100%) rename {tools => site_scons/site_tools}/web.py (100%) rename {tools => site_scons/site_tools}/windows.py (100%) diff --git a/SConstruct b/SConstruct index 8acea262..e54379a0 100644 --- a/SConstruct +++ b/SConstruct @@ -27,7 +27,16 @@ if profile: elif os.path.isfile(profile + ".py"): customs.append(profile + ".py") opts = Variables(customs, ARGUMENTS) -cpp_tool = Tool("godotcpp", toolpath=["tools"]) + +# Some environments do not have setdefault yet. +if "toolpath" not in env: + env["toolpath"] = [] + +# Needed because if we're called as SConscript, our site_tools are not automatically appended to toolpath. +env["toolpath"].append("site_scons/site_tools") + +cpp_tool = Tool("godotcpp", toolpath=env["toolpath"]) + cpp_tool.options(opts, env) opts.Update(env) diff --git a/tools/android.py b/site_scons/site_tools/android.py similarity index 100% rename from tools/android.py rename to site_scons/site_tools/android.py diff --git a/tools/common_compiler_flags.py b/site_scons/site_tools/common_compiler_flags.py similarity index 100% rename from tools/common_compiler_flags.py rename to site_scons/site_tools/common_compiler_flags.py diff --git a/tools/godotcpp.py b/site_scons/site_tools/godotcpp.py similarity index 98% rename from tools/godotcpp.py rename to site_scons/site_tools/godotcpp.py index 77a0740f..23847118 100644 --- a/tools/godotcpp.py +++ b/site_scons/site_tools/godotcpp.py @@ -49,13 +49,6 @@ def validate_parent_dir(key, val, env): raise UserError("'%s' is not a directory: %s" % (key, os.path.dirname(val))) -def get_platform_tools_paths(env): - path = env.get("custom_tools", None) - if path is None: - return ["tools"] - return [normalize_path(path, env), "tools"] - - def get_custom_platforms(env): path = env.get("custom_tools", None) if path is None: @@ -189,6 +182,13 @@ def options(opts, env): opts.Update(env) + # Some environments do not have setdefault yet. + if "toolpath" not in env: + env["toolpath"] = [] + + if env.get("custom_tools", None) is not None: + env["toolpath"].append(normalize_path(env["custom_tools"], env)) + custom_platforms = get_custom_platforms(env) opts.Add( @@ -340,7 +340,7 @@ def options(opts, env): # Add platform options (custom tools can override platforms) for pl in sorted(set(platforms + custom_platforms)): - tool = Tool(pl, toolpath=get_platform_tools_paths(env)) + tool = Tool(pl, toolpath=env["toolpath"]) if hasattr(tool, "options"): tool.options(opts) @@ -451,7 +451,7 @@ def generate(env): env["optimize"] = ARGUMENTS.get("optimize", opt_level) env["debug_symbols"] = get_cmdline_bool("debug_symbols", env.dev_build) - tool = Tool(env["platform"], toolpath=get_platform_tools_paths(env)) + tool = Tool(env["platform"], toolpath=env["toolpath"]) if tool is None or not tool.exists(env): raise ValueError("Required toolchain not found for platform " + env["platform"]) diff --git a/tools/ios.py b/site_scons/site_tools/ios.py similarity index 100% rename from tools/ios.py rename to site_scons/site_tools/ios.py diff --git a/tools/linux.py b/site_scons/site_tools/linux.py similarity index 100% rename from tools/linux.py rename to site_scons/site_tools/linux.py diff --git a/tools/macos.py b/site_scons/site_tools/macos.py similarity index 100% rename from tools/macos.py rename to site_scons/site_tools/macos.py diff --git a/tools/my_spawn.py b/site_scons/site_tools/my_spawn.py similarity index 100% rename from tools/my_spawn.py rename to site_scons/site_tools/my_spawn.py diff --git a/tools/web.py b/site_scons/site_tools/web.py similarity index 100% rename from tools/web.py rename to site_scons/site_tools/web.py diff --git a/tools/windows.py b/site_scons/site_tools/windows.py similarity index 100% rename from tools/windows.py rename to site_scons/site_tools/windows.py