diff options
author | Thomas Tanner <trtanner@btinternet.com> | 2016-03-13 09:55:01 (GMT) |
---|---|---|
committer | Thomas Tanner <trtanner@btinternet.com> | 2016-03-13 09:55:01 (GMT) |
commit | 2a1cc4e5bc95abe0cf43b811ad75bff6015fb45b (patch) | |
tree | 094e36b845065162047a20263712a6ff0a2728da /src/engine/SCons | |
parent | a014c40490ca3353d82476ca6a1db2ad80ca57fe (diff) | |
download | SCons-2a1cc4e5bc95abe0cf43b811ad75bff6015fb45b.zip SCons-2a1cc4e5bc95abe0cf43b811ad75bff6015fb45b.tar.gz SCons-2a1cc4e5bc95abe0cf43b811ad75bff6015fb45b.tar.bz2 |
Update to produce warning message.
This also means an existing empty cache directory will be treated as v2
(which is probably a good idea...)
Diffstat (limited to 'src/engine/SCons')
-rw-r--r-- | src/engine/SCons/CacheDir.py | 24 | ||||
-rw-r--r-- | src/engine/SCons/Warnings.py | 4 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/engine/SCons/CacheDir.py b/src/engine/SCons/CacheDir.py index 728871f..5b60bae 100644 --- a/src/engine/SCons/CacheDir.py +++ b/src/engine/SCons/CacheDir.py @@ -129,6 +129,10 @@ def CachePushFunc(target, source, env): CachePush = SCons.Action.Action(CachePushFunc, None) +# Nasty hack to cut down to one warning for each cachedir path that needs +# upgrading. +warned = dict() + class CacheDir(object): def __init__(self, path): @@ -147,8 +151,8 @@ class CacheDir(object): # See if there's a config file in the cache directory config_file = os.path.join(path, 'config') if not os.path.exists(config_file): - # If the directory exists we're likely version 1, otherwise - # assume we're latest. + # If the directory exists and is not empty, we're likely version 1. + # # A note: There is a race hazard here, if two processes start and # attempt to create the cache directory at the same time. However, # python doesn't really give you the option to do exclusive file @@ -157,16 +161,26 @@ class CacheDir(object): # as an attempt to alleviate this, on the basis that it's a pretty # unlikely occurence (it'd require two builds with a brand new cache # directory) - if os.path.isdir(path): + if os.path.isdir(path) and len(os.listdir(path)) != 0: self.config['prefix_len'] = 1 - else: - os.makedirs(path) + else: + if not os.path.isdir(path): + os.makedirs(path) self.config['prefix_len'] = 2 if not os.path.exists(config_file): with open(config_file, 'w') as config: self.config = json.dump(self.config, config) with open(config_file) as config: self.config = json.load(config) + # When building the project I was testing this on, this was output + # over 20 times. That seems excessive + global warned + if self.config['prefix_len'] == 1 and self.path not in warned: + msg = "Please update your cache by going into " + self.path +\ + " and running scons-rename-cachedirs.py" + SCons.Warnings.warn(SCons.Warnings.CacheV1Warning, msg) + warned[self.path] = True + def CacheDebug(self, fmt, target, cachefile): if cache_debug != self.current_cache_debug: diff --git a/src/engine/SCons/Warnings.py b/src/engine/SCons/Warnings.py index 5c27825..16319b9 100644 --- a/src/engine/SCons/Warnings.py +++ b/src/engine/SCons/Warnings.py @@ -41,10 +41,12 @@ class WarningOnByDefault(Warning): # NOTE: If you add a new warning class, add it to the man page, too! - class TargetNotBuiltWarning(Warning): # Should go to OnByDefault pass +class CacheV1Warning(WarningOnByDefault): + pass + class CacheWriteErrorWarning(Warning): pass |