Updates for 4.4.0 release
[scons.git] / SConstruct
blob215245aa31f479da512e41a8c7cd64fa5d1d692a
2 # SConstruct file to build scons packages during development.
4 # See the README.rst file for an overview of how SCons is built and tested.
5 import os.path
6 import sys
7 import textwrap
8 from time import strftime
10 copyright_years = strftime('2001 - %Y')
12 # This gets inserted into the man pages to reflect the month of release.
13 month_year = strftime('%B %Y')
15 # MIT License
17 # Copyright The SCons Foundation
19 # Permission is hereby granted, free of charge, to any person obtaining
20 # a copy of this software and associated documentation files (the
21 # "Software"), to deal in the Software without restriction, including
22 # without limitation the rights to use, copy, modify, merge, publish,
23 # distribute, sublicense, and/or sell copies of the Software, and to
24 # permit persons to whom the Software is furnished to do so, subject to
25 # the following conditions:
27 # The above copyright notice and this permission notice shall be included
28 # in all copies or substantial portions of the Software.
30 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
31 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
32 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 project = 'scons'
41 default_version = '4.4.0'
42 copyright = "Copyright (c) %s The SCons Foundation" % copyright_years
45 # We let the presence or absence of various utilities determine whether
46 # or not we bother to build certain pieces of things. This should allow
47 # people to still do SCons packaging work even if they don't have all
48 # of the utilities installed
50 print("git :%s" % git)
51 print("gzip :%s" % gzip)
52 print("unzip :%s" % unzip)
53 print("zip :%s" % zip_path)
56 # Adding some paths to sys.path, this is mainly needed
57 # for the doc toolchain.
59 addpaths = [os.path.abspath(os.path.join(os.getcwd(), 'bin')),
60 os.path.abspath(os.path.join(os.getcwd(), 'testing/framework'))]
61 for a in addpaths:
62 if a not in sys.path:
63 sys.path.append(a)
65 # Use site_scons logic to process command line arguments
66 command_line = BuildCommandLine(default_version)
67 command_line.process_command_line_vars()
69 Default('.', command_line.build_dir)
70 # Just make copies, don't symlink them.
71 SetOption('duplicate', 'copy')
73 packaging_flavors = [
74 ('tar-gz', "The normal .tar.gz file for end-user installation."),
75 ('local-tar-gz', "A .tar.gz file for dropping into other software " +
76 "for local use."),
77 ('zip', "The normal .zip file for end-user installation."),
78 ('local-zip', "A .zip file for dropping into other software " +
79 "for local use."),
80 ('src-tar-gz', "A .tar.gz file containing all the source " +
81 "(including tests and documentation)."),
82 ('src-zip', "A .zip file containing all the source " +
83 "(including tests and documentation)."),
86 test_tar_gz_dir = os.path.join(command_line.build_dir, "test-tar-gz")
87 test_src_tar_gz_dir = os.path.join(command_line.build_dir, "test-src-tar-gz")
88 test_local_tar_gz_dir = os.path.join(command_line.build_dir, "test-local-tar-gz")
89 test_zip_dir = os.path.join(command_line.build_dir, "test-zip")
90 test_src_zip_dir = os.path.join(command_line.build_dir, "test-src-zip")
91 test_local_zip_dir = os.path.join(command_line.build_dir, "test-local-zip")
93 unpack_tar_gz_dir = os.path.join(command_line.build_dir, "unpack-tar-gz")
94 unpack_zip_dir = os.path.join(command_line.build_dir, "unpack-zip")
96 if is_windows():
97 tar_hflag = ''
98 # python_project_subinst_dir = os.path.join("Lib", "site-packages", project)
99 # project_script_subinst_dir = 'Scripts'
100 else:
101 tar_hflag = 'h'
102 # python_project_subinst_dir = os.path.join("lib", project)
103 # project_script_subinst_dir = 'bin'
105 indent_fmt = ' %-26s '
107 Help("""\
108 The following aliases build packages of various types, and unpack the
109 contents into build/test-$PACKAGE subdirectories, which can be used by the
110 runtest.py -p option to run tests against what's been actually packaged:
112 """)
114 aliases = sorted(packaging_flavors + [('doc', 'The SCons documentation.')])
116 for alias, help_text in aliases:
117 tw = textwrap.TextWrapper(
118 width=78,
119 initial_indent=indent_fmt % alias,
120 subsequent_indent=indent_fmt % '' + ' ',
122 Help(tw.fill(help_text) + '\n')
124 Help("""
125 The following command-line variables can be set:
127 """)
129 for variable, help_text in command_line.command_line_variables:
130 tw = textwrap.TextWrapper(
131 width=78,
132 initial_indent=indent_fmt % variable,
133 subsequent_indent=indent_fmt % '' + ' ',
135 Help(tw.fill(help_text) + '\n')
137 revaction = SCons_revision
138 revbuilder = Builder(action=Action(SCons_revision,
139 varlist=['COPYRIGHT', 'VERSION']))
141 env = Environment(
142 ENV=command_line.ENV,
144 BUILD=command_line.build_id,
145 BUILDDIR=command_line.build_dir,
146 BUILDSYS=command_line.build_system,
147 COPYRIGHT_YEARS=copyright_years,
148 COPYRIGHT=copyright,
149 DATE=command_line.date,
150 DEB_DATE=deb_date,
152 DEVELOPER=command_line.developer,
153 DISTDIR=os.path.join(command_line.build_dir, 'dist'),
154 MONTH_YEAR=month_year,
155 REVISION=command_line.revision,
156 VERSION=command_line.version,
158 TAR_HFLAG=tar_hflag,
160 ZIP=zip_path,
161 ZIPFLAGS='-r',
162 UNZIP=unzip,
163 UNZIPFLAGS='-o -d $UNPACK_ZIP_DIR',
165 # ZCAT=zcat,
166 # ZIPID=zipit,
168 TEST_SRC_TAR_GZ_DIR=test_src_tar_gz_dir,
169 TEST_SRC_ZIP_DIR=test_src_zip_dir,
170 TEST_TAR_GZ_DIR=test_tar_gz_dir,
171 TEST_ZIP_DIR=test_zip_dir,
173 UNPACK_TAR_GZ_DIR=unpack_tar_gz_dir,
174 UNPACK_ZIP_DIR=unpack_zip_dir,
176 BUILDERS={'SCons_revision': revbuilder,
177 'SOElim': soelimbuilder},
179 PYTHON='"%s"' % sys.executable,
180 PYTHONFLAGS='-tt',
183 Version_values = [Value(command_line.version), Value(command_line.build_id)]
185 installed_local_files = create_local_packages(env)
187 update_init_file(env)
192 # Documentation.
194 Export('command_line', 'env', 'whereis', 'revaction')
196 SConscript('doc/SConscript')
199 # Copy manpage's into base dir for inclusion in pypi packages
200 man_pages = env.Install("#/", Glob("#/build/doc/man/*.1"))
202 # Build packages for pypi
203 wheel = env.Command('$DISTDIR/SCons-${VERSION}-py3-none-any.whl', ['setup.cfg', 'setup.py', 'SCons/__init__.py']+man_pages,
204 '$PYTHON setup.py bdist_wheel')
206 zip_file = env.Command('$DISTDIR/SCons-${VERSION}.zip', ['setup.cfg', 'setup.py', 'SCons/__init__.py']+man_pages,
207 '$PYTHON setup.py sdist --format=zip')
208 tgz_file = env.Command('$DISTDIR/SCons-${VERSION}.tar.gz', ['setup.cfg', 'setup.py', 'SCons/__init__.py']+man_pages,
209 '$PYTHON setup.py sdist --format=gztar')
211 # Now set depends so the above run in a particular order
212 env.Depends(tgz_file, [zip_file, wheel])
214 # NOTE: Commenting this out as the manpages are expected to be in the base directory when manually
215 # running setup.py from the base of the repo.
216 # NOTE: This used by distro package maintainers.
217 # env.AddPostAction(tgz_file, Delete(man_pages))
219 # TODO add auto copyright date to README.rst, LICENSE
220 # TODO build API DOCS