1 # SPDX-License-Identifier: MIT
3 # Copyright The SCons Foundation
7 def SCons_revision(target
, source
, env
):
8 """Interpolate specific values from the environment into a file.
10 This is used to copy files into a tree that gets packaged up
11 into the source file package.
21 # Note: We construct the __*__ substitution strings here
22 # so that they don't get replaced when this file gets
23 # copied into the tree for packaging.
24 contents
= contents
.replace('__BUILD' + '__', env
['BUILD'])
25 contents
= contents
.replace('__BUILDSYS' + '__', env
['BUILDSYS'])
26 contents
= contents
.replace('__COPYRIGHT' + '__', env
['COPYRIGHT'])
27 contents
= contents
.replace('__DATE' + '__', env
['DATE'])
28 contents
= contents
.replace('__DEB_DATE' + '__', env
['DEB_DATE'])
30 contents
= contents
.replace('__DEVELOPER' + '__', env
['DEVELOPER'])
31 contents
= contents
.replace('__FILE' + '__', str(source
[0]).replace('\\', '/'))
32 contents
= contents
.replace('__MONTH_YEAR'+ '__', env
['MONTH_YEAR'])
33 contents
= contents
.replace('__REVISION' + '__', env
['REVISION'])
34 contents
= contents
.replace('__VERSION' + '__', env
['VERSION'])
35 contents
= contents
.replace('__NULL' + '__', '')
37 with
open(t
,'w') as of
:
39 except UnicodeDecodeError as e
:
40 print("Error decoding file:%s just copying no revision edit")
41 with
open(s
, 'rb') as fp
, open(t
, 'wb') as of
:
46 os
.chmod(t
, os
.stat(s
)[0])