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'
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.15'
43 copyright = "Copyright (c) %s Steven Knight" % copyright_years
48 # An internal "whereis" routine to figure out if a given program
49 # is available on this system.
52 for dir in string.split(os.environ['PATH'], os.pathsep):
53 f = os.path.join(dir, file)
59 if stat.S_IMODE(st[stat.ST_MODE]) & 0111:
64 # We let the presence or absence of various utilities determine
65 # whether or not we bother to build certain pieces of things.
66 # This should allow people to still do SCons work even if they
67 # don't have Aegis or RPM installed, for example.
69 aegis = whereis('aegis')
70 aesub = whereis('aesub')
71 dh_builddeb = whereis('dh_builddeb')
72 fakeroot = whereis('fakeroot')
73 gzip = whereis('gzip')
74 rpmbuild = whereis('rpmbuild') or whereis('rpm')
75 unzip = whereis('unzip')
79 # Now grab the information that we "build" into the files.
82 date = ARGUMENTS['date']
84 date = time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(time.time()))
86 if ARGUMENTS.has_key('developer'):
87 developer = ARGUMENTS['developer']
88 elif os.environ.has_key('USERNAME'):
89 developer = os.environ['USERNAME']
90 elif os.environ.has_key('LOGNAME'):
91 developer = os.environ['LOGNAME']
92 elif os.environ.has_key('USER'):
93 developer = os.environ['USER']
95 if ARGUMENTS.has_key('build_system'):
96 build_system = ARGUMENTS['build_system']
98 build_system = string.split(socket.gethostname(), '.')[0]
100 if ARGUMENTS.has_key('version'):
101 revision = ARGUMENTS['version']
103 revision = os.popen(aesub + " \\$version", "r").read()[:-1]
105 revision = default_version
107 a = string.split(revision, '.')
113 revision = string.join(arr, '.')
115 # Here's how we'd turn the calculated $revision into our package $version.
116 # This makes it difficult to coordinate with other files (debian/changelog
117 # and rpm/scons.spec) that hard-code the version number, so just go with
118 # the flow for now and hard code it here, too.
122 # if str[0] == 'C' or str[0] == 'D':
124 # while len(str) > 2 and str[0] == '0':
127 #arr = map(lambda x, xxx=xxx: xxx(x), arr)
128 #version = string.join(arr, '.')
129 version = default_version
131 build_id = string.replace(revision, version + '.', '')
133 if ARGUMENTS.has_key('change'):
134 change = ARGUMENTS['change']
136 change = os.popen(aesub + " \\$change", "r").read()[:-1]
138 change = default_version
140 python_ver = sys.version[0:3]
142 platform = distutils.util.get_platform()
144 ENV = { 'PATH' : os.environ['PATH'] }
145 for key in ['AEGIS_PROJECT', 'PYTHONPATH']:
146 if os.environ.has_key(key):
147 ENV[key] = os.environ[key]
149 lib_project = os.path.join("lib", project)
151 cwd_build = os.path.join(os.getcwd(), "build")
153 test_deb_dir = os.path.join(cwd_build, "test-deb")
154 test_rpm_dir = os.path.join(cwd_build, "test-rpm")
155 test_tar_gz_dir = os.path.join(cwd_build, "test-tar-gz")
156 test_src_tar_gz_dir = os.path.join(cwd_build, "test-src-tar-gz")
157 test_local_tar_gz_dir = os.path.join(cwd_build, "test-local-tar-gz")
158 test_zip_dir = os.path.join(cwd_build, "test-zip")
159 test_src_zip_dir = os.path.join(cwd_build, "test-src-zip")
160 test_local_zip_dir = os.path.join(cwd_build, "test-local-zip")
162 unpack_tar_gz_dir = os.path.join(cwd_build, "unpack-tar-gz")
163 unpack_zip_dir = os.path.join(cwd_build, "unpack-zip")
165 if platform == "win32":
167 python_project_subinst_dir = None
168 project_script_subinst_dir = 'Scripts'
171 python_project_subinst_dir = lib_project
172 project_script_subinst_dir = 'bin'
178 # Figure out if we can handle .zip files.
185 def zipit(env, target, source):
186 print "Zipping %s:" % str(target[0])
187 def visit(arg, dirname, names):
189 path = os.path.join(dirname, name)
190 if os.path.isfile(path):
192 zf = zipfile.ZipFile(str(target[0]), 'w')
195 try: os.path.walk(env['PSV'], visit, zf)
196 finally: os.chdir(olddir)
199 def unzipit(env, target, source):
200 print "Unzipping %s:" % str(source[0])
201 zf = zipfile.ZipFile(str(source[0]), 'r')
202 for name in zf.namelist():
203 dest = os.path.join(env['UNPACK_ZIP_DIR'], name)
204 dir = os.path.dirname(dest)
210 # if the file exists, then delete it before writing
211 # to it so that we don't end up trying to write to a symlink:
212 if os.path.isfile(dest) or os.path.islink(dest):
214 if not os.path.isdir(dest):
215 open(dest, 'w').write(zf.read(name))
219 zipit = "cd $CD && $ZIP $ZIPFLAGS $( ${TARGET.abspath} $) $PSV"
220 unzipit = "$UNZIP $UNZIPFLAGS $SOURCES"
222 def SCons_revision(target, source, env):
223 """Interpolate specific values from the environment into a file.
225 This is used to copy files into a tree that gets packaged up
226 into the source file package.
232 for line in inf.readlines():
233 # Note: We construct the __*__ substitution strings here
234 # so that they don't get replaced when this file gets
235 # copied into the tree for packaging.
236 line = string.replace(line, '__BUILD' + '__', env['BUILD'])
237 line = string.replace(line, '__BUILDSYS' + '__', env['BUILDSYS'])
238 line = string.replace(line, '__COPYRIGHT' + '__', env['COPYRIGHT'])
239 line = string.replace(line, '__DATE' + '__', env['DATE'])
240 line = string.replace(line, '__DEVELOPER' + '__', env['DEVELOPER'])
241 line = string.replace(line, '__FILE' + '__', str(source[0]))
242 line = string.replace(line, '__REVISION' + '__', env['REVISION'])
243 line = string.replace(line, '__VERSION' + '__', env['VERSION'])
244 line = string.replace(line, '__NULL' + '__', '')
248 os.chmod(t, os.stat(s)[0])
250 revbuilder = Builder(action = Action(SCons_revision, varlist=['VERSION']))
256 BUILDSYS = build_system,
257 COPYRIGHT = copyright,
259 DEVELOPER = developer,
264 TAR_HFLAG = tar_hflag,
269 UNZIPFLAGS = '-o -d $UNPACK_ZIP_DIR',
274 RPM2CPIO = 'rpm2cpio',
276 TEST_DEB_DIR = test_deb_dir,
277 TEST_RPM_DIR = test_rpm_dir,
278 TEST_SRC_TAR_GZ_DIR = test_src_tar_gz_dir,
279 TEST_SRC_ZIP_DIR = test_src_zip_dir,
280 TEST_TAR_GZ_DIR = test_tar_gz_dir,
281 TEST_ZIP_DIR = test_zip_dir,
283 UNPACK_TAR_GZ_DIR = unpack_tar_gz_dir,
284 UNPACK_ZIP_DIR = unpack_zip_dir,
286 BUILDERS = { 'SCons_revision' : revbuilder },
288 PYTHON = sys.executable
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'
336 # The original packaging scheme would have have required us to push
337 # the Python version number into the package name (python1.5-scons,
338 # python2.0-scons, etc.), which would have required a definition
339 # like the following. Leave this here in case we ever decide to do
340 # this in the future, but note that this would require some modification
341 # to src/engine/setup.py before it would really work.
344 # 'pkg' : 'python2-' + project,
345 # 'src_subdir' : 'engine',
346 # 'inst_subdir' : os.path.join('lib', 'python2.1', 'site-packages'),
349 # 'debian/changelog',
351 # 'debian/copyright',
366 # 'LICENSE.txt' : '../LICENSE.txt',
372 'pkg' : project + '-script',
373 'src_subdir' : 'script',
374 'inst_subdir' : 'bin',
375 'rpm_dir' : '/usr/bin',
396 'LICENSE.txt' : '../LICENSE.txt',
397 'scons' : 'scons.py',
420 'os_spawnv_fix.diff',
428 'scons.1' : '../doc/man/scons.1',
431 'subpkgs' : [ python_scons, scons_script ],
434 'python-' + project : python_project_subinst_dir,
435 project + '-script' : project_script_subinst_dir,
444 # Initialize variables with the right directories for this package.
447 pkg_version = "%s-%s" % (pkg, version)
450 if p.has_key('src_subdir'):
451 src = os.path.join(src, p['src_subdir'])
453 build = os.path.join('build', pkg)
455 tar_gz = os.path.join(build, 'dist', "%s.tar.gz" % pkg_version)
456 platform_tar_gz = os.path.join(build,
458 "%s.%s.tar.gz" % (pkg_version, platform))
459 zip = os.path.join(build, 'dist', "%s.zip" % pkg_version)
460 platform_zip = os.path.join(build,
462 "%s.%s.zip" % (pkg_version, platform))
463 win32_exe = os.path.join(build, 'dist', "%s.win32.exe" % pkg_version)
466 # Update the environment with the relevant information
469 # We can get away with calling setup.py using a directory path
470 # like this because we put a preamble in it that will chdir()
471 # to the directory in which setup.py exists.
473 setup_py = os.path.join(build, 'setup.py')
474 env.Replace(PKG = pkg,
475 PKG_VERSION = pkg_version,
480 # Read up the list of source files from our MANIFEST.in.
481 # This list should *not* include LICENSE.txt, MANIFEST,
482 # README.txt, or setup.py. Make a copy of the list for the
485 manifest_in = File(os.path.join(src, 'MANIFEST.in')).rstr()
486 src_files = map(lambda x: x[:-1],
487 open(manifest_in).readlines())
488 raw_files = src_files[:]
489 dst_files = src_files[:]
492 MANIFEST_in_list = []
494 if p.has_key('subpkgs'):
496 # This package includes some sub-packages. Read up their
497 # MANIFEST.in files, and add them to our source and destination
498 # file lists, modifying them as appropriate to add the
501 for sp in p['subpkgs']:
502 ssubdir = sp['src_subdir']
503 isubdir = p['subinst_dirs'][sp['pkg']]
504 MANIFEST_in = File(os.path.join(src, ssubdir, 'MANIFEST.in')).rstr()
505 MANIFEST_in_list.append(MANIFEST_in)
506 files = map(lambda x: x[:-1], open(MANIFEST_in).readlines())
507 raw_files.extend(files)
508 src_files.extend(map(lambda x, s=ssubdir: os.path.join(s, x), files))
510 r = os.path.join(sp['rpm_dir'], f)
513 rpm_files.append(r + 'c')
515 files = map(lambda x, i=isubdir: os.path.join(i, x), files)
516 dst_files.extend(files)
517 for k in sp['filemap'].keys():
520 k = os.path.join(sp['src_subdir'], k)
521 p['filemap'][k] = os.path.join(sp['src_subdir'], f)
524 # Now that we have the "normal" source files, add those files
525 # that are standard for each distribution. Note that we don't
526 # add these to dst_files, because they don't get installed.
527 # And we still have the MANIFEST to add.
529 src_files.extend(p['files'])
532 # Now run everything in src_file through the sed command we
533 # concocted to expand __FILE__, __VERSION__, etc.
536 s = p['filemap'].get(b, b)
537 env.SCons_revision(os.path.join(build, b), os.path.join(src, s))
540 # NOW, finally, we can create the MANIFEST, which we do
541 # by having Python spit out the contents of the src_files
542 # array we've carefully created. After we've added
543 # MANIFEST itself to the array, of course.
545 src_files.append("MANIFEST")
546 MANIFEST_in_list.append(os.path.join(src, 'MANIFEST.in'))
548 def write_src_files(target, source, **kw):
551 f = open(str(target[0]), 'wb')
552 for file in src_files:
556 env.Command(os.path.join(build, 'MANIFEST'),
561 # Now go through and arrange to create whatever packages we can.
563 build_src_files = map(lambda x, b=build: os.path.join(b, x), src_files)
564 apply(Local, build_src_files, {})
566 distutils_formats = []
568 distutils_targets = [ win32_exe ]
570 install_targets = distutils_targets[:]
574 distutils_formats.append('gztar')
576 src_deps.append(tar_gz)
578 distutils_targets.extend([ tar_gz, platform_tar_gz ])
579 install_targets.extend([ tar_gz, platform_tar_gz ])
582 # Unpack the tar.gz archive created by the distutils into
583 # build/unpack-tar-gz/scons-{version}.
585 # We'd like to replace the last three lines with the following:
587 # tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
589 # but that gives heartburn to Cygwin's tar, so work around it
590 # with separate zcat-tar-rm commands.
592 unpack_tar_gz_files = map(lambda x, u=unpack_tar_gz_dir, pv=pkg_version:
593 os.path.join(u, pv, x),
595 env.Command(unpack_tar_gz_files, tar_gz, [
596 "rm -rf %s" % os.path.join(unpack_tar_gz_dir, pkg_version),
597 "$ZCAT $SOURCES > .temp",
598 "tar xf .temp -C $UNPACK_TAR_GZ_DIR",
603 # Run setup.py in the unpacked subdirectory to "install" everything
604 # into our build/test subdirectory. The runtest.py script will set
605 # PYTHONPATH so that the tests only look under build/test-{package},
606 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
607 # and unittest.py). This makes sure that our tests pass with what
608 # we really packaged, not because of something hanging around in
609 # the development directory.
611 # We can get away with calling setup.py using a directory path
612 # like this because we put a preamble in it that will chdir()
613 # to the directory in which setup.py exists.
615 dfiles = map(lambda x, d=test_tar_gz_dir: os.path.join(d, x), dst_files)
616 env.Command(dfiles, unpack_tar_gz_files, [
617 "rm -rf %s" % os.path.join(unpack_tar_gz_dir, pkg_version, 'build'),
618 "rm -rf $TEST_TAR_GZ_DIR",
619 "$PYTHON %s install --prefix=$TEST_TAR_GZ_DIR" % \
620 os.path.join(unpack_tar_gz_dir, pkg_version, 'setup.py'),
625 distutils_formats.append('zip')
629 distutils_targets.extend([ zip, platform_zip ])
630 install_targets.extend([ zip, platform_zip ])
633 # Unpack the zip archive created by the distutils into
634 # build/unpack-zip/scons-{version}.
636 unpack_zip_files = map(lambda x, u=unpack_zip_dir, pv=pkg_version:
637 os.path.join(u, pv, x),
640 env.Command(unpack_zip_files, zip, unzipit)
643 # Run setup.py in the unpacked subdirectory to "install" everything
644 # into our build/test subdirectory. The runtest.py script will set
645 # PYTHONPATH so that the tests only look under build/test-{package},
646 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
647 # and unittest.py). This makes sure that our tests pass with what
648 # we really packaged, not because of something hanging around in
649 # the development directory.
651 # We can get away with calling setup.py using a directory path
652 # like this because we put a preamble in it that will chdir()
653 # to the directory in which setup.py exists.
655 dfiles = map(lambda x, d=test_zip_dir: os.path.join(d, x), dst_files)
656 env.Command(dfiles, unpack_zip_files, [
657 "rm -rf %s" % os.path.join(unpack_zip_dir, pkg_version, 'build'),
658 "rm -rf $TEST_ZIP_DIR",
659 "$PYTHON %s install --prefix=$TEST_ZIP_DIR" % \
660 os.path.join(unpack_zip_dir, pkg_version, 'setup.py'),
664 topdir = os.path.join(os.getcwd(), build, 'build',
665 'bdist.' + platform, 'rpm')
667 BUILDdir = os.path.join(topdir, 'BUILD', pkg + '-' + version)
668 RPMSdir = os.path.join(topdir, 'RPMS', 'noarch')
669 SOURCESdir = os.path.join(topdir, 'SOURCES')
670 SPECSdir = os.path.join(topdir, 'SPECS')
671 SRPMSdir = os.path.join(topdir, 'SRPMS')
673 specfile_in = os.path.join('rpm', "%s.spec.in" % pkg)
674 specfile = os.path.join(SPECSdir, "%s-1.spec" % pkg_version)
675 sourcefile = os.path.join(SOURCESdir, "%s.tar.gz" % pkg_version);
676 noarch_rpm = os.path.join(RPMSdir, "%s-1.noarch.rpm" % pkg_version)
677 src_rpm = os.path.join(SRPMSdir, "%s-1.src.rpm" % pkg_version)
679 def spec_function(target, source, env):
680 """Generate the RPM .spec file from the template file.
682 This fills in the %files portion of the .spec file with a
683 list generated from our MANIFEST(s), so we don't have to
684 maintain multiple lists.
686 c = open(str(source[0]), 'rb').read()
687 c = string.replace(c, '__RPM_FILES__', env['RPM_FILES'])
688 open(str(target[0]), 'wb').write(c)
691 rpm_files_str = string.join(rpm_files, "\n") + "\n"
692 rpm_spec_env = env.Copy(RPM_FILES = rpm_files_str)
693 rpm_spec_action = Action(spec_function, varlist=['RPM_FILES'])
694 rpm_spec_env.Command(specfile, specfile_in, rpm_spec_action)
696 env.InstallAs(sourcefile, tar_gz)
698 targets = [ noarch_rpm, src_rpm ]
699 cmd = "$RPMBUILD --define '_topdir $(%s$)' -ba $SOURCES" % topdir
700 if not os.path.isdir(BUILDdir):
701 cmd = ("$( mkdir -p %s; $)" % BUILDdir) + cmd
702 env.Command(targets, specfile, cmd)
703 env.Depends(targets, sourcefile)
705 install_targets.extend(targets)
707 dfiles = map(lambda x, d=test_rpm_dir: os.path.join(d, 'usr', x),
711 "$RPM2CPIO $SOURCES | (cd $TEST_RPM_DIR && cpio -id)")
713 if dh_builddeb and fakeroot:
714 # Our Debian packaging builds directly into build/dist,
715 # so we don't need to add the .debs to install_targets.
716 deb = os.path.join('build', 'dist', "%s_%s-1_all.deb" % (pkg, version))
717 for d in p['debian_deps']:
718 b = env.SCons_revision(os.path.join(build, d), d)
721 env.Command(deb, build_src_files, [
722 "cd %s && fakeroot make -f debian/rules PYTHON=$PYTHON BUILDDEB_OPTIONS=--destdir=../../build/dist binary" % build,
725 old = os.path.join('lib', 'scons', '')
726 new = os.path.join('lib', 'python2.1', 'site-packages', '')
727 def xxx(s, old=old, new=new):
728 if s[:len(old)] == old:
729 s = new + s[len(old):]
730 return os.path.join('usr', s)
731 dfiles = map(lambda x, t=test_deb_dir: os.path.join(t, x),
735 "dpkg --fsys-tarfile $SOURCES | (cd $TEST_DEB_DIR && tar -xf -)")
739 # Generate portage files for submission to Gentoo Linux.
741 gentoo = os.path.join('build', 'gentoo')
742 ebuild = os.path.join(gentoo, 'scons-%s.ebuild' % version)
743 digest = os.path.join(gentoo, 'files', 'digest-scons-%s' % version)
744 env.Command(ebuild, os.path.join('gentoo', 'scons.ebuild.in'), SCons_revision)
745 def Digestify(target, source, env):
748 """Return a signature as a string of hex characters.
750 # NOTE: This routine is a method in the Python 2.0 interface
751 # of the native md5 module, but we want SCons to operate all
752 # the way back to at least Python 1.5.2, which doesn't have it.
757 r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
759 src = source[0].rfile()
760 contents = open(str(src)).read()
761 sig = hexdigest(md5.new(contents).digest())
762 bytes = os.stat(str(src))[6]
763 open(str(target[0]), 'w').write("MD5 %s %s %d\n" % (sig,
766 env.Command(digest, tar_gz, Digestify)
769 # Use the Python distutils to generate the appropriate packages.
772 "rm -rf %s" % os.path.join(build, 'build', 'lib'),
773 "rm -rf %s" % os.path.join(build, 'build', 'scripts'),
776 if distutils_formats:
777 commands.append("rm -rf %s" % os.path.join(build,
781 for format in distutils_formats:
782 commands.append("$PYTHON $SETUP_PY bdist_dumb -f %s" % format)
784 commands.append("$PYTHON $SETUP_PY sdist --formats=%s" % \
785 string.join(distutils_formats, ','))
787 commands.append("$PYTHON $SETUP_PY bdist_wininst")
789 env.Command(distutils_targets, build_src_files, commands)
792 # Now create local packages for people who want to let people
793 # build their SCons-buildable packages without having to
796 s_l_v = '%s-local-%s' % (pkg, version)
798 local = os.path.join('build', pkg + '-local')
799 cwd_local = os.path.join(os.getcwd(), local)
800 cwd_local_slv = os.path.join(os.getcwd(), local, s_l_v)
802 local_tar_gz = os.path.join('build', 'dist', "%s.tar.gz" % s_l_v)
803 local_zip = os.path.join('build', 'dist', "%s.zip" % s_l_v)
807 "$PYTHON $SETUP_PY install --install-script=%s --install-lib=%s --no-compile" % \
808 (cwd_local, cwd_local_slv),
809 "mv %s/scons %s/scons.py" % (local, local),
812 rf = filter(lambda x: x != "scons", raw_files)
813 rf = map(lambda x, slv=s_l_v: os.path.join(slv, x), rf)
814 rf.append("scons.py")
815 local_targets = map(lambda x, s=local: os.path.join(s, x), rf)
817 env.Command(local_targets, build_src_files, commands)
819 scons_LICENSE = os.path.join(local, 'scons-LICENSE')
820 env.SCons_revision(scons_LICENSE, 'LICENSE-local')
821 local_targets.append(scons_LICENSE)
823 scons_README = os.path.join(local, 'scons-README')
824 env.SCons_revision(scons_README, 'README-local')
825 local_targets.append(scons_README)
828 env.Command(local_tar_gz,
830 "cd %s && tar czf $( ${TARGET.abspath} $) *" % local)
832 unpack_targets = map(lambda x, d=test_local_tar_gz_dir:
835 commands = ["rm -rf %s" % test_local_tar_gz_dir,
836 "mkdir %s" % test_local_tar_gz_dir,
837 "cd %s && tar xzf $( ${SOURCE.abspath} $)" % test_local_tar_gz_dir]
839 env.Command(unpack_targets, local_tar_gz, commands)
842 zipenv = env.Copy(CD = local, PSV = '.')
843 zipenv.Command(local_zip, local_targets, zipit)
845 unpack_targets = map(lambda x, d=test_local_zip_dir:
848 commands = ["rm -rf %s" % test_local_zip_dir,
849 "mkdir %s" % test_local_zip_dir,
852 zipenv = env.Copy(UNPACK_ZIP_DIR = test_local_zip_dir)
853 zipenv.Command(unpack_targets, local_zip, unzipit)
856 # And, lastly, install the appropriate packages in the
857 # appropriate subdirectory.
859 b_d_files = env.Install(os.path.join('build', 'dist'), install_targets)
867 SConscript('etc/SConscript')
872 BuildDir('build/doc', 'doc')
874 Export('env', 'whereis')
876 SConscript('build/doc/SConscript')
879 # If we're running in the actual Aegis project, pack up a complete
880 # source archive from the project files and files in the change,
881 # so we can share it with helpful developers who don't use Aegis.
886 cmd = "aegis -list -unf -c %s cf 2>/dev/null" % change
887 for line in map(lambda x: x[:-1], os.popen(cmd, "r").readlines()):
888 a = string.split(line)
892 cmd = "aegis -list -terse pf 2>/dev/null"
893 pf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines())
894 cmd = "aegis -list -terse cf 2>/dev/null"
895 cf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines())
904 sfiles = filter(lambda x: x[-9:] != '.aeignore' and x[-9:] != '.sconsign',
908 ps = "%s-src" % project
909 psv = "%s-%s" % (ps, version)
910 b_ps = os.path.join('build', ps)
911 b_psv = os.path.join('build', psv)
912 b_psv_stamp = b_psv + '-stamp'
914 src_tar_gz = os.path.join('build', 'dist', '%s.tar.gz' % psv)
915 src_zip = os.path.join('build', 'dist', '%s.zip' % psv)
917 Local(src_tar_gz, src_zip)
920 env.SCons_revision(os.path.join(b_ps, file), file)
922 b_ps_files = map(lambda x, d=b_ps: os.path.join(d, x), sfiles)
925 "cp -rp %s %s" % (b_ps, b_psv),
926 "find %s -name .sconsign -exec rm {} \\;" % b_psv,
930 env.Command(b_psv_stamp, src_deps + b_ps_files, cmds)
932 apply(Local, b_ps_files, {})
936 env.Command(src_tar_gz, b_psv_stamp,
937 "tar cz${TAR_HFLAG} -f $TARGET -C build %s" % psv)
940 # Unpack the archive into build/unpack/scons-{version}.
942 unpack_tar_gz_files = map(lambda x, u=unpack_tar_gz_dir, psv=psv:
943 os.path.join(u, psv, x),
947 # We'd like to replace the last three lines with the following:
949 # tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
951 # but that gives heartburn to Cygwin's tar, so work around it
952 # with separate zcat-tar-rm commands.
953 env.Command(unpack_tar_gz_files, src_tar_gz, [
954 "rm -rf %s" % os.path.join(unpack_tar_gz_dir, psv),
955 "$ZCAT $SOURCES > .temp",
956 "tar xf .temp -C $UNPACK_TAR_GZ_DIR",
961 # Run setup.py in the unpacked subdirectory to "install" everything
962 # into our build/test subdirectory. The runtest.py script will set
963 # PYTHONPATH so that the tests only look under build/test-{package},
964 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
965 # and unittest.py). This makes sure that our tests pass with what
966 # we really packaged, not because of something hanging around in
967 # the development directory.
969 # We can get away with calling setup.py using a directory path
970 # like this because we put a preamble in it that will chdir()
971 # to the directory in which setup.py exists.
973 dfiles = map(lambda x, d=test_src_tar_gz_dir: os.path.join(d, x),
975 ENV = env.Dictionary('ENV')
976 ENV['SCONS_LIB_DIR'] = os.path.join(unpack_tar_gz_dir, psv, 'src', 'engine')
977 ENV['USERNAME'] = developer
978 env.Copy(ENV = ENV).Command(dfiles, unpack_tar_gz_files, [
979 "rm -rf %s" % os.path.join(unpack_tar_gz_dir,
984 "rm -rf $TEST_SRC_TAR_GZ_DIR",
985 "cd %s && $PYTHON %s %s" % \
986 (os.path.join(unpack_tar_gz_dir, psv),
987 os.path.join('src', 'script', 'scons.py'),
988 os.path.join('build', 'scons')),
989 "$PYTHON %s install --prefix=$TEST_SRC_TAR_GZ_DIR" % \
990 os.path.join(unpack_tar_gz_dir,
999 zipenv = env.Copy(CD = 'build', PSV = psv)
1000 zipenv.Command(src_zip, b_psv_stamp, zipit)
1003 # Unpack the archive into build/unpack/scons-{version}.
1005 unpack_zip_files = map(lambda x, u=unpack_zip_dir, psv=psv:
1006 os.path.join(u, psv, x),
1009 env.Command(unpack_zip_files, src_zip, unzipit)
1012 # Run setup.py in the unpacked subdirectory to "install" everything
1013 # into our build/test subdirectory. The runtest.py script will set
1014 # PYTHONPATH so that the tests only look under build/test-{package},
1015 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
1016 # and unittest.py). This makes sure that our tests pass with what
1017 # we really packaged, not because of something hanging around in
1018 # the development directory.
1020 # We can get away with calling setup.py using a directory path
1021 # like this because we put a preamble in it that will chdir()
1022 # to the directory in which setup.py exists.
1024 dfiles = map(lambda x, d=test_src_zip_dir: os.path.join(d, x),
1026 ENV = env.Dictionary('ENV')
1027 ENV['SCONS_LIB_DIR'] = os.path.join(unpack_zip_dir, psv, 'src', 'engine')
1028 ENV['USERNAME'] = developer
1029 env.Copy(ENV = ENV).Command(dfiles, unpack_zip_files, [
1030 "rm -rf %s" % os.path.join(unpack_zip_dir,
1035 "rm -rf $TEST_SRC_ZIP_DIR",
1036 "cd %s && $PYTHON %s %s" % \
1037 (os.path.join(unpack_zip_dir, psv),
1038 os.path.join('src', 'script', 'scons.py'),
1039 os.path.join('build', 'scons')),
1040 "$PYTHON %s install --prefix=$TEST_SRC_ZIP_DIR" % \
1041 os.path.join(unpack_zip_dir,