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.95'
43 copyright = "Copyright (c) %s The SCons Foundation" % 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', 'LOGNAME', '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.
230 contents = open(s, 'rb').read()
231 # Note: We construct the __*__ substitution strings here
232 # so that they don't get replaced when this file gets
233 # copied into the tree for packaging.
234 contents = string.replace(contents, '__BUILD' + '__', env['BUILD'])
235 contents = string.replace(contents, '__BUILDSYS' + '__', env['BUILDSYS'])
236 contents = string.replace(contents, '__COPYRIGHT' + '__', env['COPYRIGHT'])
237 contents = string.replace(contents, '__DATE' + '__', env['DATE'])
238 contents = string.replace(contents, '__DEVELOPER' + '__', env['DEVELOPER'])
239 contents = string.replace(contents, '__FILE' + '__', str(source[0]))
240 contents = string.replace(contents, '__REVISION' + '__', env['REVISION'])
241 contents = string.replace(contents, '__VERSION' + '__', env['VERSION'])
242 contents = string.replace(contents, '__NULL' + '__', '')
243 open(t, 'wb').write(contents)
244 os.chmod(t, os.stat(s)[0])
246 revbuilder = Builder(action = Action(SCons_revision,
247 varlist=['COPYRIGHT', 'VERSION']))
253 BUILDSYS = build_system,
254 COPYRIGHT = copyright,
256 DEVELOPER = developer,
261 TAR_HFLAG = tar_hflag,
266 UNZIPFLAGS = '-o -d $UNPACK_ZIP_DIR',
271 RPM2CPIO = 'rpm2cpio',
273 TEST_DEB_DIR = test_deb_dir,
274 TEST_RPM_DIR = test_rpm_dir,
275 TEST_SRC_TAR_GZ_DIR = test_src_tar_gz_dir,
276 TEST_SRC_ZIP_DIR = test_src_zip_dir,
277 TEST_TAR_GZ_DIR = test_tar_gz_dir,
278 TEST_ZIP_DIR = test_zip_dir,
280 UNPACK_TAR_GZ_DIR = unpack_tar_gz_dir,
281 UNPACK_ZIP_DIR = unpack_zip_dir,
283 BUILDERS = { 'SCons_revision' : revbuilder },
285 PYTHON = sys.executable
289 # Define SCons packages.
291 # In the original, more complicated packaging scheme, we were going
292 # to have separate packages for:
294 # python-scons only the build engine
295 # scons-script only the script
296 # scons the script plus the build engine
298 # We're now only delivering a single "scons" package, but this is still
299 # "built" as two sub-packages (the build engine and the script), so
300 # the definitions remain here, even though we're not using them for
305 'pkg' : 'python-' + project,
306 'src_subdir' : 'engine',
307 'inst_subdir' : os.path.join('lib', 'python1.5', 'site-packages'),
308 'rpm_dir' : '/usr/lib/scons',
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.2', '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',
372 'rpm_dir' : '/usr/bin',
393 'LICENSE.txt' : '../LICENSE.txt',
394 'scons' : 'scons.py',
395 'sconsign' : 'sconsign.py',
418 'os_spawnv_fix.diff',
427 'scons.1' : '../doc/man/scons.1',
428 'sconsign.1' : '../doc/man/sconsign.1',
431 'subpkgs' : [ python_scons, scons_script ],
434 'python-' + project : python_project_subinst_dir,
435 project + '-script' : project_script_subinst_dir,
439 scripts = ['scons', 'sconsign']
446 # Initialize variables with the right directories for this package.
449 pkg_version = "%s-%s" % (pkg, version)
452 if p.has_key('src_subdir'):
453 src = os.path.join(src, p['src_subdir'])
455 build = os.path.join('build', pkg)
457 tar_gz = os.path.join(build, 'dist', "%s.tar.gz" % pkg_version)
458 platform_tar_gz = os.path.join(build,
460 "%s.%s.tar.gz" % (pkg_version, platform))
461 zip = os.path.join(build, 'dist', "%s.zip" % pkg_version)
462 platform_zip = os.path.join(build,
464 "%s.%s.zip" % (pkg_version, platform))
465 win32_exe = os.path.join(build, 'dist', "%s.win32.exe" % pkg_version)
468 # Update the environment with the relevant information
471 # We can get away with calling setup.py using a directory path
472 # like this because we put a preamble in it that will chdir()
473 # to the directory in which setup.py exists.
475 setup_py = os.path.join(build, 'setup.py')
476 env.Replace(PKG = pkg,
477 PKG_VERSION = pkg_version,
482 # Read up the list of source files from our MANIFEST.in.
483 # This list should *not* include LICENSE.txt, MANIFEST,
484 # README.txt, or setup.py. Make a copy of the list for the
487 manifest_in = File(os.path.join(src, 'MANIFEST.in')).rstr()
488 src_files = map(lambda x: x[:-1],
489 open(manifest_in).readlines())
490 raw_files = src_files[:]
491 dst_files = src_files[:]
494 MANIFEST_in_list = []
496 if p.has_key('subpkgs'):
498 # This package includes some sub-packages. Read up their
499 # MANIFEST.in files, and add them to our source and destination
500 # file lists, modifying them as appropriate to add the
503 for sp in p['subpkgs']:
504 ssubdir = sp['src_subdir']
505 isubdir = p['subinst_dirs'][sp['pkg']]
506 MANIFEST_in = File(os.path.join(src, ssubdir, 'MANIFEST.in')).rstr()
507 MANIFEST_in_list.append(MANIFEST_in)
508 files = map(lambda x: x[:-1], open(MANIFEST_in).readlines())
509 raw_files.extend(files)
510 src_files.extend(map(lambda x, s=ssubdir: os.path.join(s, x), files))
512 r = os.path.join(sp['rpm_dir'], f)
515 rpm_files.append(r + 'c')
517 files = map(lambda x, i=isubdir: os.path.join(i, x), files)
518 dst_files.extend(files)
519 for k in sp['filemap'].keys():
522 k = os.path.join(sp['src_subdir'], k)
523 p['filemap'][k] = os.path.join(sp['src_subdir'], f)
526 # Now that we have the "normal" source files, add those files
527 # that are standard for each distribution. Note that we don't
528 # add these to dst_files, because they don't get installed.
529 # And we still have the MANIFEST to add.
531 src_files.extend(p['files'])
534 # Now run everything in src_file through the sed command we
535 # concocted to expand __FILE__, __VERSION__, etc.
538 s = p['filemap'].get(b, b)
539 env.SCons_revision(os.path.join(build, b), os.path.join(src, s))
542 # NOW, finally, we can create the MANIFEST, which we do
543 # by having Python spit out the contents of the src_files
544 # array we've carefully created. After we've added
545 # MANIFEST itself to the array, of course.
547 src_files.append("MANIFEST")
548 MANIFEST_in_list.append(os.path.join(src, 'MANIFEST.in'))
550 def write_src_files(target, source, **kw):
553 f = open(str(target[0]), 'wb')
554 for file in src_files:
558 env.Command(os.path.join(build, 'MANIFEST'),
563 # Now go through and arrange to create whatever packages we can.
565 build_src_files = map(lambda x, b=build: os.path.join(b, x), src_files)
566 apply(Local, build_src_files, {})
568 distutils_formats = []
570 distutils_targets = [ win32_exe ]
572 install_targets = distutils_targets[:]
576 distutils_formats.append('gztar')
578 src_deps.append(tar_gz)
580 distutils_targets.extend([ tar_gz, platform_tar_gz ])
581 install_targets.extend([ tar_gz, platform_tar_gz ])
584 # Unpack the tar.gz archive created by the distutils into
585 # build/unpack-tar-gz/scons-{version}.
587 # We'd like to replace the last three lines with the following:
589 # tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
591 # but that gives heartburn to Cygwin's tar, so work around it
592 # with separate zcat-tar-rm commands.
594 unpack_tar_gz_files = map(lambda x, u=unpack_tar_gz_dir, pv=pkg_version:
595 os.path.join(u, pv, x),
597 env.Command(unpack_tar_gz_files, tar_gz, [
598 "rm -rf %s" % os.path.join(unpack_tar_gz_dir, pkg_version),
599 "$ZCAT $SOURCES > .temp",
600 "tar xf .temp -C $UNPACK_TAR_GZ_DIR",
605 # Run setup.py in the unpacked subdirectory to "install" everything
606 # into our build/test subdirectory. The runtest.py script will set
607 # PYTHONPATH so that the tests only look under build/test-{package},
608 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
609 # and unittest.py). This makes sure that our tests pass with what
610 # we really packaged, not because of something hanging around in
611 # the development directory.
613 # We can get away with calling setup.py using a directory path
614 # like this because we put a preamble in it that will chdir()
615 # to the directory in which setup.py exists.
617 dfiles = map(lambda x, d=test_tar_gz_dir: os.path.join(d, x), dst_files)
618 env.Command(dfiles, unpack_tar_gz_files, [
619 "rm -rf %s" % os.path.join(unpack_tar_gz_dir, pkg_version, 'build'),
620 "rm -rf $TEST_TAR_GZ_DIR",
621 "$PYTHON %s install --prefix=$TEST_TAR_GZ_DIR" % \
622 os.path.join(unpack_tar_gz_dir, pkg_version, 'setup.py'),
627 distutils_formats.append('zip')
631 distutils_targets.extend([ zip, platform_zip ])
632 install_targets.extend([ zip, platform_zip ])
635 # Unpack the zip archive created by the distutils into
636 # build/unpack-zip/scons-{version}.
638 unpack_zip_files = map(lambda x, u=unpack_zip_dir, pv=pkg_version:
639 os.path.join(u, pv, x),
642 env.Command(unpack_zip_files, zip, [
643 "rm -rf %s" % os.path.join(unpack_zip_dir, pkg_version),
648 # Run setup.py in the unpacked subdirectory to "install" everything
649 # into our build/test subdirectory. The runtest.py script will set
650 # PYTHONPATH so that the tests only look under build/test-{package},
651 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
652 # and unittest.py). This makes sure that our tests pass with what
653 # we really packaged, not because of something hanging around in
654 # the development directory.
656 # We can get away with calling setup.py using a directory path
657 # like this because we put a preamble in it that will chdir()
658 # to the directory in which setup.py exists.
660 dfiles = map(lambda x, d=test_zip_dir: os.path.join(d, x), dst_files)
661 env.Command(dfiles, unpack_zip_files, [
662 "rm -rf %s" % os.path.join(unpack_zip_dir, pkg_version, 'build'),
663 "rm -rf $TEST_ZIP_DIR",
664 "$PYTHON %s install --prefix=$TEST_ZIP_DIR" % \
665 os.path.join(unpack_zip_dir, pkg_version, 'setup.py'),
669 topdir = os.path.join(os.getcwd(), build, 'build',
670 'bdist.' + platform, 'rpm')
672 BUILDdir = os.path.join(topdir, 'BUILD', pkg + '-' + version)
673 RPMSdir = os.path.join(topdir, 'RPMS', 'noarch')
674 SOURCESdir = os.path.join(topdir, 'SOURCES')
675 SPECSdir = os.path.join(topdir, 'SPECS')
676 SRPMSdir = os.path.join(topdir, 'SRPMS')
678 specfile_in = os.path.join('rpm', "%s.spec.in" % pkg)
679 specfile = os.path.join(SPECSdir, "%s-1.spec" % pkg_version)
680 sourcefile = os.path.join(SOURCESdir, "%s.tar.gz" % pkg_version);
681 noarch_rpm = os.path.join(RPMSdir, "%s-1.noarch.rpm" % pkg_version)
682 src_rpm = os.path.join(SRPMSdir, "%s-1.src.rpm" % pkg_version)
684 def spec_function(target, source, env):
685 """Generate the RPM .spec file from the template file.
687 This fills in the %files portion of the .spec file with a
688 list generated from our MANIFEST(s), so we don't have to
689 maintain multiple lists.
691 c = open(str(source[0]), 'rb').read()
692 c = string.replace(c, '__RPM_FILES__', env['RPM_FILES'])
693 open(str(target[0]), 'wb').write(c)
696 rpm_files_str = string.join(rpm_files, "\n") + "\n"
697 rpm_spec_env = env.Copy(RPM_FILES = rpm_files_str)
698 rpm_spec_action = Action(spec_function, varlist=['RPM_FILES'])
699 rpm_spec_env.Command(specfile, specfile_in, rpm_spec_action)
701 env.InstallAs(sourcefile, tar_gz)
704 targets = [ noarch_rpm, src_rpm ]
705 cmd = "$RPMBUILD --define '_topdir $(%s$)' -ba $SOURCES" % topdir
706 if not os.path.isdir(BUILDdir):
707 cmd = ("$( mkdir -p %s; $)" % BUILDdir) + cmd
708 env.Command(targets, specfile, cmd)
709 env.Depends(targets, sourcefile)
711 install_targets.extend(targets)
713 dfiles = map(lambda x, d=test_rpm_dir: os.path.join(d, 'usr', x),
717 "$RPM2CPIO $SOURCES | (cd $TEST_RPM_DIR && cpio -id)")
719 if dh_builddeb and fakeroot:
720 # Our Debian packaging builds directly into build/dist,
721 # so we don't need to add the .debs to install_targets.
722 deb = os.path.join('build', 'dist', "%s_%s-1_all.deb" % (pkg, version))
723 for d in p['debian_deps']:
724 b = env.SCons_revision(os.path.join(build, d), d)
727 env.Command(deb, build_src_files, [
728 "cd %s && fakeroot make -f debian/rules PYTHON=$PYTHON BUILDDEB_OPTIONS=--destdir=../../build/dist binary" % build,
731 old = os.path.join('lib', 'scons', '')
732 new = os.path.join('lib', 'python2.2', 'site-packages', '')
733 def xxx(s, old=old, new=new):
734 if s[:len(old)] == old:
735 s = new + s[len(old):]
736 return os.path.join('usr', s)
737 dfiles = map(lambda x, t=test_deb_dir: os.path.join(t, x),
741 "dpkg --fsys-tarfile $SOURCES | (cd $TEST_DEB_DIR && tar -xf -)")
745 # Generate portage files for submission to Gentoo Linux.
747 gentoo = os.path.join('build', 'gentoo')
748 ebuild = os.path.join(gentoo, 'scons-%s.ebuild' % version)
749 digest = os.path.join(gentoo, 'files', 'digest-scons-%s' % version)
750 env.Command(ebuild, os.path.join('gentoo', 'scons.ebuild.in'), SCons_revision)
751 def Digestify(target, source, env):
754 """Return a signature as a string of hex characters.
756 # NOTE: This routine is a method in the Python 2.0 interface
757 # of the native md5 module, but we want SCons to operate all
758 # the way back to at least Python 1.5.2, which doesn't have it.
763 r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
765 src = source[0].rfile()
766 contents = open(str(src)).read()
767 sig = hexdigest(md5.new(contents).digest())
768 bytes = os.stat(str(src))[6]
769 open(str(target[0]), 'w').write("MD5 %s %s %d\n" % (sig,
772 env.Command(digest, tar_gz, Digestify)
775 # Use the Python distutils to generate the appropriate packages.
778 "rm -rf %s" % os.path.join(build, 'build', 'lib'),
779 "rm -rf %s" % os.path.join(build, 'build', 'scripts'),
782 if distutils_formats:
783 commands.append("rm -rf %s" % os.path.join(build,
787 for format in distutils_formats:
788 commands.append("$PYTHON $SETUP_PY bdist_dumb -f %s" % format)
790 commands.append("$PYTHON $SETUP_PY sdist --formats=%s" % \
791 string.join(distutils_formats, ','))
793 commands.append("$PYTHON $SETUP_PY bdist_wininst")
795 env.Command(distutils_targets, build_src_files, commands)
798 # Now create local packages for people who want to let people
799 # build their SCons-buildable packages without having to
802 s_l_v = '%s-local-%s' % (pkg, version)
804 local = os.path.join('build', pkg + '-local')
805 cwd_local = os.path.join(os.getcwd(), local)
806 cwd_local_slv = os.path.join(os.getcwd(), local, s_l_v)
808 local_tar_gz = os.path.join('build', 'dist', "%s.tar.gz" % s_l_v)
809 local_zip = os.path.join('build', 'dist', "%s.zip" % s_l_v)
813 "$PYTHON $SETUP_PY install --install-script=%s --install-lib=%s --no-compile" % \
814 (cwd_local, cwd_local_slv),
817 for script in scripts:
818 commands.append("mv %s/%s %s/%s.py" % (local, script, local, script))
820 rf = filter(lambda x: not x in scripts, raw_files)
821 rf = map(lambda x, slv=s_l_v: os.path.join(slv, x), rf)
822 for script in scripts:
823 rf.append("%s.py" % script)
824 local_targets = map(lambda x, s=local: os.path.join(s, x), rf)
826 env.Command(local_targets, build_src_files, commands)
828 scons_LICENSE = os.path.join(local, 'scons-LICENSE')
829 env.SCons_revision(scons_LICENSE, 'LICENSE-local')
830 local_targets.append(scons_LICENSE)
832 scons_README = os.path.join(local, 'scons-README')
833 env.SCons_revision(scons_README, 'README-local')
834 local_targets.append(scons_README)
837 env.Command(local_tar_gz,
839 "cd %s && tar czf $( ${TARGET.abspath} $) *" % local)
841 unpack_targets = map(lambda x, d=test_local_tar_gz_dir:
844 commands = ["rm -rf %s" % test_local_tar_gz_dir,
845 "mkdir %s" % test_local_tar_gz_dir,
846 "cd %s && tar xzf $( ${SOURCE.abspath} $)" % test_local_tar_gz_dir]
848 env.Command(unpack_targets, local_tar_gz, commands)
851 env.Command(local_zip, local_targets, zipit,
852 CD = local, PSV = '.')
854 unpack_targets = map(lambda x, d=test_local_zip_dir:
857 commands = ["rm -rf %s" % test_local_zip_dir,
858 "mkdir %s" % test_local_zip_dir,
861 env.Command(unpack_targets, local_zip, unzipit,
862 UNPACK_ZIP_DIR = test_local_zip_dir)
865 # And, lastly, install the appropriate packages in the
866 # appropriate subdirectory.
868 b_d_files = env.Install(os.path.join('build', 'dist'), install_targets)
876 SConscript('etc/SConscript')
881 Export('env', 'whereis')
883 SConscript('doc/SConscript')
886 # If we're running in the actual Aegis project, pack up a complete
887 # source archive from the project files and files in the change,
888 # so we can share it with helpful developers who don't use Aegis.
893 cmd = "aegis -list -unf -c %s cf 2>/dev/null" % change
894 for line in map(lambda x: x[:-1], os.popen(cmd, "r").readlines()):
895 a = string.split(line)
899 cmd = "aegis -list -terse pf 2>/dev/null"
900 pf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines())
901 cmd = "aegis -list -terse cf 2>/dev/null"
902 cf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines())
911 sfiles = filter(lambda x: x[-9:] != '.aeignore' and x[-9:] != '.sconsign',
915 ps = "%s-src" % project
916 psv = "%s-%s" % (ps, version)
917 b_ps = os.path.join('build', ps)
918 b_psv = os.path.join('build', psv)
919 b_psv_stamp = b_psv + '-stamp'
921 src_tar_gz = os.path.join('build', 'dist', '%s.tar.gz' % psv)
922 src_zip = os.path.join('build', 'dist', '%s.zip' % psv)
924 Local(src_tar_gz, src_zip)
927 env.SCons_revision(os.path.join(b_ps, file), file)
929 b_ps_files = map(lambda x, d=b_ps: os.path.join(d, x), sfiles)
932 "cp -rp %s %s" % (b_ps, b_psv),
933 "find %s -name .sconsign -exec rm {} \\;" % b_psv,
937 env.Command(b_psv_stamp, src_deps + b_ps_files, cmds)
939 apply(Local, b_ps_files, {})
943 env.Command(src_tar_gz, b_psv_stamp,
944 "tar cz${TAR_HFLAG} -f $TARGET -C build %s" % psv)
947 # Unpack the archive into build/unpack/scons-{version}.
949 unpack_tar_gz_files = map(lambda x, u=unpack_tar_gz_dir, psv=psv:
950 os.path.join(u, psv, x),
954 # We'd like to replace the last three lines with the following:
956 # tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
958 # but that gives heartburn to Cygwin's tar, so work around it
959 # with separate zcat-tar-rm commands.
960 env.Command(unpack_tar_gz_files, src_tar_gz, [
961 "rm -rf %s" % os.path.join(unpack_tar_gz_dir, psv),
962 "$ZCAT $SOURCES > .temp",
963 "tar xf .temp -C $UNPACK_TAR_GZ_DIR",
968 # Run setup.py in the unpacked subdirectory to "install" everything
969 # into our build/test subdirectory. The runtest.py script will set
970 # PYTHONPATH so that the tests only look under build/test-{package},
971 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
972 # and unittest.py). This makes sure that our tests pass with what
973 # we really packaged, not because of something hanging around in
974 # the development directory.
976 # We can get away with calling setup.py using a directory path
977 # like this because we put a preamble in it that will chdir()
978 # to the directory in which setup.py exists.
980 dfiles = map(lambda x, d=test_src_tar_gz_dir: os.path.join(d, x),
982 scons_lib_dir = os.path.join(unpack_tar_gz_dir, psv, 'src', 'engine')
983 ENV = env.Dictionary('ENV').copy()
984 ENV['SCONS_LIB_DIR'] = scons_lib_dir
985 ENV['USERNAME'] = developer
986 env.Command(dfiles, unpack_tar_gz_files,
988 "rm -rf %s" % os.path.join(unpack_tar_gz_dir,
993 "rm -rf $TEST_SRC_TAR_GZ_DIR",
994 "cd %s && $PYTHON %s %s" % \
995 (os.path.join(unpack_tar_gz_dir, psv),
996 os.path.join('src', 'script', 'scons.py'),
997 os.path.join('build', 'scons')),
998 "$PYTHON %s install --prefix=$TEST_SRC_TAR_GZ_DIR" % \
999 os.path.join(unpack_tar_gz_dir,
1009 env.Command(src_zip, b_psv_stamp, zipit, CD = 'build', PSV = psv)
1012 # Unpack the archive into build/unpack/scons-{version}.
1014 unpack_zip_files = map(lambda x, u=unpack_zip_dir, psv=psv:
1015 os.path.join(u, psv, x),
1018 env.Command(unpack_zip_files, src_zip, [
1019 "rm -rf %s" % os.path.join(unpack_zip_dir, psv),
1024 # Run setup.py in the unpacked subdirectory to "install" everything
1025 # into our build/test subdirectory. The runtest.py script will set
1026 # PYTHONPATH so that the tests only look under build/test-{package},
1027 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
1028 # and unittest.py). This makes sure that our tests pass with what
1029 # we really packaged, not because of something hanging around in
1030 # the development directory.
1032 # We can get away with calling setup.py using a directory path
1033 # like this because we put a preamble in it that will chdir()
1034 # to the directory in which setup.py exists.
1036 dfiles = map(lambda x, d=test_src_zip_dir: os.path.join(d, x),
1038 scons_lib_dir = os.path.join(unpack_zip_dir, psv, 'src', 'engine')
1039 ENV = env.Dictionary('ENV').copy()
1040 ENV['SCONS_LIB_DIR'] = scons_lib_dir
1041 ENV['USERNAME'] = developer
1042 env.Command(dfiles, unpack_zip_files,
1044 "rm -rf %s" % os.path.join(unpack_zip_dir,
1049 "rm -rf $TEST_SRC_ZIP_DIR",
1050 "cd %s && $PYTHON %s %s" % \
1051 (os.path.join(unpack_zip_dir, psv),
1052 os.path.join('src', 'script', 'scons.py'),
1053 os.path.join('build', 'scons')),
1054 "$PYTHON %s install --prefix=$TEST_SRC_ZIP_DIR" % \
1055 os.path.join(unpack_zip_dir,