|
@@ -16,8 +16,7 @@ from typing import Generator, List, Optional, Union, cast
|
|
from misc.utility.color import print_error, print_info, print_warning
|
|
from misc.utility.color import print_error, print_info, print_warning
|
|
|
|
|
|
# Get the "Godot" folder name ahead of time
|
|
# Get the "Godot" folder name ahead of time
|
|
-base_folder_path = str(os.path.abspath(Path(__file__).parent)) + "/"
|
|
|
|
-base_folder_only = os.path.basename(os.path.normpath(base_folder_path))
|
|
|
|
|
|
+base_folder = Path(__file__).resolve().parent
|
|
|
|
|
|
compiler_version_cache = None
|
|
compiler_version_cache = None
|
|
|
|
|
|
@@ -83,6 +82,29 @@ def add_source_files(self, sources, files, allow_gen=False):
|
|
return True
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
+def redirect_emitter(target, source, env):
|
|
|
|
+ """
|
|
|
|
+ Emitter to automatically redirect object/library build files to the `bin/obj` directory,
|
|
|
|
+ retaining subfolder structure. External build files will attempt to retain subfolder
|
|
|
|
+ structure relative to their environment's parent directory, sorted under `bin/obj/external`.
|
|
|
|
+ If `redirect_build_objects` is `False`, or an external build file isn't relative to the
|
|
|
|
+ passed environment, this emitter does nothing.
|
|
|
|
+ """
|
|
|
|
+ if not env["redirect_build_objects"]:
|
|
|
|
+ return target, source
|
|
|
|
+
|
|
|
|
+ redirected_targets = []
|
|
|
|
+ for item in target:
|
|
|
|
+ if base_folder in (path := Path(item.get_abspath()).resolve()).parents:
|
|
|
|
+ item = env.File(f"#bin/obj/{path.relative_to(base_folder)}")
|
|
|
|
+ elif (alt_base := Path(env.Dir(".").get_abspath()).resolve().parent) in path.parents:
|
|
|
|
+ item = env.File(f"#bin/obj/external/{path.relative_to(alt_base)}")
|
|
|
|
+ else:
|
|
|
|
+ print_warning(f'Failed to redirect "{path}"')
|
|
|
|
+ redirected_targets.append(item)
|
|
|
|
+ return redirected_targets, source
|
|
|
|
+
|
|
|
|
+
|
|
def disable_warnings(self):
|
|
def disable_warnings(self):
|
|
# 'self' is the environment
|
|
# 'self' is the environment
|
|
if self.msvc and not using_clang(self):
|
|
if self.msvc and not using_clang(self):
|
|
@@ -150,7 +172,7 @@ def get_version_info(module_version_string="", silent=False):
|
|
|
|
|
|
|
|
|
|
def get_git_info():
|
|
def get_git_info():
|
|
- os.chdir(base_folder_path)
|
|
|
|
|
|
+ os.chdir(base_folder)
|
|
|
|
|
|
# Parse Git hash if we're in a Git repo.
|
|
# Parse Git hash if we're in a Git repo.
|
|
git_hash = ""
|
|
git_hash = ""
|
|
@@ -775,7 +797,7 @@ def show_progress(env):
|
|
if env["ninja"]:
|
|
if env["ninja"]:
|
|
return
|
|
return
|
|
|
|
|
|
- NODE_COUNT_FILENAME = f"{base_folder_path}.scons_node_count"
|
|
|
|
|
|
+ NODE_COUNT_FILENAME = base_folder / ".scons_node_count"
|
|
|
|
|
|
class ShowProgress:
|
|
class ShowProgress:
|
|
def __init__(self):
|
|
def __init__(self):
|