5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 Verify that we handle the case where Install() and InstallAs()
29 Builder instances are saved and then re-used from a different, Clone()d
30 construction environment, after the .Install() and .InstallAs() methods
31 are replaced by wrappers that fetch the saved methods from a different
39 test
= TestSCons
.TestSCons()
41 test
.subdir('outside', 'sub')
43 test
.write('SConstruct', """\
44 DefaultEnvironment(tools=[])
48 def cat(env, source, target):
49 target = str(target[0])
50 with open(target, 'wb') as ofp:
52 with open(str(src), 'rb') as ifp:
56 env = Environment(tools=[], DESTDIR='dest')
57 env.Append(BUILDERS={'Cat': Builder(action=cat)})
59 env.SconsInternalInstallFunc = env.Install
60 env.SconsInternalInstallAsFunc = env.InstallAs
63 def InstallWithDestDir(dir, source):
64 abspath = os.path.splitdrive(env.Dir(dir).get_abspath())[1]
65 return env.SconsInternalInstallFunc('$DESTDIR' + abspath, source)
68 def InstallAsWithDestDir(target, source):
69 abspath = os.path.splitdrive(env.File(target).get_abspath())[1]
70 return env.SconsInternalInstallAsFunc('$DESTDIR' + abspath, source)
73 # Add the wrappers directly as attributes.
74 env.Install = InstallWithDestDir
75 env.InstallAs = InstallAsWithDestDir
79 t = e1.Cat(target='f1.out', source='f1.in')
80 e1.Install('export', source=t)
81 t = e1.Cat(target='f2.out', source='f2.in')
82 e1.InstallAs('export/f2-new.out', source=t)
86 t = e2.Cat(target='f3.out', source='f3.in')
87 e2.Install('export', source=t)
88 t = e2.Cat(target='f4.out', source='f4.in')
89 e2.InstallAs('export/f4-new.out', source=t)
92 test
.write('f1.in', "f1.in\n")
93 test
.write('f2.in', "f2.in\n")
94 test
.write('f3.in', "f3.in\n")
95 test
.write('f4.in', "f4.in\n")
97 test
.run(arguments
='.')
99 export
= os
.path
.splitdrive(test
.workpath('export'))[1]
101 f1_out
= test
.workpath('dest') + os
.path
.join(export
, 'f1.out')
102 f2_new_out
= test
.workpath('dest') + os
.path
.join(export
, 'f2-new.out')
103 f3_out
= test
.workpath('dest') + os
.path
.join(export
, 'f3.out')
104 f4_new_out
= test
.workpath('dest') + os
.path
.join(export
, 'f4-new.out')
106 test
.must_match(f1_out
, "f1.in\n")
107 test
.must_match(f2_new_out
, "f2.in\n")
108 test
.must_match(f3_out
, "f3.in\n")
109 test
.must_match(f4_new_out
, "f4.in\n")
111 test
.up_to_date(arguments
='.')
117 # indent-tabs-mode:nil
119 # vim: set expandtab tabstop=4 shiftwidth=4: