2 # SConstruct file to build scons packages during development.
4 # See the README file for an overview of how SCons is built and tested.
7 copyright_years = '2001, 2002, 2003, 2004'
12 # Permission is hereby granted, free of charge, to any person obtaining
13 # a copy of this software and associated documentation files (the
14 # "Software"), to deal in the Software without restriction, including
15 # without limitation the rights to use, copy, modify, merge, publish,
16 # distribute, sublicense, and/or sell copies of the Software, and to
17 # permit persons to whom the Software is furnished to do so, subject to
18 # the following conditions:
20 # The above copyright notice and this permission notice shall be included
21 # in all copies or substantial portions of the Software.
23 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
24 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
25 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 default_version = '0.96'
43 copyright = "Copyright (c) %s The SCons Foundation" % copyright_years
50 # An internal "whereis" routine to figure out if a given program
51 # is available on this system.
54 for dir in string.split(os.environ['PATH'], os.pathsep):
55 f = os.path.join(dir, file)
61 if stat.S_IMODE(st[stat.ST_MODE]) & 0111:
66 # We let the presence or absence of various utilities determine
67 # whether or not we bother to build certain pieces of things.
68 # This should allow people to still do SCons work even if they
69 # don't have Aegis or RPM installed, for example.
71 aegis = whereis('aegis')
72 aesub = whereis('aesub')
73 dh_builddeb = whereis('dh_builddeb')
74 fakeroot = whereis('fakeroot')
75 gzip = whereis('gzip')
76 rpmbuild = whereis('rpmbuild') or whereis('rpm')
77 unzip = whereis('unzip')
81 # Now grab the information that we "build" into the files.
84 date = ARGUMENTS['date']
86 date = time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(time.time()))
88 if ARGUMENTS.has_key('developer'):
89 developer = ARGUMENTS['developer']
90 elif os.environ.has_key('USERNAME'):
91 developer = os.environ['USERNAME']
92 elif os.environ.has_key('LOGNAME'):
93 developer = os.environ['LOGNAME']
94 elif os.environ.has_key('USER'):
95 developer = os.environ['USER']
97 if ARGUMENTS.has_key('build_system'):
98 build_system = ARGUMENTS['build_system']
100 build_system = string.split(socket.gethostname(), '.')[0]
102 if ARGUMENTS.has_key('version'):
103 revision = ARGUMENTS['version']
105 revision = os.popen(aesub + " \\$version", "r").read()[:-1]
107 revision = default_version
109 # This is old code that adds an initial "0" to revision numbers < 10.
110 #a = string.split(revision, '.')
116 #revision = string.join(arr, '.')
118 # Here's how we'd turn the calculated $revision into our package $version.
119 # This makes it difficult to coordinate with other files (debian/changelog
120 # and rpm/scons.spec) that hard-code the version number, so just go with
121 # the flow for now and hard code it here, too.
125 # if str[0] == 'C' or str[0] == 'D':
127 # while len(str) > 2 and str[0] == '0':
130 #arr = map(lambda x, xxx=xxx: xxx(x), arr)
131 #version = string.join(arr, '.')
132 version = default_version
134 build_id = string.replace(revision, version + '.', '')
136 if ARGUMENTS.has_key('change'):
137 change = ARGUMENTS['change']
139 change = os.popen(aesub + " \\$change", "r").read()[:-1]
141 change = default_version
143 python_ver = sys.version[0:3]
145 platform = distutils.util.get_platform()
147 ENV = { 'PATH' : os.environ['PATH'] }
148 for key in ['AEGIS_PROJECT', 'LOGNAME', 'PYTHONPATH']:
149 if os.environ.has_key(key):
150 ENV[key] = os.environ[key]
152 cwd_build = os.path.join(os.getcwd(), "build")
154 test_deb_dir = os.path.join(cwd_build, "test-deb")
155 test_rpm_dir = os.path.join(cwd_build, "test-rpm")
156 test_tar_gz_dir = os.path.join(cwd_build, "test-tar-gz")
157 test_src_tar_gz_dir = os.path.join(cwd_build, "test-src-tar-gz")
158 test_local_tar_gz_dir = os.path.join(cwd_build, "test-local-tar-gz")
159 test_zip_dir = os.path.join(cwd_build, "test-zip")
160 test_src_zip_dir = os.path.join(cwd_build, "test-src-zip")
161 test_local_zip_dir = os.path.join(cwd_build, "test-local-zip")
163 unpack_tar_gz_dir = os.path.join(cwd_build, "unpack-tar-gz")
164 unpack_zip_dir = os.path.join(cwd_build, "unpack-zip")
166 if platform == "win32":
168 python_project_subinst_dir = os.path.join("Lib", "site-packages", project)
169 project_script_subinst_dir = 'Scripts'
172 python_project_subinst_dir = os.path.join("lib", project)
173 project_script_subinst_dir = 'bin'
179 # Figure out if we can handle .zip files.
186 def zipit(env, target, source):
187 print "Zipping %s:" % str(target[0])
188 def visit(arg, dirname, names):
190 path = os.path.join(dirname, name)
191 if os.path.isfile(path):
193 zf = zipfile.ZipFile(str(target[0]), 'w')
196 try: os.path.walk(env['PSV'], visit, zf)
197 finally: os.chdir(olddir)
200 def unzipit(env, target, source):
201 print "Unzipping %s:" % str(source[0])
202 zf = zipfile.ZipFile(str(source[0]), 'r')
203 for name in zf.namelist():
204 dest = os.path.join(env['UNPACK_ZIP_DIR'], name)
205 dir = os.path.dirname(dest)
211 # if the file exists, then delete it before writing
212 # to it so that we don't end up trying to write to a symlink:
213 if os.path.isfile(dest) or os.path.islink(dest):
215 if not os.path.isdir(dest):
216 open(dest, 'w').write(zf.read(name))
220 zipit = "cd $CD && $ZIP $ZIPFLAGS $( ${TARGET.abspath} $) $PSV"
221 unzipit = "$UNZIP $UNZIPFLAGS $SOURCES"
223 def SCons_revision(target, source, env):
224 """Interpolate specific values from the environment into a file.
226 This is used to copy files into a tree that gets packaged up
227 into the source file package.
231 contents = open(s, 'rb').read()
232 # Note: We construct the __*__ substitution strings here
233 # so that they don't get replaced when this file gets
234 # copied into the tree for packaging.
235 contents = string.replace(contents, '__BUILD' + '__', env['BUILD'])
236 contents = string.replace(contents, '__BUILDSYS' + '__', env['BUILDSYS'])
237 contents = string.replace(contents, '__COPYRIGHT' + '__', env['COPYRIGHT'])
238 contents = string.replace(contents, '__DATE' + '__', env['DATE'])
239 contents = string.replace(contents, '__DEVELOPER' + '__', env['DEVELOPER'])
240 contents = string.replace(contents, '__FILE' + '__', str(source[0]))
241 contents = string.replace(contents, '__REVISION' + '__', env['REVISION'])
242 contents = string.replace(contents, '__VERSION' + '__', env['VERSION'])
243 contents = string.replace(contents, '__NULL' + '__', '')
244 open(t, 'wb').write(contents)
245 os.chmod(t, os.stat(s)[0])
247 revbuilder = Builder(action = Action(SCons_revision,
248 varlist=['COPYRIGHT', 'VERSION']))
254 BUILDSYS = build_system,
255 COPYRIGHT = copyright,
257 DEVELOPER = developer,
262 TAR_HFLAG = tar_hflag,
267 UNZIPFLAGS = '-o -d $UNPACK_ZIP_DIR',
272 RPM2CPIO = 'rpm2cpio',
274 TEST_DEB_DIR = test_deb_dir,
275 TEST_RPM_DIR = test_rpm_dir,
276 TEST_SRC_TAR_GZ_DIR = test_src_tar_gz_dir,
277 TEST_SRC_ZIP_DIR = test_src_zip_dir,
278 TEST_TAR_GZ_DIR = test_tar_gz_dir,
279 TEST_ZIP_DIR = test_zip_dir,
281 UNPACK_TAR_GZ_DIR = unpack_tar_gz_dir,
282 UNPACK_ZIP_DIR = unpack_zip_dir,
284 BUILDERS = { 'SCons_revision' : revbuilder },
286 PYTHON = sys.executable
289 Version_values = [Value(version), Value(build_id)]
292 # Define SCons packages.
294 # In the original, more complicated packaging scheme, we were going
295 # to have separate packages for:
297 # python-scons only the build engine
298 # scons-script only the script
299 # scons the script plus the build engine
301 # We're now only delivering a single "scons" package, but this is still
302 # "built" as two sub-packages (the build engine and the script), so
303 # the definitions remain here, even though we're not using them for
308 'pkg' : 'python-' + project,
309 'src_subdir' : 'engine',
310 'inst_subdir' : os.path.join('lib', 'python1.5', 'site-packages'),
311 'rpm_dir' : '/usr/lib/scons',
324 'files' : [ 'LICENSE.txt',
331 'LICENSE.txt' : '../LICENSE.txt'
335 'SCons/__init__.py' : Version_values,
340 # The original packaging scheme would have have required us to push
341 # the Python version number into the package name (python1.5-scons,
342 # python2.0-scons, etc.), which would have required a definition
343 # like the following. Leave this here in case we ever decide to do
344 # this in the future, but note that this would require some modification
345 # to src/engine/setup.py before it would really work.
348 # 'pkg' : 'python2-' + project,
349 # 'src_subdir' : 'engine',
350 # 'inst_subdir' : os.path.join('lib', 'python2.2', 'site-packages'),
353 # 'debian/changelog',
355 # 'debian/copyright',
370 # 'LICENSE.txt' : '../LICENSE.txt',
376 'pkg' : project + '-script',
377 'src_subdir' : 'script',
378 'inst_subdir' : 'bin',
379 'rpm_dir' : '/usr/bin',
400 'LICENSE.txt' : '../LICENSE.txt',
401 'scons' : 'scons.py',
402 'sconsign' : 'sconsign.py',
406 'scons' : Version_values,
407 'sconsign' : Version_values,
430 'os_spawnv_fix.diff',
439 'scons.1' : '../doc/man/scons.1',
440 'sconsign.1' : '../doc/man/sconsign.1',
443 'subpkgs' : [ python_scons, scons_script ],
446 'python-' + project : python_project_subinst_dir,
447 project + '-script' : project_script_subinst_dir,
451 scripts = ['scons', 'sconsign']
458 # Initialize variables with the right directories for this package.
461 pkg_version = "%s-%s" % (pkg, version)
464 if p.has_key('src_subdir'):
465 src = os.path.join(src, p['src_subdir'])
467 build = os.path.join('build', pkg)
469 tar_gz = os.path.join(build, 'dist', "%s.tar.gz" % pkg_version)
470 platform_tar_gz = os.path.join(build,
472 "%s.%s.tar.gz" % (pkg_version, platform))
473 zip = os.path.join(build, 'dist', "%s.zip" % pkg_version)
474 platform_zip = os.path.join(build,
476 "%s.%s.zip" % (pkg_version, platform))
477 win32_exe = os.path.join(build, 'dist', "%s.win32.exe" % pkg_version)
480 # Update the environment with the relevant information
483 # We can get away with calling setup.py using a directory path
484 # like this because we put a preamble in it that will chdir()
485 # to the directory in which setup.py exists.
487 setup_py = os.path.join(build, 'setup.py')
488 env.Replace(PKG = pkg,
489 PKG_VERSION = pkg_version,
494 # Read up the list of source files from our MANIFEST.in.
495 # This list should *not* include LICENSE.txt, MANIFEST,
496 # README.txt, or setup.py. Make a copy of the list for the
499 manifest_in = File(os.path.join(src, 'MANIFEST.in')).rstr()
500 src_files = map(lambda x: x[:-1],
501 open(manifest_in).readlines())
502 raw_files = src_files[:]
503 dst_files = src_files[:]
506 MANIFEST_in_list = []
508 if p.has_key('subpkgs'):
510 # This package includes some sub-packages. Read up their
511 # MANIFEST.in files, and add them to our source and destination
512 # file lists, modifying them as appropriate to add the
515 for sp in p['subpkgs']:
516 ssubdir = sp['src_subdir']
517 isubdir = p['subinst_dirs'][sp['pkg']]
518 MANIFEST_in = File(os.path.join(src, ssubdir, 'MANIFEST.in')).rstr()
519 MANIFEST_in_list.append(MANIFEST_in)
520 files = map(lambda x: x[:-1], open(MANIFEST_in).readlines())
521 raw_files.extend(files)
522 src_files.extend(map(lambda x, s=ssubdir: os.path.join(s, x), files))
524 r = os.path.join(sp['rpm_dir'], f)
527 rpm_files.append(r + 'c')
528 files = map(lambda x, i=isubdir: os.path.join(i, x), files)
529 dst_files.extend(files)
530 for k, f in sp['filemap'].items():
532 k = os.path.join(ssubdir, k)
533 p['filemap'][k] = os.path.join(ssubdir, f)
534 for f, deps in sp['explicit_deps'].items():
535 f = os.path.join(build, ssubdir, f)
539 # Now that we have the "normal" source files, add those files
540 # that are standard for each distribution. Note that we don't
541 # add these to dst_files, because they don't get installed.
542 # And we still have the MANIFEST to add.
544 src_files.extend(p['files'])
547 # Now run everything in src_file through the sed command we
548 # concocted to expand __FILE__, __VERSION__, etc.
551 s = p['filemap'].get(b, b)
552 env.SCons_revision(os.path.join(build, b), os.path.join(src, s))
555 # NOW, finally, we can create the MANIFEST, which we do
556 # by having Python spit out the contents of the src_files
557 # array we've carefully created. After we've added
558 # MANIFEST itself to the array, of course.
560 src_files.append("MANIFEST")
561 MANIFEST_in_list.append(os.path.join(src, 'MANIFEST.in'))
563 def write_src_files(target, source, **kw):
566 f = open(str(target[0]), 'wb')
567 for file in src_files:
571 env.Command(os.path.join(build, 'MANIFEST'),
576 # Now go through and arrange to create whatever packages we can.
578 build_src_files = map(lambda x, b=build: os.path.join(b, x), src_files)
579 apply(Local, build_src_files, {})
581 distutils_formats = []
583 distutils_targets = [ win32_exe ]
585 install_targets = distutils_targets[:]
589 distutils_formats.append('gztar')
591 src_deps.append(tar_gz)
593 distutils_targets.extend([ tar_gz, platform_tar_gz ])
594 install_targets.extend([ tar_gz, platform_tar_gz ])
597 # Unpack the tar.gz archive created by the distutils into
598 # build/unpack-tar-gz/scons-{version}.
600 # We'd like to replace the last three lines with the following:
602 # tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
604 # but that gives heartburn to Cygwin's tar, so work around it
605 # with separate zcat-tar-rm commands.
607 unpack_tar_gz_files = map(lambda x, u=unpack_tar_gz_dir, pv=pkg_version:
608 os.path.join(u, pv, x),
610 env.Command(unpack_tar_gz_files, tar_gz, [
611 Delete(os.path.join(unpack_tar_gz_dir, pkg_version)),
612 "$ZCAT $SOURCES > .temp",
613 "tar xf .temp -C $UNPACK_TAR_GZ_DIR",
618 # Run setup.py in the unpacked subdirectory to "install" everything
619 # into our build/test subdirectory. The runtest.py script will set
620 # PYTHONPATH so that the tests only look under build/test-{package},
621 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
622 # and unittest.py). This makes sure that our tests pass with what
623 # we really packaged, not because of something hanging around in
624 # the development directory.
626 # We can get away with calling setup.py using a directory path
627 # like this because we put a preamble in it that will chdir()
628 # to the directory in which setup.py exists.
630 dfiles = map(lambda x, d=test_tar_gz_dir: os.path.join(d, x), dst_files)
631 env.Command(dfiles, unpack_tar_gz_files, [
632 Delete(os.path.join(unpack_tar_gz_dir, pkg_version, 'build')),
633 Delete("$TEST_TAR_GZ_DIR"),
634 '$PYTHON "%s" install "--prefix=$TEST_TAR_GZ_DIR"' % \
635 os.path.join(unpack_tar_gz_dir, pkg_version, 'setup.py'),
639 # Generate portage files for submission to Gentoo Linux.
641 gentoo = os.path.join('build', 'gentoo')
642 ebuild = os.path.join(gentoo, 'scons-%s.ebuild' % version)
643 digest = os.path.join(gentoo, 'files', 'digest-scons-%s' % version)
644 env.Command(ebuild, os.path.join('gentoo', 'scons.ebuild.in'), SCons_revision)
645 def Digestify(target, source, env):
648 """Return a signature as a string of hex characters.
650 # NOTE: This routine is a method in the Python 2.0 interface
651 # of the native md5 module, but we want SCons to operate all
652 # the way back to at least Python 1.5.2, which doesn't have it.
657 r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
659 src = source[0].rfile()
660 contents = open(str(src)).read()
661 sig = hexdigest(md5.new(contents).digest())
662 bytes = os.stat(str(src))[6]
663 open(str(target[0]), 'w').write("MD5 %s %s %d\n" % (sig,
666 env.Command(digest, tar_gz, Digestify)
670 distutils_formats.append('zip')
674 distutils_targets.extend([ zip, platform_zip ])
675 install_targets.extend([ zip, platform_zip ])
678 # Unpack the zip archive created by the distutils into
679 # build/unpack-zip/scons-{version}.
681 unpack_zip_files = map(lambda x, u=unpack_zip_dir, pv=pkg_version:
682 os.path.join(u, pv, x),
685 env.Command(unpack_zip_files, zip, [
686 Delete(os.path.join(unpack_zip_dir, pkg_version)),
691 # Run setup.py in the unpacked subdirectory to "install" everything
692 # into our build/test subdirectory. The runtest.py script will set
693 # PYTHONPATH so that the tests only look under build/test-{package},
694 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
695 # and unittest.py). This makes sure that our tests pass with what
696 # we really packaged, not because of something hanging around in
697 # the development directory.
699 # We can get away with calling setup.py using a directory path
700 # like this because we put a preamble in it that will chdir()
701 # to the directory in which setup.py exists.
703 dfiles = map(lambda x, d=test_zip_dir: os.path.join(d, x), dst_files)
704 env.Command(dfiles, unpack_zip_files, [
705 Delete(os.path.join(unpack_zip_dir, pkg_version, 'build')),
706 Delete("$TEST_ZIP_DIR"),
707 '$PYTHON "%s" install "--prefix=$TEST_ZIP_DIR"' % \
708 os.path.join(unpack_zip_dir, pkg_version, 'setup.py'),
712 topdir = os.path.join(os.getcwd(), build, 'build',
713 'bdist.' + platform, 'rpm')
715 BUILDdir = os.path.join(topdir, 'BUILD', pkg + '-' + version)
716 RPMSdir = os.path.join(topdir, 'RPMS', 'noarch')
717 SOURCESdir = os.path.join(topdir, 'SOURCES')
718 SPECSdir = os.path.join(topdir, 'SPECS')
719 SRPMSdir = os.path.join(topdir, 'SRPMS')
721 specfile_in = os.path.join('rpm', "%s.spec.in" % pkg)
722 specfile = os.path.join(SPECSdir, "%s-1.spec" % pkg_version)
723 sourcefile = os.path.join(SOURCESdir, "%s.tar.gz" % pkg_version);
724 noarch_rpm = os.path.join(RPMSdir, "%s-1.noarch.rpm" % pkg_version)
725 src_rpm = os.path.join(SRPMSdir, "%s-1.src.rpm" % pkg_version)
727 def spec_function(target, source, env):
728 """Generate the RPM .spec file from the template file.
730 This fills in the %files portion of the .spec file with a
731 list generated from our MANIFEST(s), so we don't have to
732 maintain multiple lists.
734 c = open(str(source[0]), 'rb').read()
735 c = string.replace(c, '__RPM_FILES__', env['RPM_FILES'])
736 open(str(target[0]), 'wb').write(c)
739 rpm_files_str = string.join(rpm_files, "\n") + "\n"
740 rpm_spec_env = env.Copy(RPM_FILES = rpm_files_str)
741 rpm_spec_action = Action(spec_function, varlist=['RPM_FILES'])
742 rpm_spec_env.Command(specfile, specfile_in, rpm_spec_action)
744 env.InstallAs(sourcefile, tar_gz)
747 targets = [ noarch_rpm, src_rpm ]
748 cmd = "$RPMBUILD --define '_topdir $(%s$)' -ba $SOURCES" % topdir
749 if not os.path.isdir(BUILDdir):
750 cmd = ("$( mkdir -p %s; $)" % BUILDdir) + cmd
751 env.Command(targets, specfile, cmd)
752 env.Depends(targets, sourcefile)
754 install_targets.extend(targets)
756 dfiles = map(lambda x, d=test_rpm_dir: os.path.join(d, 'usr', x),
760 "$RPM2CPIO $SOURCES | (cd $TEST_RPM_DIR && cpio -id)")
762 if dh_builddeb and fakeroot:
763 # Our Debian packaging builds directly into build/dist,
764 # so we don't need to add the .debs to install_targets.
765 deb = os.path.join('build', 'dist', "%s_%s-1_all.deb" % (pkg, version))
766 for d in p['debian_deps']:
767 b = env.SCons_revision(os.path.join(build, d), d)
770 env.Command(deb, build_src_files, [
771 "cd %s && fakeroot make -f debian/rules PYTHON=$PYTHON BUILDDEB_OPTIONS=--destdir=../../build/dist binary" % build,
774 old = os.path.join('lib', 'scons', '')
775 new = os.path.join('lib', 'python2.2', 'site-packages', '')
776 def xxx(s, old=old, new=new):
777 if s[:len(old)] == old:
778 s = new + s[len(old):]
779 return os.path.join('usr', s)
780 dfiles = map(lambda x, t=test_deb_dir: os.path.join(t, x),
784 "dpkg --fsys-tarfile $SOURCES | (cd $TEST_DEB_DIR && tar -xf -)")
788 # Use the Python distutils to generate the appropriate packages.
791 Delete(os.path.join(build, 'build', 'lib')),
792 Delete(os.path.join(build, 'build', 'scripts')),
795 if distutils_formats:
796 commands.append(Delete(os.path.join(build,
800 for format in distutils_formats:
801 commands.append("$PYTHON $SETUP_PY bdist_dumb -f %s" % format)
803 commands.append("$PYTHON $SETUP_PY sdist --formats=%s" % \
804 string.join(distutils_formats, ','))
806 commands.append("$PYTHON $SETUP_PY bdist_wininst")
808 env.Command(distutils_targets, build_src_files, commands)
811 # Now create local packages for people who want to let people
812 # build their SCons-buildable packages without having to
815 s_l_v = '%s-local-%s' % (pkg, version)
817 local = os.path.join('build', pkg + '-local')
818 cwd_local = os.path.join(os.getcwd(), local)
819 cwd_local_slv = os.path.join(os.getcwd(), local, s_l_v)
821 local_tar_gz = os.path.join('build', 'dist', "%s.tar.gz" % s_l_v)
822 local_zip = os.path.join('build', 'dist', "%s.zip" % s_l_v)
826 '$PYTHON $SETUP_PY install "--install-script=%s" "--install-lib=%s" --no-compile' % \
827 (cwd_local, cwd_local_slv),
830 for script in scripts:
831 #commands.append("mv %s/%s %s/%s.py" % (local, script, local, script))
832 local_script = os.path.join(local, script)
833 commands.append(Move(local_script + '.py', local_script))
835 rf = filter(lambda x: not x in scripts, raw_files)
836 rf = map(lambda x, slv=s_l_v: os.path.join(slv, x), rf)
837 for script in scripts:
838 rf.append("%s.py" % script)
839 local_targets = map(lambda x, s=local: os.path.join(s, x), rf)
841 env.Command(local_targets, build_src_files, commands)
843 scons_LICENSE = os.path.join(local, 'scons-LICENSE')
844 env.SCons_revision(scons_LICENSE, 'LICENSE-local')
845 local_targets.append(scons_LICENSE)
847 scons_README = os.path.join(local, 'scons-README')
848 env.SCons_revision(scons_README, 'README-local')
849 local_targets.append(scons_README)
852 env.Command(local_tar_gz,
854 "cd %s && tar czf $( ${TARGET.abspath} $) *" % local)
856 unpack_targets = map(lambda x, d=test_local_tar_gz_dir:
859 commands = [Delete(test_local_tar_gz_dir),
860 Mkdir(test_local_tar_gz_dir),
861 "cd %s && tar xzf $( ${SOURCE.abspath} $)" % test_local_tar_gz_dir]
863 env.Command(unpack_targets, local_tar_gz, commands)
866 env.Command(local_zip, local_targets, zipit,
867 CD = local, PSV = '.')
869 unpack_targets = map(lambda x, d=test_local_zip_dir:
872 commands = [Delete(test_local_zip_dir),
873 Mkdir(test_local_zip_dir),
876 env.Command(unpack_targets, local_zip, unzipit,
877 UNPACK_ZIP_DIR = test_local_zip_dir)
880 # And, lastly, install the appropriate packages in the
881 # appropriate subdirectory.
883 b_d_files = env.Install(os.path.join('build', 'dist'), install_targets)
891 SConscript('etc/SConscript')
896 Export('env', 'whereis')
898 SConscript('doc/SConscript')
901 # If we're running in the actual Aegis project, pack up a complete
902 # source archive from the project files and files in the change,
903 # so we can share it with helpful developers who don't use Aegis.
908 cmd = "aegis -list -unf -c %s cf 2>/dev/null" % change
909 for line in map(lambda x: x[:-1], os.popen(cmd, "r").readlines()):
910 a = string.split(line)
914 cmd = "aegis -list -terse pf 2>/dev/null"
915 pf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines())
916 cmd = "aegis -list -terse -c %s cf 2>/dev/null" % change
917 cf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines())
926 sfiles = filter(lambda x: x[-9:] != '.aeignore' and
927 x[-9:] != '.sconsign' and
928 x[-10:] != '.cvsignore',
932 ps = "%s-src" % project
933 psv = "%s-%s" % (ps, version)
934 b_ps = os.path.join('build', ps)
935 b_psv = os.path.join('build', psv)
936 b_psv_stamp = b_psv + '-stamp'
938 src_tar_gz = os.path.join('build', 'dist', '%s.tar.gz' % psv)
939 src_zip = os.path.join('build', 'dist', '%s.zip' % psv)
941 Local(src_tar_gz, src_zip)
944 env.SCons_revision(os.path.join(b_ps, file), file)
946 b_ps_files = map(lambda x, d=b_ps: os.path.join(d, x), sfiles)
953 env.Command(b_psv_stamp, src_deps + b_ps_files, cmds)
955 apply(Local, b_ps_files, {})
959 env.Command(src_tar_gz, b_psv_stamp,
960 "tar cz${TAR_HFLAG} -f $TARGET -C build %s" % psv)
963 # Unpack the archive into build/unpack/scons-{version}.
965 unpack_tar_gz_files = map(lambda x, u=unpack_tar_gz_dir, psv=psv:
966 os.path.join(u, psv, x),
970 # We'd like to replace the last three lines with the following:
972 # tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
974 # but that gives heartburn to Cygwin's tar, so work around it
975 # with separate zcat-tar-rm commands.
976 env.Command(unpack_tar_gz_files, src_tar_gz, [
977 Delete(os.path.join(unpack_tar_gz_dir, psv)),
978 "$ZCAT $SOURCES > .temp",
979 "tar xf .temp -C $UNPACK_TAR_GZ_DIR",
984 # Run setup.py in the unpacked subdirectory to "install" everything
985 # into our build/test subdirectory. The runtest.py script will set
986 # PYTHONPATH so that the tests only look under build/test-{package},
987 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
988 # and unittest.py). This makes sure that our tests pass with what
989 # we really packaged, not because of something hanging around in
990 # the development directory.
992 # We can get away with calling setup.py using a directory path
993 # like this because we put a preamble in it that will chdir()
994 # to the directory in which setup.py exists.
996 dfiles = map(lambda x, d=test_src_tar_gz_dir: os.path.join(d, x),
998 scons_lib_dir = os.path.join(unpack_tar_gz_dir, psv, 'src', 'engine')
999 ENV = env.Dictionary('ENV').copy()
1000 ENV['SCONS_LIB_DIR'] = scons_lib_dir
1001 ENV['USERNAME'] = developer
1002 env.Command(dfiles, unpack_tar_gz_files,
1004 Delete(os.path.join(unpack_tar_gz_dir,
1009 Delete("$TEST_SRC_TAR_GZ_DIR"),
1010 'cd "%s" && $PYTHON "%s" "%s"' % \
1011 (os.path.join(unpack_tar_gz_dir, psv),
1012 os.path.join('src', 'script', 'scons.py'),
1013 os.path.join('build', 'scons')),
1014 '$PYTHON "%s" install "--prefix=$TEST_SRC_TAR_GZ_DIR"' % \
1015 os.path.join(unpack_tar_gz_dir,
1025 env.Command(src_zip, b_psv_stamp, zipit, CD = 'build', PSV = psv)
1028 # Unpack the archive into build/unpack/scons-{version}.
1030 unpack_zip_files = map(lambda x, u=unpack_zip_dir, psv=psv:
1031 os.path.join(u, psv, x),
1034 env.Command(unpack_zip_files, src_zip, [
1035 Delete(os.path.join(unpack_zip_dir, psv)),
1040 # Run setup.py in the unpacked subdirectory to "install" everything
1041 # into our build/test subdirectory. The runtest.py script will set
1042 # PYTHONPATH so that the tests only look under build/test-{package},
1043 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
1044 # and unittest.py). This makes sure that our tests pass with what
1045 # we really packaged, not because of something hanging around in
1046 # the development directory.
1048 # We can get away with calling setup.py using a directory path
1049 # like this because we put a preamble in it that will chdir()
1050 # to the directory in which setup.py exists.
1052 dfiles = map(lambda x, d=test_src_zip_dir: os.path.join(d, x),
1054 scons_lib_dir = os.path.join(unpack_zip_dir, psv, 'src', 'engine')
1055 ENV = env.Dictionary('ENV').copy()
1056 ENV['SCONS_LIB_DIR'] = scons_lib_dir
1057 ENV['USERNAME'] = developer
1058 env.Command(dfiles, unpack_zip_files,
1060 Delete(os.path.join(unpack_zip_dir,
1065 Delete("$TEST_SRC_ZIP_DIR"),
1066 'cd "%s" && $PYTHON "%s" "%s"' % \
1067 (os.path.join(unpack_zip_dir, psv),
1068 os.path.join('src', 'script', 'scons.py'),
1069 os.path.join('build', 'scons')),
1070 '$PYTHON "%s" install "--prefix=$TEST_SRC_ZIP_DIR"' % \
1071 os.path.join(unpack_zip_dir,