Browse Source

Add options for more human-friendly build output

Timo Schwarzer 8 years ago
parent
commit
f93bb4f458
3 changed files with 48 additions and 4 deletions
  1. 3 0
      .gitignore
  2. 2 2
      .travis.yml
  3. 43 2
      SConstruct

+ 3 - 0
.gitignore

@@ -284,3 +284,6 @@ platform/windows/godot_res.res
 # Visual Studio 2017 and Visual Studio Code workspace folder
 /.vs
 /.vscode
+
+# Scons progress indicator
+.scons_node_count

+ 2 - 2
.travis.yml

@@ -88,8 +88,8 @@ script:
       sh ./misc/travis/clang-format.sh;
     else
       if [ "$TRAVIS_OS_NAME" = "windows" ]; then
-        scons platform=$GODOT_TARGET CXX=$CXX openssl=builtin;
+        scons platform=$GODOT_TARGET progress=no verbose=yes CXX=$CXX openssl=builtin;
       else
-        scons platform=$GODOT_TARGET bits=64 CXX=$CXX openssl=builtin;
+        scons platform=$GODOT_TARGET progress=no verbose=yes bits=64 CXX=$CXX openssl=builtin;
       fi
     fi

+ 43 - 2
SConstruct

@@ -150,9 +150,11 @@ opts.Add('disable_3d', "Disable 3D nodes for smaller executable (yes/no)", 'no')
 opts.Add('disable_advanced_gui', "Disable advance 3D gui nodes and behaviors (yes/no)", 'no')
 opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all generated binary files", '')
 opts.Add('unix_global_settings_path', "UNIX-specific path to system-wide settings. Currently only used for templates", '')
-opts.Add('verbose', "Enable verbose output for the compilation (yes/no)", 'yes')
+opts.Add('verbose', "Enable verbose output for the compilation (yes/no)", 'no')
 opts.Add('vsproj', "Generate Visual Studio Project. (yes/no)", 'no')
-opts.Add('warnings', "Set the level of warnings emitted during compilation (extra/all/moderate/no)", 'all')
+opts.Add('warnings', "Set the level of warnings emitted during compilation (extra/all/moderate/no)", 'no')
+opts.Add('progress', "Show a progress indicator during build (yes/no)", 'yes')
+opts.Add('dev', "If yes, alias for verbose=yes warnings=all (yes/no)", 'no')
 
 # Thirdparty libraries
 opts.Add('builtin_enet', "Use the builtin enet library (yes/no)", 'yes')
@@ -231,6 +233,10 @@ if selected_platform in platform_list:
         env = detect.create(env_base)
     else:
         env = env_base.Clone()
+    
+    if (env["dev"] == "yes"):
+        env["warnings"] = "all"
+        env["verbose"] = "yes"
 
     if env['vsproj'] == "yes":
         env.vs_incs = []
@@ -449,3 +455,38 @@ else:
     for x in platform_list:
         print("\t" + x)
     print("\nPlease run scons again with argument: platform=<string>")
+
+
+screen = sys.stdout
+node_count = 0
+node_count_max = 0
+node_count_interval = 1
+node_count_fname = str(env.Dir('#')) + '/.scons_node_count'
+
+def progress_function(node):
+    global node_count, node_count_max, node_count_interval, node_count_fname
+    node_count += node_count_interval
+    if (node_count_max > 0 and node_count <= node_count_max):
+        screen.write('\r[%3d%%] ' % (node_count * 100 / node_count_max))
+        screen.flush()
+    elif (node_count_max > 0 and node_count > node_count_max):
+        screen.write('\r[100%] ')
+        screen.flush()
+    else:
+        screen.write('\r[Initial build] ')
+        screen.flush()
+
+def progress_finish(target, source, env):
+    global node_count
+    with open(node_count_fname, 'w') as f:
+        f.write('%d\n' % node_count)
+
+if (env["progress"] == "yes"):
+    try:
+        with open(node_count_fname) as f:
+            node_count_max = int(f.readline())
+    except:
+        pass
+    Progress(progress_function, interval = node_count_interval)
+    progress_finish_command = Command('progress_finish', [], progress_finish)
+    AlwaysBuild(progress_finish_command)