From 755fe44095622d2ed2ac7a469686286212ea6f3c Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Wed, 24 Apr 2002 16:11:40 +0000 Subject: Make Alias work with -U, -u, and -D (Anthony Roach) --- src/CHANGES.txt | 2 ++ src/engine/SCons/Node/Alias.py | 6 ++++++ test/option--D.py | 17 +++++++++++++++-- test/option--U.py | 19 +++++++++++++++++-- test/option-u.py | 8 ++++++-- 5 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 41b5899..ce10511 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -122,6 +122,8 @@ RELEASE 0.07 - - Fixed use of sys.path so Python modules can be imported from the SConscript directory. + - Fix for using Aliases with the -u, -U and -D options. + From Moshe Zadka: - Changes for official Debian packaging. diff --git a/src/engine/SCons/Node/Alias.py b/src/engine/SCons/Node/Alias.py index 31f0a9b..c6159da 100644 --- a/src/engine/SCons/Node/Alias.py +++ b/src/engine/SCons/Node/Alias.py @@ -87,6 +87,12 @@ class Alias(SCons.Node.Node): def sconsign(self): """An Alias is not recorded in .sconsign files""" pass + + def is_under(self, dir): + # Make Alias nodes get built regardless of + # what directory scons was run from. Alias nodes + # are outside the filesystem: + return 1 default_ans = AliasNameSpace() diff --git a/test/option--D.py b/test/option--D.py index 572cd65..b1d06b0 100644 --- a/test/option--D.py +++ b/test/option--D.py @@ -26,6 +26,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import sys import TestSCons +import os python = sys.executable @@ -42,8 +43,9 @@ file.close() """) test.write('SConstruct', """ +import SCons.Defaults B = Builder(name='B', action='%s build.py $TARGET $SOURCES') -env = Environment(BUILDERS = [B]) +env = Environment(BUILDERS = [B, SCons.Defaults.Alias]) env.B(target = 'sub1/foo.out', source = 'sub1/foo.in') Export('env') SConscript('sub1/SConscript') @@ -60,8 +62,9 @@ test.write(['sub1', 'foo.in'], "sub1/foo.in") test.write(['sub2', 'SConscript'], """ Import('env') -env.B(target = 'bar.out', source = 'bar.in') +env.Alias('bar', env.B(target = 'bar.out', source = 'bar.in')) Default('.') + """) test.write(['sub2', 'bar.in'], "sub2/bar.in") @@ -71,5 +74,15 @@ test.run(arguments = '-D', chdir = 'sub1') test.fail_test(test.read(['sub1', 'foo.out']) != "sub1/foo.in") test.fail_test(test.read(['sub2', 'bar.out']) != "sub2/bar.in") +test.unlink(['sub1', 'foo.out']) +test.unlink(['sub2', 'bar.out']) + +test.run(arguments = '-D bar', chdir = 'sub1') + +test.fail_test(os.path.exists(test.workpath('sub1', 'foo.out'))) +test.fail_test(not os.path.exists(test.workpath('sub2', 'bar.out'))) + + + test.pass_test() diff --git a/test/option--U.py b/test/option--U.py index 128e6c1..7f3e3f2 100644 --- a/test/option--U.py +++ b/test/option--U.py @@ -44,8 +44,9 @@ file.close() """) test.write('SConstruct', """ +import SCons.Defaults B = Builder(name='B', action='%s build.py $TARGET $SOURCES') -env = Environment(BUILDERS = [B]) +env = Environment(BUILDERS = [B, SCons.Defaults.Alias]) Default(env.B(target = 'sub1/foo.out', source = 'sub1/foo.in')) Export('env') SConscript('sub2/SConscript') @@ -57,7 +58,9 @@ Default(env.B(target = 'sub2/xxx.out', source = 'xxx.in')) test.write(['sub2', 'SConscript'], """ Import('env') -Default(env.B(target = 'bar.out', source = 'bar.in')) +bar = env.B(target = 'bar.out', source = 'bar.in') +Default(bar) +env.Alias('bar', bar) Default(env.B(target = '../bar.out', source = 'bar.in')) """) @@ -106,5 +109,17 @@ test.fail_test(not os.path.exists(test.workpath('sub3', 'baz.out'))) test.fail_test(os.path.exists(test.workpath('bar.out'))) test.fail_test(not os.path.exists(test.workpath('sub2/xxx.out'))) +test.unlink(['sub1', 'foo.out']) +test.unlink(['sub3', 'baz.out']) +test.unlink(['sub2', 'xxx.out']) + +test.run(chdir = 'sub3', arguments='-U bar') +test.fail_test(os.path.exists(test.workpath('sub1', 'foo.out'))) +test.fail_test(not os.path.exists(test.workpath('sub2', 'bar.out'))) +test.fail_test(not os.path.exists(test.workpath('sub2b', 'bar.out'))) +test.fail_test(os.path.exists(test.workpath('sub3', 'baz.out'))) +test.fail_test(os.path.exists(test.workpath('bar.out'))) +test.fail_test(os.path.exists(test.workpath('sub2/xxx.out'))) + test.pass_test() diff --git a/test/option-u.py b/test/option-u.py index dbeec6a..8f23746 100644 --- a/test/option-u.py +++ b/test/option-u.py @@ -44,13 +44,14 @@ file.close() """) test.write('SConstruct', """ +import SCons.Defaults B = Builder(name='B', action='%s build.py $TARGET $SOURCES') -env = Environment(BUILDERS = [B]) +env = Environment(BUILDERS = [B, SCons.Defaults.Alias]) env.B(target = 'sub1/foo.out', source = 'sub1/foo.in') Default('.') Export('env') SConscript('sub2/SConscript') -env.B(target = 'sub3/baz.out', source = 'sub3/baz.in') +env.Alias('baz', env.B(target = 'sub3/baz.out', source = 'sub3/baz.in')) """ % python) test.write(['sub2', 'SConscript'], """ @@ -73,5 +74,8 @@ test.run(chdir = 'sub2', arguments = '-u') test.fail_test(test.read(['sub2', 'bar.out']) != "sub2/bar.in") test.fail_test(os.path.exists(test.workpath('sub3', 'baz.out'))) +test.run(chdir = 'sub2', arguments = '-u baz') +test.fail_test(test.read(['sub3', 'baz.out']) != "sub3/baz.in") + test.pass_test() -- cgit v0.12