SCons: Fix running 'scons' without platform argument
The cache and progress logic assumed the 'env' to be defined,
but it is only when the selected platform is in the supported list.
Fixes #17497.
(cherry picked from commit a44f9ca545
)
This commit is contained in:
parent
fa9e03996c
commit
9ab9dd73b0
47
SConstruct
47
SConstruct
|
@ -495,22 +495,20 @@ else:
|
|||
print("\nPlease run scons again with argument: platform=<string>")
|
||||
|
||||
|
||||
screen = sys.stdout
|
||||
node_count = 0
|
||||
node_count_max = 0
|
||||
node_count_interval = 1
|
||||
if ('env' in locals()):
|
||||
# The following only makes sense when the env is defined, and assumes it is
|
||||
if 'env' in locals():
|
||||
screen = sys.stdout
|
||||
# Progress reporting is not available in non-TTY environments since it
|
||||
# messes with the output (for example, when writing to a file)
|
||||
show_progress = (env['progress'] and sys.stdout.isatty())
|
||||
node_count = 0
|
||||
node_count_max = 0
|
||||
node_count_interval = 1
|
||||
node_count_fname = str(env.Dir('#')) + '/.scons_node_count'
|
||||
# Progress reporting is not available in non-TTY environments since it
|
||||
# messes with the output (for example, when writing to a file)
|
||||
if sys.stdout.isatty():
|
||||
show_progress = env['progress']
|
||||
else:
|
||||
show_progress = False
|
||||
|
||||
import time, math
|
||||
import time, math
|
||||
|
||||
class cache_progress:
|
||||
class cache_progress:
|
||||
# The default is 1 GB cache and 12 hours half life
|
||||
def __init__(self, path = None, limit = 1073741824, half_life = 43200):
|
||||
self.path = path
|
||||
|
@ -591,23 +589,24 @@ class cache_progress:
|
|||
total_size += os.path.getsize(fp)
|
||||
return total_size
|
||||
|
||||
def progress_finish(target, source, env):
|
||||
def progress_finish(target, source, env):
|
||||
global node_count, progressor
|
||||
with open(node_count_fname, 'w') as f:
|
||||
f.write('%d\n' % node_count)
|
||||
progressor.delete(progressor.file_list())
|
||||
|
||||
try:
|
||||
try:
|
||||
with open(node_count_fname) as f:
|
||||
node_count_max = int(f.readline())
|
||||
except:
|
||||
except:
|
||||
pass
|
||||
cache_directory = os.environ.get("SCONS_CACHE")
|
||||
# Simple cache pruning, attached to SCons' progress callback. Trim the
|
||||
# cache directory to a size not larger than cache_limit.
|
||||
cache_limit = float(os.getenv("SCONS_CACHE_LIMIT", 1024)) * 1024 * 1024
|
||||
progressor = cache_progress(cache_directory, cache_limit)
|
||||
Progress(progressor, interval = node_count_interval)
|
||||
|
||||
progress_finish_command = Command('progress_finish', [], progress_finish)
|
||||
AlwaysBuild(progress_finish_command)
|
||||
cache_directory = os.environ.get("SCONS_CACHE")
|
||||
# Simple cache pruning, attached to SCons' progress callback. Trim the
|
||||
# cache directory to a size not larger than cache_limit.
|
||||
cache_limit = float(os.getenv("SCONS_CACHE_LIMIT", 1024)) * 1024 * 1024
|
||||
progressor = cache_progress(cache_directory, cache_limit)
|
||||
Progress(progressor, interval = node_count_interval)
|
||||
|
||||
progress_finish_command = Command('progress_finish', [], progress_finish)
|
||||
AlwaysBuild(progress_finish_command)
|
||||
|
|
Loading…
Reference in New Issue