1 # SPDX-License-Identifier: MIT
3 # Copyright The SCons Foundation
5 """Build the scons-local packages."""
9 from zip_utils
import zipit
, zipappit
10 from Utilities
import is_windows
13 def get_local_package_file_list():
14 """Get list of all files which should be included in scons-local package"""
16 s_files
= glob("SCons/**", recursive
=True)
18 # import pdb; pdb.set_trace()
20 non_test
= [f
for f
in s_files
if "Tests.py" not in f
]
22 f
for f
in non_test
if '.xml' not in f
or "SCons/Tool/docbook" in f
24 filtered_list
= [f
for f
in non_test_non_doc
if 'pyc' not in f
]
25 filtered_list
= [f
for f
in filtered_list
if '__pycache__' not in f
]
26 filtered_list
= [f
for f
in filtered_list
if not os
.path
.isdir(f
)]
31 def install_local_package_files(env
):
33 all_local_installed
= []
34 files
= get_local_package_file_list()
35 target_dir
= '#/build/scons-local/scons-local-$VERSION'
37 all_local_installed
.extend(
38 env
.Install(os
.path
.join(target_dir
, os
.path
.dirname(f
)), f
)
44 'scripts/scons-configure-cache.py',
45 'scripts/sconsign.py',
48 for bf
in basedir_files
:
49 fn
= os
.path
.basename(bf
)
50 all_local_installed
.append(
51 env
.SCons_revision(f
'#/build/scons-local/{fn}', bf
)
54 # Now copy manpages into scons-local package
55 built_manpage_files
= env
.Glob('build/doc/man/*.1')
56 for bmp
in built_manpage_files
:
57 fn
= os
.path
.basename(str(bmp
))
58 all_local_installed
.append(
59 env
.SCons_revision(f
'#/build/scons-local/{fn}', bmp
)
63 ('scons-${VERSION}.bat', 'scripts/scons.bat'),
64 ('scons-README', 'README-local'),
65 ('scons-LICENSE', 'LICENSE-local'),
67 for t
, f
in rename_files
:
68 target_file
= f
"#/build/scons-local/{t}"
69 all_local_installed
.append(env
.SCons_revision(target_file
, f
))
71 return all_local_installed
74 def create_local_packages(env
):
75 [env
.Tool(x
) for x
in ['packaging', 'filesystem', 'zip']]
76 installed_files
= install_local_package_files(env
)
78 build_local_dir
= 'build/scons-local'
79 local_zip
= env
.Command(
80 '#build/dist/scons-local-${VERSION}.zip',
86 env
.Alias("local-zip", local_zip
)
88 # We need to descend into the versioned directory for zipapp,
89 # but we don't know the version. env.Glob lets us expand that.
90 # The action isn't going to use the sources, but including
91 # them makes sure SCons has populated the dir we're going to zip.
92 app_dir
= env
.Glob(f
"{build_local_dir}/scons-local-*")[0]
94 target
='#build/dist/scons-local-${VERSION}.pyz',
95 source
=installed_files
,
99 entry
='SCons.Script.Main:main',
101 env
.Alias("local-zipapp", zipapp
)
104 # avoid problem with tar interpreting c:/ as a remote machine
105 tar_cargs
= '-cz --force-local -f'
109 local_tar
= env
.Command(
110 '#build/dist/scons-local-${VERSION}.tar.gz',
112 "cd %s && tar %s $( ${TARGET.abspath} $) *" % (build_local_dir
, tar_cargs
),
114 env
.Alias("local-tar-gz", local_tar
)
116 print(f
"Package:{local_zip}")
117 print(f
"Zipapp:{zipapp}")