diff options
-rw-r--r-- | buildscripts/scons_cache_prune.py | 28 | ||||
-rw-r--r-- | site_scons/site_tools/validate_cache_dir.py | 31 | ||||
-rw-r--r-- | src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/CacheDir.py | 3 |
3 files changed, 16 insertions, 46 deletions
diff --git a/buildscripts/scons_cache_prune.py b/buildscripts/scons_cache_prune.py index 84f40f78ac8..9b32db16b1f 100644 --- a/buildscripts/scons_cache_prune.py +++ b/buildscripts/scons_cache_prune.py @@ -24,9 +24,10 @@ GIGBYTES = 1024 * 1024 * 1024 CacheItem = collections.namedtuple("CacheContents", ["path", "time", "size"]) -def get_cachefile_size(file_path, is_cksum): +def get_cachefile_size(file_path): """Get the size of the cachefile.""" - if is_cksum: + + if file_path.lower().endswith('.cksum') or file_path.lower().endswith('.cksum.del'): size = 0 for cksum_path in os.listdir(file_path): cksum_path = os.path.join(file_path, cksum_path) @@ -50,26 +51,19 @@ def collect_cache_contents(cache_path): for file_name in os.listdir(path): file_path = os.path.join(path, file_name) # Cache prune script is allowing only directories with this extension - # which comes from the validate_cache_dir.py tool in SCons, it must match + # which comes from the validate_cache_dir.py tool in scons, it must match # the extension set in that file. - cksum_type = False - if os.path.isdir(file_path): - hash_length = -32 - tmp_length = -len('.cksum.tmp') + hash_length - cksum_type = (file_path.lower().endswith('.cksum') - or file_path.lower().endswith('.cksum.del') - or file_path.lower()[tmp_length:hash_length] == '.cksum.tmp') - - if not cksum_type: - LOGGER.warning( - "cache item %s is a directory and not a file. " - "The cache may be corrupt.", file_path) - continue + if os.path.isdir(file_path) and not file_path.lower().endswith( + '.cksum') and not file_path.lower().endswith('.cksum.del'): + LOGGER.warning( + "cache item %s is a directory and not a file. " + "The cache may be corrupt.", file_path) + continue try: item = CacheItem(path=file_path, time=os.stat(file_path).st_atime, - size=get_cachefile_size(file_path, cksum_type)) + size=get_cachefile_size(file_path)) total += item.size diff --git a/site_scons/site_tools/validate_cache_dir.py b/site_scons/site_tools/validate_cache_dir.py index e6d9118d3d1..2c78fb7deca 100644 --- a/site_scons/site_tools/validate_cache_dir.py +++ b/site_scons/site_tools/validate_cache_dir.py @@ -24,7 +24,6 @@ import datetime import json import logging import os -import sys import pathlib import shutil import traceback @@ -34,10 +33,7 @@ import SCons cache_debug_suffix = " (target: %s, cachefile: %s) " -class ValidateCacheDirError(SCons.Errors.BuildError): - pass - -class InvalidChecksum(ValidateCacheDirError): +class InvalidChecksum(SCons.Errors.BuildError): def __init__(self, src, dst, reason, cache_csig='', computed_csig=''): self.message = f"ERROR: md5 checksum {reason} for {src} ({dst})" self.cache_csig = cache_csig @@ -45,14 +41,14 @@ class InvalidChecksum(ValidateCacheDirError): def __str__(self): return self.message -class CacheTransferFailed(ValidateCacheDirError): +class CacheTransferFailed(SCons.Errors.BuildError): def __init__(self, src, dst, reason): self.message = f"ERROR: cachedir transfer {reason} while transfering {src} to {dst}" def __str__(self): return self.message -class UnsupportedError(ValidateCacheDirError): +class UnsupportedError(SCons.Errors.BuildError): def __init__(self, class_name, feature): self.message = f"{class_name} does not support {feature}" @@ -178,7 +174,7 @@ class CacheDirValidate(SCons.CacheDir.CacheDir): try: return super().push(node) except CacheTransferFailed as ex: - self.print_push_issue(node, ex) + self.print_cache_issue(node, ex) return False def CacheDebugJson(self, json_data, target, cachefile): @@ -201,17 +197,6 @@ class CacheDirValidate(SCons.CacheDir.CacheDir): self.json_log.write(json.dumps(json_data) + '\n') def CacheDebug(self, fmt, target, cachefile): - - # Capture exception information for exception types - # which may bubble up from SCons proper. Non ValidateCacheDirError - # failures which come up from SCons may omit exception information. - # if this is a Non ValidateCacheDirError exception, we will emit a ValidateCacheDirError - # in place, which will capture the exception information and come back through - # this function to be logged in our normal CacheDirValidate process. - ex = sys.exc_info()[1] - if ex and not isinstance(ex, ValidateCacheDirError): - raise CacheTransferFailed(target, cachefile, f"failed: {ex}") from ex - # The target cachefile will live in a directory with the special # extension for this cachedir class. Check if this cachefile is # in a directory like that and customize the debug logs. @@ -227,14 +212,6 @@ class CacheDirValidate(SCons.CacheDir.CacheDir): self.CacheDebug(log_msg + cache_debug_suffix, realnode, cachefile) self.CacheDebugJson(json_info, realnode, cachefile) - def print_push_issue(self, node, ex): - - cksum_dir = pathlib.Path(self.cachepath(node)[1]) - msg = ('An issue was detected while pushing to the cache:\n' + - ' ' + "\n ".join("".join(traceback.format_exc()).split("\n"))) - - self._log(msg, str(ex), {'type': 'push_fail', 'error': msg}, node, cksum_dir) - def print_cache_issue(self, node, ex): cksum_dir = pathlib.Path(self.cachepath(node)[1]) diff --git a/src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/CacheDir.py b/src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/CacheDir.py index 48f2e5447c5..804a315c717 100644 --- a/src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/CacheDir.py +++ b/src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/CacheDir.py @@ -131,8 +131,7 @@ def CachePushFunc(target, source, env): # the CacheDir being on a separate file system that's full. # In any case, inability to push a file to cache doesn't affect # the correctness of the build, so just print a warning. - msg = errfmt % (str(t), cachefile) - cd.CacheDebug(errfmt, str(t), cachefile) + msg = errfmt % (str(target), cachefile) SCons.Warnings.warn(SCons.Warnings.CacheWriteErrorWarning, msg) CachePush = SCons.Action.Action(CachePushFunc, None) |