summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Moody <daniel.moody@mongodb.com>2021-04-09 18:59:19 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-09 20:15:23 +0000
commitd23bccf28cd3ec616eee1d753060834c11cf5bee (patch)
treeff7f9e67b65bc33fe379540193b63ccfe67036f8
parent3c9bdbf7a96eae083f7057694719f10c8c0b00cb (diff)
downloadmongo-d23bccf28cd3ec616eee1d753060834c11cf5bee.tar.gz
SERVER-54732 Updated vendor scons to match https://github.com/SCons/scons/pull/3894
-rw-r--r--src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/CacheDir.py24
-rw-r--r--src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Environment.py53
-rw-r--r--src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Node/FS.py8
3 files changed, 61 insertions, 24 deletions
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 e6ddfac0a7e..ebfb6c106df 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
@@ -61,7 +61,7 @@ def CacheRetrieveFunc(target, source, env):
if fs.islink(cachefile):
fs.symlink(fs.readlink(cachefile), t.get_internal_path())
else:
- env.copy_from_cache(cachefile, t.get_internal_path())
+ cd.copy_from_cache(env, cachefile, t.get_internal_path())
try:
os.utime(cachefile, None)
except OSError:
@@ -123,7 +123,7 @@ def CachePushFunc(target, source, env):
if fs.islink(t.get_internal_path()):
fs.symlink(fs.readlink(t.get_internal_path()), tempfile)
else:
- fs.copy2(t.get_internal_path(), tempfile)
+ cd.copy_to_cache(env, t.get_internal_path(), tempfile)
fs.rename(tempfile, cachefile)
st = fs.stat(t.get_internal_path())
fs.chmod(cachefile, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE)
@@ -279,6 +279,20 @@ class CacheDir(object):
self.debugFP.write("requests: %d, hits: %d, misses: %d, hit rate: %.2f%%\n" %
(self.requests, self.hits, self.misses, self.hit_ratio))
+ @classmethod
+ def copy_from_cache(cls, env, src, dst):
+ if env.cache_timestamp_newer:
+ return env.fs.copy(src, dst)
+ else:
+ return env.fs.copy2(src, dst)
+
+ @classmethod
+ def copy_to_cache(cls, env, src, dst):
+ try:
+ return env.fs.copy2(src, dst)
+ except AttributeError as ex:
+ raise EnvironmentError from ex
+
@property
def hit_ratio(self):
return (100.0 * self.hits / self.requests if self.requests > 0 else 100)
@@ -293,6 +307,12 @@ class CacheDir(object):
def is_readonly(self):
return cache_readonly
+ def get_cachedir_csig(self, node):
+ cachedir, cachefile = self.cachepath(node)
+ if cachefile and os.path.exists(cachefile):
+ return SCons.Util.MD5filesignature(cachefile, \
+ SCons.Node.FS.File.md5_chunksize * 1024)
+
def cachepath(self, node):
"""
"""
diff --git a/src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Environment.py b/src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Environment.py
index c51df4009e3..6c32dd0d456 100644
--- a/src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Environment.py
+++ b/src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Environment.py
@@ -873,9 +873,11 @@ def default_decide_target(dependency, target, prev_ni, repo_node=None):
return f(dependency, target, prev_ni, repo_node)
-def default_copy_from_cache(src, dst):
- f = SCons.Defaults.DefaultEnvironment().copy_from_cache
- return f(src, dst)
+def default_copy_from_cache(env, src, dst):
+ return SCons.CacheDir.CacheDir.copy_from_cache(env, src, dst)
+
+def default_copy_to_cache(env, src, dst):
+ return SCons.CacheDir.CacheDir.copy_to_cache(env, src, dst)
class Base(SubstitutionEnvironment):
@@ -937,7 +939,7 @@ class Base(SubstitutionEnvironment):
self.decide_target = default_decide_target
self.decide_source = default_decide_source
- self.copy_from_cache = default_copy_from_cache
+ self.cache_timestamp_newer = False
self._dict['BUILDERS'] = BuilderDict(self._dict['BUILDERS'], self)
@@ -1011,17 +1013,36 @@ class Base(SubstitutionEnvironment):
except KeyError:
return None
+ def validate_CacheDir_class(self, custom_class=None):
+ """Validate the passed custom CacheDir class, or if no args are passed,
+ validate the custom CacheDir class from the environment.
+ """
+
+ if custom_class is None:
+ custom_class = self.get("CACHEDIR_CLASS", SCons.CacheDir.CacheDir)
+ if not issubclass(custom_class, SCons.CacheDir.CacheDir):
+ raise UserError("Custom CACHEDIR_CLASS %s not derived from CacheDir" % str(custom_class))
+ return custom_class
+
def get_CacheDir(self):
try:
path = self._CacheDir_path
except AttributeError:
path = SCons.Defaults.DefaultEnvironment()._CacheDir_path
+
+ cachedir_class = self.validate_CacheDir_class()
try:
- if path == self._last_CacheDir_path:
+ if (path == self._last_CacheDir_path
+ # this checks if the cachedir class type has changed from what the
+ # instantiated cache dir type is. If the are exactly the same we
+ # can just keep using the existing one, otherwise the user is requesting
+ # something new, so we will re-instantiate below.
+ and type(self._last_CacheDir) is cachedir_class):
return self._last_CacheDir
except AttributeError:
pass
- cd = SCons.CacheDir.CacheDir(path)
+
+ cd = cachedir_class(path)
self._last_CacheDir_path = path
self._last_CacheDir = cd
return cd
@@ -1453,14 +1474,8 @@ class Base(SubstitutionEnvironment):
def _changed_timestamp_match(self, dependency, target, prev_ni, repo_node=None):
return dependency.changed_timestamp_match(target, prev_ni, repo_node)
- def _copy_from_cache(self, src, dst):
- return self.fs.copy(src, dst)
-
- def _copy2_from_cache(self, src, dst):
- return self.fs.copy2(src, dst)
-
def Decider(self, function):
- copy_function = self._copy2_from_cache
+ self.cache_timestamp_newer = False
if function in ('MD5', 'content'):
if not SCons.Util.md5:
raise UserError("MD5 signatures are not available in this version of Python.")
@@ -1469,7 +1484,7 @@ class Base(SubstitutionEnvironment):
function = self._changed_timestamp_then_content
elif function in ('timestamp-newer', 'make'):
function = self._changed_timestamp_newer
- copy_function = self._copy_from_cache
+ self.cache_timestamp_newer = True
elif function == 'timestamp-match':
function = self._changed_timestamp_match
elif not callable(function):
@@ -1481,8 +1496,6 @@ class Base(SubstitutionEnvironment):
self.decide_target = function
self.decide_source = function
- self.copy_from_cache = copy_function
-
def Detect(self, progs):
"""Return the first available program in progs.
@@ -1933,10 +1946,14 @@ class Base(SubstitutionEnvironment):
nkw = self.subst_kw(kw)
return SCons.Builder.Builder(**nkw)
- def CacheDir(self, path):
+ def CacheDir(self, path, custom_class=None):
import SCons.CacheDir
if path is not None:
path = self.subst(path)
+
+ if custom_class:
+ self['CACHEDIR_CLASS'] = self.validate_CacheDir_class(custom_class)
+
self._CacheDir_path = path
def Clean(self, targets, files):
@@ -2002,7 +2019,7 @@ class Base(SubstitutionEnvironment):
pass
else:
del kw['target_factory']
-
+
bld = SCons.Builder.Builder(**bkw)
return bld(self, target, source, **kw)
diff --git a/src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Node/FS.py b/src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Node/FS.py
index 65d1ac14296..57b3644223f 100644
--- a/src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Node/FS.py
+++ b/src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Node/FS.py
@@ -963,7 +963,7 @@ class Entry(Base):
def disambiguate(self, must_exist=None):
"""
- """
+ """
if self.isfile():
self.__class__ = File
self._morph()
@@ -3609,10 +3609,10 @@ class File(Base):
except AttributeError:
pass
- cachedir, cachefile = self.get_build_env().get_CacheDir().cachepath(self)
+ cache = self.get_build_env().get_CacheDir()
+ cachedir, cachefile = cache.cachepath(self)
if not self.exists() and cachefile and os.path.exists(cachefile):
- self.cachedir_csig = SCons.Util.MD5filesignature(cachefile, \
- SCons.Node.FS.File.md5_chunksize * 1024)
+ self.cachedir_csig = cache.get_cachedir_csig(self)
else:
self.cachedir_csig = self.get_csig()
return self.cachedir_csig