1 # SPDX-License-Identifier: MIT
3 # Copyright The SCons Foundation
9 def b(target
, source
, env
):
10 with
open(target
[0].abspath
, 'w') as f
:
13 def scan(node
, env
, path
):
14 """Have the node depend on a directory, which depends on a Value node."""
15 sample_dir
= env
.fs
.Dir('dir2')
16 env
.Depends(sample_dir
, env
.Value('c'))
17 return [sample_dir
, env
.Value('d'), env
.Value(b
'\x03\x0F', name
='name3')]
19 scanner
= Scanner(function
=scan
, node_class
=SCons
.Node
.Node
)
20 builder
= Builder(action
=b
, source_scanner
=scanner
)
22 DefaultEnvironment(tools
=[])
23 env
= Environment(tools
=[])
24 env
.Append(BUILDERS
={'B': builder
})
26 # Create a node and a directory that each depend on an instance of
27 # SCons.Node.Python.Value.
28 sample_dir
= env
.fs
.Dir('dir1')
29 env
.Depends(sample_dir
, [env
.Value('a'), env
.Value(b
'\x01\x0F', name
='name1')])
31 sample_file
= env
.fs
.File('testfile')
32 env
.Depends(sample_file
, [env
.Value('b'), env
.Value(b
'\x02\x0F', name
='name2')])
34 env
.B(target
='File1.out', source
=[sample_dir
, sample_file
])