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',
405 'extra_rpm_files' : [
407 'sconsign-' + version,
411 'scons' : Version_values,
412 'sconsign' : Version_values,
435 'os_spawnv_fix.diff',
444 'scons.1' : '../doc/man/scons.1',
445 'sconsign.1' : '../doc/man/sconsign.1',
448 'subpkgs' : [ python_scons, scons_script ],
451 'python-' + project : python_project_subinst_dir,
452 project + '-script' : project_script_subinst_dir,
456 scripts = ['scons', 'sconsign']
463 # Initialize variables with the right directories for this package.
466 pkg_version = "%s-%s" % (pkg, version)
469 if p.has_key('src_subdir'):
470 src = os.path.join(src, p['src_subdir'])
472 build = os.path.join('build', pkg)
474 tar_gz = os.path.join(build, 'dist', "%s.tar.gz" % pkg_version)
475 platform_tar_gz = os.path.join(build,
477 "%s.%s.tar.gz" % (pkg_version, platform))
478 zip = os.path.join(build, 'dist', "%s.zip" % pkg_version)
479 platform_zip = os.path.join(build,
481 "%s.%s.zip" % (pkg_version, platform))
482 win32_exe = os.path.join(build, 'dist', "%s.win32.exe" % pkg_version)
485 # Update the environment with the relevant information
488 # We can get away with calling setup.py using a directory path
489 # like this because we put a preamble in it that will chdir()
490 # to the directory in which setup.py exists.
492 setup_py = os.path.join(build, 'setup.py')
493 env.Replace(PKG = pkg,
494 PKG_VERSION = pkg_version,
499 # Read up the list of source files from our MANIFEST.in.
500 # This list should *not* include LICENSE.txt, MANIFEST,
501 # README.txt, or setup.py. Make a copy of the list for the
504 manifest_in = File(os.path.join(src, 'MANIFEST.in')).rstr()
505 src_files = map(lambda x: x[:-1],
506 open(manifest_in).readlines())
507 raw_files = src_files[:]
508 dst_files = src_files[:]
511 MANIFEST_in_list = []
513 if p.has_key('subpkgs'):
515 # This package includes some sub-packages. Read up their
516 # MANIFEST.in files, and add them to our source and destination
517 # file lists, modifying them as appropriate to add the
520 for sp in p['subpkgs']:
521 ssubdir = sp['src_subdir']
522 isubdir = p['subinst_dirs'][sp['pkg']]
523 MANIFEST_in = File(os.path.join(src, ssubdir, 'MANIFEST.in')).rstr()
524 MANIFEST_in_list.append(MANIFEST_in)
525 files = map(lambda x: x[:-1], open(MANIFEST_in).readlines())
526 raw_files.extend(files)
527 src_files.extend(map(lambda x, s=ssubdir: os.path.join(s, x), files))
529 r = os.path.join(sp['rpm_dir'], f)
532 rpm_files.append(r + 'c')
533 for f in sp.get('extra_rpm_files', []):
534 r = os.path.join(sp['rpm_dir'], f)
536 files = map(lambda x, i=isubdir: os.path.join(i, x), files)
537 dst_files.extend(files)
538 for k, f in sp['filemap'].items():
540 k = os.path.join(ssubdir, k)
541 p['filemap'][k] = os.path.join(ssubdir, f)
542 for f, deps in sp['explicit_deps'].items():
543 f = os.path.join(build, ssubdir, f)
547 # Now that we have the "normal" source files, add those files
548 # that are standard for each distribution. Note that we don't
549 # add these to dst_files, because they don't get installed.
550 # And we still have the MANIFEST to add.
552 src_files.extend(p['files'])
555 # Now run everything in src_file through the sed command we
556 # concocted to expand __FILE__, __VERSION__, etc.
559 s = p['filemap'].get(b, b)
560 env.SCons_revision(os.path.join(build, b), os.path.join(src, s))
563 # NOW, finally, we can create the MANIFEST, which we do
564 # by having Python spit out the contents of the src_files
565 # array we've carefully created. After we've added
566 # MANIFEST itself to the array, of course.
568 src_files.append("MANIFEST")
569 MANIFEST_in_list.append(os.path.join(src, 'MANIFEST.in'))
571 def write_src_files(target, source, **kw):
574 f = open(str(target[0]), 'wb')
575 for file in src_files:
579 env.Command(os.path.join(build, 'MANIFEST'),
584 # Now go through and arrange to create whatever packages we can.
586 build_src_files = map(lambda x, b=build: os.path.join(b, x), src_files)
587 apply(Local, build_src_files, {})
589 distutils_formats = []
591 distutils_targets = [ win32_exe ]
593 install_targets = distutils_targets[:]
597 distutils_formats.append('gztar')
599 src_deps.append(tar_gz)
601 distutils_targets.extend([ tar_gz, platform_tar_gz ])
602 install_targets.extend([ tar_gz, platform_tar_gz ])
605 # Unpack the tar.gz archive created by the distutils into
606 # build/unpack-tar-gz/scons-{version}.
608 # We'd like to replace the last three lines with the following:
610 # tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
612 # but that gives heartburn to Cygwin's tar, so work around it
613 # with separate zcat-tar-rm commands.
615 unpack_tar_gz_files = map(lambda x, u=unpack_tar_gz_dir, pv=pkg_version:
616 os.path.join(u, pv, x),
618 env.Command(unpack_tar_gz_files, tar_gz, [
619 Delete(os.path.join(unpack_tar_gz_dir, pkg_version)),
620 "$ZCAT $SOURCES > .temp",
621 "tar xf .temp -C $UNPACK_TAR_GZ_DIR",
626 # Run setup.py in the unpacked subdirectory to "install" everything
627 # into our build/test subdirectory. The runtest.py script will set
628 # PYTHONPATH so that the tests only look under build/test-{package},
629 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
630 # and unittest.py). This makes sure that our tests pass with what
631 # we really packaged, not because of something hanging around in
632 # the development directory.
634 # We can get away with calling setup.py using a directory path
635 # like this because we put a preamble in it that will chdir()
636 # to the directory in which setup.py exists.
638 dfiles = map(lambda x, d=test_tar_gz_dir: os.path.join(d, x), dst_files)
639 env.Command(dfiles, unpack_tar_gz_files, [
640 Delete(os.path.join(unpack_tar_gz_dir, pkg_version, 'build')),
641 Delete("$TEST_TAR_GZ_DIR"),
642 '$PYTHON "%s" install "--prefix=$TEST_TAR_GZ_DIR" --standalone-lib' % \
643 os.path.join(unpack_tar_gz_dir, pkg_version, 'setup.py'),
647 # Generate portage files for submission to Gentoo Linux.
649 gentoo = os.path.join('build', 'gentoo')
650 ebuild = os.path.join(gentoo, 'scons-%s.ebuild' % version)
651 digest = os.path.join(gentoo, 'files', 'digest-scons-%s' % version)
652 env.Command(ebuild, os.path.join('gentoo', 'scons.ebuild.in'), SCons_revision)
653 def Digestify(target, source, env):
656 """Return a signature as a string of hex characters.
658 # NOTE: This routine is a method in the Python 2.0 interface
659 # of the native md5 module, but we want SCons to operate all
660 # the way back to at least Python 1.5.2, which doesn't have it.
665 r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
667 src = source[0].rfile()
668 contents = open(str(src)).read()
669 sig = hexdigest(md5.new(contents).digest())
670 bytes = os.stat(str(src))[6]
671 open(str(target[0]), 'w').write("MD5 %s %s %d\n" % (sig,
674 env.Command(digest, tar_gz, Digestify)
678 distutils_formats.append('zip')
682 distutils_targets.extend([ zip, platform_zip ])
683 install_targets.extend([ zip, platform_zip ])
686 # Unpack the zip archive created by the distutils into
687 # build/unpack-zip/scons-{version}.
689 unpack_zip_files = map(lambda x, u=unpack_zip_dir, pv=pkg_version:
690 os.path.join(u, pv, x),
693 env.Command(unpack_zip_files, zip, [
694 Delete(os.path.join(unpack_zip_dir, pkg_version)),
699 # Run setup.py in the unpacked subdirectory to "install" everything
700 # into our build/test subdirectory. The runtest.py script will set
701 # PYTHONPATH so that the tests only look under build/test-{package},
702 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
703 # and unittest.py). This makes sure that our tests pass with what
704 # we really packaged, not because of something hanging around in
705 # the development directory.
707 # We can get away with calling setup.py using a directory path
708 # like this because we put a preamble in it that will chdir()
709 # to the directory in which setup.py exists.
711 dfiles = map(lambda x, d=test_zip_dir: os.path.join(d, x), dst_files)
712 env.Command(dfiles, unpack_zip_files, [
713 Delete(os.path.join(unpack_zip_dir, pkg_version, 'build')),
714 Delete("$TEST_ZIP_DIR"),
715 '$PYTHON "%s" install "--prefix=$TEST_ZIP_DIR" --standalone-lib' % \
716 os.path.join(unpack_zip_dir, pkg_version, 'setup.py'),
720 topdir = os.path.join(os.getcwd(), build, 'build',
721 'bdist.' + platform, 'rpm')
723 BUILDdir = os.path.join(topdir, 'BUILD', pkg + '-' + version)
724 RPMSdir = os.path.join(topdir, 'RPMS', 'noarch')
725 SOURCESdir = os.path.join(topdir, 'SOURCES')
726 SPECSdir = os.path.join(topdir, 'SPECS')
727 SRPMSdir = os.path.join(topdir, 'SRPMS')
729 specfile_in = os.path.join('rpm', "%s.spec.in" % pkg)
730 specfile = os.path.join(SPECSdir, "%s-1.spec" % pkg_version)
731 sourcefile = os.path.join(SOURCESdir, "%s.tar.gz" % pkg_version);
732 noarch_rpm = os.path.join(RPMSdir, "%s-1.noarch.rpm" % pkg_version)
733 src_rpm = os.path.join(SRPMSdir, "%s-1.src.rpm" % pkg_version)
735 def spec_function(target, source, env):
736 """Generate the RPM .spec file from the template file.
738 This fills in the %files portion of the .spec file with a
739 list generated from our MANIFEST(s), so we don't have to
740 maintain multiple lists.
742 c = open(str(source[0]), 'rb').read()
743 c = string.replace(c, '__RPM_FILES__', env['RPM_FILES'])
744 open(str(target[0]), 'wb').write(c)
747 rpm_files_str = string.join(rpm_files, "\n") + "\n"
748 rpm_spec_env = env.Copy(RPM_FILES = rpm_files_str)
749 rpm_spec_action = Action(spec_function, varlist=['RPM_FILES'])
750 rpm_spec_env.Command(specfile, specfile_in, rpm_spec_action)
752 env.InstallAs(sourcefile, tar_gz)
755 targets = [ noarch_rpm, src_rpm ]
756 cmd = "$RPMBUILD --define '_topdir $(%s$)' -ba $SOURCES" % topdir
757 if not os.path.isdir(BUILDdir):
758 cmd = ("$( mkdir -p %s; $)" % BUILDdir) + cmd
759 env.Command(targets, specfile, cmd)
760 env.Depends(targets, sourcefile)
762 install_targets.extend(targets)
764 dfiles = map(lambda x, d=test_rpm_dir: os.path.join(d, 'usr', x),
768 "$RPM2CPIO $SOURCES | (cd $TEST_RPM_DIR && cpio -id)")
770 if dh_builddeb and fakeroot:
771 # Our Debian packaging builds directly into build/dist,
772 # so we don't need to add the .debs to install_targets.
773 deb = os.path.join('build', 'dist', "%s_%s-1_all.deb" % (pkg, version))
774 for d in p['debian_deps']:
775 b = env.SCons_revision(os.path.join(build, d), d)
778 env.Command(deb, build_src_files, [
779 "cd %s && fakeroot make -f debian/rules PYTHON=$PYTHON BUILDDEB_OPTIONS=--destdir=../../build/dist binary" % build,
782 old = os.path.join('lib', 'scons', '')
783 new = os.path.join('lib', 'python2.2', 'site-packages', '')
784 def xxx(s, old=old, new=new):
785 if s[:len(old)] == old:
786 s = new + s[len(old):]
787 return os.path.join('usr', s)
788 dfiles = map(lambda x, t=test_deb_dir: os.path.join(t, x),
792 "dpkg --fsys-tarfile $SOURCES | (cd $TEST_DEB_DIR && tar -xf -)")
796 # Use the Python distutils to generate the appropriate packages.
799 Delete(os.path.join(build, 'build', 'lib')),
800 Delete(os.path.join(build, 'build', 'scripts')),
803 if distutils_formats:
804 commands.append(Delete(os.path.join(build,
808 for format in distutils_formats:
809 commands.append("$PYTHON $SETUP_PY bdist_dumb -f %s" % format)
811 commands.append("$PYTHON $SETUP_PY sdist --formats=%s" % \
812 string.join(distutils_formats, ','))
814 commands.append("$PYTHON $SETUP_PY bdist_wininst")
816 env.Command(distutils_targets, build_src_files, commands)
819 # Now create local packages for people who want to let people
820 # build their SCons-buildable packages without having to
823 s_l_v = '%s-local-%s' % (pkg, version)
825 local = os.path.join('build', pkg + '-local')
826 cwd_local = os.path.join(os.getcwd(), local)
827 cwd_local_slv = os.path.join(os.getcwd(), local, s_l_v)
829 local_tar_gz = os.path.join('build', 'dist', "%s.tar.gz" % s_l_v)
830 local_zip = os.path.join('build', 'dist', "%s.zip" % s_l_v)
834 '$PYTHON $SETUP_PY install "--install-script=%s" "--install-lib=%s" --no-install-man --no-compile --standalone-lib --no-version-script' % \
835 (cwd_local, cwd_local_slv),
838 for script in scripts:
839 #commands.append("mv %s/%s %s/%s.py" % (local, script, local, script))
840 local_script = os.path.join(local, script)
841 commands.append(Move(local_script + '.py', local_script))
843 rf = filter(lambda x: not x in scripts, raw_files)
844 rf = map(lambda x, slv=s_l_v: os.path.join(slv, x), rf)
845 for script in scripts:
846 rf.append("%s.py" % script)
847 local_targets = map(lambda x, s=local: os.path.join(s, x), rf)
849 env.Command(local_targets, build_src_files, commands)
851 scons_LICENSE = os.path.join(local, 'scons-LICENSE')
852 env.SCons_revision(scons_LICENSE, 'LICENSE-local')
853 local_targets.append(scons_LICENSE)
855 scons_README = os.path.join(local, 'scons-README')
856 env.SCons_revision(scons_README, 'README-local')
857 local_targets.append(scons_README)
860 env.Command(local_tar_gz,
862 "cd %s && tar czf $( ${TARGET.abspath} $) *" % local)
864 unpack_targets = map(lambda x, d=test_local_tar_gz_dir:
867 commands = [Delete(test_local_tar_gz_dir),
868 Mkdir(test_local_tar_gz_dir),
869 "cd %s && tar xzf $( ${SOURCE.abspath} $)" % test_local_tar_gz_dir]
871 env.Command(unpack_targets, local_tar_gz, commands)
874 env.Command(local_zip, local_targets, zipit,
875 CD = local, PSV = '.')
877 unpack_targets = map(lambda x, d=test_local_zip_dir:
880 commands = [Delete(test_local_zip_dir),
881 Mkdir(test_local_zip_dir),
884 env.Command(unpack_targets, local_zip, unzipit,
885 UNPACK_ZIP_DIR = test_local_zip_dir)
888 # And, lastly, install the appropriate packages in the
889 # appropriate subdirectory.
891 b_d_files = env.Install(os.path.join('build', 'dist'), install_targets)
899 SConscript('etc/SConscript')
904 Export('env', 'whereis')
906 SConscript('doc/SConscript')
909 # If we're running in the actual Aegis project, pack up a complete
910 # source archive from the project files and files in the change,
911 # so we can share it with helpful developers who don't use Aegis.
916 cmd = "aegis -list -unf -c %s cf 2>/dev/null" % change
917 for line in map(lambda x: x[:-1], os.popen(cmd, "r").readlines()):
918 a = string.split(line)
922 cmd = "aegis -list -terse pf 2>/dev/null"
923 pf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines())
924 cmd = "aegis -list -terse -c %s cf 2>/dev/null" % change
925 cf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines())
934 sfiles = filter(lambda x: x[-9:] != '.aeignore' and
935 x[-9:] != '.sconsign' and
936 x[-10:] != '.cvsignore',
940 ps = "%s-src" % project
941 psv = "%s-%s" % (ps, version)
942 b_ps = os.path.join('build', ps)
943 b_psv = os.path.join('build', psv)
944 b_psv_stamp = b_psv + '-stamp'
946 src_tar_gz = os.path.join('build', 'dist', '%s.tar.gz' % psv)
947 src_zip = os.path.join('build', 'dist', '%s.zip' % psv)
949 Local(src_tar_gz, src_zip)
952 env.SCons_revision(os.path.join(b_ps, file), file)
954 b_ps_files = map(lambda x, d=b_ps: os.path.join(d, x), sfiles)
961 env.Command(b_psv_stamp, src_deps + b_ps_files, cmds)
963 apply(Local, b_ps_files, {})
967 env.Command(src_tar_gz, b_psv_stamp,
968 "tar cz${TAR_HFLAG} -f $TARGET -C build %s" % psv)
971 # Unpack the archive into build/unpack/scons-{version}.
973 unpack_tar_gz_files = map(lambda x, u=unpack_tar_gz_dir, psv=psv:
974 os.path.join(u, psv, x),
978 # We'd like to replace the last three lines with the following:
980 # tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
982 # but that gives heartburn to Cygwin's tar, so work around it
983 # with separate zcat-tar-rm commands.
984 env.Command(unpack_tar_gz_files, src_tar_gz, [
985 Delete(os.path.join(unpack_tar_gz_dir, psv)),
986 "$ZCAT $SOURCES > .temp",
987 "tar xf .temp -C $UNPACK_TAR_GZ_DIR",
992 # Run setup.py in the unpacked subdirectory to "install" everything
993 # into our build/test subdirectory. The runtest.py script will set
994 # PYTHONPATH so that the tests only look under build/test-{package},
995 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
996 # and unittest.py). This makes sure that our tests pass with what
997 # we really packaged, not because of something hanging around in
998 # the development directory.
1000 # We can get away with calling setup.py using a directory path
1001 # like this because we put a preamble in it that will chdir()
1002 # to the directory in which setup.py exists.
1004 dfiles = map(lambda x, d=test_src_tar_gz_dir: os.path.join(d, x),
1006 scons_lib_dir = os.path.join(unpack_tar_gz_dir, psv, 'src', 'engine')
1007 ENV = env.Dictionary('ENV').copy()
1008 ENV['SCONS_LIB_DIR'] = scons_lib_dir
1009 ENV['USERNAME'] = developer
1010 env.Command(dfiles, unpack_tar_gz_files,
1012 Delete(os.path.join(unpack_tar_gz_dir,
1017 Delete("$TEST_SRC_TAR_GZ_DIR"),
1018 'cd "%s" && $PYTHON "%s" "%s"' % \
1019 (os.path.join(unpack_tar_gz_dir, psv),
1020 os.path.join('src', 'script', 'scons.py'),
1021 os.path.join('build', 'scons')),
1022 '$PYTHON "%s" install "--prefix=$TEST_SRC_TAR_GZ_DIR" --standalone-lib' % \
1023 os.path.join(unpack_tar_gz_dir,
1033 env.Command(src_zip, b_psv_stamp, zipit, CD = 'build', PSV = psv)
1036 # Unpack the archive into build/unpack/scons-{version}.
1038 unpack_zip_files = map(lambda x, u=unpack_zip_dir, psv=psv:
1039 os.path.join(u, psv, x),
1042 env.Command(unpack_zip_files, src_zip, [
1043 Delete(os.path.join(unpack_zip_dir, psv)),
1048 # Run setup.py in the unpacked subdirectory to "install" everything
1049 # into our build/test subdirectory. The runtest.py script will set
1050 # PYTHONPATH so that the tests only look under build/test-{package},
1051 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
1052 # and unittest.py). This makes sure that our tests pass with what
1053 # we really packaged, not because of something hanging around in
1054 # the development directory.
1056 # We can get away with calling setup.py using a directory path
1057 # like this because we put a preamble in it that will chdir()
1058 # to the directory in which setup.py exists.
1060 dfiles = map(lambda x, d=test_src_zip_dir: os.path.join(d, x),
1062 scons_lib_dir = os.path.join(unpack_zip_dir, psv, 'src', 'engine')
1063 ENV = env.Dictionary('ENV').copy()
1064 ENV['SCONS_LIB_DIR'] = scons_lib_dir
1065 ENV['USERNAME'] = developer
1066 env.Command(dfiles, unpack_zip_files,
1068 Delete(os.path.join(unpack_zip_dir,
1073 Delete("$TEST_SRC_ZIP_DIR"),
1074 'cd "%s" && $PYTHON "%s" "%s"' % \
1075 (os.path.join(unpack_zip_dir, psv),
1076 os.path.join('src', 'script', 'scons.py'),
1077 os.path.join('build', 'scons')),
1078 '$PYTHON "%s" install "--prefix=$TEST_SRC_ZIP_DIR" --standalone-lib' % \
1079 os.path.join(unpack_zip_dir,