Arrange for local copies of files in build/ so the Aegis build will continue to work.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 12 Nov 2002 04:24:15 +0000 (04:24 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 12 Nov 2002 04:24:15 +0000 (04:24 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@493 fdb21ef1-2011-0410-befe-b5e4ea1792b1

SConstruct
src/engine/SCons/Node/FS.py
src/engine/SCons/Node/FSTests.py
test/Repository/Local.py

index 15e0db48509f2b0f8d9d1a78340193b2ade4cd53..143f1a6bce93a76e3ec415f0c0aaa406166964e1 100644 (file)
@@ -461,9 +461,11 @@ for p in [ scons ]:
     # like this because we put a preamble in it that will chdir()
     # to the directory in which setup.py exists.
     #
+    setup_py = os.path.join(build, 'setup.py')
     env.Update(PKG = pkg,
                PKG_VERSION = pkg_version,
-               SETUP_PY = os.path.join(build, 'setup.py'))
+               SETUP_PY = setup_py)
+    Local(setup_py)
 
     #
     # Read up the list of source files from our MANIFEST.in.
@@ -540,6 +542,7 @@ for p in [ scons ]:
     # Now go through and arrange to create whatever packages we can.
     #
     build_src_files = map(lambda x, b=build: os.path.join(b, x), src_files)
+    apply(Local, build_src_files, {})
 
     distutils_formats = []
 
@@ -678,6 +681,7 @@ for p in [ scons ]:
         for d in p['debian_deps']:
             b = env.SCons_revision(os.path.join(build, d), d)
             env.Depends(deb, b)
+            Local(b)
         env.Command(deb, build_src_files, [
             "cd %s && fakeroot make -f debian/rules PYTHON=$PYTHON BUILDDEB_OPTIONS=--destdir=../../build/dist binary" % build,
                     ])
@@ -788,6 +792,8 @@ if change:
 
         env.Command(b_psv_stamp, src_deps + b_ps_files, cmds)
 
+        apply(Local, b_ps_files, {})
+
         if gzip:
 
             env.Command(src_tar_gz, b_psv_stamp,
index fac962711606f922df7d4a7315a8b28aa2f85d43..3b0e6ca34ef345f8c3106268dcf9f3aa6aeabb8d 100644 (file)
@@ -45,15 +45,21 @@ import SCons.Warnings
 
 try:
     import os
-    file_link = os.link
+    _link = os.link
 except AttributeError:
     import shutil
     import stat
-    def file_link(src, dest):
+    def _link(src, dest):
         shutil.copy2(src, dest)
         st=os.stat(src)
         os.chmod(dest, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE)
 
+def file_link(src, dest):
+    dir, file = os.path.split(dest)
+    if dir and not os.path.isdir(dir):
+        os.makedirs(dir)
+    _link(src, dest)
+
 class ParentOfRoot:
     """
     An instance of this class is used as the parent of the root of a
@@ -735,7 +741,8 @@ class File(Entry):
     def _morph(self):
         """Turn a file system node into a File object."""
         self.created = 0
-        self._local = 0
+        if not hasattr(self, '_local'):
+            self._local = 0
 
     def root(self):
         return self.dir.root()
@@ -861,8 +868,7 @@ class File(Entry):
                 except OSError:
                     pass
                 self.__createDir()
-                file_link(src.abspath,
-                          self.abspath)
+                file_link(src.abspath, self.abspath)
                 self.created = 1
 
                 # Set our exists cache accordingly
index 8f9f5e4406e7a0a4bdf6dc8312b0c501cbe731f6..9e6e095c97979af0980b605ad8b9b268dcd4e82c 100644 (file)
@@ -631,6 +631,15 @@ class FSTestCase(unittest.TestCase):
         f1.prepare()
         assert not os.path.exists(test.workpath("remove_me"))
 
+        e = fs.Entry('e_local')
+        assert not hasattr(e, '_local')
+        e.set_local()
+        assert e._local == 1
+        f = fs.File('e_local')
+        assert f._local == 1
+        f = fs.File('f_local')
+        assert f._local == 0
+
         #XXX test current() for directories
 
         #XXX test sconsign() for directories
index 67f43cf3febbee4be64079294d543558561f96ee..033fb710dad6781b6cf4a8cddcfa62e684c1feac 100644 (file)
@@ -30,10 +30,16 @@ import TestSCons
 
 test = TestSCons.TestSCons()
 
-test.subdir('repository', 'work')
+test.subdir('repository', ['repository', 'src'],
+            'work', ['work', 'src'])
 
+repository_aaa_out = test.workpath('repository', 'aaa.out')
+repository_build_bbb_1 = test.workpath('repository', 'build', 'bbb.1')
+repository_build_bbb_2 = test.workpath('repository', 'build', 'bbb.2')
 work_aaa_mid = test.workpath('work', 'aaa.mid')
 work_aaa_out = test.workpath('work', 'aaa.out')
+work_build_bbb_1 = test.workpath('work', 'build', 'bbb.1')
+work_build_bbb_2 = test.workpath('work', 'build', 'bbb.2')
 
 opts = "-Y " + test.workpath('repository')
 
@@ -50,24 +56,48 @@ env = Environment(BUILDERS={'Build':Build})
 env.Build('aaa.mid', 'aaa.in')
 env.Build('aaa.out', 'aaa.mid')
 Local('aaa.out')
+
+Export("env")
+BuildDir('build', 'src')
+SConscript('build/SConscript')
+""")
+
+test.write(['repository', 'src', 'SConscript'], r"""
+def bbb_copy(env, source, target):
+    target = str(target[0])
+    print 'bbb_copy()'
+    open(target, "wb").write(open('build/bbb.1', "rb").read())
+
+Import("env")
+env.Build('bbb.1', 'bbb.0')
+Local('bbb.1')
+env.Command('bbb.2', 'bbb.x', bbb_copy)
+env.Depends('bbb.2', 'bbb.1')
 """)
 
 test.write(['repository', 'aaa.in'], "repository/aaa.in\n")
+test.write(['repository', 'src', 'bbb.0'], "repository/src/bbb.0\n")
+test.write(['repository', 'src', 'bbb.x'], "repository/src/bbb.x\n")
 
 #
 test.run(chdir = 'repository', options = opts, arguments = '.')
 
+test.fail_test(test.read(repository_aaa_out) != "repository/aaa.in\n")
+test.fail_test(test.read(repository_build_bbb_2) != "repository/src/bbb.0\n")
+
+test.up_to_date(chdir = 'repository', options = opts, arguments = '.')
+
 # Make the entire repository non-writable, so we'll detect
 # if we try to write into it accidentally.
 test.writable('repository', 0)
 
-test.up_to_date(chdir = 'repository', options = opts, arguments = '.')
-
 #
-test.run(chdir = 'work', options = opts, arguments = '.')
+test.run(chdir = 'work', options = opts, arguments = 'aaa.out build/bbb.2')
 
 test.fail_test(os.path.exists(work_aaa_mid))
 test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n")
+test.fail_test(test.read(work_build_bbb_1) != "repository/src/bbb.0\n")
+test.fail_test(os.path.exists(work_build_bbb_2))
 
 #
 test.write(['work', 'aaa.in'], "work/aaa.in\n")