parent
362193db6a
commit
c87b4f9d71
|
@ -39,6 +39,10 @@ if sys.version_info < (3,):
|
||||||
result += c
|
result += c
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def qualname(obj):
|
||||||
|
# Not properly equivalent to __qualname__ in py3, but it doesn't matter.
|
||||||
|
return obj.__name__
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
@ -88,3 +92,6 @@ else:
|
||||||
else:
|
else:
|
||||||
result += chr(c)
|
result += chr(c)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def qualname(obj):
|
||||||
|
return obj.__qualname__
|
||||||
|
|
30
methods.py
30
methods.py
|
@ -3,7 +3,7 @@ import re
|
||||||
import glob
|
import glob
|
||||||
import subprocess
|
import subprocess
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from compat import iteritems, isbasestring, decode_utf8
|
from compat import iteritems, isbasestring, decode_utf8, qualname
|
||||||
|
|
||||||
|
|
||||||
def add_source_files(self, sources, files, warn_duplicates=True):
|
def add_source_files(self, sources, files, warn_duplicates=True):
|
||||||
|
@ -724,10 +724,12 @@ def show_progress(env):
|
||||||
# Progress reporting is not available in non-TTY environments since it
|
# Progress reporting is not available in non-TTY environments since it
|
||||||
# messes with the output (for example, when writing to a file)
|
# messes with the output (for example, when writing to a file)
|
||||||
show_progress = env["progress"] and sys.stdout.isatty()
|
show_progress = env["progress"] and sys.stdout.isatty()
|
||||||
node_count = 0
|
node_count_data = {
|
||||||
node_count_max = 0
|
"count": 0,
|
||||||
node_count_interval = 1
|
"max": 0,
|
||||||
node_count_fname = str(env.Dir("#")) + "/.scons_node_count"
|
"interval": 1,
|
||||||
|
"fname": str(env.Dir("#")) + "/.scons_node_count",
|
||||||
|
}
|
||||||
|
|
||||||
import time, math
|
import time, math
|
||||||
|
|
||||||
|
@ -746,10 +748,11 @@ def show_progress(env):
|
||||||
self.delete(self.file_list())
|
self.delete(self.file_list())
|
||||||
|
|
||||||
def __call__(self, node, *args, **kw):
|
def __call__(self, node, *args, **kw):
|
||||||
nonlocal node_count, node_count_max, node_count_interval, node_count_fname, show_progress
|
|
||||||
if show_progress:
|
if show_progress:
|
||||||
# Print the progress percentage
|
# Print the progress percentage
|
||||||
node_count += node_count_interval
|
node_count_data["count"] += node_count_data["interval"]
|
||||||
|
node_count = node_count_data["count"]
|
||||||
|
node_count_max = node_count_data["max"]
|
||||||
if node_count_max > 0 and node_count <= node_count_max:
|
if node_count_max > 0 and node_count <= node_count_max:
|
||||||
screen.write("\r[%3d%%] " % (node_count * 100 / node_count_max))
|
screen.write("\r[%3d%%] " % (node_count * 100 / node_count_max))
|
||||||
screen.flush()
|
screen.flush()
|
||||||
|
@ -817,14 +820,13 @@ def show_progress(env):
|
||||||
return total_size
|
return total_size
|
||||||
|
|
||||||
def progress_finish(target, source, env):
|
def progress_finish(target, source, env):
|
||||||
nonlocal node_count, progressor
|
with open(node_count_data["fname"], "w") as f:
|
||||||
with open(node_count_fname, "w") as f:
|
f.write("%d\n" % node_count_data["count"])
|
||||||
f.write("%d\n" % node_count)
|
|
||||||
progressor.delete(progressor.file_list())
|
progressor.delete(progressor.file_list())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(node_count_fname) as f:
|
with open(node_count_data["fname"]) as f:
|
||||||
node_count_max = int(f.readline())
|
node_count_data["max"] = int(f.readline())
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -833,7 +835,7 @@ def show_progress(env):
|
||||||
# cache directory to a size not larger than cache_limit.
|
# cache directory to a size not larger than cache_limit.
|
||||||
cache_limit = float(os.getenv("SCONS_CACHE_LIMIT", 1024)) * 1024 * 1024
|
cache_limit = float(os.getenv("SCONS_CACHE_LIMIT", 1024)) * 1024 * 1024
|
||||||
progressor = cache_progress(cache_directory, cache_limit)
|
progressor = cache_progress(cache_directory, cache_limit)
|
||||||
Progress(progressor, interval=node_count_interval)
|
Progress(progressor, interval=node_count_data["interval"])
|
||||||
|
|
||||||
progress_finish_command = Command("progress_finish", [], progress_finish)
|
progress_finish_command = Command("progress_finish", [], progress_finish)
|
||||||
AlwaysBuild(progress_finish_command)
|
AlwaysBuild(progress_finish_command)
|
||||||
|
@ -844,7 +846,7 @@ def dump(env):
|
||||||
from json import dump
|
from json import dump
|
||||||
|
|
||||||
def non_serializable(obj):
|
def non_serializable(obj):
|
||||||
return "<<non-serializable: %s>>" % (type(obj).__qualname__)
|
return "<<non-serializable: %s>>" % (qualname(type(obj)))
|
||||||
|
|
||||||
with open(".scons_env.json", "w") as f:
|
with open(".scons_env.json", "w") as f:
|
||||||
dump(env.Dictionary(), f, indent=4, default=non_serializable)
|
dump(env.Dictionary(), f, indent=4, default=non_serializable)
|
||||||
|
|
Loading…
Reference in New Issue