1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# SPDX-License-Identifier: MIT
#
# Copyright The SCons Foundation
import SCons
class CustomCacheDir1(SCons.CacheDir.CacheDir):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
print("INSTANCIATED %s" % str(type(self).__name__))
@classmethod
def copy_to_cache(cls, env, src, dst):
print("MY_CUSTOM_CACHEDIR_CLASS1")
super().copy_to_cache(env, src, dst)
class CustomCacheDir2(SCons.CacheDir.CacheDir):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
print("INSTANCIATED %s" % str(type(self).__name__))
@classmethod
def copy_to_cache(cls, env, src, dst):
print("MY_CUSTOM_CACHEDIR_CLASS2")
super().copy_to_cache(env, src, dst)
DefaultEnvironment(tools=[])
env = Environment(tools=[])
env.CacheDir('cache1', CustomCacheDir1)
env.CacheDir('cache2', CustomCacheDir2)
# two cachedirs were initialized, but the second one was the most recent
# and should remain in the cloned environment, even when we switch the
# original environment back. The cachedir2 should be the only copy_to_cache
# function we call.
cloned = env.Clone()
cloned.Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE'))
env.CacheDir('cache1', CustomCacheDir1)
|