3 # Copyright The SCons Foundation
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 from zip_utils
import zipit
27 from Utilities
import is_windows
30 def get_local_package_file_list():
32 Get list of all files which should be included in scons-local package
34 s_files
= glob("SCons/**", recursive
=True)
36 # import pdb; pdb.set_trace()
38 non_test
= [f
for f
in s_files
if "Tests.py" not in f
]
39 non_test_non_doc
= [f
for f
in non_test
if '.xml' not in f
or "SCons/Tool/docbook" in f
]
40 filtered_list
= [f
for f
in non_test_non_doc
if 'pyc' not in f
]
41 filtered_list
= [f
for f
in filtered_list
if '__pycache__' not in f
]
42 filtered_list
= [f
for f
in filtered_list
if not os
.path
.isdir(f
)]
47 def install_local_package_files(env
):
49 all_local_installed
= []
50 files
= get_local_package_file_list()
51 target_dir
= '#/build/scons-local/scons-local-$VERSION'
53 all_local_installed
.extend(env
.Install(os
.path
.join(target_dir
, os
.path
.dirname(f
)),
56 basedir_files
= ['scripts/scons.bat',
58 'scripts/scons-configure-cache.py',
59 'scripts/sconsign.py',
61 for bf
in basedir_files
:
62 fn
= os
.path
.basename(bf
)
63 all_local_installed
.append(env
.SCons_revision('#/build/scons-local/%s'%fn
, bf
))
65 # Now copy manpages into scons-local package
66 built_manpage_files
= env
.Glob('build/doc/man/*.1')
67 for bmp
in built_manpage_files
:
68 fn
= os
.path
.basename(str(bmp
))
69 all_local_installed
.append(env
.SCons_revision('#/build/scons-local/%s'%fn
, bmp
))
71 rename_files
= [('scons-${VERSION}.bat', 'scripts/scons.bat'),
72 ('scons-README', 'README-local'),
73 ('scons-LICENSE', 'LICENSE-local')]
74 for t
, f
in rename_files
:
75 target_file
= "#/build/scons-local/%s"%t
76 all_local_installed
.append(env
.SCons_revision(target_file
, f
))
78 return all_local_installed
81 def create_local_packages(env
):
82 # Add SubstFile builder
84 [env
.Tool(x
) for x
in ['packaging', 'filesystem', 'zip']]
85 installed_files
= install_local_package_files(env
)
87 build_local_dir
= 'build/scons-local'
88 package
= env
.Command('#build/dist/scons-local-${VERSION}.zip',
96 # avoid problem with tar interpreting c:/ as a remote machine
97 tar_cargs
= '-cz --force-local -f'
101 env
.Command('#build/dist/scons-local-${VERSION}.tar.gz',
103 "cd %s && tar %s $( ${TARGET.abspath} $) *" % (build_local_dir
, tar_cargs
))
105 print("Package:%s"%package
)