Browse Source

SCons: Dump construction environment to a file

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.
Andrii Doroshenko (Xrayez) 5 years ago
parent
commit
42bee75e86
3 changed files with 18 additions and 1 deletions
  1. 3 0
      .gitignore
  2. 4 1
      SConstruct
  3. 11 0
      methods.py

+ 3 - 0
.gitignore

@@ -340,6 +340,9 @@ platform/windows/godot_res.res
 # Visual Studio Code workspace file
 # Visual Studio Code workspace file
 *.code-workspace
 *.code-workspace
 
 
+# Scons construction environment dump
+.scons_env.json
+
 # Scons progress indicator
 # Scons progress indicator
 .scons_node_count
 .scons_node_count
 
 

+ 4 - 1
SConstruct

@@ -688,6 +688,9 @@ elif selected_platform != "":
     else:
     else:
         sys.exit(255)
         sys.exit(255)
 
 
-# The following only makes sense when the env is defined, and assumes it is
+# The following only makes sense when the 'env' is defined, and assumes it is.
 if "env" in locals():
 if "env" in locals():
     methods.show_progress(env)
     methods.show_progress(env)
+    # TODO: replace this with `env.Dump(format="json")`
+    # once we start requiring SCons 4.0 as min version.
+    methods.dump(env)

+ 11 - 0
methods.py

@@ -778,3 +778,14 @@ def show_progress(env):
 
 
     progress_finish_command = Command("progress_finish", [], progress_finish)
     progress_finish_command = Command("progress_finish", [], progress_finish)
     AlwaysBuild(progress_finish_command)
     AlwaysBuild(progress_finish_command)
+
+
+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)