From: stevenknight Date: Tue, 12 Nov 2002 04:24:15 +0000 (+0000) Subject: Arrange for local copies of files in build/ so the Aegis build will continue to work. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a5ff490c2ff3471be7e60bd77c7e8696849e1ca6;p=scons.git Arrange for local copies of files in build/ so the Aegis build will continue to work. git-svn-id: http://scons.tigris.org/svn/scons/trunk@493 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/SConstruct b/SConstruct index 15e0db48..143f1a6b 100644 --- a/SConstruct +++ b/SConstruct @@ -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, diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index fac96271..3b0e6ca3 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -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 diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 8f9f5e44..9e6e095c 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -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 diff --git a/test/Repository/Local.py b/test/Repository/Local.py index 67f43cf3..033fb710 100644 --- a/test/Repository/Local.py +++ b/test/Repository/Local.py @@ -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")