Add Alias() global function. (Anthony Roach)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 18 Apr 2003 03:39:08 +0000 (03:39 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 18 Apr 2003 03:39:08 +0000 (03:39 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@650 fdb21ef1-2011-0410-befe-b5e4ea1792b1

doc/man/scons.1
src/CHANGES.txt
src/engine/SCons/Script/SConscript.py
test/Alias.py

index 9f5d7f89b69b95723950109e14f19eef9d1d833d..27dd9a7f6a0cb4054552bbe0dd6870fec21b71b0 100644 (file)
@@ -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
index eb385e332856f063f059fb8a57e0a8e8e7d42eed..2f3ffbd0fc2e2aac1cc05d7a6c95031dbd8e477e 100644 (file)
@@ -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.
index 7c207324a624c4c8566d11883d2a298dc1608125..1c9d2b2e7fe3f460466f6e99a858f7cdc373dc59 100644 (file)
@@ -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
index 6608d72c422c288d0057b9a284f3999512c3ad12..ea9465269ebedbc33af3794c2c8ba25d8072ba0d 100644 (file)
@@ -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'], """