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 | |
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...)
-rw-r--r-- | doc/man/scons.xml | 10 | ||||
-rw-r--r-- | src/CHANGES.txt | 7 | ||||
-rw-r--r-- | src/engine/SCons/CacheDir.py | 24 | ||||
-rw-r--r-- | src/engine/SCons/Warnings.py | 4 |
4 files changed, 39 insertions, 6 deletions
diff --git a/doc/man/scons.xml b/doc/man/scons.xml index 5c832c2..59ac678 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -1707,6 +1707,16 @@ specifies the type of warnings to be enabled or disabled:</para> </listitem> </varlistentry> <varlistentry> + <term>--warn=cache-v1, --warn=no-cache-v1</term> + <listitem> +<para>Enables or disables warnings about the cache directory being in the +original (v1) layout. +<emphasis role="bold">CacheDir</emphasis>(). +These warnings are enabled by default.</para> + + </listitem> + </varlistentry> + <varlistentry> <term>--warn=cache-write-error, --warn=no-cache-write-error</term> <listitem> <para>Enables or disables warnings about errors trying to diff --git a/src/CHANGES.txt b/src/CHANGES.txt index dc8a281..52cff62 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -6,6 +6,13 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER + From Tom Tanner: + - change cache to use 2 character subdirectories, rather than one character. + For existing caches, you will need to run the scons-rename-cachedirs.py + script to update them to the new format. You will get a warning for this + every time you build. + - Fix a bunch of unit tests on windows + From Dirk Baechle: - Removed a lot of compatibility methods and workarounds for Python versions < 2.7, in order to prepare the work 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 |