-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SCons: Dump construction environment to a file #37248
Conversation
methods.py
Outdated
def dump(env): | ||
# Dumps latest build information for debugging purposes and external tools. | ||
from json import dump | ||
def non_serializable(obj): | ||
return "<<non-serializable: %s>>" % (type(obj).__qualname__) | ||
with open(".scons_env.json", "w") as f: | ||
dump(env.Dictionary(), f, indent=4, default=non_serializable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SCons also provides its own env.Dump()
method, but the output is pretty-printable so it's not really usable nor can be converted to a dictionary to be used by external tools, so I just serialize env.Dictionary()
as JSON here.
Not everything can be serialized so those fields are replaced with <<non-serializable: %s>>
markers.
Note: the env.Dump
doesn't serialize non-serializable types either.
@akien-mga, I've submitted a PR to SCons fellows at SCons/scons#3672 as you suggested at IRC:
In either case this PR is ready feature-wise. |
I wonder whether it really makes sense to merge this PR. Given that SCons/scons#3672 is merged, by the time Godot starts to use SCons 4.0, I'll likely be using Godot 4.0-stable... I'm sort of fine patching Godot as of now, especially if this feature likely won't be cherry-picked for 3.2, so I'd have to patch the |
Well it's not a lot of code, and now that the feature is being included in SCons 4.0, we can add a comment about it to eventually replace this by I don't mind cherry-picking it to I expect that dumping the env contents doesn't take a significant amount of time? |
Measured with if "env" in locals():
methods.show_progress(env)
import time
t1 = time.perf_counter()
methods.dump(env)
t2 = time.perf_counter()
print(t2 - t1) # prints 0.0058202
Exit() |
A new `methods.dump(env)` is added to dump the construction environment used by SCons to build Godot to a `.scons_env.json`. The file can be used for debugging purposes and any external tool.
if "env" in locals(): | ||
methods.show_progress(env) | ||
# TODO: replace this with `env.Dump(format="json")` | ||
# once we start requiring SCons 4.0 as min version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added as TODO.
Thanks! |
Cherry-picked for 3.2.2. |
A new
methods.dump(env)
is added to dump the construction environment used by SCons to build Godot to a.scons_env.json
. The file can be used for debugging purposes and any external tool.Features/benefits
SConscript("godot/SConstruct")
, so this PR can be used as a possible workaround to transfer construction environment acrossscons
processes..scons_env.json
to bug reports. The construction environment also includes info such as enabled/disabled modules as reported here for example: Custom C++ module and XCode dSYM fail #37234.godot/.travis.yml
Line 143 in 5efd436
.scons_env.json
, you can fetch the needed build suffix to call recently built binary withPROGSUFFIX
without having to hardcode the binary path much (Refactor build object suffix to standardized tuples/target triples identifying build options #24030).Example output
Produces:
.scons_env.json
PR state
The PR is meant to be rebased after #37198, so ignore progress logic diff. I'd just like to know if something like this would be
usefulneeded for Godot.