2 # SConstruct file to build scons packages during development.
4 # See the README file for an overview of how SCons is built and tested.
8 # Copyright (c) 2001, 2002 Steven Knight
10 # Permission is hereby granted, free of charge, to any person obtaining
11 # a copy of this software and associated documentation files (the
12 # "Software"), to deal in the Software without restriction, including
13 # without limitation the rights to use, copy, modify, merge, publish,
14 # distribute, sublicense, and/or sell copies of the Software, and to
15 # permit persons to whom the Software is furnished to do so, subject to
16 # the following conditions:
18 # The above copyright notice and this permission notice shall be included
19 # in all copies or substantial portions of the Software.
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
22 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
23 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 default_version = '0.10'
45 # An internal "whereis" routine to figure out if a given program
46 # is available on this system.
49 for dir in string.split(os.environ['PATH'], os.pathsep):
50 f = os.path.join(dir, file)
56 if stat.S_IMODE(st[stat.ST_MODE]) & 0111:
61 # We let the presence or absence of various utilities determine
62 # whether or not we bother to build certain pieces of things.
63 # This should allow people to still do SCons work even if they
64 # don't have Aegis or RPM installed, for example.
66 aegis = whereis('aegis')
67 aesub = whereis('aesub')
68 dh_builddeb = whereis('dh_builddeb')
69 fakeroot = whereis('fakeroot')
70 gzip = whereis('gzip')
71 rpmbuild = whereis('rpmbuild') or whereis('rpm')
72 unzip = whereis('unzip')
76 # Now grab the information that we "build" into the files.
79 date = ARGUMENTS['date']
81 date = time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(time.time()))
83 if ARGUMENTS.has_key('developer'):
84 developer = ARGUMENTS['developer']
85 elif os.environ.has_key('USERNAME'):
86 developer = os.environ['USERNAME']
87 elif os.environ.has_key('LOGNAME'):
88 developer = os.environ['LOGNAME']
89 elif os.environ.has_key('USER'):
90 developer = os.environ['USER']
92 if ARGUMENTS.has_key('build_system'):
93 build_system = ARGUMENTS['build_system']
95 build_system = string.split(socket.gethostname(), '.')[0]
97 if ARGUMENTS.has_key('version'):
98 revision = ARGUMENTS['version']
100 revision = os.popen(aesub + " \\$version", "r").read()[:-1]
102 revision = default_version
104 a = string.split(revision, '.')
110 revision = string.join(arr, '.')
112 # Here's how we'd turn the calculated $revision into our package $version.
113 # This makes it difficult to coordinate with other files (debian/changelog
114 # and rpm/scons.spec) that hard-code the version number, so just go with
115 # the flow for now and hard code it here, too.
119 # if str[0] == 'C' or str[0] == 'D':
121 # while len(str) > 2 and str[0] == '0':
124 #arr = map(lambda x, xxx=xxx: xxx(x), arr)
125 #version = string.join(arr, '.')
126 version = default_version
128 build_id = string.replace(revision, version + '.', '')
130 if ARGUMENTS.has_key('change'):
131 change = ARGUMENTS['change']
133 change = os.popen(aesub + " \\$change", "r").read()[:-1]
135 change = default_version
137 python_ver = sys.version[0:3]
139 platform = distutils.util.get_platform()
141 ENV = { 'PATH' : os.environ['PATH'] }
142 for key in ['AEGIS_PROJECT', 'PYTHONPATH']:
143 if os.environ.has_key(key):
144 ENV[key] = os.environ[key]
146 lib_project = os.path.join("lib", project)
148 cwd_build = os.path.join(os.getcwd(), "build")
150 test_deb_dir = os.path.join(cwd_build, "test-deb")
151 test_rpm_dir = os.path.join(cwd_build, "test-rpm")
152 test_tar_gz_dir = os.path.join(cwd_build, "test-tar-gz")
153 test_src_tar_gz_dir = os.path.join(cwd_build, "test-src-tar-gz")
154 test_local_tar_gz_dir = os.path.join(cwd_build, "test-local-tar-gz")
155 test_zip_dir = os.path.join(cwd_build, "test-zip")
156 test_src_zip_dir = os.path.join(cwd_build, "test-src-zip")
157 test_local_zip_dir = os.path.join(cwd_build, "test-local-zip")
159 unpack_tar_gz_dir = os.path.join(cwd_build, "unpack-tar-gz")
160 unpack_zip_dir = os.path.join(cwd_build, "unpack-zip")
162 if platform == "win32":
164 python_project_subinst_dir = None
165 project_script_subinst_dir = 'Scripts'
168 python_project_subinst_dir = lib_project
169 project_script_subinst_dir = 'bin'
175 # Figure out if we can handle .zip files.
182 def zipit(env, target, source):
183 print "Zipping %s:" % str(target[0])
184 def visit(arg, dirname, names):
186 path = os.path.join(dirname, name)
187 if os.path.isfile(path):
189 zf = zipfile.ZipFile(str(target[0]), 'w')
192 try: os.path.walk(env['PSV'], visit, zf)
193 finally: os.chdir(olddir)
196 def unzipit(env, target, source):
197 print "Unzipping %s:" % str(source[0])
198 zf = zipfile.ZipFile(str(source[0]), 'r')
199 for name in zf.namelist():
200 dest = os.path.join(env['UNPACK_ZIP_DIR'], name)
201 dir = os.path.dirname(dest)
207 # if the file exists, then delete it before writing
208 # to it so that we don't end up trying to write to a symlink:
209 if os.path.isfile(dest) or os.path.islink(dest):
211 if not os.path.isdir(dest):
212 open(dest, 'w').write(zf.read(name))
216 zipit = "cd $CD && $ZIP $ZIPFLAGS $( ${TARGET.abspath} $) $PSV"
217 unzipit = "$UNZIP $UNZIPFLAGS $SOURCES"
219 def SCons_revision(target, source, env):
220 """Interpolate specific values from the environment into a file.
222 This is used to copy files into a tree that gets packaged up
223 into the source file package.
227 # Note: We don't use $VERSION from the environment so that
228 # this routine will change when the version number changes
229 # and things will get rebuilt properly.
233 for line in inf.readlines():
234 # Note: We construct the __*__ substitution strings here
235 # so that they don't get replaced when this file gets
236 # copied into the tree for packaging.
237 line = string.replace(line, '__BUILD' + '__', env['BUILD'])
238 line = string.replace(line, '__BUILDSYS' + '__', env['BUILDSYS'])
239 line = string.replace(line, '__DATE' + '__', env['DATE'])
240 line = string.replace(line, '__DEVELOPER' + '__', env['DEVELOPER'])
241 line = string.replace(line, '__FILE' + '__', s)
242 line = string.replace(line, '__REVISION' + '__', env['REVISION'])
243 line = string.replace(line, '__VERSION' + '__', version)
247 os.chmod(t, os.stat(s)[0])
249 revbuilder = Builder(action = SCons_revision)
255 BUILDSYS = build_system,
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
290 # Define SCons packages.
292 # In the original, more complicated packaging scheme, we were going
293 # to have separate packages for:
295 # python-scons only the build engine
296 # scons-script only the script
297 # scons the script plus the build engine
299 # We're now only delivering a single "scons" package, but this is still
300 # "built" as two sub-packages (the build engine and the script), so
301 # the definitions remain here, even though we're not using them for
306 'pkg' : 'python-' + project,
307 'src_subdir' : 'engine',
308 'inst_subdir' : os.path.join('lib', 'python1.5', 'site-packages'),
321 'files' : [ 'LICENSE.txt',
328 'LICENSE.txt' : '../LICENSE.txt'
333 # The original packaging scheme would have have required us to push
334 # the Python version number into the package name (python1.5-scons,
335 # python2.0-scons, etc.), which would have required a definition
336 # like the following. Leave this here in case we ever decide to do
337 # this in the future, but note that this would require some modification
338 # to src/engine/setup.py before it would really work.
341 # 'pkg' : 'python2-' + project,
342 # 'src_subdir' : 'engine',
343 # 'inst_subdir' : os.path.join('lib', 'python2.1', 'site-packages'),
346 # 'debian/changelog',
348 # 'debian/copyright',
363 # 'LICENSE.txt' : '../LICENSE.txt',
369 'pkg' : project + '-script',
370 'src_subdir' : 'script',
371 'inst_subdir' : 'bin',
392 'LICENSE.txt' : '../LICENSE.txt',
393 'scons' : 'scons.py',
416 'os_spawnv_fix.diff',
424 'scons.1' : '../doc/man/scons.1',
427 'subpkgs' : [ python_scons, scons_script ],
430 'python-' + project : python_project_subinst_dir,
431 project + '-script' : project_script_subinst_dir,
440 # Initialize variables with the right directories for this package.
443 pkg_version = "%s-%s" % (pkg, version)
446 if p.has_key('src_subdir'):
447 src = os.path.join(src, p['src_subdir'])
449 build = os.path.join('build', pkg)
451 tar_gz = os.path.join(build, 'dist', "%s.tar.gz" % pkg_version)
452 platform_tar_gz = os.path.join(build,
454 "%s.%s.tar.gz" % (pkg_version, platform))
455 zip = os.path.join(build, 'dist', "%s.zip" % pkg_version)
456 platform_zip = os.path.join(build,
458 "%s.%s.zip" % (pkg_version, platform))
459 win32_exe = os.path.join(build, 'dist', "%s.win32.exe" % pkg_version)
462 # Update the environment with the relevant information
465 # We can get away with calling setup.py using a directory path
466 # like this because we put a preamble in it that will chdir()
467 # to the directory in which setup.py exists.
469 setup_py = os.path.join(build, 'setup.py')
470 env.Update(PKG = pkg,
471 PKG_VERSION = pkg_version,
476 # Read up the list of source files from our MANIFEST.in.
477 # This list should *not* include LICENSE.txt, MANIFEST,
478 # README.txt, or setup.py. Make a copy of the list for the
481 manifest_in = File(os.path.join(src, 'MANIFEST.in')).rstr()
482 src_files = map(lambda x: x[:-1],
483 open(manifest_in).readlines())
484 raw_files = src_files[:]
485 dst_files = src_files[:]
487 MANIFEST_in_list = []
489 if p.has_key('subpkgs'):
491 # This package includes some sub-packages. Read up their
492 # MANIFEST.in files, and add them to our source and destination
493 # file lists, modifying them as appropriate to add the
496 for sp in p['subpkgs']:
497 ssubdir = sp['src_subdir']
498 isubdir = p['subinst_dirs'][sp['pkg']]
499 MANIFEST_in = File(os.path.join(src, ssubdir, 'MANIFEST.in')).rstr()
500 MANIFEST_in_list.append(MANIFEST_in)
501 f = map(lambda x: x[:-1], open(MANIFEST_in).readlines())
503 src_files.extend(map(lambda x, s=ssubdir: os.path.join(s, x), f))
505 f = map(lambda x, i=isubdir: os.path.join(i, x), f)
507 for k in sp['filemap'].keys():
510 k = os.path.join(sp['src_subdir'], k)
511 p['filemap'][k] = os.path.join(sp['src_subdir'], f)
514 # Now that we have the "normal" source files, add those files
515 # that are standard for each distribution. Note that we don't
516 # add these to dst_files, because they don't get installed.
517 # And we still have the MANIFEST to add.
519 src_files.extend(p['files'])
522 # Now run everything in src_file through the sed command we
523 # concocted to expand __FILE__, __VERSION__, etc.
526 s = p['filemap'].get(b, b)
527 env.SCons_revision(os.path.join(build, b), os.path.join(src, s))
530 # NOW, finally, we can create the MANIFEST, which we do
531 # by having Python spit out the contents of the src_files
532 # array we've carefully created. After we've added
533 # MANIFEST itself to the array, of course.
535 src_files.append("MANIFEST")
536 MANIFEST_in_list.append(os.path.join(src, 'MANIFEST.in'))
538 def write_src_files(target, source, **kw):
541 f = open(str(target[0]), 'wb')
542 for file in src_files:
546 env.Command(os.path.join(build, 'MANIFEST'),
551 # Now go through and arrange to create whatever packages we can.
553 build_src_files = map(lambda x, b=build: os.path.join(b, x), src_files)
554 apply(Local, build_src_files, {})
556 distutils_formats = []
558 distutils_targets = [ win32_exe ]
560 install_targets = distutils_targets[:]
564 distutils_formats.append('gztar')
566 src_deps.append(tar_gz)
568 distutils_targets.extend([ tar_gz, platform_tar_gz ])
569 install_targets.extend([ tar_gz, platform_tar_gz ])
572 # Unpack the tar.gz archive created by the distutils into
573 # build/unpack-tar-gz/scons-{version}.
575 # We'd like to replace the last three lines with the following:
577 # tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
579 # but that gives heartburn to Cygwin's tar, so work around it
580 # with separate zcat-tar-rm commands.
582 unpack_tar_gz_files = map(lambda x, u=unpack_tar_gz_dir, pv=pkg_version:
583 os.path.join(u, pv, x),
585 env.Command(unpack_tar_gz_files, tar_gz, [
586 "rm -rf %s" % os.path.join(unpack_tar_gz_dir, pkg_version),
587 "$ZCAT $SOURCES > .temp",
588 "tar xf .temp -C $UNPACK_TAR_GZ_DIR",
593 # Run setup.py in the unpacked subdirectory to "install" everything
594 # into our build/test subdirectory. The runtest.py script will set
595 # PYTHONPATH so that the tests only look under build/test-{package},
596 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
597 # and unittest.py). This makes sure that our tests pass with what
598 # we really packaged, not because of something hanging around in
599 # the development directory.
601 # We can get away with calling setup.py using a directory path
602 # like this because we put a preamble in it that will chdir()
603 # to the directory in which setup.py exists.
605 dfiles = map(lambda x, d=test_tar_gz_dir: os.path.join(d, x), dst_files)
606 env.Command(dfiles, unpack_tar_gz_files, [
607 "rm -rf %s" % os.path.join(unpack_tar_gz_dir, pkg_version, 'build'),
608 "rm -rf $TEST_TAR_GZ_DIR",
609 "$PYTHON %s install --prefix=$TEST_TAR_GZ_DIR" % \
610 os.path.join(unpack_tar_gz_dir, pkg_version, 'setup.py'),
615 distutils_formats.append('zip')
619 distutils_targets.extend([ zip, platform_zip ])
620 install_targets.extend([ zip, platform_zip ])
623 # Unpack the zip archive created by the distutils into
624 # build/unpack-zip/scons-{version}.
626 unpack_zip_files = map(lambda x, u=unpack_zip_dir, pv=pkg_version:
627 os.path.join(u, pv, x),
630 env.Command(unpack_zip_files, zip, unzipit)
633 # Run setup.py in the unpacked subdirectory to "install" everything
634 # into our build/test subdirectory. The runtest.py script will set
635 # PYTHONPATH so that the tests only look under build/test-{package},
636 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
637 # and unittest.py). This makes sure that our tests pass with what
638 # we really packaged, not because of something hanging around in
639 # the development directory.
641 # We can get away with calling setup.py using a directory path
642 # like this because we put a preamble in it that will chdir()
643 # to the directory in which setup.py exists.
645 dfiles = map(lambda x, d=test_zip_dir: os.path.join(d, x), dst_files)
646 env.Command(dfiles, unpack_zip_files, [
647 "rm -rf %s" % os.path.join(unpack_zip_dir, pkg_version, 'build'),
648 "rm -rf $TEST_ZIP_DIR",
649 "$PYTHON %s install --prefix=$TEST_ZIP_DIR" % \
650 os.path.join(unpack_zip_dir, pkg_version, 'setup.py'),
654 topdir = os.path.join(os.getcwd(), build, 'build',
655 'bdist.' + platform, 'rpm')
657 BUILDdir = os.path.join(topdir, 'BUILD', pkg + '-' + version)
658 RPMSdir = os.path.join(topdir, 'RPMS', 'noarch')
659 SOURCESdir = os.path.join(topdir, 'SOURCES')
660 SPECSdir = os.path.join(topdir, 'SPECS')
661 SRPMSdir = os.path.join(topdir, 'SRPMS')
663 specfile = os.path.join(SPECSdir, "%s-1.spec" % pkg_version)
664 sourcefile = os.path.join(SOURCESdir, "%s.tar.gz" % pkg_version);
665 noarch_rpm = os.path.join(RPMSdir, "%s-1.noarch.rpm" % pkg_version)
666 src_rpm = os.path.join(SRPMSdir, "%s-1.src.rpm" % pkg_version)
668 env.InstallAs(specfile, os.path.join('rpm', "%s.spec" % pkg))
669 env.InstallAs(sourcefile, tar_gz)
671 targets = [ noarch_rpm, src_rpm ]
672 cmd = "$RPMBUILD --define '_topdir $(%s$)' -ba $SOURCES" % topdir
673 if not os.path.isdir(BUILDdir):
674 cmd = ("$( mkdir -p %s; $)" % BUILDdir) + cmd
675 env.Command(targets, specfile, cmd)
676 env.Depends(targets, sourcefile)
678 install_targets.extend(targets)
680 dfiles = map(lambda x, d=test_rpm_dir: os.path.join(d, 'usr', x),
684 "$RPM2CPIO $SOURCES | (cd $TEST_RPM_DIR && cpio -id)")
686 if dh_builddeb and fakeroot:
687 # Our Debian packaging builds directly into build/dist,
688 # so we don't need to add the .debs to install_targets.
689 deb = os.path.join('build', 'dist', "%s_%s-1_all.deb" % (pkg, version))
690 for d in p['debian_deps']:
691 b = env.SCons_revision(os.path.join(build, d), d)
694 env.Command(deb, build_src_files, [
695 "cd %s && fakeroot make -f debian/rules PYTHON=$PYTHON BUILDDEB_OPTIONS=--destdir=../../build/dist binary" % build,
698 old = os.path.join('lib', 'scons', '')
699 new = os.path.join('lib', 'python2.1', 'site-packages', '')
700 def xxx(s, old=old, new=new):
701 if s[:len(old)] == old:
702 s = new + s[len(old):]
703 return os.path.join('usr', s)
704 dfiles = map(lambda x, t=test_deb_dir: os.path.join(t, x),
708 "dpkg --fsys-tarfile $SOURCES | (cd $TEST_DEB_DIR && tar -xf -)")
711 # Use the Python distutils to generate the appropriate packages.
714 "rm -rf %s" % os.path.join(build, 'build', 'lib'),
715 "rm -rf %s" % os.path.join(build, 'build', 'scripts'),
718 if distutils_formats:
719 commands.append("rm -rf %s" % os.path.join(build,
723 for format in distutils_formats:
724 commands.append("$PYTHON $SETUP_PY bdist_dumb -f %s" % format)
726 commands.append("$PYTHON $SETUP_PY sdist --formats=%s" % \
727 string.join(distutils_formats, ','))
729 commands.append("$PYTHON $SETUP_PY bdist_wininst")
731 env.Command(distutils_targets, build_src_files, commands)
734 # Now create local packages for people who want to let people
735 # build their SCons-buildable packages without having to
738 s_l_v = '%s-local-%s' % (pkg, version)
740 local = os.path.join('build', pkg + '-local')
741 cwd_local = os.path.join(os.getcwd(), local)
742 cwd_local_slv = os.path.join(os.getcwd(), local, s_l_v)
744 local_tar_gz = os.path.join('build', 'dist', "%s.tar.gz" % s_l_v)
745 local_zip = os.path.join('build', 'dist', "%s.zip" % s_l_v)
749 "$PYTHON $SETUP_PY install --install-script=%s --install-lib=%s --no-compile" % \
750 (cwd_local, cwd_local_slv),
751 "mv %s/scons %s/scons.py" % (local, local),
754 rf = filter(lambda x: x != "scons", raw_files)
755 rf = map(lambda x, slv=s_l_v: os.path.join(slv, x), rf)
756 rf.append("scons.py")
757 local_targets = map(lambda x, s=local: os.path.join(s, x), rf)
759 env.Command(local_targets, build_src_files, commands)
761 scons_LICENSE = os.path.join(local, 'scons-LICENSE')
762 env.SCons_revision(scons_LICENSE, 'LICENSE-local')
763 local_targets.append(scons_LICENSE)
765 scons_README = os.path.join(local, 'scons-README')
766 env.SCons_revision(scons_README, 'README-local')
767 local_targets.append(scons_README)
770 env.Command(local_tar_gz,
772 "cd %s && tar czf $( ${TARGET.abspath} $) *" % local)
774 unpack_targets = map(lambda x, d=test_local_tar_gz_dir:
777 commands = ["rm -rf %s" % test_local_tar_gz_dir,
778 "mkdir %s" % test_local_tar_gz_dir,
779 "cd %s && tar xzf $( ${SOURCE.abspath} $)" % test_local_tar_gz_dir]
781 env.Command(unpack_targets, local_tar_gz, commands)
784 zipenv = env.Copy(CD = local, PSV = '.')
785 zipenv.Command(local_zip, local_targets, zipit)
787 unpack_targets = map(lambda x, d=test_local_zip_dir:
790 commands = ["rm -rf %s" % test_local_zip_dir,
791 "mkdir %s" % test_local_zip_dir,
794 zipenv = env.Copy(UNPACK_ZIP_DIR = test_local_zip_dir)
795 zipenv.Command(unpack_targets, local_zip, unzipit)
798 # And, lastly, install the appropriate packages in the
799 # appropriate subdirectory.
801 b_d_files = env.Install(os.path.join('build', 'dist'), install_targets)
809 SConscript('etc/SConscript')
814 BuildDir('build/doc', 'doc')
816 Export('env', 'whereis')
818 SConscript('build/doc/SConscript')
821 # If we're running in the actual Aegis project, pack up a complete
822 # source archive from the project files and files in the change,
823 # so we can share it with helpful developers who don't use Aegis.
828 cmd = "aegis -list -unf -c %s cf 2>/dev/null" % change
829 for line in map(lambda x: x[:-1], os.popen(cmd, "r").readlines()):
830 a = string.split(line)
834 cmd = "aegis -list -terse pf 2>/dev/null"
835 pf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines())
836 cmd = "aegis -list -terse cf 2>/dev/null"
837 cf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines())
843 sfiles = filter(lambda x: x[-9:] != '.aeignore' and x[-9:] != '.sconsign',
847 ps = "%s-src" % project
848 psv = "%s-%s" % (ps, version)
849 b_ps = os.path.join('build', ps)
850 b_psv = os.path.join('build', psv)
851 b_psv_stamp = b_psv + '-stamp'
853 src_tar_gz = os.path.join('build', 'dist', '%s.tar.gz' % psv)
854 src_zip = os.path.join('build', 'dist', '%s.zip' % psv)
856 Local(src_tar_gz, src_zip)
859 env.SCons_revision(os.path.join(b_ps, file), file)
861 b_ps_files = map(lambda x, d=b_ps: os.path.join(d, x), sfiles)
864 "cp -rp %s %s" % (b_ps, b_psv),
865 "find %s -name .sconsign -exec rm {} \\;" % b_psv,
869 env.Command(b_psv_stamp, src_deps + b_ps_files, cmds)
871 apply(Local, b_ps_files, {})
875 env.Command(src_tar_gz, b_psv_stamp,
876 "tar cz${TAR_HFLAG} -f $TARGET -C build %s" % psv)
879 # Unpack the archive into build/unpack/scons-{version}.
881 unpack_tar_gz_files = map(lambda x, u=unpack_tar_gz_dir, psv=psv:
882 os.path.join(u, psv, x),
886 # We'd like to replace the last three lines with the following:
888 # tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
890 # but that gives heartburn to Cygwin's tar, so work around it
891 # with separate zcat-tar-rm commands.
892 env.Command(unpack_tar_gz_files, src_tar_gz, [
893 "rm -rf %s" % os.path.join(unpack_tar_gz_dir, psv),
894 "$ZCAT $SOURCES > .temp",
895 "tar xf .temp -C $UNPACK_TAR_GZ_DIR",
900 # Run setup.py in the unpacked subdirectory to "install" everything
901 # into our build/test subdirectory. The runtest.py script will set
902 # PYTHONPATH so that the tests only look under build/test-{package},
903 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
904 # and unittest.py). This makes sure that our tests pass with what
905 # we really packaged, not because of something hanging around in
906 # the development directory.
908 # We can get away with calling setup.py using a directory path
909 # like this because we put a preamble in it that will chdir()
910 # to the directory in which setup.py exists.
912 dfiles = map(lambda x, d=test_src_tar_gz_dir: os.path.join(d, x),
914 ENV = env.Dictionary('ENV')
915 ENV['SCONS_LIB_DIR'] = os.path.join(unpack_tar_gz_dir, psv, 'src', 'engine')
916 ENV['USERNAME'] = developer
917 env.Copy(ENV = ENV).Command(dfiles, unpack_tar_gz_files, [
918 "rm -rf %s" % os.path.join(unpack_tar_gz_dir,
923 "rm -rf $TEST_SRC_TAR_GZ_DIR",
924 "cd %s && $PYTHON %s %s" % \
925 (os.path.join(unpack_tar_gz_dir, psv),
926 os.path.join('src', 'script', 'scons.py'),
927 os.path.join('build', 'scons')),
928 "$PYTHON %s install --prefix=$TEST_SRC_TAR_GZ_DIR" % \
929 os.path.join(unpack_tar_gz_dir,
938 zipenv = env.Copy(CD = 'build', PSV = psv)
939 zipenv.Command(src_zip, b_psv_stamp, zipit)
942 # Unpack the archive into build/unpack/scons-{version}.
944 unpack_zip_files = map(lambda x, u=unpack_zip_dir, psv=psv:
945 os.path.join(u, psv, x),
948 env.Command(unpack_zip_files, src_zip, unzipit)
951 # Run setup.py in the unpacked subdirectory to "install" everything
952 # into our build/test subdirectory. The runtest.py script will set
953 # PYTHONPATH so that the tests only look under build/test-{package},
954 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
955 # and unittest.py). This makes sure that our tests pass with what
956 # we really packaged, not because of something hanging around in
957 # the development directory.
959 # We can get away with calling setup.py using a directory path
960 # like this because we put a preamble in it that will chdir()
961 # to the directory in which setup.py exists.
963 dfiles = map(lambda x, d=test_src_zip_dir: os.path.join(d, x),
965 ENV = env.Dictionary('ENV')
966 ENV['SCONS_LIB_DIR'] = os.path.join(unpack_zip_dir, psv, 'src', 'engine')
967 ENV['USERNAME'] = developer
968 env.Copy(ENV = ENV).Command(dfiles, unpack_zip_files, [
969 "rm -rf %s" % os.path.join(unpack_zip_dir,
974 "rm -rf $TEST_SRC_ZIP_DIR",
975 "cd %s && $PYTHON %s %s" % \
976 (os.path.join(unpack_zip_dir, psv),
977 os.path.join('src', 'script', 'scons.py'),
978 os.path.join('build', 'scons')),
979 "$PYTHON %s install --prefix=$TEST_SRC_ZIP_DIR" % \
980 os.path.join(unpack_zip_dir,