From bf4b91b352d6c14d9aebdcebe2b05a73723eea5f Mon Sep 17 00:00:00 2001 From: stevenknight Date: Fri, 18 Apr 2003 03:39:08 +0000 Subject: [PATCH] Add Alias() global function. (Anthony Roach) git-svn-id: http://scons.tigris.org/svn/scons/trunk@650 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- doc/man/scons.1 | 12 +++++++++++- src/CHANGES.txt | 4 ++++ src/engine/SCons/Script/SConscript.py | 9 +++++++++ test/Alias.py | 11 +++++++++-- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 9f5d7f89..27dd9a7f 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -1445,7 +1445,9 @@ which exists outside of any file system. This Node object, or the alias name, may be used as a dependency of any other target, including another alias. Alias can be called multiple times for the same -alias to add additional targets to the alias. +alias to add additional targets to the alias. There is also an Alias +global function for creating or referencing an alias independently of +any construction environment. .ES env.Alias('install', ['/usr/local/bin', '/usr/local/lib']) @@ -3007,6 +3009,14 @@ an Action object, or anything that can be converted into an Action object (see below). +.TP +.RI Alias ( name ) +Creates or references an alias independent of the construction environment. + +.ES +Alias('install') +.EE + .TP .RI BuildDir( build_dir ", " src_dir ", [" duplicate ]) This specifies a build directory diff --git a/src/CHANGES.txt b/src/CHANGES.txt index eb385e33..2f3ffbd0 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -65,6 +65,10 @@ RELEASE 0.14 - XXX - Add support for using Ghostscript to convert Postscript to PDF files. + From Anthony Roach: + + - Add a standalone "Alias" function (separate from an Environment). + From Greg Spencer: - Support the C preprocessor #import statement. diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 7c207324..1c9d2b2e 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -43,6 +43,7 @@ import SCons.Tool import SCons.Util import SCons.Options import SCons +import SCons.Node.Alias import os import os.path @@ -461,6 +462,13 @@ def AddPostAction(files, action): def Exit(value=0): sys.exit(value) + +def Alias(name): + alias = SCons.Node.Alias.default_ans.lookup(name) + if alias is None: + alias = SCons.Node.Alias.default_ans.Alias(name) + return alias + def BuildDefaultGlobals(): """ Create a dictionary containing all the default globals for @@ -519,4 +527,5 @@ def BuildDefaultGlobals(): globals['TargetSignatures'] = TargetSignatures globals['Tool'] = SCons.Tool.Tool globals['WhereIs'] = SCons.Util.WhereIs + globals['Alias'] = Alias return globals diff --git a/test/Alias.py b/test/Alias.py index 6608d72c..ea946526 100644 --- a/test/Alias.py +++ b/test/Alias.py @@ -50,11 +50,18 @@ env.B(target = 'f2.out', source = 'f2.in') env.B(target = 'f3.out', source = 'f3.in') SConscript('sub1/SConscript', "env") SConscript('sub2/SConscript', "env") -env.Alias('foo', ['f2.out', 'sub1']) -env.Alias('bar', ['sub2', 'f3.out']) + +foo = Alias('foo') +foo2 = env.Alias('foo', ['f2.out', 'sub1']) +assert foo == foo2 +bar = env.Alias('bar', ['sub2', 'f3.out']) env.Alias('blat', ['sub2', 'f3.out']) env.Alias('blat', ['f2.out', 'sub1']) env.Depends('f1.out', 'bar') + +assert Alias('foo') == foo +assert Alias('bar') == bar + """ % python) test.write(['sub1', 'SConscript'], """ -- 2.26.2