SCons: Add emitter to declutter build objects

This commit is contained in:
Thaddeus Crews
2025-01-13 11:13:17 -06:00
parent 0028fd625e
commit 10ed66f28c
7 changed files with 50 additions and 11 deletions

View File

@ -14,6 +14,7 @@ from importlib.util import module_from_spec, spec_from_file_location
from types import ModuleType
from SCons import __version__ as scons_raw_version
from SCons.Builder import ListEmitter
# Explicitly resolve the helper modules, this is done to avoid clash with
# modules of the same name that might be randomly added (e.g. someone adding
@ -236,6 +237,13 @@ opts.Add(BoolVariable("engine_update_check", "Enable engine update checks in the
opts.Add(BoolVariable("steamapi", "Enable minimal SteamAPI integration for usage time tracking (editor only)", False))
opts.Add("cache_path", "Path to a directory where SCons cache files will be stored. No value disables the cache.", "")
opts.Add("cache_limit", "Max size (in GiB) for the SCons cache. 0 means no limit.", "0")
opts.Add(
BoolVariable(
"redirect_build_objects",
"Enable redirecting built objects/libraries to `bin/obj/` to declutter the repository.",
True,
)
)
# Thirdparty libraries
opts.Add(BoolVariable("builtin_brotli", "Use the built-in Brotli library", True))
@ -1052,6 +1060,14 @@ if env["ninja"]:
if env["threads"]:
env.Append(CPPDEFINES=["THREADS_ENABLED"])
# Ensure build objects are put in their own folder if `redirect_build_objects` is enabled.
env.Prepend(LIBEMITTER=[methods.redirect_emitter])
env.Prepend(SHLIBEMITTER=[methods.redirect_emitter])
for key in (emitters := env.StaticObject.builder.emitter):
emitters[key] = ListEmitter([methods.redirect_emitter] + env.Flatten(emitters[key]))
for key in (emitters := env.SharedObject.builder.emitter):
emitters[key] = ListEmitter([methods.redirect_emitter] + env.Flatten(emitters[key]))
# Build subdirs, the build order is dependent on link order.
Export("env")