[Avida-SVN] r1040 - in development: . source source/third-party source/tools support/scons support/scons/scons-local-0.96.1 support/scons/scons-local-0.96.1/SCons support/scons/scons-local-0.96.1/SCons/Node support/scons/scons-local-0.96.1/SCons/Optik support/scons/scons-local-0.96.1/SCons/Options support/scons/scons-local-0.96.1/SCons/Platform support/scons/scons-local-0.96.1/SCons/Scanner support/scons/scons-local-0.96.1/SCons/Script support/scons/scons-local-0.96.1/SCons/Sig support/scons/scons-local-0.96.1/SCons/Tool support/utils/AvidaUtils
avidaedward at myxo.css.msu.edu
avidaedward at myxo.css.msu.edu
Thu Oct 12 12:23:39 PDT 2006
Author: avidaedward
Date: 2006-10-12 15:23:38 -0400 (Thu, 12 Oct 2006)
New Revision: 1040
Added:
development/support/scons/scons-local-0.96.1/
development/support/scons/scons-local-0.96.1/SCons/
development/support/scons/scons-local-0.96.1/SCons/Action.py
development/support/scons/scons-local-0.96.1/SCons/Builder.py
development/support/scons/scons-local-0.96.1/SCons/Conftest.py
development/support/scons/scons-local-0.96.1/SCons/Debug.py
development/support/scons/scons-local-0.96.1/SCons/Defaults.py
development/support/scons/scons-local-0.96.1/SCons/Environment.py
development/support/scons/scons-local-0.96.1/SCons/Errors.py
development/support/scons/scons-local-0.96.1/SCons/Executor.py
development/support/scons/scons-local-0.96.1/SCons/Job.py
development/support/scons/scons-local-0.96.1/SCons/Node/
development/support/scons/scons-local-0.96.1/SCons/Node/Alias.py
development/support/scons/scons-local-0.96.1/SCons/Node/FS.py
development/support/scons/scons-local-0.96.1/SCons/Node/Python.py
development/support/scons/scons-local-0.96.1/SCons/Node/__init__.py
development/support/scons/scons-local-0.96.1/SCons/Optik/
development/support/scons/scons-local-0.96.1/SCons/Optik/__init__.py
development/support/scons/scons-local-0.96.1/SCons/Optik/errors.py
development/support/scons/scons-local-0.96.1/SCons/Optik/option.py
development/support/scons/scons-local-0.96.1/SCons/Optik/option_parser.py
development/support/scons/scons-local-0.96.1/SCons/Options/
development/support/scons/scons-local-0.96.1/SCons/Options/BoolOption.py
development/support/scons/scons-local-0.96.1/SCons/Options/EnumOption.py
development/support/scons/scons-local-0.96.1/SCons/Options/ListOption.py
development/support/scons/scons-local-0.96.1/SCons/Options/PackageOption.py
development/support/scons/scons-local-0.96.1/SCons/Options/PathOption.py
development/support/scons/scons-local-0.96.1/SCons/Options/__init__.py
development/support/scons/scons-local-0.96.1/SCons/Platform/
development/support/scons/scons-local-0.96.1/SCons/Platform/__init__.py
development/support/scons/scons-local-0.96.1/SCons/Platform/aix.py
development/support/scons/scons-local-0.96.1/SCons/Platform/cygwin.py
development/support/scons/scons-local-0.96.1/SCons/Platform/darwin.py
development/support/scons/scons-local-0.96.1/SCons/Platform/hpux.py
development/support/scons/scons-local-0.96.1/SCons/Platform/irix.py
development/support/scons/scons-local-0.96.1/SCons/Platform/os2.py
development/support/scons/scons-local-0.96.1/SCons/Platform/posix.py
development/support/scons/scons-local-0.96.1/SCons/Platform/sunos.py
development/support/scons/scons-local-0.96.1/SCons/Platform/win32.py
development/support/scons/scons-local-0.96.1/SCons/SConf.py
development/support/scons/scons-local-0.96.1/SCons/SConsign.py
development/support/scons/scons-local-0.96.1/SCons/Scanner/
development/support/scons/scons-local-0.96.1/SCons/Scanner/C.py
development/support/scons/scons-local-0.96.1/SCons/Scanner/D.py
development/support/scons/scons-local-0.96.1/SCons/Scanner/Fortran.py
development/support/scons/scons-local-0.96.1/SCons/Scanner/IDL.py
development/support/scons/scons-local-0.96.1/SCons/Scanner/Prog.py
development/support/scons/scons-local-0.96.1/SCons/Scanner/__init__.py
development/support/scons/scons-local-0.96.1/SCons/Script/
development/support/scons/scons-local-0.96.1/SCons/Script/SConscript.py
development/support/scons/scons-local-0.96.1/SCons/Script/__init__.py
development/support/scons/scons-local-0.96.1/SCons/Sig/
development/support/scons/scons-local-0.96.1/SCons/Sig/MD5.py
development/support/scons/scons-local-0.96.1/SCons/Sig/TimeStamp.py
development/support/scons/scons-local-0.96.1/SCons/Sig/__init__.py
development/support/scons/scons-local-0.96.1/SCons/Taskmaster.py
development/support/scons/scons-local-0.96.1/SCons/Tool/
development/support/scons/scons-local-0.96.1/SCons/Tool/386asm.py
development/support/scons/scons-local-0.96.1/SCons/Tool/BitKeeper.py
development/support/scons/scons-local-0.96.1/SCons/Tool/CVS.py
development/support/scons/scons-local-0.96.1/SCons/Tool/JavaCommon.py
development/support/scons/scons-local-0.96.1/SCons/Tool/Perforce.py
development/support/scons/scons-local-0.96.1/SCons/Tool/PharLapCommon.py
development/support/scons/scons-local-0.96.1/SCons/Tool/RCS.py
development/support/scons/scons-local-0.96.1/SCons/Tool/SCCS.py
development/support/scons/scons-local-0.96.1/SCons/Tool/Subversion.py
development/support/scons/scons-local-0.96.1/SCons/Tool/__init__.py
development/support/scons/scons-local-0.96.1/SCons/Tool/aixc++.py
development/support/scons/scons-local-0.96.1/SCons/Tool/aixcc.py
development/support/scons/scons-local-0.96.1/SCons/Tool/aixf77.py
development/support/scons/scons-local-0.96.1/SCons/Tool/aixlink.py
development/support/scons/scons-local-0.96.1/SCons/Tool/ar.py
development/support/scons/scons-local-0.96.1/SCons/Tool/as.py
development/support/scons/scons-local-0.96.1/SCons/Tool/bcc32.py
development/support/scons/scons-local-0.96.1/SCons/Tool/c++.py
development/support/scons/scons-local-0.96.1/SCons/Tool/cc.py
development/support/scons/scons-local-0.96.1/SCons/Tool/cvf.py
development/support/scons/scons-local-0.96.1/SCons/Tool/default.py
development/support/scons/scons-local-0.96.1/SCons/Tool/dmd.py
development/support/scons/scons-local-0.96.1/SCons/Tool/dvipdf.py
development/support/scons/scons-local-0.96.1/SCons/Tool/dvips.py
development/support/scons/scons-local-0.96.1/SCons/Tool/f77.py
development/support/scons/scons-local-0.96.1/SCons/Tool/f90.py
development/support/scons/scons-local-0.96.1/SCons/Tool/f95.py
development/support/scons/scons-local-0.96.1/SCons/Tool/fortran.py
development/support/scons/scons-local-0.96.1/SCons/Tool/g++.py
development/support/scons/scons-local-0.96.1/SCons/Tool/g77.py
development/support/scons/scons-local-0.96.1/SCons/Tool/gas.py
development/support/scons/scons-local-0.96.1/SCons/Tool/gcc.py
development/support/scons/scons-local-0.96.1/SCons/Tool/gnulink.py
development/support/scons/scons-local-0.96.1/SCons/Tool/gs.py
development/support/scons/scons-local-0.96.1/SCons/Tool/hpc++.py
development/support/scons/scons-local-0.96.1/SCons/Tool/hpcc.py
development/support/scons/scons-local-0.96.1/SCons/Tool/hplink.py
development/support/scons/scons-local-0.96.1/SCons/Tool/icc.py
development/support/scons/scons-local-0.96.1/SCons/Tool/icl.py
development/support/scons/scons-local-0.96.1/SCons/Tool/ifl.py
development/support/scons/scons-local-0.96.1/SCons/Tool/ifort.py
development/support/scons/scons-local-0.96.1/SCons/Tool/ilink.py
development/support/scons/scons-local-0.96.1/SCons/Tool/ilink32.py
development/support/scons/scons-local-0.96.1/SCons/Tool/jar.py
development/support/scons/scons-local-0.96.1/SCons/Tool/javac.py
development/support/scons/scons-local-0.96.1/SCons/Tool/javah.py
development/support/scons/scons-local-0.96.1/SCons/Tool/latex.py
development/support/scons/scons-local-0.96.1/SCons/Tool/lex.py
development/support/scons/scons-local-0.96.1/SCons/Tool/link.py
development/support/scons/scons-local-0.96.1/SCons/Tool/linkloc.py
development/support/scons/scons-local-0.96.1/SCons/Tool/m4.py
development/support/scons/scons-local-0.96.1/SCons/Tool/masm.py
development/support/scons/scons-local-0.96.1/SCons/Tool/midl.py
development/support/scons/scons-local-0.96.1/SCons/Tool/mingw.py
development/support/scons/scons-local-0.96.1/SCons/Tool/mslib.py
development/support/scons/scons-local-0.96.1/SCons/Tool/mslink.py
development/support/scons/scons-local-0.96.1/SCons/Tool/msvc.py
development/support/scons/scons-local-0.96.1/SCons/Tool/msvs.py
development/support/scons/scons-local-0.96.1/SCons/Tool/nasm.py
development/support/scons/scons-local-0.96.1/SCons/Tool/pdflatex.py
development/support/scons/scons-local-0.96.1/SCons/Tool/pdftex.py
development/support/scons/scons-local-0.96.1/SCons/Tool/qt.py
development/support/scons/scons-local-0.96.1/SCons/Tool/rmic.py
development/support/scons/scons-local-0.96.1/SCons/Tool/sgiar.py
development/support/scons/scons-local-0.96.1/SCons/Tool/sgic++.py
development/support/scons/scons-local-0.96.1/SCons/Tool/sgicc.py
development/support/scons/scons-local-0.96.1/SCons/Tool/sgilink.py
development/support/scons/scons-local-0.96.1/SCons/Tool/sunar.py
development/support/scons/scons-local-0.96.1/SCons/Tool/sunc++.py
development/support/scons/scons-local-0.96.1/SCons/Tool/suncc.py
development/support/scons/scons-local-0.96.1/SCons/Tool/sunlink.py
development/support/scons/scons-local-0.96.1/SCons/Tool/swig.py
development/support/scons/scons-local-0.96.1/SCons/Tool/tar.py
development/support/scons/scons-local-0.96.1/SCons/Tool/tex.py
development/support/scons/scons-local-0.96.1/SCons/Tool/tlib.py
development/support/scons/scons-local-0.96.1/SCons/Tool/yacc.py
development/support/scons/scons-local-0.96.1/SCons/Tool/zip.py
development/support/scons/scons-local-0.96.1/SCons/Util.py
development/support/scons/scons-local-0.96.1/SCons/Warnings.py
development/support/scons/scons-local-0.96.1/SCons/__init__.py
development/support/scons/scons-local-0.96.1/SCons/dblite.py
development/support/scons/scons-local-0.96.1/SCons/exitfuncs.py
Removed:
development/source/archive/
development/source/third-party/boost/
development/source/tools/nTemplateTests.cc
development/source/tools/nTemplateTests.h
development/support/scons/scons-local-0.96.92/
Modified:
development/BuildAvida.py
development/SConstruct
development/source/SConscript
development/source/tools/SConscript
development/support/scons/scons.py
development/support/scons/sconsign.py
development/support/utils/AvidaUtils/CmdLineOpts.py
development/support/utils/AvidaUtils/PlatformTool.py
Log:
Pruning Avida development branch.
- Removed some dead test code in tools subdirectory.
- Removed boost into extras.
- Removed archive library into extras.
- The above required reverting to older version 0.96.1 of SCons.
- Backported build system for older version of SCons.
Modified: development/BuildAvida.py
===================================================================
--- development/BuildAvida.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/BuildAvida.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -38,8 +38,7 @@
# Tell Python where to find the main SCons build script, the SCons
# library, and our SCons customizations.
sys.path.append(os.path.join(sys.path[0], 'support/scons'))
-os.environ["SCONS_LIB_DIR"] = os.path.join(sys.path[0],
- 'support/scons/scons-local-0.96.92')
+os.environ["SCONS_LIB_DIR"] = os.path.join(sys.path[0], 'support/scons/scons-local-0.96.1')
# Any command line arguments are passed to SCons when it is imported by
# the next line.
Modified: development/SConstruct
===================================================================
--- development/SConstruct 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/SConstruct 2006-10-12 19:23:38 UTC (rev 1040)
@@ -57,7 +57,7 @@
'#/source/drivers',
'#/source/event',
'#/source/main',
- '#/source/third-party/boost',
+ #'#/source/third-party/boost',
'#/source/tools',
],
LIBPATH = [
@@ -75,21 +75,24 @@
)
# Tell SCons where to find its subscripts.
-environment.SConscript('source/SConscript', build_dir = '$buildDir')
+environment.SConscript('source/SConscript',
+ build_dir = '$buildDir',
+ duplicate = 0,
+)
environment.SConscript('support/config/SConscript')
# XXX beginnings of consistency tests. @kgn
-environment.SConscript('consistencytests/SConscript', build_dir = 'consistencytest_output')
+environment.SConscript('consistencytests/SConscript',
+ build_dir = 'consistencytest_output',
+ duplicate = 0,
+)
# XXX beginnings of 'extras'. @kgn
-#environment.SConscript('../avida-extras/SConscript', build_dir =
-#'../avida-extras/$buildDir')
-
-# XXX beginnings of 'extras'. @kgn
if environment.subst('$extrasDir') not in ['None', 'none', '']:
environment.SConscript(
os.path.join(environment.subst('$extrasDir'), 'SConscript'),
- build_dir = '$extrasBuildDir'
+ #build_dir = '$extrasBuildDir',
+ duplicate = 0
)
if environment['PLATFORM'] == 'win32':
Modified: development/source/SConscript
===================================================================
--- development/source/SConscript 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/source/SConscript 2006-10-12 19:23:38 UTC (rev 1040)
@@ -1,21 +1,31 @@
Import('environment')
-environment.SConscript( [
- 'actions/SConscript',
- 'analyze/SConscript',
- #'archive/SConscript',
- 'classification/SConscript',
- 'cpu/SConscript',
- 'drivers/SConscript',
- 'main/SConscript',
- 'platform/SConscript',
- 'targets/SConscript',
- 'third-party/SConscript',
- 'tools/SConscript',
- #'support/SConscript',
- #'utils/SConscript',
-] )
+#environment.SConscript( [
+# 'actions/SConscript',
+# 'analyze/SConscript',
+# #'archive/SConscript',
+# 'classification/SConscript',
+# 'cpu/SConscript',
+# 'drivers/SConscript',
+# 'main/SConscript',
+# 'platform/SConscript',
+# 'targets/SConscript',
+# 'third-party/SConscript',
+# 'tools/SConscript',
+# #'support/SConscript',
+# #'utils/SConscript',
+#] )
+environment.SConscript('actions/SConscript')
+environment.SConscript('analyze/SConscript')
+environment.SConscript('classification/SConscript')
+environment.SConscript('cpu/SConscript')
+environment.SConscript('drivers/SConscript')
+environment.SConscript('main/SConscript')
+environment.SConscript('platform/SConscript')
+environment.SConscript('targets/SConscript')
+environment.SConscript('third-party/SConscript')
+environment.SConscript('tools/SConscript')
#if environment['enableTestCode'] in ('True', '1', 1):
# environment.SConscript('testsuites/SConscript')
Modified: development/source/tools/SConscript
===================================================================
--- development/source/tools/SConscript 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/source/tools/SConscript 2006-10-12 19:23:38 UTC (rev 1040)
@@ -63,7 +63,6 @@
'cVerifierSuiteRecurser.h',
'cWeightedIndex.h',
'functions.h',
- 'nTemplateTests.h',
'tArgDataEntry.h',
'tArray.h',
'tBuffer.h',
@@ -120,7 +119,6 @@
'cTools.cc',
'cWeightedIndex.cc',
'cCycleCheck.cc',
- 'nTemplateTests.cc',
]
environment.Library('tools', srcs)
Deleted: development/source/tools/nTemplateTests.cc
===================================================================
--- development/source/tools/nTemplateTests.cc 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/source/tools/nTemplateTests.cc 2006-10-12 19:23:38 UTC (rev 1040)
@@ -1,772 +0,0 @@
-/*
- * nTemplateTests.cc
- * Avida
- *
- * Copyright 2005-2006 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology
- *
- */
-
-#include "nTemplateTests.h"
-
-
-/*
-Unit tests
-*/
-#include "cXMLArchive.h"
-#include "tArray.h"
-#include "tBuffer.h"
-#include "tDictionary.h"
-#include "tHashTable.h"
-#include "tList.h"
-#include "tManagedPointerArray.h"
-#include "tMatrix.h"
-#include "tMemTrack.h"
-#include "tSmartArray.h"
-
-#include "lightweight_test.h"
-
-#include <cstdio> // for std::remove() to remove temporary files.
-#include <iomanip>
-#include <iostream>
-#include <fstream>
-#include <string>
-
-namespace nTemplateTests {
- /*
- Test-helpers.
- */
- class A {
- tMemTrack<A> mt;
- public:
- int m_i;
- int m_j;
- public:
- A():m_i(-1),m_j(-1){}
- A(const A &in):m_i(in.m_i),m_j(in.m_j){}
- A& operator=(const A& in){
- m_i = in.m_i;
- m_j = in.m_j;
- return *this;
- }
- template<class Archive>
- void serialize(Archive & a, const unsigned int version){
- a.ArkvObj("m_i", m_i);
- a.ArkvObj("m_j", m_j);
- }
- };
- // ostream output, needed for tHashTable::OK()
- std::ostream& operator << (std::ostream& out, const A & a){
- out << "(" << a.m_i << "," << a.m_j << ")";
- return out;
- }
-
- template <class T>
- void save_stuff(const T &s, const char * filename){
- std::ofstream ofs(filename);
- cXMLOArchive oa(ofs);
- oa.ArkvObj("TemplateTest", s);
- }
-
- template <class T>
- void restore_stuff(T &s, const char * filename) {
- std::ifstream ifs(filename);
- cXMLIArchive ia(ifs);
- ia.ArkvObj("TemplateTest", s);
- }
-
-
- namespace utTemplateTests_hello_world {
- void test(){
- std::cout << CURRENT_FUNCTION << std::endl;
- TEST(true);
- TEST(false);
- }
- }
-
-
- namespace utMemTrack {
- void test() {
- std::cout << CURRENT_FUNCTION << std::endl;
- TEST(0 == tMemTrack<A>::Instances());
- {
- A a;
- TEST(1 == tMemTrack<A>::Instances());
- }
- TEST(0 == tMemTrack<A>::Instances());
- A *p;
- TEST(0 == tMemTrack<A>::Instances());
- p = new A();
- TEST(1 == tMemTrack<A>::Instances());
- delete p;
- TEST(0 == tMemTrack<A>::Instances());
-
- }
- }
-
- namespace utList_basic_serialization {
- void test() {
-# ifdef ENABLE_SERIALIZATION
- std::cout << CURRENT_FUNCTION << std::endl;
- TEST(0 == tMemTrack<A>::Instances());
- A *a;
- tList<A> l;
- tListIterator<A> it(l);
- std::string filename("./tList_basic_serialization.xml");
- int i, listsize = 10;
-
- TEST(1 == tMemTrack<tList<A> >::Instances());
- TEST(1 == tMemTrack<tListNode<A> >::Instances());
-
- /*
- Construct basic list.
- */
- TEST(0 == tMemTrack<A>::Instances());
- for(i=0; i<listsize; i++){
- a = new A;
- a->m_i = i;
- l.PushRear(a);
- }
- TEST(listsize == tMemTrack<A>::Instances());
- TEST(1 + listsize == tMemTrack<tListNode<A> >::Instances());
-
- /*
- Verify basic list contents.
- */
- TEST(listsize == tMemTrack<A>::Instances());
- it.Reset();
- for(i=0; (a = it.Next()); i++){
- TEST(i == a->m_i);
- }
-
- /*
- Save basic list.
- */
- save_stuff<>(l, filename.c_str());
- it.Reset();
- for(i=0; (a = it.Next()); i++){
- delete a;
- }
- l.Clear();
- TEST(0 == tMemTrack<A>::Instances());
- TEST(1 == tMemTrack<tList<A> >::Instances());
- TEST(1 == tMemTrack<tListNode<A> >::Instances());
-
- /*
- Reload basic list.
- */
- restore_stuff<>(l, filename.c_str());
- TEST(1 == tMemTrack<tList<A> >::Instances());
- TEST(listsize == tMemTrack<A>::Instances());
- TEST(1 + listsize == tMemTrack<tListNode<A> >::Instances());
-
- /*
- Verify contents of reloaded basic list.
- */
- for(i=0; i<listsize; i++){
- a = l.Pop();
- TEST(i == a->m_i);
- delete a;
- }
-
- TEST(0 == tMemTrack<A>::Instances());
- TEST(1 == tMemTrack<tList<A> >::Instances());
- TEST(1 == tMemTrack<tListNode<A> >::Instances());
-
- std::remove(filename.c_str());
-# endif // ENABLE_SERIALIZATION
- }
- } // utList_basic_serialization
-
- namespace utList_archive_structure {
- void test() {
-# ifdef ENABLE_SERIALIZATION
- std::cout << CURRENT_FUNCTION << std::endl;
- std::string filename("./tList_archive_structure.xml");
-
- A *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9, *a10;
-
- tList<A> l;
- tListIterator<A> it(l);
-
- /*
- Construct list...
- */
- TEST(0 == tMemTrack<A>::Instances());
- a1 = new A;
- a2 = new A;
- TEST(2 == tMemTrack<A>::Instances());
- l.PushRear(a1);
- l.PushRear(a2);
- l.PushRear(a1);
- l.PushRear(a2);
- TEST(2 == tMemTrack<A>::Instances());
-
- /*
- Verify list structure. It should now contain two copies each,
- interleaved, of two instances of A.
- */
- it.Reset();
- a3 = it.Next();
- a4 = it.Next();
- a5 = it.Next();
- a6 = it.Next();
- TEST(2 == tMemTrack<A>::Instances());
-
- a1->m_i = 3;
- a2->m_i = 5;
- TEST(3 == a3->m_i);
- TEST(5 == a4->m_i);
- TEST(3 == a5->m_i);
- TEST(5 == a6->m_i);
-
- /*
- Save to disk, clear, and reload.
- */
- save_stuff<>(l, filename.c_str());
- TEST(2 == tMemTrack<A>::Instances());
-
- l.Clear();
- TEST(2 == tMemTrack<A>::Instances());
-
- restore_stuff<>(l, filename.c_str());
-
- /*
- New list should contain two copies each, interleaved, of the two
- new instances of A.
- */
- TEST(4 == tMemTrack<A>::Instances());
-
- /*
- Verify new list structure.
- */
- it.Reset();
- a7 = it.Next();
- a8 = it.Next();
- a9 = it.Next();
- a10 = it.Next();
- TEST(4 == tMemTrack<A>::Instances());
-
- TEST(3 == a7->m_i);
- TEST(5 == a8->m_i);
- TEST(3 == a9->m_i);
- TEST(5 == a10->m_i);
-
- /*
- Verify that elements of old and new lists are independent.
- */
- a1->m_i = 7;
- a7->m_i = 11;
- a8->m_i = 13;
- TEST(7 == a3->m_i);
- TEST(5 == a4->m_i);
- TEST(7 == a5->m_i);
- TEST(5 == a6->m_i);
- TEST(11 == a7->m_i);
- TEST(13 == a8->m_i);
- TEST(11 == a9->m_i);
- TEST(13 == a10->m_i);
-
- l.Clear();
- /*
- Delete originals instances of A.
- */
- delete a1;
- delete a2;
- /*
- Delete reloaded copies of A.
- */
- delete a7;
- delete a8;
- TEST(0 == tMemTrack<A>::Instances());
-
- std::remove(filename.c_str());
-# endif // ENABLE_SERIALIZATION
- }
- } // utList_archive_structure
-
- namespace utArrays_of_pointers {
- void test() {
-# ifdef ENABLE_SERIALIZATION
- std::cout << CURRENT_FUNCTION << std::endl;
- const int num_instances = 3;
- tArray<A *> instance_array(num_instances);
- TEST(0 == tMemTrack<A>::Instances());
- for (int i = 0; i < num_instances; i++){
- instance_array[i] = new A();
- }
- TEST(num_instances == tMemTrack<A>::Instances());
- for (int i = 0; i < num_instances; i++){
- delete instance_array[i];
- }
- TEST(0 == tMemTrack<A>::Instances());
-# endif // ENABLE_SERIALIZATION
- }
- } // utArrays_of_pointers
-
- namespace utArray_basic_serialization {
- void test() {
-# ifdef ENABLE_SERIALIZATION
- std::cout << CURRENT_FUNCTION << std::endl;
- std::string filename("./tArray_basic_serialization.xml");
- int i, arraysize = 10;
-
- TEST(0 == tMemTrack<A>::Instances());
- tArray<A> l(arraysize);
- TEST(arraysize == tMemTrack<A>::Instances());
-
- /*
- Construct basic array.
- */
- for(i=0; i<arraysize; i++){
- l[i].m_i = i;
- }
-
- /*
- Verify basic array contents.
- */
- for(i=0; i<arraysize; i++){
- TEST(i == l[i].m_i);
- }
-
- /*
- Save basic array.
- */
- save_stuff<>(l, filename.c_str());
- l.ResizeClear(0);
- TEST(0 == tMemTrack<A>::Instances());
-
- /*
- Reload basic array.
- */
- restore_stuff<>(l, filename.c_str());
- TEST(arraysize == tMemTrack<A>::Instances());
-
- /*
- Verify contents of reloaded basic array.
- */
- for(i=0; i<arraysize; i++){
- TEST(i == l[i].m_i);
- }
-
- l.ResizeClear(0);
- TEST(0 == tMemTrack<A>::Instances());
-
- std::remove(filename.c_str());
-# endif // ENABLE_SERIALIZATION
- }
- } // utArray_basic_serialization
-
- namespace utHashTable_basic_serialization {
- void test() {
-# ifdef ENABLE_SERIALIZATION
- std::cout << CURRENT_FUNCTION << std::endl;
- std::string filename("./tHashTable_basic_serialization.xml");
-
- TEST(0 == tMemTrack<A>::Instances());
- tHashTable<cString, A> d;
- char keystr[9] = "number 0";
- int i, dictsize = 10;
- TEST(0 == tMemTrack<A>::Instances());
-
- // Sanity checks.
- TEST(d.OK());
- TEST(0 == d.GetSize());
- TEST(!d.HasEntry("blah"));
- {
- A a;
- TEST(!d.Find("blah", a));
- }
-
- /*
- Construct basic dict.
- */
- for(i=0; i<dictsize; i++){
- A a;
- keystr[7] = '0' + i;
- a.m_i = i;
- d.Add(cString(keystr), a);
- }
- TEST(dictsize == tMemTrack<A>::Instances());
-
- /*
- Verify basic dict contents.
- */
- for(i=0; i<dictsize; i++){
- A a;
- keystr[7] = '0' + i;
- TEST(d.Find(cString(keystr), a));
- TEST(i == a.m_i);
- }
- TEST(d.OK());
-
- /*
- Save basic table.
- */
- save_stuff<>(d, filename.c_str());
- TEST(dictsize == tMemTrack<A>::Instances());
-
- /*
- Reload basic table.
- */
- {
- tHashTable<cString, A> d2;
- restore_stuff<>(d2, filename.c_str());
- TEST(2 * dictsize == tMemTrack<A>::Instances());
- TEST(d2.OK());
-
- /*
- Verify contents of reloaded basic dict.
- */
- for(i=0; i<dictsize; i++){
- A a;
- keystr[7] = '0' + i;
- TEST(d2.Find(cString(keystr), a));
- TEST(i == a.m_i);
- }
- TEST(2 * dictsize == tMemTrack<A>::Instances());
- }
-
- TEST(dictsize == tMemTrack<A>::Instances());
-
- std::remove(filename.c_str());
-# endif // ENABLE_SERIALIZATION
- }
- } // utHashTable_basic_serialization
-
- namespace utDictionary_basic_serialization {
- void test() {
-# ifdef ENABLE_SERIALIZATION
- std::cout << CURRENT_FUNCTION << std::endl;
- std::string filename("./tDictionary_basic_serialization.xml");
-
- TEST(0 == tMemTrack<A>::Instances());
- tDictionary<A> d;
- char keystr[9] = "number 0";
- int i, dictsize = 10;
- TEST(0 == tMemTrack<A>::Instances());
-
- // Sanity checks.
- TEST(d.OK());
- TEST(0 == d.GetSize());
- TEST(!d.HasEntry("blah"));
- {
- A a;
- TEST(!d.Find("blah", a));
- }
- TEST(cString("") == d.NearMatch("blah"));
-
- /*
- Construct basic dict.
- */
- for(i=0; i<dictsize; i++){
- A a;
- keystr[7] = '0' + i;
- a.m_i = i;
- d.Add(cString(keystr), a);
- }
- TEST(dictsize == tMemTrack<A>::Instances());
-
- /*
- Verify basic dict contents.
- */
- for(i=0; i<dictsize; i++){
- A a;
- keystr[7] = '0' + i;
- TEST(d.Find(cString(keystr), a));
- TEST(i == a.m_i);
- }
- TEST(d.OK());
-
- /*
- Save basic list.
- */
- save_stuff<>(d, filename.c_str());
- TEST(dictsize == tMemTrack<A>::Instances());
-
- /*
- Reload basic list.
- */
- {
- tDictionary<A> d2;
- restore_stuff<>(d2, filename.c_str());
- TEST(2 * dictsize == tMemTrack<A>::Instances());
- TEST(d2.OK());
-
- /*
- Verify contents of reloaded basic dict.
- */
- for(i=0; i<dictsize; i++){
- A a;
- keystr[7] = '0' + i;
- TEST(d2.Find(cString(keystr), a));
- TEST(i == a.m_i);
- }
- TEST(2 * dictsize == tMemTrack<A>::Instances());
- }
-
- TEST(dictsize == tMemTrack<A>::Instances());
-
- std::remove(filename.c_str());
-# endif // ENABLE_SERIALIZATION
- }
- } // utDictionary_basic_serialization
-
- namespace utBuffer_basic_serialization {
- void test() {
-# ifdef ENABLE_SERIALIZATION
- std::cout << CURRENT_FUNCTION << std::endl;
- std::string filename("./tBuffer_basic_serialization.xml");
- A a;
- int i, buffer_size = 10;
-
- TEST(1 == tMemTrack<A>::Instances());
- tBuffer<A> b(buffer_size);
- TEST(1 + buffer_size == tMemTrack<A>::Instances());
-
- /*
- Construct basic buffer.
- */
- for(i=0; i < buffer_size - 1; i++){
- a.m_i = i;
- b.Add(a);
- }
-
- /*
- Verify basic buffer contents.
- */
- for(i=0; i < buffer_size - 1; i++){
- TEST(buffer_size - 2 - i == b[i].m_i);
- }
- TEST(b.GetCapacity() == buffer_size);
- TEST(b.GetTotal() == buffer_size - 1);
- TEST(b.GetNumStored() == buffer_size - 1);
- TEST(b.GetNum() == buffer_size - 1);
-
- /*
- Save and clear basic buffer.
- */
- save_stuff<>(b, filename.c_str());
- b.Clear();
- for(i=0; i < buffer_size - 1; i++){
- a.m_i = 0;
- b.Add(a);
- }
- for(i=0; i < buffer_size - 1; i++){
- TEST(0 == b[i].m_i);
- }
- b.Clear();
- TEST(b.GetCapacity() == buffer_size);
- TEST(b.GetTotal() == 0);
- TEST(b.GetNumStored() == 0);
- TEST(b.GetNum() == 0);
-
- /*
- Reload basic buffer.
- */
- restore_stuff<>(b, filename.c_str());
- TEST(1 + buffer_size == tMemTrack<A>::Instances());
-
- /*
- Verify contents of reloaded basic buffer.
- */
- for(i=0; i < buffer_size - 1; i++){
- TEST(buffer_size - 2 - i == b[i].m_i);
- }
- TEST(b.GetCapacity() == buffer_size);
- TEST(b.GetTotal() == buffer_size - 1);
- TEST(b.GetNumStored() == buffer_size - 1);
- TEST(b.GetNum() == buffer_size - 1);
-
- std::remove(filename.c_str());
-# endif // ENABLE_SERIALIZATION
- }
- } // utBuffer_basic_serialization
-
- namespace utManagedPointerArray_basic_serialization {
- void test() {
-# ifdef ENABLE_SERIALIZATION
- std::cout << CURRENT_FUNCTION << std::endl;
- std::string filename("./tManagedPointerArray_basic_serialization.xml");
- int i, arraysize = 10;
-
- TEST(0 == tMemTrack<A>::Instances());
- tManagedPointerArray<A> l(arraysize);
- TEST(arraysize == tMemTrack<A>::Instances());
-
- /*
- Construct basic array.
- */
- for(i=0; i<arraysize; i++){
- l[i].m_i = i;
- }
-
- /*
- Verify basic array contents.
- */
- for(i=0; i<arraysize; i++){
- TEST(i == l[i].m_i);
- }
-
- /*
- Save basic array.
- */
- save_stuff<>(l, filename.c_str());
- l.ResizeClear(0);
- TEST(0 == tMemTrack<A>::Instances());
-
- /*
- Reload basic array.
- */
- restore_stuff<>(l, filename.c_str());
- TEST(arraysize == tMemTrack<A>::Instances());
-
- /*
- Verify contents of reloaded basic array.
- */
- for(i=0; i<arraysize; i++){
- TEST(i == l[i].m_i);
- }
-
- l.ResizeClear(0);
- TEST(0 == tMemTrack<A>::Instances());
-
- std::remove(filename.c_str());
-# endif // ENABLE_SERIALIZATION
- }
- } // utManagedPointerArray_basic_serialization
-
- namespace utSmartArray_basic_serialization {
- void test() {
-# ifdef ENABLE_SERIALIZATION
- std::cout << CURRENT_FUNCTION << std::endl;
- std::string filename("./tSmartArray_basic_serialization.xml");
- int i, arraysize = 10;
-
- TEST(0 == tMemTrack<A>::Instances());
- tSmartArray<A> l(arraysize);
- TEST(arraysize == tMemTrack<A>::Instances());
-
- /*
- Construct basic array.
- */
- for(i=0; i<arraysize; i++){
- l[i].m_i = i;
- }
-
- /*
- Verify basic array contents.
- */
- for(i=0; i<arraysize; i++){
- TEST(i == l[i].m_i);
- }
-
- /*
- Save basic array.
- */
- save_stuff<>(l, filename.c_str());
- l.ResizeClear(0);
- TEST(0 == tMemTrack<A>::Instances());
-
- /*
- Reload basic array.
- */
- restore_stuff<>(l, filename.c_str());
- TEST(arraysize == tMemTrack<A>::Instances());
-
- /*
- Verify contents of reloaded basic array.
- */
- for(i=0; i<arraysize; i++){
- TEST(i == l[i].m_i);
- }
-
- l.ResizeClear(0);
- TEST(0 == tMemTrack<A>::Instances());
-
- std::remove(filename.c_str());
-# endif // ENABLE_SERIALIZATION
- }
- } // utSmartArray_basic_serialization
-
- namespace utMatrix_basic_serialization {
- void test() {
-# ifdef ENABLE_SERIALIZATION
- std::cout << CURRENT_FUNCTION << std::endl;
- std::string filename("./tMatrix_basic_serialization.xml");
- int i, j, rows = 3, cols = 5;
-
- TEST(0 == tMemTrack<A>::Instances());
- tMatrix<A> m(rows, cols);
- TEST(rows * cols == tMemTrack<A>::Instances());
-
- /*
- Construct basic matrix.
- */
- for(i=0; i<rows; i++){
- for(j=0; j<cols; j++){
- m[i][j].m_i = i;
- m[i][j].m_j = j;
- }
- }
-
- /*
- Verify basic matrix contents.
- */
- for(i=0; i<rows; i++){
- for(j=0; j<cols; j++){
- TEST(i == m[i][j].m_i);
- TEST(j == m[i][j].m_j);
- }
- }
-
- /*
- Save basic matrix.
- */
- save_stuff<>(m, filename.c_str());
- m.ResizeClear(1,1);
- TEST(1 == tMemTrack<A>::Instances());
-
- /*
- Reload basic matrix.
- */
- restore_stuff<>(m, filename.c_str());
- TEST(rows * cols == tMemTrack<A>::Instances());
-
- /*
- Verify contents of reloaded basic matrix.
- */
- for(i=0; i<rows; i++){
- for(j=0; j<cols; j++){
- TEST(i == m[i][j].m_i);
- TEST(j == m[i][j].m_j);
- }
- }
-
- m.ResizeClear(1,1);
- TEST(1 == tMemTrack<A>::Instances());
-
- std::remove(filename.c_str());
-# endif // ENABLE_SERIALIZATION
- }
- } // utMatrix_basic_serialization
-
-
-
-
- void UnitTests(bool full)
- {
- //if(full) utTemplateTests_hello_world::test();
- if(full) utMemTrack::test();
- if(full) utList_basic_serialization::test();
- if(full) utList_archive_structure::test();
- if(full) utArrays_of_pointers::test();
- if(full) utArray_basic_serialization::test();
- if(full) utHashTable_basic_serialization::test();
- if(full) utDictionary_basic_serialization::test();
- if(full) utBuffer_basic_serialization::test();
- if(full) utManagedPointerArray_basic_serialization::test();
- if(full) utSmartArray_basic_serialization::test();
- if(full) utMatrix_basic_serialization::test();
- }
-} // nTemplateTests
Deleted: development/source/tools/nTemplateTests.h
===================================================================
--- development/source/tools/nTemplateTests.h 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/source/tools/nTemplateTests.h 2006-10-12 19:23:38 UTC (rev 1040)
@@ -1,22 +0,0 @@
-/*
- * nTemplateTests.h
- * Avida
- *
- * Copyright 2005-2006 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology
- *
- */
-
-#ifndef nTemplateTests_h
-#define nTemplateTests_h
-
-namespace nTemplateTests {
- /**
- * Run unit tests
- *
- * @param full Run full test suite; if false, just the fast tests.
- **/
- void UnitTests(bool full = false);
-}
-
-#endif
Added: development/support/scons/scons-local-0.96.1/SCons/Action.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Action.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Action.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,642 @@
+"""SCons.Action
+
+This encapsulates information about executing any sort of action that
+can build one or more target Nodes (typically files) from one or more
+source Nodes (also typically files) given a specific Environment.
+
+The base class here is ActionBase. The base class supplies just a few
+OO utility methods and some generic methods for displaying information
+about an Action in response to the various commands that control printing.
+
+The heavy lifting is handled by subclasses for the different types of
+actions we might execute:
+
+ CommandAction
+ CommandGeneratorAction
+ FunctionAction
+ ListAction
+
+The subclasses supply the following public interface methods used by
+other modules:
+
+ __call__()
+ THE public interface, "calling" an Action object executes the
+ command or Python function. This also takes care of printing
+ a pre-substitution command for debugging purposes.
+
+ get_contents()
+ Fetches the "contents" of an Action for signature calculation.
+ This is what the Sig/*.py subsystem uses to decide if a target
+ needs to be rebuilt because its action changed.
+
+ genstring()
+ Returns a string representation of the Action *without* command
+ substitution, but allows a CommandGeneratorAction to generate
+ the right action based on the specified target, source and env.
+ This is used by the Signature subsystem (through the Executor)
+ to compare the actions used to build a target last time and
+ this time.
+
+Subclasses also supply the following methods for internal use within
+this module:
+
+ __str__()
+ Returns a string representation of the Action *without* command
+ substitution. This is used by the __call__() methods to display
+ the pre-substitution command whenever the --debug=presub option
+ is used.
+
+ strfunction()
+ Returns a substituted string representation of the Action.
+ This is used by the ActionBase.show() command to display the
+ command/function that will be executed to generate the target(s).
+
+ execute()
+ The internal method that really, truly, actually handles the
+ execution of a command or Python function. This is used so
+ that the __call__() methods can take care of displaying any
+ pre-substitution representations, and *then* execute an action
+ without worrying about the specific Actions involved.
+
+There is a related independent ActionCaller class that looks like a
+regular Action, and which serves as a wrapper for arbitrary functions
+that we want to let the user specify the arguments to now, but actually
+execute later (when an out-of-date check determines that it's needed to
+be executed, for example). Objects of this class are returned by an
+ActionFactory class that provides a __call__() method as a convenient
+way for wrapping up the functions.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Action.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+import os.path
+import re
+import string
+import sys
+
+from SCons.Debug import logInstanceCreation
+import SCons.Errors
+import SCons.Util
+
+class _Null:
+ pass
+
+_null = _Null
+
+print_actions = 1
+execute_actions = 1
+print_actions_presub = 0
+
+default_ENV = None
+
+def rfile(n):
+ try:
+ return n.rfile()
+ except AttributeError:
+ return n
+
+def _actionAppend(act1, act2):
+ # This function knows how to slap two actions together.
+ # Mainly, it handles ListActions by concatenating into
+ # a single ListAction.
+ a1 = Action(act1)
+ a2 = Action(act2)
+ if a1 is None or a2 is None:
+ raise TypeError, "Cannot append %s to %s" % (type(act1), type(act2))
+ if isinstance(a1, ListAction):
+ if isinstance(a2, ListAction):
+ return ListAction(a1.list + a2.list)
+ else:
+ return ListAction(a1.list + [ a2 ])
+ else:
+ if isinstance(a2, ListAction):
+ return ListAction([ a1 ] + a2.list)
+ else:
+ return ListAction([ a1, a2 ])
+
+class CommandGenerator:
+ """
+ Wraps a command generator function so the Action() factory
+ function can tell a generator function from a function action.
+ """
+ def __init__(self, generator):
+ self.generator = generator
+
+ def __add__(self, other):
+ return _actionAppend(self, other)
+
+ def __radd__(self, other):
+ return _actionAppend(other, self)
+
+def _do_create_action(act, *args, **kw):
+ """This is the actual "implementation" for the
+ Action factory method, below. This handles the
+ fact that passing lists to Action() itself has
+ different semantics than passing lists as elements
+ of lists.
+
+ The former will create a ListAction, the latter
+ will create a CommandAction by converting the inner
+ list elements to strings."""
+
+ if isinstance(act, ActionBase):
+ return act
+ if SCons.Util.is_List(act):
+ return apply(CommandAction, (act,)+args, kw)
+ if isinstance(act, CommandGenerator):
+ return apply(CommandGeneratorAction, (act.generator,)+args, kw)
+ if callable(act):
+ return apply(FunctionAction, (act,)+args, kw)
+ if SCons.Util.is_String(act):
+ var=SCons.Util.get_environment_var(act)
+ if var:
+ # This looks like a string that is purely an Environment
+ # variable reference, like "$FOO" or "${FOO}". We do
+ # something special here...we lazily evaluate the contents
+ # of that Environment variable, so a user could put something
+ # like a function or a CommandGenerator in that variable
+ # instead of a string.
+ lcg = LazyCmdGenerator(var)
+ return apply(CommandGeneratorAction, (lcg,)+args, kw)
+ commands = string.split(str(act), '\n')
+ if len(commands) == 1:
+ return apply(CommandAction, (commands[0],)+args, kw)
+ else:
+ listCmdActions = map(lambda x: CommandAction(x), commands)
+ return apply(ListAction, (listCmdActions,)+args, kw)
+ return None
+
+def Action(act, strfunction=_null, varlist=[], presub=_null):
+ """A factory for action objects."""
+ if SCons.Util.is_List(act):
+ acts = map(lambda x, s=strfunction, v=varlist, ps=presub:
+ _do_create_action(x, strfunction=s, varlist=v, presub=ps),
+ act)
+ acts = filter(lambda x: not x is None, acts)
+ if len(acts) == 1:
+ return acts[0]
+ else:
+ return ListAction(acts, strfunction=strfunction, varlist=varlist, presub=presub)
+ else:
+ return _do_create_action(act, strfunction=strfunction, varlist=varlist, presub=presub)
+
+class ActionBase:
+ """Base class for actions that create output objects."""
+ def __init__(self, strfunction=_null, presub=_null, **kw):
+ if not strfunction is _null:
+ self.strfunction = strfunction
+ if presub is _null:
+ self.presub = print_actions_presub
+ else:
+ self.presub = presub
+
+ def __cmp__(self, other):
+ return cmp(self.__dict__, other.__dict__)
+
+ def __call__(self, target, source, env,
+ errfunc=None,
+ presub=_null,
+ show=_null,
+ execute=_null):
+ if not SCons.Util.is_List(target):
+ target = [target]
+ if not SCons.Util.is_List(source):
+ source = [source]
+ if presub is _null: presub = self.presub
+ if show is _null: show = print_actions
+ if execute is _null: execute = execute_actions
+ if presub:
+ t = string.join(map(str, target), 'and')
+ l = string.join(self.presub_lines(env), '\n ')
+ out = "Building %s with action(s):\n %s\n" % (t, l)
+ sys.stdout.write(out)
+ if show and self.strfunction:
+ s = self.strfunction(target, source, env)
+ if s:
+ sys.stdout.write(s + '\n')
+ if execute:
+ stat = self.execute(target, source, env)
+ if stat and errfunc:
+ errfunc(stat)
+ return stat
+ else:
+ return 0
+
+ def presub_lines(self, env):
+ # CommandGeneratorAction needs a real environment
+ # in order to return the proper string here, since
+ # it may call LazyCmdGenerator, which looks up a key
+ # in that env. So we temporarily remember the env here,
+ # and CommandGeneratorAction will use this env
+ # when it calls its __generate method.
+ self.presub_env = env
+ lines = string.split(str(self), '\n')
+ self.presub_env = None # don't need this any more
+ return lines
+
+ def genstring(self, target, source, env):
+ return str(self)
+
+ def get_actions(self):
+ return [self]
+
+ def __add__(self, other):
+ return _actionAppend(self, other)
+
+ def __radd__(self, other):
+ return _actionAppend(other, self)
+
+def _string_from_cmd_list(cmd_list):
+ """Takes a list of command line arguments and returns a pretty
+ representation for printing."""
+ cl = []
+ for arg in map(str, cmd_list):
+ if ' ' in arg or '\t' in arg:
+ arg = '"' + arg + '"'
+ cl.append(arg)
+ return string.join(cl)
+
+class CommandAction(ActionBase):
+ """Class for command-execution actions."""
+ def __init__(self, cmd, **kw):
+ # Cmd list can actually be a list or a single item...basically
+ # anything that we could pass in as the first arg to
+ # Environment.subst_list().
+ if __debug__: logInstanceCreation(self)
+ apply(ActionBase.__init__, (self,), kw)
+ self.cmd_list = cmd
+
+ def __str__(self):
+ return str(self.cmd_list)
+
+ def strfunction(self, target, source, env):
+ cmd_list = env.subst_list(self.cmd_list, 0, target, source)
+ return string.join(map(_string_from_cmd_list, cmd_list), "\n")
+
+ def execute(self, target, source, env):
+ """Execute a command action.
+
+ This will handle lists of commands as well as individual commands,
+ because construction variable substitution may turn a single
+ "command" into a list. This means that this class can actually
+ handle lists of commands, even though that's not how we use it
+ externally.
+ """
+ import SCons.Util
+
+ escape = env.get('ESCAPE', lambda x: x)
+
+ if env.has_key('SHELL'):
+ shell = env['SHELL']
+ else:
+ raise SCons.Errors.UserError('Missing SHELL construction variable.')
+
+ # for SConf support (by now): check, if we want to pipe the command
+ # output to somewhere else
+ if env.has_key('PIPE_BUILD'):
+ pipe_build = 1
+ if env.has_key('PSPAWN'):
+ pspawn = env['PSPAWN']
+ else:
+ raise SCons.Errors.UserError('Missing PSPAWN construction variable.')
+ if env.has_key('PSTDOUT'):
+ pstdout = env['PSTDOUT']
+ else:
+ raise SCons.Errors.UserError('Missing PSTDOUT construction variable.')
+ if env.has_key('PSTDERR'):
+ pstderr = env['PSTDERR']
+ else:
+ raise SCons.Errors.UserError('Missing PSTDOUT construction variable.')
+ else:
+ pipe_build = 0
+ if env.has_key('SPAWN'):
+ spawn = env['SPAWN']
+ else:
+ raise SCons.Errors.UserError('Missing SPAWN construction variable.')
+
+ cmd_list = env.subst_list(self.cmd_list, 0, target, source)
+ for cmd_line in cmd_list:
+ if len(cmd_line):
+ try:
+ ENV = env['ENV']
+ except KeyError:
+ global default_ENV
+ if not default_ENV:
+ import SCons.Environment
+ default_ENV = SCons.Environment.Environment()['ENV']
+ ENV = default_ENV
+
+ # ensure that the ENV values are all strings:
+ for key, value in ENV.items():
+ if SCons.Util.is_List(value):
+ # If the value is a list, then we assume
+ # it is a path list, because that's a pretty
+ # common list like value to stick in an environment
+ # variable:
+ value = SCons.Util.flatten(value)
+ ENV[key] = string.join(map(str, value), os.pathsep)
+ elif not SCons.Util.is_String(value):
+ # If it isn't a string or a list, then
+ # we just coerce it to a string, which
+ # is proper way to handle Dir and File instances
+ # and will produce something reasonable for
+ # just about everything else:
+ ENV[key] = str(value)
+
+ # Escape the command line for the command
+ # interpreter we are using
+ cmd_line = SCons.Util.escape_list(cmd_line, escape)
+ if pipe_build:
+ ret = pspawn( shell, escape, cmd_line[0], cmd_line,
+ ENV, pstdout, pstderr )
+ else:
+ ret = spawn(shell, escape, cmd_line[0], cmd_line, ENV)
+ if ret:
+ return ret
+ return 0
+
+ def get_contents(self, target, source, env, dict=None):
+ """Return the signature contents of this action's command line.
+
+ This strips $(-$) and everything in between the string,
+ since those parts don't affect signatures.
+ """
+ cmd = self.cmd_list
+ if SCons.Util.is_List(cmd):
+ cmd = string.join(map(str, cmd))
+ else:
+ cmd = str(cmd)
+ return env.subst_target_source(cmd, SCons.Util.SUBST_SIG, target, source, dict)
+
+class CommandGeneratorAction(ActionBase):
+ """Class for command-generator actions."""
+ def __init__(self, generator, **kw):
+ if __debug__: logInstanceCreation(self)
+ apply(ActionBase.__init__, (self,), kw)
+ self.generator = generator
+
+ def __generate(self, target, source, env, for_signature):
+ # ensure that target is a list, to make it easier to write
+ # generator functions:
+ if not SCons.Util.is_List(target):
+ target = [target]
+
+ ret = self.generator(target=target, source=source, env=env, for_signature=for_signature)
+ gen_cmd = Action(ret)
+ if not gen_cmd:
+ raise SCons.Errors.UserError("Object returned from command generator: %s cannot be used to create an Action." % repr(ret))
+ return gen_cmd
+
+ def strfunction(self, target, source, env):
+ if not SCons.Util.is_List(source):
+ source = [source]
+ rsources = map(rfile, source)
+ act = self.__generate(target, source, env, 0)
+ if act.strfunction:
+ return act.strfunction(target, rsources, env)
+ else:
+ return None
+
+ def __str__(self):
+ try:
+ env = self.presub_env or {}
+ except AttributeError:
+ env = {}
+ act = self.__generate([], [], env, 0)
+ return str(act)
+
+ def genstring(self, target, source, env):
+ return str(self.__generate(target, source, env, 0))
+
+ def execute(self, target, source, env):
+ rsources = map(rfile, source)
+ act = self.__generate(target, source, env, 0)
+ return act.execute(target, source, env)
+
+ def get_contents(self, target, source, env, dict=None):
+ """Return the signature contents of this action's command line.
+
+ This strips $(-$) and everything in between the string,
+ since those parts don't affect signatures.
+ """
+ return self.__generate(target, source, env, 1).get_contents(target, source, env, dict=None)
+
+class LazyCmdGenerator:
+ """This is not really an Action, although it kind of looks like one.
+ This is really a simple callable class that acts as a command
+ generator. It holds on to a key into an Environment dictionary,
+ then waits until execution time to see what type it is, then tries
+ to create an Action out of it."""
+ def __init__(self, var):
+ if __debug__: logInstanceCreation(self)
+ self.var = SCons.Util.to_String(var)
+
+ def strfunction(self, target, source, env):
+ try:
+ return env[self.var]
+ except KeyError:
+ # The variable reference substitutes to nothing.
+ return ''
+
+ def __str__(self):
+ return 'LazyCmdGenerator: %s'%str(self.var)
+
+ def __call__(self, target, source, env, for_signature):
+ try:
+ return env[self.var]
+ except KeyError:
+ # The variable reference substitutes to nothing.
+ return ''
+
+ def __cmp__(self, other):
+ return cmp(self.__dict__, other.__dict__)
+
+class FunctionAction(ActionBase):
+ """Class for Python function actions."""
+
+ def __init__(self, execfunction, **kw):
+ if __debug__: logInstanceCreation(self)
+ self.execfunction = execfunction
+ apply(ActionBase.__init__, (self,), kw)
+ self.varlist = kw.get('varlist', [])
+
+ def function_name(self):
+ try:
+ return self.execfunction.__name__
+ except AttributeError:
+ try:
+ return self.execfunction.__class__.__name__
+ except AttributeError:
+ return "unknown_python_function"
+
+ def strfunction(self, target, source, env):
+ def array(a):
+ def quote(s):
+ return '"' + str(s) + '"'
+ return '[' + string.join(map(quote, a), ", ") + ']'
+ name = self.function_name()
+ tstr = array(target)
+ sstr = array(source)
+ return "%s(%s, %s)" % (name, tstr, sstr)
+
+ def __str__(self):
+ return "%s(env, target, source)" % self.function_name()
+
+ def execute(self, target, source, env):
+ rsources = map(rfile, source)
+ return self.execfunction(target=target, source=rsources, env=env)
+
+ def get_contents(self, target, source, env, dict=None):
+ """Return the signature contents of this callable action.
+
+ By providing direct access to the code object of the
+ function, Python makes this extremely easy. Hooray!
+ """
+ try:
+ # "self.execfunction" is a function.
+ contents = str(self.execfunction.func_code.co_code)
+ except AttributeError:
+ # "self.execfunction" is a callable object.
+ try:
+ contents = str(self.execfunction.__call__.im_func.func_code.co_code)
+ except AttributeError:
+ try:
+ # See if execfunction will do the heavy lifting for us.
+ gc = self.execfunction.get_contents
+ except AttributeError:
+ # This is weird, just do the best we can.
+ contents = str(self.execfunction)
+ else:
+ contents = gc(target, source, env, dict)
+ return contents + env.subst(string.join(map(lambda v: '${'+v+'}',
+ self.varlist)))
+
+class ListAction(ActionBase):
+ """Class for lists of other actions."""
+ def __init__(self, list, **kw):
+ if __debug__: logInstanceCreation(self)
+ apply(ActionBase.__init__, (self,), kw)
+ self.list = map(lambda x: Action(x), list)
+
+ def get_actions(self):
+ return self.list
+
+ def __str__(self):
+ s = []
+ for l in self.list:
+ s.append(str(l))
+ return string.join(s, "\n")
+
+ def strfunction(self, target, source, env):
+ s = []
+ for l in self.list:
+ if l.strfunction:
+ x = l.strfunction(target, source, env)
+ if not SCons.Util.is_List(x):
+ x = [x]
+ s.extend(x)
+ return string.join(s, "\n")
+
+ def execute(self, target, source, env):
+ for l in self.list:
+ r = l.execute(target, source, env)
+ if r:
+ return r
+ return 0
+
+ def get_contents(self, target, source, env, dict=None):
+ """Return the signature contents of this action list.
+
+ Simple concatenation of the signatures of the elements.
+ """
+ dict = SCons.Util.subst_dict(target, source)
+ return string.join(map(lambda x, t=target, s=source, e=env, d=dict:
+ x.get_contents(t, s, e, d),
+ self.list),
+ "")
+
+class ActionCaller:
+ """A class for delaying calling an Action function with specific
+ (positional and keyword) arguments until the Action is actually
+ executed.
+
+ This class looks to the rest of the world like a normal Action object,
+ but what it's really doing is hanging on to the arguments until we
+ have a target, source and env to use for the expansion.
+ """
+ def __init__(self, parent, args, kw):
+ self.parent = parent
+ self.args = args
+ self.kw = kw
+ def get_contents(self, target, source, env, dict=None):
+ actfunc = self.parent.actfunc
+ try:
+ # "self.actfunc" is a function.
+ contents = str(actfunc.func_code.co_code)
+ except AttributeError:
+ # "self.actfunc" is a callable object.
+ try:
+ contents = str(actfunc.__call__.im_func.func_code.co_code)
+ except AttributeError:
+ # No __call__() method, so it might be a builtin
+ # or something like that. Do the best we can.
+ contents = str(actfunc)
+ return contents
+ def subst_args(self, target, source, env):
+ return map(lambda x, e=env, t=target, s=source:
+ e.subst(x, 0, t, s),
+ self.args)
+ def subst_kw(self, target, source, env):
+ kw = {}
+ for key in self.kw.keys():
+ kw[key] = env.subst(self.kw[key], 0, target, source)
+ return kw
+ def __call__(self, target, source, env):
+ args = self.subst_args(target, source, env)
+ kw = self.subst_kw(target, source, env)
+ return apply(self.parent.actfunc, args, kw)
+ def strfunction(self, target, source, env):
+ args = self.subst_args(target, source, env)
+ kw = self.subst_kw(target, source, env)
+ return apply(self.parent.strfunc, args, kw)
+
+class ActionFactory:
+ """A factory class that will wrap up an arbitrary function
+ as an SCons-executable Action object.
+
+ The real heavy lifting here is done by the ActionCaller class.
+ We just collect the (positional and keyword) arguments that we're
+ called with and give them to the ActionCaller object we create,
+ so it can hang onto them until it needs them.
+ """
+ def __init__(self, actfunc, strfunc):
+ self.actfunc = actfunc
+ self.strfunc = strfunc
+ def __call__(self, *args, **kw):
+ ac = ActionCaller(self, args, kw)
+ return Action(ac, strfunction=ac.strfunction)
Added: development/support/scons/scons-local-0.96.1/SCons/Builder.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Builder.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Builder.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,772 @@
+"""SCons.Builder
+
+Builder object subsystem.
+
+A Builder object is a callable that encapsulates information about how
+to execute actions to create a target Node (file) from source Nodes
+(files), and how to create those dependencies for tracking.
+
+The main entry point here is the Builder() factory method. This provides
+a procedural interface that creates the right underlying Builder object
+based on the keyword arguments supplied and the types of the arguments.
+
+The goal is for this external interface to be simple enough that the
+vast majority of users can create new Builders as necessary to support
+building new types of files in their configurations, without having to
+dive any deeper into this subsystem.
+
+The base class here is BuilderBase. This is a concrete base class which
+does, in fact, represent most Builder objects that we (or users) create.
+
+There is (at present) one subclasses:
+
+ MultiStepBuilder
+
+ This is a Builder that knows how to "chain" Builders so that
+ users can specify a source file that requires multiple steps
+ to turn into a target file. A canonical example is building a
+ program from yacc input file, which requires invoking a builder
+ to turn the .y into a .c, the .c into a .o, and the .o into an
+ executable program.
+
+There is also two proxies that look like Builders:
+
+ CompositeBuilder
+
+ This proxies for a Builder with an action that is actually a
+ dictionary that knows how to map file suffixes to a specific
+ action. This is so that we can invoke different actions
+ (compilers, compile options) for different flavors of source
+ files.
+
+ ListBuilder
+
+ This proxies for a Builder *invocation* where the target
+ is a list of files, not a single file.
+
+Builders and their proxies have the following public interface methods
+used by other modules:
+
+ __call__()
+ THE public interface. Calling a Builder object (with the
+ use of internal helper methods) sets up the target and source
+ dependencies, appropriate mapping to a specific action, and the
+ environment manipulation necessary for overridden construction
+ variable. This also takes care of warning about possible mistakes
+ in keyword arguments.
+
+ targets()
+ Returns the list of targets for a specific builder instance.
+
+ add_emitter()
+ Adds an emitter for a specific file suffix, used by some Tool
+ modules to specify that (for example) a yacc invocation on a .y
+ can create a .h *and* a .c file.
+
+ add_action()
+ Adds an action for a specific file suffix, heavily used by
+ Tool modules to add their specific action(s) for turning
+ a source file into an object file to the global static
+ and shared object file Builders.
+
+There are the following methods for internal use within this module:
+
+ _execute()
+ The internal method that handles the heavily lifting when a
+ Builder is called. This is used so that the __call__() methods
+ can set up warning about possible mistakes in keyword-argument
+ overrides, and *then* execute all of the steps necessary so that
+ the warnings only occur once.
+
+ get_name()
+ Returns the Builder's name within a specific Environment,
+ primarily used to try to return helpful information in error
+ messages.
+
+ adjust_suffix()
+ get_prefix()
+ get_suffix()
+ get_src_suffix()
+ set_src_suffix()
+ Miscellaneous stuff for handling the prefix and suffix
+ manipulation we use in turning source file names into target
+ file names.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Builder.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import UserDict
+import UserList
+
+import SCons.Action
+from SCons.Debug import logInstanceCreation
+from SCons.Errors import InternalError, UserError
+import SCons.Executor
+import SCons.Node.FS
+import SCons.Util
+import SCons.Warnings
+
+class _Null:
+ pass
+
+_null = _Null
+
+class DictCmdGenerator(SCons.Util.Selector):
+ """This is a callable class that can be used as a
+ command generator function. It holds on to a dictionary
+ mapping file suffixes to Actions. It uses that dictionary
+ to return the proper action based on the file suffix of
+ the source file."""
+
+ def src_suffixes(self):
+ return self.keys()
+
+ def add_action(self, suffix, action):
+ """Add a suffix-action pair to the mapping.
+ """
+ self[suffix] = action
+
+ def __call__(self, target, source, env, for_signature):
+ ext = None
+ for src in map(str, source):
+ my_ext = SCons.Util.splitext(src)[1]
+ if ext and my_ext != ext:
+ raise UserError("While building `%s' from `%s': Cannot build multiple sources with different extensions: %s, %s" % (repr(map(str, target)), src, ext, my_ext))
+ ext = my_ext
+
+ if not ext:
+ raise UserError("While building `%s': Cannot deduce file extension from source files: %s" % (repr(map(str, target)), repr(map(str, source))))
+
+ try:
+ ret = SCons.Util.Selector.__call__(self, env, source)
+ except KeyError, e:
+ raise UserError("Ambiguous suffixes after environment substitution: %s == %s == %s" % (e[0], e[1], e[2]))
+ if ret is None:
+ raise UserError("While building `%s': Don't know how to build a file with suffix `%s'." % (repr(map(str, target)), ext))
+ return ret
+
+class CallableSelector(SCons.Util.Selector):
+ """A callable dictionary that will, in turn, call the value it
+ finds if it can."""
+ def __call__(self, env, source):
+ value = SCons.Util.Selector.__call__(self, env, source)
+ if callable(value):
+ value = value(env, source)
+ return value
+
+class DictEmitter(SCons.Util.Selector):
+ """A callable dictionary that maps file suffixes to emitters.
+ When called, it finds the right emitter in its dictionary for the
+ suffix of the first source file, and calls that emitter to get the
+ right lists of targets and sources to return. If there's no emitter
+ for the suffix in its dictionary, the original target and source are
+ returned.
+ """
+ def __call__(self, target, source, env):
+ emitter = SCons.Util.Selector.__call__(self, env, source)
+ if emitter:
+ target, source = emitter(target, source, env)
+ return (target, source)
+
+class ListEmitter(UserList.UserList):
+ """A callable list of emitters that calls each in sequence,
+ returning the result.
+ """
+ def __call__(self, target, source, env):
+ for e in self.data:
+ target, source = e(target, source, env)
+ return (target, source)
+
+# These are a common errors when calling a Builder;
+# they are similar to the 'target' and 'source' keyword args to builders,
+# so we issue warnings when we see them. The warnings can, of course,
+# be disabled.
+misleading_keywords = {
+ 'targets' : 'target',
+ 'sources' : 'source',
+}
+
+class OverrideWarner(UserDict.UserDict):
+ """A class for warning about keyword arguments that we use as
+ overrides in a Builder call.
+
+ This class exists to handle the fact that a single MultiStepBuilder
+ call can actually invoke multiple builders as a result of a single
+ user-level Builder call. This class only emits the warnings once,
+ no matter how many Builders are invoked.
+ """
+ def __init__(self, dict):
+ UserDict.UserDict.__init__(self, dict)
+ self.already_warned = None
+ def warn(self):
+ if self.already_warned:
+ return
+ for k in self.keys():
+ try:
+ alt = misleading_keywords[k]
+ except KeyError:
+ pass
+ else:
+ SCons.Warnings.warn(SCons.Warnings.MisleadingKeywordsWarning,
+ "Did you mean to use `%s' instead of `%s'?" % (alt, k))
+ self.already_warned = 1
+
+def Builder(**kw):
+ """A factory for builder objects."""
+ composite = None
+ if kw.has_key('generator'):
+ if kw.has_key('action'):
+ raise UserError, "You must not specify both an action and a generator."
+ kw['action'] = SCons.Action.CommandGenerator(kw['generator'])
+ del kw['generator']
+ elif kw.has_key('action') and SCons.Util.is_Dict(kw['action']):
+ composite = DictCmdGenerator(kw['action'])
+ kw['action'] = SCons.Action.CommandGenerator(composite)
+ kw['src_suffix'] = composite.src_suffixes()
+
+ if kw.has_key('emitter'):
+ emitter = kw['emitter']
+ if SCons.Util.is_String(emitter):
+ # This allows users to pass in an Environment
+ # variable reference (like "$FOO") as an emitter.
+ # We will look in that Environment variable for
+ # a callable to use as the actual emitter.
+ var = SCons.Util.get_environment_var(emitter)
+ if not var:
+ raise UserError, "Supplied emitter '%s' does not appear to refer to an Environment variable" % emitter
+ kw['emitter'] = EmitterProxy(var)
+ elif SCons.Util.is_Dict(emitter):
+ kw['emitter'] = DictEmitter(emitter)
+ elif SCons.Util.is_List(emitter):
+ kw['emitter'] = ListEmitter(emitter)
+
+ if kw.has_key('src_builder'):
+ ret = apply(MultiStepBuilder, (), kw)
+ else:
+ ret = apply(BuilderBase, (), kw)
+
+ if not composite is None:
+ ret = CompositeBuilder(ret, composite)
+
+ return ret
+
+def _init_nodes(builder, env, overrides, tlist, slist):
+ """Initialize lists of target and source nodes with all of
+ the proper Builder information.
+ """
+
+ # First, figure out if there are any errors in the way the targets
+ # were specified.
+ for t in tlist:
+ if t.side_effect:
+ raise UserError, "Multiple ways to build the same target were specified for: %s" % str(t)
+ if t.has_builder():
+ if not t.env is None and not t.env is env:
+ t_contents = t.builder.action.get_contents(tlist, slist, t.env)
+ contents = t.builder.action.get_contents(tlist, slist, env)
+
+ if t_contents == contents:
+ SCons.Warnings.warn(SCons.Warnings.DuplicateEnvironmentWarning,
+ "Two different environments were specified for target %s,\n\tbut they appear to have the same action: %s"%(str(t), t.builder.action.strfunction(tlist, slist, t.env)))
+
+ else:
+ raise UserError, "Two environments with different actions were specified for the same target: %s"%str(t)
+
+ elif t.overrides != overrides:
+ raise UserError, "Two different sets of overrides were specified for the same target: %s"%str(t)
+
+ elif builder.target_scanner and t.target_scanner and builder.target_scanner != t.target_scanner:
+ raise UserError, "Two different scanners were specified for the same target: %s"%str(t)
+
+ if builder.multi:
+ if t.builder != builder:
+ if isinstance(t.builder, ListBuilder) and isinstance(builder, ListBuilder) and t.builder.builder == builder.builder:
+ raise UserError, "Two different target sets have a target in common: %s"%str(t)
+ else:
+ raise UserError, "Two different builders (%s and %s) were specified for the same target: %s"%(t.builder.get_name(env), builder.get_name(env), str(t))
+ elif t.sources != slist:
+ raise UserError, "Multiple ways to build the same target were specified for: %s" % str(t)
+
+ if builder.single_source:
+ if len(slist) > 1:
+ raise UserError, "More than one source given for single-source builder: targets=%s sources=%s" % (map(str,tlist), map(str,slist))
+
+ # The targets are fine, so find or make the appropriate Executor to
+ # build this particular list of targets from this particular list of
+ # sources.
+ executor = None
+ if builder.multi:
+ try:
+ executor = tlist[0].get_executor(create = 0)
+ except AttributeError:
+ pass
+ else:
+ executor.add_sources(slist)
+ if executor is None:
+ executor = SCons.Executor.Executor(builder.action,
+ env or builder.env,
+ [builder.overrides, overrides],
+ tlist,
+ slist)
+
+ # Now set up the relevant information in the target Nodes themselves.
+ for t in tlist:
+ t.overrides = overrides
+ t.cwd = SCons.Node.FS.default_fs.getcwd()
+ t.builder_set(builder)
+ t.env_set(env)
+ t.add_source(slist)
+ t.set_executor(executor)
+ if builder.target_scanner:
+ t.target_scanner = builder.target_scanner
+ if t.source_scanner is None:
+ t.source_scanner = builder.source_scanner
+
+ # Add backup source scanners from the environment to the source
+ # nodes. This may not be necessary if the node will have a real
+ # source scanner added later (which is why these are the "backup"
+ # source scanners, not the real ones), but because source nodes may
+ # be used multiple times for different targets, it ends up being
+ # more efficient to do this calculation once here, as opposed to
+ # delaying it until later when we potentially have to calculate it
+ # over and over and over.
+ for s in slist:
+ if s.source_scanner is None and s.backup_source_scanner is None:
+ s.backup_source_scanner = env.get_scanner(s.scanner_key())
+
+class EmitterProxy:
+ """This is a callable class that can act as a
+ Builder emitter. It holds on to a string that
+ is a key into an Environment dictionary, and will
+ look there at actual build time to see if it holds
+ a callable. If so, we will call that as the actual
+ emitter."""
+ def __init__(self, var):
+ self.var = SCons.Util.to_String(var)
+
+ def __call__(self, target, source, env):
+ emitter = self.var
+
+ # Recursively substitute the variable.
+ # We can't use env.subst() because it deals only
+ # in strings. Maybe we should change that?
+ while SCons.Util.is_String(emitter) and env.has_key(emitter):
+ emitter = env[emitter]
+ if callable(emitter):
+ target, source = emitter(target, source, env)
+ elif SCons.Util.is_List(emitter):
+ for e in emitter:
+ target, source = e(target, source, env)
+
+ return (target, source)
+
+
+ def __cmp__(self, other):
+ return cmp(self.var, other.var)
+
+class BuilderBase:
+ """Base class for Builders, objects that create output
+ nodes (files) from input nodes (files).
+ """
+
+ def __init__(self, action = None,
+ prefix = '',
+ suffix = '',
+ src_suffix = '',
+ target_factory = SCons.Node.FS.default_fs.File,
+ source_factory = SCons.Node.FS.default_fs.File,
+ target_scanner = None,
+ source_scanner = None,
+ emitter = None,
+ multi = 0,
+ env = None,
+ single_source = 0,
+ **overrides):
+ if __debug__: logInstanceCreation(self, 'BuilderBase')
+ self.action = SCons.Action.Action(action)
+ self.multi = multi
+ if SCons.Util.is_Dict(prefix):
+ prefix = CallableSelector(prefix)
+ self.prefix = prefix
+ if SCons.Util.is_Dict(suffix):
+ suffix = CallableSelector(suffix)
+ self.suffix = suffix
+ self.env = env
+ self.single_source = single_source
+ if overrides.has_key('overrides'):
+ SCons.Warnings.warn(SCons.Warnings.DeprecatedWarning,
+ "The \"overrides\" keyword to Builder() creation has been deprecated;\n" +\
+ "\tspecify the items as keyword arguments to the Builder() call instead.")
+ overrides.update(overrides['overrides'])
+ del overrides['overrides']
+ self.overrides = overrides
+
+ self.set_src_suffix(src_suffix)
+
+ self.target_factory = target_factory
+ self.source_factory = source_factory
+ self.target_scanner = target_scanner
+ self.source_scanner = source_scanner
+
+ self.emitter = emitter
+
+ def __nonzero__(self):
+ raise InternalError, "Do not test for the Node.builder attribute directly; use Node.has_builder() instead"
+
+ def get_name(self, env):
+ """Attempts to get the name of the Builder.
+
+ Look at the BUILDERS variable of env, expecting it to be a
+ dictionary containing this Builder, and return the key of the
+ dictionary."""
+
+ try:
+ index = env['BUILDERS'].values().index(self)
+ return env['BUILDERS'].keys()[index]
+ except (AttributeError, KeyError, ValueError):
+ return str(self.__class__)
+
+ def __cmp__(self, other):
+ return cmp(self.__dict__, other.__dict__)
+
+ def splitext(self, path):
+ return SCons.Util.splitext(path)
+
+ def _create_nodes(self, env, overwarn, target = None, source = None):
+ """Create and return lists of target and source nodes.
+ """
+ def _adjustixes(files, pre, suf):
+ if not files:
+ return []
+ result = []
+ if not SCons.Util.is_List(files):
+ files = [files]
+
+ for f in files:
+ if SCons.Util.is_String(f):
+ f = SCons.Util.adjustixes(f, pre, suf)
+ result.append(f)
+ return result
+
+ overwarn.warn()
+
+ env = env.Override(overwarn.data)
+
+ src_suf = self.get_src_suffix(env)
+
+ source = _adjustixes(source, None, src_suf)
+ slist = env.arg2nodes(source, self.source_factory)
+
+ pre = self.get_prefix(env, slist)
+ suf = self.get_suffix(env, slist)
+
+ if target is None:
+ try:
+ t_from_s = slist[0].target_from_source
+ except AttributeError:
+ raise UserError("Do not know how to create a target from source `%s'" % slist[0])
+ tlist = [ t_from_s(pre, suf, self.splitext) ]
+ else:
+ target = _adjustixes(target, pre, suf)
+ tlist = env.arg2nodes(target, self.target_factory)
+
+ if self.emitter:
+ # The emitter is going to do str(node), but because we're
+ # being called *from* a builder invocation, the new targets
+ # don't yet have a builder set on them and will look like
+ # source files. Fool the emitter's str() calls by setting
+ # up a temporary builder on the new targets.
+ new_targets = []
+ for t in tlist:
+ if not t.is_derived():
+ t.builder = self
+ new_targets.append(t)
+
+ target, source = self.emitter(target=tlist, source=slist, env=env)
+
+ # Now delete the temporary builders that we attached to any
+ # new targets, so that _init_nodes() doesn't do weird stuff
+ # to them because it thinks they already have builders.
+ for t in new_targets:
+ if t.builder is self:
+ # Only delete the temporary builder if the emitter
+ # didn't change it on us.
+ t.builder = None
+
+ # Have to call arg2nodes yet again, since it is legal for
+ # emitters to spit out strings as well as Node instances.
+ slist = env.arg2nodes(source, self.source_factory)
+ tlist = env.arg2nodes(target, self.target_factory)
+
+ return tlist, slist
+
+ def _execute(self, env, target = None, source = _null, overwarn={}):
+ if source is _null:
+ source = target
+ target = None
+
+ if(self.single_source and
+ SCons.Util.is_List(source) and
+ len(source) > 1 and
+ target is None):
+ result = []
+ if target is None: target = [None]*len(source)
+ for k in range(len(source)):
+ t = self._execute(env, target[k], source[k], overwarn)
+ if SCons.Util.is_List(t):
+ result.extend(t)
+ else:
+ result.append(t)
+ return result
+
+ tlist, slist = self._create_nodes(env, overwarn, target, source)
+
+ if len(tlist) == 1:
+ builder = self
+ else:
+ builder = ListBuilder(self, env, tlist)
+ _init_nodes(builder, env, overwarn.data, tlist, slist)
+
+ return tlist
+
+ def __call__(self, env, target = None, source = _null, **kw):
+ return self._execute(env, target, source, OverrideWarner(kw))
+
+ def adjust_suffix(self, suff):
+ if suff and not suff[0] in [ '.', '_', '$' ]:
+ return '.' + suff
+ return suff
+
+ def get_prefix(self, env, sources=[]):
+ prefix = self.prefix
+ if callable(prefix):
+ prefix = prefix(env, sources)
+ return env.subst(prefix)
+
+ def get_suffix(self, env, sources=[]):
+ suffix = self.suffix
+ if callable(suffix):
+ suffix = suffix(env, sources)
+ else:
+ suffix = self.adjust_suffix(suffix)
+ return env.subst(suffix)
+
+ def src_suffixes(self, env):
+ return map(lambda x, s=self, e=env: e.subst(s.adjust_suffix(x)),
+ self.src_suffix)
+
+ def set_src_suffix(self, src_suffix):
+ if not src_suffix:
+ src_suffix = []
+ elif not SCons.Util.is_List(src_suffix):
+ src_suffix = [ src_suffix ]
+ self.src_suffix = src_suffix
+
+ def get_src_suffix(self, env):
+ """Get the first src_suffix in the list of src_suffixes."""
+ ret = self.src_suffixes(env)
+ if not ret:
+ return ''
+ return ret[0]
+
+ def targets(self, node):
+ """Return the list of targets for this builder instance.
+
+ For most normal builders, this is just the supplied node.
+ """
+ return [ node ]
+
+ def add_emitter(self, suffix, emitter):
+ """Add a suffix-emitter mapping to this Builder.
+
+ This assumes that emitter has been initialized with an
+ appropriate dictionary type, and will throw a TypeError if
+ not, so the caller is responsible for knowing that this is an
+ appropriate method to call for the Builder in question.
+ """
+ self.emitter[suffix] = emitter
+
+class ListBuilder(SCons.Util.Proxy):
+ """A Proxy to support building an array of targets (for example,
+ foo.o and foo.h from foo.y) from a single Action execution.
+ """
+
+ def __init__(self, builder, env, tlist):
+ if __debug__: logInstanceCreation(self)
+ SCons.Util.Proxy.__init__(self, builder)
+ self.builder = builder
+ self.target_scanner = builder.target_scanner
+ self.source_scanner = builder.source_scanner
+ self.env = env
+ self.tlist = tlist
+ self.multi = builder.multi
+ self.single_source = builder.single_source
+
+ def targets(self, node):
+ """Return the list of targets for this builder instance.
+ """
+ return self.tlist
+
+ def __cmp__(self, other):
+ return cmp(self.__dict__, other.__dict__)
+
+ def get_name(self, env):
+ """Attempts to get the name of the Builder."""
+
+ return "ListBuilder(%s)" % self.builder.get_name(env)
+
+class MultiStepBuilder(BuilderBase):
+ """This is a builder subclass that can build targets in
+ multiple steps. The src_builder parameter to the constructor
+ accepts a builder that is called to build sources supplied to
+ this builder. The targets of that first build then become
+ the sources of this builder.
+
+ If this builder has a src_suffix supplied, then the src_builder
+ builder is NOT invoked if the suffix of a source file matches
+ src_suffix.
+ """
+ def __init__(self, src_builder,
+ action = None,
+ prefix = '',
+ suffix = '',
+ src_suffix = '',
+ target_factory = SCons.Node.FS.default_fs.File,
+ source_factory = SCons.Node.FS.default_fs.File,
+ target_scanner = None,
+ source_scanner = None,
+ emitter=None,
+ single_source=0):
+ if __debug__: logInstanceCreation(self)
+ BuilderBase.__init__(self, action, prefix, suffix, src_suffix,
+ target_factory, source_factory,
+ target_scanner, source_scanner, emitter,
+ single_source = single_source)
+ if not SCons.Util.is_List(src_builder):
+ src_builder = [ src_builder ]
+ self.src_builder = src_builder
+ self.sdict = {}
+ self.cached_src_suffixes = {} # source suffixes keyed on id(env)
+
+ def _execute(self, env, target = None, source = _null, overwarn={}):
+ if source is _null:
+ source = target
+ target = None
+
+ slist = env.arg2nodes(source, self.source_factory)
+ final_sources = []
+
+ try:
+ sdict = self.sdict[id(env)]
+ except KeyError:
+ sdict = {}
+ self.sdict[id(env)] = sdict
+ for bld in self.src_builder:
+ if SCons.Util.is_String(bld):
+ try:
+ bld = env['BUILDERS'][bld]
+ except KeyError:
+ continue
+ for suf in bld.src_suffixes(env):
+ sdict[suf] = bld
+
+ src_suffixes = self.src_suffixes(env)
+
+ for snode in slist:
+ try:
+ get_suffix = snode.get_suffix
+ except AttributeError:
+ ext = self.splitext(str(snode))
+ else:
+ ext = get_suffix()
+ try:
+ subsidiary_builder = sdict[ext]
+ except KeyError:
+ final_sources.append(snode)
+ else:
+ tgt = subsidiary_builder._execute(env, None, snode, overwarn)
+ # If the subsidiary Builder returned more than one target,
+ # then filter out any sources that this Builder isn't
+ # capable of building.
+ if len(tgt) > 1:
+ tgt = filter(lambda x, self=self, suf=src_suffixes:
+ self.splitext(SCons.Util.to_String(x))[1] in suf,
+ tgt)
+ final_sources.extend(tgt)
+
+ return BuilderBase._execute(self, env, target, final_sources, overwarn)
+
+ def get_src_builders(self, env):
+ """Return all the src_builders for this Builder.
+
+ This is essentially a recursive descent of the src_builder "tree."
+ """
+ ret = []
+ for bld in self.src_builder:
+ if SCons.Util.is_String(bld):
+ # All Environments should have a BUILDERS
+ # variable, so no need to check for it.
+ try:
+ bld = env['BUILDERS'][bld]
+ except KeyError:
+ continue
+ ret.append(bld)
+ return ret
+
+ def src_suffixes(self, env):
+ """Return a list of the src_suffix attributes for all
+ src_builders of this Builder.
+ """
+ try:
+ return self.cached_src_suffixes[id(env)]
+ except KeyError:
+ suffixes = BuilderBase.src_suffixes(self, env)
+ for builder in self.get_src_builders(env):
+ suffixes.extend(builder.src_suffixes(env))
+ self.cached_src_suffixes[id(env)] = suffixes
+ return suffixes
+
+class CompositeBuilder(SCons.Util.Proxy):
+ """A Builder Proxy whose main purpose is to always have
+ a DictCmdGenerator as its action, and to provide access
+ to the DictCmdGenerator's add_action() method.
+ """
+
+ def __init__(self, builder, cmdgen):
+ if __debug__: logInstanceCreation(self)
+ SCons.Util.Proxy.__init__(self, builder)
+
+ # cmdgen should always be an instance of DictCmdGenerator.
+ self.cmdgen = cmdgen
+ self.builder = builder
+
+ def add_action(self, suffix, action):
+ self.cmdgen.add_action(suffix, action)
+ self.set_src_suffix(self.cmdgen.src_suffixes())
+
+ def __cmp__(self, other):
+ return cmp(self.__dict__, other.__dict__)
Added: development/support/scons/scons-local-0.96.1/SCons/Conftest.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Conftest.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Conftest.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,488 @@
+"""SCons.Conftest
+
+Autoconf-like configuration support; low level implementation of tests.
+"""
+
+#
+# Copyright (c) 2003 Stichting NLnet Labs
+# Copyright (c) 2001, 2002, 2003 Steven Knight
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+#
+# The purpose of this module is to define how a check is to be performed.
+# Use one of the Check...() functions below.
+#
+
+#
+# A context class is used that defines functions for carrying out the tests,
+# logging and messages. The following methods and members must be present:
+#
+# context.Display(msg) Function called to print messages that are normally
+# displayed for the user. Newlines are explicitly used.
+# The text should also be written to the logfile!
+#
+# context.Log(msg) Function called to write to a log file.
+#
+# context.BuildProg(text, ext)
+# Function called to build a program, using "ext" for the
+# file extention. Must return an empty string for
+# success, an error message for failure.
+# For reliable test results building should be done just
+# like an actual program would be build, using the same
+# command and arguments (including configure results so
+# far).
+#
+# context.CompileProg(text, ext)
+# Function called to compile a program, using "ext" for
+# the file extention. Must return an empty string for
+# success, an error message for failure.
+# For reliable test results compiling should be done just
+# like an actual source file would be compiled, using the
+# same command and arguments (including configure results
+# so far).
+#
+# context.AppendLIBS(lib_name_list)
+# Append "lib_name_list" to the value of LIBS.
+# "lib_namelist" is a list of strings.
+# Return the value of LIBS before changing it (any type
+# can be used, it is passed to SetLIBS() later.
+#
+# context.SetLIBS(value)
+# Set LIBS to "value". The type of "value" is what
+# AppendLIBS() returned.
+# Return the value of LIBS before changing it (any type
+# can be used, it is passed to SetLIBS() later.
+#
+# context.headerfilename
+# Name of file to append configure results to, usually
+# "confdefs.h".
+# The file must not exist or be empty when starting.
+# Empty or None to skip this (some tests will not work!).
+#
+# context.vardict Dictionary holding variables used for the tests and
+# stores results from the tests, used for the build
+# commands.
+# Normally contains "CC", "LIBS", "CPPFLAGS", etc.
+#
+# context.havedict Dictionary holding results from the tests that are to
+# be used inside a program.
+# Names often start with "HAVE_". These are zero
+# (feature not present) or one (feature present). Other
+# variables may have any value, e.g., "PERLVERSION" can
+# be a number and "SYSTEMNAME" a string.
+#
+
+import string
+from types import IntType
+
+#
+# PUBLIC FUNCTIONS
+#
+
+# Generic remarks:
+# - When a language is specified which is not supported the test fails. The
+# message is a bit different, because not all the arguments for the normal
+# message are available yet (chicken-egg problem).
+
+
+def CheckBuilder(context, text = None, language = None):
+ """
+ Configure check to see if the compiler works.
+ Note that this uses the current value of compiler and linker flags, make
+ sure $CFLAGS, $CPPFLAGS and $LIBS are set correctly.
+ "language" should be "C" or "C++" and is used to select the compiler.
+ Default is "C".
+ "text" may be used to specify the code to be build.
+ Returns an empty string for success, an error message for failure.
+ """
+ lang, suffix, msg = _lang2suffix(language)
+ if msg:
+ context.Display("%s\n" % msg)
+ return msg
+
+ if not text:
+ text = """
+ int main() {
+ return 0;
+ }\n\n"""
+
+ context.Display("Checking if building a %s file works... " % lang)
+ ret = context.BuildProg(text, suffix)
+ _YesNoResult(context, ret, None, text)
+ return ret
+
+
+def CheckFunc(context, function_name, header = None, language = None):
+ """
+ Configure check for a function "function_name".
+ "language" should be "C" or "C++" and is used to select the compiler.
+ Default is "C".
+ Optional "header" can be defined to define a function prototype, include a
+ header file or anything else that comes before main().
+ Sets HAVE_function_name in context.havedict according to the result.
+ Note that this uses the current value of compiler and linker flags, make
+ sure $CFLAGS, $CPPFLAGS and $LIBS are set correctly.
+ Returns an empty string for success, an error message for failure.
+ """
+
+ # Remarks from autoconf:
+ # - Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
+ # which includes <sys/select.h> which contains a prototype for select.
+ # Similarly for bzero.
+ # - assert.h is included to define __stub macros and hopefully few
+ # prototypes, which can conflict with char $1(); below.
+ # - Override any gcc2 internal prototype to avoid an error.
+ # - We use char for the function declaration because int might match the
+ # return type of a gcc2 builtin and then its argument prototype would
+ # still apply.
+ # - The GNU C library defines this for functions which it implements to
+ # always fail with ENOSYS. Some functions are actually named something
+ # starting with __ and the normal name is an alias.
+
+ if context.headerfilename:
+ includetext = '#include "%s"' % context.headerfilename
+ else:
+ includetext = ''
+ if not header:
+ header = """
+ #ifdef __cplusplus
+ extern "C"
+ #endif
+ char %s();""" % function_name
+
+ lang, suffix, msg = _lang2suffix(language)
+ if msg:
+ context.Display("Cannot check for %s(): %s\n" % (function_name, msg))
+ return msg
+
+ text = """
+ %(include)s
+ #include <assert.h>
+ %(hdr)s
+
+ int main() {
+ #if defined (__stub_%(name)s) || defined (__stub___%(name)s)
+ fail fail fail
+ #else
+ %(name)s();
+ #endif
+
+ return 0;
+ }\n\n""" % { 'name': function_name,
+ 'include': includetext,
+ 'hdr': header }
+
+ context.Display("Checking for %s function %s()... " % (lang, function_name))
+ ret = context.BuildProg(text, suffix)
+ _YesNoResult(context, ret, "HAVE_" + function_name, text)
+ return ret
+
+
+def CheckHeader(context, header_name, header = None, language = None,
+ include_quotes = None):
+ """
+ Configure check for a C or C++ header file "header_name".
+ Optional "header" can be defined to do something before including the
+ header file (unusual, supported for consistency).
+ "language" should be "C" or "C++" and is used to select the compiler.
+ Default is "C".
+ Sets HAVE_header_name in context.havedict according to the result.
+ Note that this uses the current value of compiler and linker flags, make
+ sure $CFLAGS and $CPPFLAGS are set correctly.
+ Returns an empty string for success, an error message for failure.
+ """
+ # Why compile the program instead of just running the preprocessor?
+ # It is possible that the header file exists, but actually using it may
+ # fail (e.g., because it depends on other header files). Thus this test is
+ # more strict. It may require using the "header" argument.
+ #
+ # Use <> by default, because the check is normally used for system header
+ # files. SCons passes '""' to overrule this.
+
+ # Include "confdefs.h" first, so that the header can use HAVE_HEADER_H.
+ if context.headerfilename:
+ includetext = '#include "%s"\n' % context.headerfilename
+ else:
+ includetext = ''
+ if not header:
+ header = ""
+
+ lang, suffix, msg = _lang2suffix(language)
+ if msg:
+ context.Display("Cannot check for header file %s: %s\n"
+ % (header_name, msg))
+ return msg
+
+ if not include_quotes:
+ include_quotes = "<>"
+
+ text = "%s%s\n#include %s%s%s\n\n" % (includetext, header,
+ include_quotes[0], header_name, include_quotes[1])
+
+ context.Display("Checking for %s header file %s... " % (lang, header_name))
+ ret = context.CompileProg(text, suffix)
+ _YesNoResult(context, ret, "HAVE_" + header_name, text)
+ return ret
+
+
+def CheckType(context, type_name, fallback = None,
+ header = None, language = None):
+ """
+ Configure check for a C or C++ type "type_name".
+ Optional "header" can be defined to include a header file.
+ "language" should be "C" or "C++" and is used to select the compiler.
+ Default is "C".
+ Sets HAVE_type_name in context.havedict according to the result.
+ Note that this uses the current value of compiler and linker flags, make
+ sure $CFLAGS, $CPPFLAGS and $LIBS are set correctly.
+ Returns an empty string for success, an error message for failure.
+ """
+
+ # Include "confdefs.h" first, so that the header can use HAVE_HEADER_H.
+ if context.headerfilename:
+ includetext = '#include "%s"' % context.headerfilename
+ else:
+ includetext = ''
+ if not header:
+ header = ""
+
+ lang, suffix, msg = _lang2suffix(language)
+ if msg:
+ context.Display("Cannot check for %s type: %s\n" % (type_name, msg))
+ return msg
+
+ # Remarks from autoconf about this test:
+ # - Grepping for the type in include files is not reliable (grep isn't
+ # portable anyway).
+ # - Using "TYPE my_var;" doesn't work for const qualified types in C++.
+ # Adding an initializer is not valid for some C++ classes.
+ # - Using the type as parameter to a function either fails for K&$ C or for
+ # C++.
+ # - Using "TYPE *my_var;" is valid in C for some types that are not
+ # declared (struct something).
+ # - Using "sizeof(TYPE)" is valid when TYPE is actually a variable.
+ # - Using the previous two together works reliably.
+ text = """
+ %(include)s
+ %(header)s
+
+ int main() {
+ if ((%(name)s *) 0)
+ return 0;
+ if (sizeof (%(name)s))
+ return 0;
+ }\n\n""" % { 'include': includetext,
+ 'header': header,
+ 'name': type_name }
+
+ context.Display("Checking for %s type %s... " % (lang, type_name))
+ ret = context.BuildProg(text, suffix)
+ _YesNoResult(context, ret, "HAVE_" + type_name, text)
+ if ret and fallback and context.headerfilename:
+ f = open(context.headerfilename, "a")
+ f.write("typedef %s %s;\n" % (fallback, type_name))
+ f.close()
+
+ return ret
+
+
+def CheckLib(context, libs, func_name, header = None,
+ extra_libs = None, call = None, language = None, autoadd = 1):
+ """
+ Configure check for a C or C++ libraries "libs". Searches through
+ the list of libraries, until one is found where the test succeeds.
+ Tests if "func_name" or "call" exists in the library. Note: if it exists
+ in another library the test succeeds anyway!
+ Optional "header" can be defined to include a header file. If not given a
+ default prototype for "func_name" is added.
+ Optional "extra_libs" is a list of library names to be added after
+ "lib_name" in the build command. To be used for libraries that "lib_name"
+ depends on.
+ Optional "call" replaces the call to "func_name" in the test code. It must
+ consist of complete C statements, including a trailing ";".
+ There must either be a "func_name" or a "call" argument (or both).
+ "language" should be "C" or "C++" and is used to select the compiler.
+ Default is "C".
+ Note that this uses the current value of compiler and linker flags, make
+ sure $CFLAGS, $CPPFLAGS and $LIBS are set correctly.
+ Returns an empty string for success, an error message for failure.
+ """
+ # Include "confdefs.h" first, so that the header can use HAVE_HEADER_H.
+ if context.headerfilename:
+ includetext = '#include "%s"' % context.headerfilename
+ else:
+ includetext = ''
+ if not header:
+ header = ""
+
+ text = """
+ %s
+ %s """ % (includetext, header)
+
+ # Add a function declaration if needed.
+ if func_name and func_name != "main" and not header:
+ text = text + """
+ #ifdef __cplusplus
+ extern "C"
+ #endif
+ char %s();""" % func_name
+
+ # The actual test code.
+ if not call:
+ call = "%s();" % func_name
+ text = text + """
+ int
+ main() {
+ %s
+ return 0;
+ }
+ \n\n""" % call
+
+ i = string.find(call, "\n")
+ if i > 0:
+ calltext = call[:i] + ".."
+ elif call[-1] == ';':
+ calltext = call[:-1]
+ else:
+ calltext = call
+
+ for lib_name in libs:
+
+ lang, suffix, msg = _lang2suffix(language)
+ if msg:
+ context.Display("Cannot check for library %s: %s\n" % (lib_name, msg))
+ return msg
+
+ context.Display("Checking for %s in %s library %s... "
+ % (calltext, lang, lib_name))
+ if lib_name:
+ l = [ lib_name ]
+ if extra_libs:
+ l.extend(extra_libs)
+ oldLIBS = context.AppendLIBS(l)
+ sym = "HAVE_LIB" + lib_name
+ else:
+ oldLIBS = -1
+ sym = None
+
+ ret = context.BuildProg(text, suffix)
+
+ _YesNoResult(context, ret, sym, text)
+ if oldLIBS != -1 and (ret or not autoadd):
+ context.SetLIBS(oldLIBS)
+
+ if ret == "":
+ return ret
+
+ return ret
+
+#
+# END OF PUBLIC FUNCTIONS
+#
+
+def _YesNoResult(context, ret, key, text):
+ """
+ Handle the result of a test with a "yes" or "no" result.
+ "ret" is the return value: empty if OK, error message when not.
+ "key" is the name of the symbol to be defined (HAVE_foo).
+ "text" is the source code of the program used for testing.
+ """
+ if key:
+ _Have(context, key, not ret)
+ if ret:
+ context.Display("no\n")
+ _LogFailed(context, text, ret)
+ else:
+ context.Display("yes\n")
+
+
+def _Have(context, key, have):
+ """
+ Store result of a test in context.havedict and context.headerfilename.
+ "key" is a "HAVE_abc" name. It is turned into all CAPITALS and ":./" are
+ replaced by an underscore.
+ The value of "have" can be:
+ 1 - Feature is defined, add "#define key".
+ 0 - Feature is not defined, add "/* #undef key */".
+ Adding "undef" is what autoconf does. Not useful for the
+ compiler, but it shows that the test was done.
+ number - Feature is defined to this number "#define key have".
+ Doesn't work for 0 or 1, use a string then.
+ string - Feature is defined to this string "#define key have".
+ Give "have" as is should appear in the header file, include quotes
+ when desired and escape special characters!
+ """
+ key_up = string.upper(key)
+ key_up = string.replace(key_up, ':', '_')
+ key_up = string.replace(key_up, '.', '_')
+ key_up = string.replace(key_up, '/', '_')
+ key_up = string.replace(key_up, ' ', '_')
+ context.havedict[key_up] = have
+ if context.headerfilename:
+ f = open(context.headerfilename, "a")
+ if have == 1:
+ f.write("#define %s\n" % key_up)
+ elif have == 0:
+ f.write("/* #undef %s */\n" % key_up)
+ elif type(have) == IntType:
+ f.write("#define %s %d\n" % (key_up, have))
+ else:
+ f.write("#define %s %s\n" % (key_up, str(have)))
+ f.close()
+
+
+def _LogFailed(context, text, msg):
+ """
+ Write to the log about a failed program.
+ Add line numbers, so that error messages can be understood.
+ """
+ context.Log("Failed program was:\n")
+ lines = string.split(text, '\n')
+ if len(lines) and lines[-1] == '':
+ lines = lines[:-1] # remove trailing empty line
+ n = 1
+ for line in lines:
+ context.Log("%d: %s\n" % (n, line))
+ n = n + 1
+ context.Log("Error message: %s\n" % msg)
+
+
+def _lang2suffix(lang):
+ """
+ Convert a language name to a suffix.
+ When "lang" is empty or None C is assumed.
+ Returns a tuple (lang, suffix, None) when it works.
+ For an unrecognized language returns (None, None, msg).
+ Where:
+ lang = the unified language name
+ suffix = the suffix, including the leading dot
+ msg = an error message
+ """
+ if not lang or lang in ["C", "c"]:
+ return ("C", ".c", None)
+ if lang in ["c++", "C++", "cpp", "CXX", "cxx"]:
+ return ("C++", ".cpp", None)
+
+ return None, None, "Unsupported language: %s" % lang
+
+
+# vim: set sw=4 et sts=4 tw=79 fo+=l:
Added: development/support/scons/scons-local-0.96.1/SCons/Debug.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Debug.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Debug.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,102 @@
+"""SCons.Debug
+
+Code for debugging SCons internal things. Not everything here is
+guaranteed to work all the way back to Python 1.5.2, and shouldn't be
+needed by most users.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Debug.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+
+# Recipe 14.10 from the Python Cookbook.
+import string
+import sys
+try:
+ import weakref
+except ImportError:
+ def logInstanceCreation(instance, name=None):
+ pass
+else:
+ def logInstanceCreation(instance, name=None):
+ if name is None:
+ name = instance.__class__.__name__
+ if not tracked_classes.has_key(name):
+ tracked_classes[name] = []
+ tracked_classes[name].append(weakref.ref(instance))
+
+
+
+tracked_classes = {}
+
+def string_to_classes(s):
+ if s == '*':
+ c = tracked_classes.keys()
+ c.sort()
+ return c
+ else:
+ return string.split(s)
+
+def countLoggedInstances(classes, file=sys.stdout):
+ for classname in string_to_classes(classes):
+ file.write("%s: %d\n" % (classname, len(tracked_classes[classname])))
+
+def listLoggedInstances(classes, file=sys.stdout):
+ for classname in string_to_classes(classes):
+ file.write('\n%s:\n' % classname)
+ for ref in tracked_classes[classname]:
+ obj = ref()
+ if obj is not None:
+ file.write(' %s\n' % repr(obj))
+
+def dumpLoggedInstances(classes, file=sys.stdout):
+ for classname in string_to_classes(classes):
+ file.write('\n%s:\n' % classname)
+ for ref in tracked_classes[classname]:
+ obj = ref()
+ if obj is not None:
+ file.write(' %s:\n' % obj)
+ for key, value in obj.__dict__.items():
+ file.write(' %20s : %s\n' % (key, value))
+
+
+
+if sys.platform[:5] == "linux":
+ # Linux doesn't actually support memory usage stats from getrusage().
+ def memory():
+ mstr = open('/proc/self/stat').read()
+ mstr = string.split(mstr)[22]
+ return int(mstr)
+else:
+ try:
+ import resource
+ except ImportError:
+ def memory():
+ return 0
+ else:
+ def memory():
+ res = resource.getrusage(resource.RUSAGE_SELF)
+ return res[4]
Added: development/support/scons/scons-local-0.96.1/SCons/Defaults.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Defaults.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Defaults.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,356 @@
+"""SCons.Defaults
+
+Builders and other things for the local site. Here's where we'll
+duplicate the functionality of autoconf until we move it into the
+installation procedure or use something like qmconf.
+
+The code that reads the registry to find MSVC components was borrowed
+from distutils.msvccompiler.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/branch.96/baseline/src/engine/SCons/Defaults.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+
+
+import os
+import os.path
+import shutil
+import stat
+import string
+import time
+import types
+
+import SCons.Action
+import SCons.Builder
+import SCons.Environment
+import SCons.Scanner.C
+import SCons.Scanner.D
+import SCons.Scanner.Prog
+import SCons.Sig
+
+# A placeholder for a default Environment (for fetching source files
+# from source code management systems and the like). This must be
+# initialized later, after the top-level directory is set by the calling
+# interface.
+_default_env = None
+
+# Lazily instantiate the default environment so the overhead of creating
+# it doesn't apply when it's not needed.
+def DefaultEnvironment(*args, **kw):
+ global _default_env
+ if not _default_env:
+ _default_env = apply(SCons.Environment.Environment, args, kw)
+ _default_env._build_signature = 1
+ _default_env._calc_module = SCons.Sig.default_module
+ return _default_env
+
+# Emitters for setting the shared attribute on object files,
+# and an action for checking that all of the source files
+# going into a shared library are, in fact, shared.
+def StaticObjectEmitter(target, source, env):
+ for tgt in target:
+ tgt.attributes.shared = None
+ return (target, source)
+
+def SharedObjectEmitter(target, source, env):
+ for tgt in target:
+ tgt.attributes.shared = 1
+ return (target, source)
+
+def SharedFlagChecker(source, target, env):
+ same = env.subst('$STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME')
+ if same == '0' or same == '' or same == 'False':
+ for src in source:
+ try:
+ shared = src.attributes.shared
+ except AttributeError:
+ shared = None
+ if not shared:
+ raise SCons.Errors.UserError, "Source file: %s is static and is not compatible with shared target: %s" % (src, target[0])
+
+SharedCheck = SCons.Action.Action(SharedFlagChecker, None)
+
+# Scanners and suffixes for common languages.
+ObjSourceScan = SCons.Scanner.Scanner({})
+
+CScan = SCons.Scanner.C.CScan()
+
+CSuffixes = [".c", ".C", ".cxx", ".cpp", ".c++", ".cc",
+ ".h", ".H", ".hxx", ".hpp", ".hh",
+ ".F", ".fpp", ".FPP",
+ ".S", ".spp", ".SPP"]
+
+for suffix in CSuffixes:
+ ObjSourceScan.add_scanner(suffix, CScan)
+
+DScan = SCons.Scanner.D.DScan()
+
+DSuffixes = ['.d']
+
+for suffix in DSuffixes:
+ ObjSourceScan.add_scanner(suffix, DScan)
+
+IDLSuffixes = [".idl", ".IDL"]
+
+# cleanup
+del suffix
+
+# Actions for common languages.
+CAction = SCons.Action.Action("$CCCOM")
+DAction = SCons.Action.Action("$DCOM")
+ShCAction = SCons.Action.Action("$SHCCCOM")
+CXXAction = SCons.Action.Action("$CXXCOM")
+ShCXXAction = SCons.Action.Action("$SHCXXCOM")
+
+ASAction = SCons.Action.Action("$ASCOM")
+ASPPAction = SCons.Action.Action("$ASPPCOM")
+
+LinkAction = SCons.Action.Action("$LINKCOM")
+ShLinkAction = SCons.Action.Action("$SHLINKCOM")
+
+ArAction = SCons.Action.Action("$ARCOM")
+
+LexAction = SCons.Action.Action("$LEXCOM")
+YaccAction = SCons.Action.Action("$YACCCOM")
+
+ProgScan = SCons.Scanner.Prog.ProgScan()
+
+def DVI():
+ """Common function to generate a DVI file Builder."""
+ return SCons.Builder.Builder(action = {},
+ # The suffix is not configurable via a
+ # construction variable like $DVISUFFIX
+ # because the output file name is
+ # hard-coded within TeX.
+ suffix = '.dvi')
+
+def PDF():
+ """A function for generating the PDF Builder."""
+ return SCons.Builder.Builder(action = { },
+ prefix = '$PDFPREFIX',
+ suffix = '$PDFSUFFIX')
+
+# Common tasks that we allow users to perform in platform-independent
+# ways by creating ActionFactory instances.
+ActionFactory = SCons.Action.ActionFactory
+
+Chmod = ActionFactory(os.chmod,
+ lambda dest, mode: 'Chmod("%s", 0%o)' % (dest, mode))
+
+def Copy(dest, src):
+ def _copy_func(target, source, env, dest=dest, src=src):
+ dest = str(env.arg2nodes(dest, env.fs.Entry)[0])
+ src = str(env.arg2nodes(src, env.fs.Entry)[0])
+ shutil.copytree(src, dest, 1)
+ def _copy_str(target, source, env, dest=dest, src=src):
+ dest = str(env.arg2nodes(dest, env.fs.Entry)[0])
+ src = str(env.arg2nodes(src, env.fs.Entry)[0])
+ return 'Copy("%s", "%s")' % (dest, src)
+ return SCons.Action.Action(_copy_func, strfunction=_copy_str)
+
+def copy_func(dest, src):
+ if os.path.isfile(src):
+ return shutil.copy(src, dest)
+ else:
+ return shutil.copytree(src, dest, 1)
+
+Copy = ActionFactory(copy_func,
+ lambda dest, src: 'Copy("%s", "%s")' % (dest, src))
+
+def delete_func(entry, must_exist=0):
+ if not must_exist and not os.path.exists(entry):
+ return None
+ if os.path.isfile(entry):
+ return os.unlink(entry)
+ else:
+ return shutil.rmtree(entry, 1)
+
+def delete_strfunc(entry, must_exist=0):
+ return 'Delete("%s")' % entry
+
+Delete = ActionFactory(delete_func, delete_strfunc)
+
+Mkdir = ActionFactory(os.makedirs,
+ lambda dir: 'Mkdir("%s")' % dir)
+
+Move = ActionFactory(lambda dest, src: os.rename(src, dest),
+ lambda dest, src: 'Move("%s", "%s")' % (dest, src))
+
+def touch_func(file):
+ mtime = int(time.time())
+ if os.path.exists(file):
+ atime = os.path.getatime(file)
+ else:
+ open(file, 'w')
+ atime = mtime
+ return os.utime(file, (atime, mtime))
+
+Touch = ActionFactory(touch_func,
+ lambda file: 'Touch("%s")' % file)
+
+# Internal utility functions
+def copyFunc(dest, source, env):
+ """Install a source file into a destination by copying it (and its
+ permission/mode bits)."""
+ shutil.copy2(source, dest)
+ st = os.stat(source)
+ os.chmod(dest, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE)
+ return 0
+
+def _concat(prefix, list, suffix, env, f=lambda x: x):
+ """Creates a new list from 'list' by first interpolating each
+ element in the list using the 'env' dictionary and then calling f
+ on the list, and finally concatenating 'prefix' and 'suffix' onto
+ each element of the list. A trailing space on 'prefix' or leading
+ space on 'suffix' will cause them to be put into separate list
+ elements rather than being concatenated."""
+
+ if not list:
+ return list
+
+ list = f(env.subst_path(list))
+
+ ret = []
+
+ # ensure that prefix and suffix are strings
+ prefix = str(env.subst(prefix, SCons.Util.SUBST_RAW))
+ suffix = str(env.subst(suffix, SCons.Util.SUBST_RAW))
+
+ for x in list:
+ x = str(x)
+ if x:
+
+ if prefix:
+ if prefix[-1] == ' ':
+ ret.append(prefix[:-1])
+ elif x[:len(prefix)] != prefix:
+ x = prefix + x
+
+ ret.append(x)
+
+ if suffix:
+ if suffix[0] == ' ':
+ ret.append(suffix[1:])
+ elif x[-len(suffix):] != suffix:
+ ret[-1] = ret[-1]+suffix
+
+ return ret
+
+def _stripixes(prefix, list, suffix, stripprefix, stripsuffix, env, c=None):
+ """This is a wrapper around _concat() that checks for the existence
+ of prefixes or suffixes on list elements and strips them where it
+ finds them. This is used by tools (like the GNU linker) that need
+ to turn something like 'libfoo.a' into '-lfoo'."""
+
+ if not callable(c):
+ if callable(env["_concat"]):
+ c = env["_concat"]
+ else:
+ c = _concat
+ def f(list, sp=stripprefix, ss=stripsuffix):
+ ret = []
+ for l in list:
+ if not SCons.Util.is_String(l):
+ l = str(l)
+ if l[:len(sp)] == sp:
+ l = l[len(sp):]
+ if l[-len(ss):] == ss:
+ l = l[:-len(ss)]
+ ret.append(l)
+ return ret
+ return c(prefix, list, suffix, env, f)
+
+def _defines(prefix, defs, suffix, env, c=_concat):
+ """A wrapper around _concat that turns a list or string
+ into a list of C preprocessor command-line definitions.
+ """
+ if SCons.Util.is_List(defs):
+ l = []
+ for d in defs:
+ if SCons.Util.is_List(d) or type(d) is types.TupleType:
+ l.append(str(d[0]) + '=' + str(d[1]))
+ else:
+ l.append(str(d))
+ elif SCons.Util.is_Dict(defs):
+ # The items in a dictionary are stored in random order, but
+ # if the order of the command-line options changes from
+ # invocation to invocation, then the signature of the command
+ # line will change and we'll get random unnecessary rebuilds.
+ # Consequently, we have to sort the keys to ensure a
+ # consistent order...
+ l = []
+ keys = defs.keys()
+ keys.sort()
+ for k in keys:
+ v = defs[k]
+ if v is None:
+ l.append(str(k))
+ else:
+ l.append(str(k) + '=' + str(v))
+ else:
+ l = [str(defs)]
+ return c(prefix, l, suffix, env)
+
+class NullCmdGenerator:
+ """This is a callable class that can be used in place of other
+ command generators if you don't want them to do anything.
+
+ The __call__ method for this class simply returns the thing
+ you instantiated it with.
+
+ Example usage:
+ env["DO_NOTHING"] = NullCmdGenerator
+ env["LINKCOM"] = "${DO_NOTHING('$LINK $SOURCES $TARGET')}"
+ """
+
+ def __init__(self, cmd):
+ self.cmd = cmd
+
+ def __call__(self, target, source, env, for_signature=None):
+ return self.cmd
+
+ConstructionEnvironment = {
+ 'BUILDERS' : {},
+ 'SCANNERS' : [],
+ 'CPPSUFFIXES': CSuffixes,
+ 'DSUFFIXES' : DSuffixes,
+ 'IDLSUFFIXES': IDLSuffixes,
+ 'PDFPREFIX' : '',
+ 'PDFSUFFIX' : '.pdf',
+ 'PSPREFIX' : '',
+ 'PSSUFFIX' : '.ps',
+ 'ENV' : {},
+ 'INSTALL' : copyFunc,
+ '_concat' : _concat,
+ '_defines' : _defines,
+ '_stripixes' : _stripixes,
+ '_LIBFLAGS' : '${_concat(LIBLINKPREFIX, LIBS, LIBLINKSUFFIX, __env__)}',
+ '_LIBDIRFLAGS' : '$( ${_concat(LIBDIRPREFIX, LIBPATH, LIBDIRSUFFIX, __env__, RDirs)} $)',
+ '_CPPINCFLAGS' : '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs)} $)',
+ '_CPPDEFFLAGS' : '${_defines(CPPDEFPREFIX, CPPDEFINES, CPPDEFSUFFIX, __env__)}',
+ 'TEMPFILE' : NullCmdGenerator
+ }
Added: development/support/scons/scons-local-0.96.1/SCons/Environment.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Environment.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Environment.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,1271 @@
+"""SCons.Environment
+
+Base class for construction Environments. These are
+the primary objects used to communicate dependency and
+construction information to the build engine.
+
+Keyword arguments supplied when the construction Environment
+is created are construction variables used to initialize the
+Environment
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Environment.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+
+import copy
+import os
+import os.path
+import string
+from UserDict import UserDict
+
+import SCons.Action
+import SCons.Builder
+from SCons.Debug import logInstanceCreation
+import SCons.Defaults
+import SCons.Errors
+import SCons.Node
+import SCons.Node.Alias
+import SCons.Node.FS
+import SCons.Node.Python
+import SCons.Platform
+import SCons.SConsign
+import SCons.Sig
+import SCons.Sig.MD5
+import SCons.Sig.TimeStamp
+import SCons.Tool
+import SCons.Util
+import SCons.Warnings
+
+class _Null:
+ pass
+
+_null = _Null
+
+CleanTargets = {}
+CalculatorArgs = {}
+
+# Pull UserError into the global name space for the benefit of
+# Environment().SourceSignatures(), which has some import statements
+# which seem to mess up its ability to reference SCons directly.
+UserError = SCons.Errors.UserError
+
+def installFunc(target, source, env):
+ """Install a source file into a target using the function specified
+ as the INSTALL construction variable."""
+ try:
+ install = env['INSTALL']
+ except KeyError:
+ raise SCons.Errors.UserError('Missing INSTALL construction variable.')
+ return install(target[0].path, source[0].path, env)
+
+def installString(target, source, env):
+ return 'Install file: "%s" as "%s"' % (source[0], target[0])
+
+installAction = SCons.Action.Action(installFunc, installString)
+
+InstallBuilder = SCons.Builder.Builder(action=installAction)
+
+def alias_builder(env, target, source):
+ pass
+
+AliasBuilder = SCons.Builder.Builder(action = alias_builder,
+ target_factory = SCons.Node.Alias.default_ans.Alias,
+ source_factory = SCons.Node.FS.default_fs.Entry,
+ multi = 1)
+
+def our_deepcopy(x):
+ """deepcopy lists and dictionaries, and just copy the reference
+ for everything else."""
+ if SCons.Util.is_Dict(x):
+ copy = {}
+ for key in x.keys():
+ copy[key] = our_deepcopy(x[key])
+ elif SCons.Util.is_List(x):
+ copy = map(our_deepcopy, x)
+ try:
+ copy = x.__class__(copy)
+ except AttributeError:
+ pass
+ else:
+ copy = x
+ return copy
+
+def apply_tools(env, tools, toolpath):
+ if tools:
+ # Filter out null tools from the list.
+ tools = filter(None, tools)
+ for tool in tools:
+ if SCons.Util.is_String(tool):
+ env.Tool(tool, toolpath)
+ else:
+ tool(env)
+
+# These names are controlled by SCons; users should never set or override
+# them. This warning can optionally be turned off, but scons will still
+# ignore the illegal variable names even if it's off.
+reserved_construction_var_names = \
+ ['TARGET', 'TARGETS', 'SOURCE', 'SOURCES']
+
+def copy_non_reserved_keywords(dict):
+ result = our_deepcopy(dict)
+ for k in result.keys():
+ if k in reserved_construction_var_names:
+ SCons.Warnings.warn(SCons.Warnings.ReservedVariableWarning,
+ "Ignoring attempt to set reserved variable `%s'" % k)
+ del result[k]
+ return result
+
+class BuilderWrapper:
+ """Wrapper class that associates an environment with a Builder at
+ instantiation."""
+ def __init__(self, env, builder):
+ self.env = env
+ self.builder = builder
+
+ def __call__(self, *args, **kw):
+ return apply(self.builder, (self.env,) + args, kw)
+
+ # This allows a Builder to be executed directly
+ # through the Environment to which it's attached.
+ # In practice, we shouldn't need this, because
+ # builders actually get executed through a Node.
+ # But we do have a unit test for this, and can't
+ # yet rule out that it would be useful in the
+ # future, so leave it for now.
+ def execute(self, **kw):
+ kw['env'] = self.env
+ apply(self.builder.execute, (), kw)
+
+class BuilderDict(UserDict):
+ """This is a dictionary-like class used by an Environment to hold
+ the Builders. We need to do this because every time someone changes
+ the Builders in the Environment's BUILDERS dictionary, we must
+ update the Environment's attributes."""
+ def __init__(self, dict, env):
+ # Set self.env before calling the superclass initialization,
+ # because it will end up calling our other methods, which will
+ # need to point the values in this dictionary to self.env.
+ self.env = env
+ UserDict.__init__(self, dict)
+
+ def __setitem__(self, item, val):
+ UserDict.__setitem__(self, item, val)
+ try:
+ self.setenvattr(item, val)
+ except AttributeError:
+ # Have to catch this because sometimes __setitem__ gets
+ # called out of __init__, when we don't have an env
+ # attribute yet, nor do we want one!
+ pass
+
+ def setenvattr(self, item, val):
+ """Set the corresponding environment attribute for this Builder.
+
+ If the value is already a BuilderWrapper, we pull the builder
+ out of it and make another one, so that making a copy of an
+ existing BuilderDict is guaranteed separate wrappers for each
+ Builder + Environment pair."""
+ try:
+ builder = val.builder
+ except AttributeError:
+ builder = val
+ setattr(self.env, item, BuilderWrapper(self.env, builder))
+
+ def __delitem__(self, item):
+ UserDict.__delitem__(self, item)
+ delattr(self.env, item)
+
+ def update(self, dict):
+ for i, v in dict.items():
+ self.__setitem__(i, v)
+
+class Base:
+ """Base class for construction Environments. These are
+ the primary objects used to communicate dependency and
+ construction information to the build engine.
+
+ Keyword arguments supplied when the construction Environment
+ is created are construction variables used to initialize the
+ Environment.
+ """
+
+ #######################################################################
+ # This is THE class for interacting with the SCons build engine,
+ # and it contains a lot of stuff, so we're going to try to keep this
+ # a little organized by grouping the methods.
+ #######################################################################
+
+ #######################################################################
+ # Methods that make an Environment act like a dictionary. These have
+ # the expected standard names for Python mapping objects. Note that
+ # we don't actually make an Environment a subclass of UserDict for
+ # performance reasons. Note also that we only supply methods for
+ # dictionary functionality that we actually need and use.
+ #######################################################################
+
+ def __init__(self,
+ platform=None,
+ tools=None,
+ toolpath=[],
+ options=None,
+ **kw):
+ if __debug__: logInstanceCreation(self)
+ self.fs = SCons.Node.FS.default_fs
+ self.ans = SCons.Node.Alias.default_ans
+ self.lookup_list = SCons.Node.arg2nodes_lookups
+ self._dict = our_deepcopy(SCons.Defaults.ConstructionEnvironment)
+
+ self._dict['__env__'] = self
+ self._dict['BUILDERS'] = BuilderDict(self._dict['BUILDERS'], self)
+
+ if platform is None:
+ platform = self._dict.get('PLATFORM', None)
+ if platform is None:
+ platform = SCons.Platform.Platform()
+ if SCons.Util.is_String(platform):
+ platform = SCons.Platform.Platform(platform)
+ self._dict['PLATFORM'] = str(platform)
+ platform(self)
+
+ # Apply the passed-in variables before calling the tools,
+ # because they may use some of them:
+ apply(self.Replace, (), kw)
+
+ # Update the environment with the customizable options
+ # before calling the tools, since they may use some of the options:
+ if options:
+ options.Update(self)
+
+ if tools is None:
+ tools = self._dict.get('TOOLS', None)
+ if tools is None:
+ tools = ['default']
+ apply_tools(self, tools, toolpath)
+
+ # Reapply the passed in variables after calling the tools,
+ # since they should overide anything set by the tools:
+ apply(self.Replace, (), kw)
+
+ # Update the environment with the customizable options
+ # after calling the tools, since they should override anything
+ # set by the tools:
+ if options:
+ options.Update(self)
+
+ def __cmp__(self, other):
+ # Since an Environment now has an '__env__' construction variable
+ # that refers to itself, delete that variable to avoid infinite
+ # loops when comparing the underlying dictionaries in some Python
+ # versions (*cough* 1.5.2 *cough*)...
+ sdict = self._dict.copy()
+ del sdict['__env__']
+ odict = other._dict.copy()
+ del odict['__env__']
+ return cmp(sdict, odict)
+
+ def __getitem__(self, key):
+ return self._dict[key]
+
+ def __setitem__(self, key, value):
+ if key in reserved_construction_var_names:
+ SCons.Warnings.warn(SCons.Warnings.ReservedVariableWarning,
+ "Ignoring attempt to set reserved variable `%s'" % key)
+ elif key == 'BUILDERS':
+ try:
+ bd = self._dict[key]
+ for k in bd.keys():
+ del bd[k]
+ except KeyError:
+ self._dict[key] = BuilderDict(kwbd, self)
+ self._dict[key].update(value)
+ elif key == 'SCANNERS':
+ self._dict[key] = value
+ self.scanner_map_delete()
+ else:
+ if not SCons.Util.is_valid_construction_var(key):
+ raise SCons.Errors.UserError, "Illegal construction variable `%s'" % key
+ self._dict[key] = value
+
+ def __delitem__(self, key):
+ del self._dict[key]
+
+ def items(self):
+ "Emulates the items() method of dictionaries."""
+ return self._dict.items()
+
+ def has_key(self, key):
+ return self._dict.has_key(key)
+
+ def get(self, key, default=None):
+ "Emulates the get() method of dictionaries."""
+ return self._dict.get(key, default)
+
+ #######################################################################
+ # Utility methods that are primarily for internal use by SCons.
+ # These begin with lower-case letters. Note that the subst() method
+ # is actually already out of the closet and used by people.
+ #######################################################################
+
+ def arg2nodes(self, args, node_factory=_null, lookup_list=_null):
+ if node_factory is _null:
+ node_factory = self.fs.File
+ if lookup_list is _null:
+ lookup_list = self.lookup_list
+
+ if not args:
+ return []
+
+ if SCons.Util.is_List(args):
+ args = SCons.Util.flatten(args)
+ else:
+ args = [args]
+
+ nodes = []
+ for v in args:
+ if SCons.Util.is_String(v):
+ n = None
+ for l in lookup_list:
+ n = l(v)
+ if not n is None:
+ break
+ if not n is None:
+ if SCons.Util.is_String(n):
+ n = self.subst(n, raw=1)
+ if node_factory:
+ n = node_factory(n)
+ if SCons.Util.is_List(n):
+ nodes.extend(n)
+ else:
+ nodes.append(n)
+ elif node_factory:
+ v = node_factory(self.subst(v, raw=1))
+ if SCons.Util.is_List(v):
+ nodes.extend(v)
+ else:
+ nodes.append(v)
+ else:
+ nodes.append(v)
+
+ return nodes
+
+ def get_calculator(self):
+ try:
+ return self._calculator
+ except AttributeError:
+ try:
+ module = self._calc_module
+ c = apply(SCons.Sig.Calculator, (module,), CalculatorArgs)
+ except AttributeError:
+ # Note that we're calling get_calculator() here, so the
+ # DefaultEnvironment() must have a _calc_module attribute
+ # to avoid infinite recursion.
+ c = SCons.Defaults.DefaultEnvironment().get_calculator()
+ self._calculator = c
+ return c
+
+ def get_builder(self, name):
+ """Fetch the builder with the specified name from the environment.
+ """
+ try:
+ return self._dict['BUILDERS'][name]
+ except KeyError:
+ return None
+
+ def get_scanner(self, skey):
+ """Find the appropriate scanner given a key (usually a file suffix).
+ """
+ try:
+ sm = self.scanner_map
+ except AttributeError:
+ try:
+ scanners = self._dict['SCANNERS']
+ except KeyError:
+ self.scanner_map = {}
+ return None
+ else:
+ self.scanner_map = sm = {}
+ # Reverse the scanner list so that, if multiple scanners
+ # claim they can scan the same suffix, earlier scanners
+ # in the list will overwrite later scanners, so that
+ # the result looks like a "first match" to the user.
+ if not SCons.Util.is_List(scanners):
+ scanners = [scanners]
+ scanners.reverse()
+ for scanner in scanners:
+ for k in scanner.get_skeys(self):
+ sm[k] = scanner
+ try:
+ return sm[skey]
+ except KeyError:
+ return None
+
+ def scanner_map_delete(self, kw=None):
+ """Delete the cached scanner map (if we need to).
+ """
+ if not kw is None and not kw.has_key('SCANNERS'):
+ return
+ try:
+ del self.scanner_map
+ except AttributeError:
+ pass
+
+ def subst(self, string, raw=0, target=None, source=None, dict=None, conv=None):
+ """Recursively interpolates construction variables from the
+ Environment into the specified string, returning the expanded
+ result. Construction variables are specified by a $ prefix
+ in the string and begin with an initial underscore or
+ alphabetic character followed by any number of underscores
+ or alphanumeric characters. The construction variable names
+ may be surrounded by curly braces to separate the name from
+ trailing characters.
+ """
+ return SCons.Util.scons_subst(string, self, raw, target, source, dict, conv)
+
+ def subst_kw(self, kw, raw=0, target=None, source=None, dict=None):
+ nkw = {}
+ for k, v in kw.items():
+ k = self.subst(k, raw, target, source, dict)
+ if SCons.Util.is_String(v):
+ v = self.subst(v, raw, target, source, dict)
+ nkw[k] = v
+ return nkw
+
+ def subst_list(self, string, raw=0, target=None, source=None, dict=None, conv=None):
+ """Calls through to SCons.Util.scons_subst_list(). See
+ the documentation for that function."""
+ return SCons.Util.scons_subst_list(string, self, raw, target, source, dict, conv)
+
+
+ def subst_path(self, path):
+ """Substitute a path list, turning EntryProxies into Nodes
+ and leaving Nodes (and other objects) as-is."""
+
+ if not SCons.Util.is_List(path):
+ path = [path]
+
+ def s(obj):
+ """This is the "string conversion" routine that we have our
+ substitutions use to return Nodes, not strings. This relies
+ on the fact that an EntryProxy object has a get() method that
+ returns the underlying Node that it wraps, which is a bit of
+ architectural dependence that we might need to break or modify
+ in the future in response to additional requirements."""
+ try:
+ get = obj.get
+ except AttributeError:
+ pass
+ else:
+ obj = get()
+ return obj
+
+ r = []
+ for p in path:
+ if SCons.Util.is_String(p):
+ p = self.subst(p, conv=s)
+ if SCons.Util.is_List(p):
+ if len(p) == 1:
+ p = p[0]
+ else:
+ # We have an object plus a string, or multiple
+ # objects that we need to smush together. No choice
+ # but to make them into a string.
+ p = string.join(map(SCons.Util.to_String, p), '')
+ else:
+ p = s(p)
+ r.append(p)
+ return r
+
+ subst_target_source = subst
+
+ def _update(self, dict):
+ """Update an environment's values directly, bypassing the normal
+ checks that occur when users try to set items.
+ """
+ self._dict.update(dict)
+
+ def use_build_signature(self):
+ try:
+ return self._build_signature
+ except AttributeError:
+ b = SCons.Defaults.DefaultEnvironment()._build_signature
+ self._build_signature = b
+ return b
+
+ #######################################################################
+ # Public methods for manipulating an Environment. These begin with
+ # upper-case letters. The essential characteristic of methods in
+ # this section is that they do *not* have corresponding same-named
+ # global functions. For example, a stand-alone Append() function
+ # makes no sense, because Append() is all about appending values to
+ # an Environment's construction variables.
+ #######################################################################
+
+ def Append(self, **kw):
+ """Append values to existing construction variables
+ in an Environment.
+ """
+ kw = copy_non_reserved_keywords(kw)
+ for key, val in kw.items():
+ # It would be easier on the eyes to write this using
+ # "continue" statements whenever we finish processing an item,
+ # but Python 1.5.2 apparently doesn't let you use "continue"
+ # within try:-except: blocks, so we have to nest our code.
+ try:
+ orig = self._dict[key]
+ except KeyError:
+ # No existing variable in the environment, so just set
+ # it to the new value.
+ self._dict[key] = val
+ else:
+ try:
+ # Most straightforward: just try to add them
+ # together. This will work in most cases, when the
+ # original and new values are of compatible types.
+ self._dict[key] = orig + val
+ except TypeError:
+ try:
+ # Try to update a dictionary value with another.
+ # If orig isn't a dictionary, it won't have an
+ # update() method; if val isn't a dictionary,
+ # it won't have a keys() method. Either way,
+ # it's an AttributeError.
+ orig.update(val)
+ except AttributeError:
+ try:
+ # Check if the original is a list.
+ add_to_orig = orig.append
+ except AttributeError:
+ # The original isn't a list, but the new
+ # value is (by process of elimination),
+ # so insert the original in the new value
+ # (if there's one to insert) and replace
+ # the variable with it.
+ if orig:
+ val.insert(0, orig)
+ self._dict[key] = val
+ else:
+ # The original is a list, so append the new
+ # value to it (if there's a value to append).
+ if val:
+ add_to_orig(val)
+ self.scanner_map_delete(kw)
+
+ def AppendENVPath(self, name, newpath, envname = 'ENV', sep = os.pathsep):
+ """Append path elements to the path 'name' in the 'ENV'
+ dictionary for this environment. Will only add any particular
+ path once, and will normpath and normcase all paths to help
+ assure this. This can also handle the case where the env
+ variable is a list instead of a string.
+ """
+
+ orig = ''
+ if self._dict.has_key(envname) and self._dict[envname].has_key(name):
+ orig = self._dict[envname][name]
+
+ nv = SCons.Util.AppendPath(orig, newpath, sep)
+
+ if not self._dict.has_key(envname):
+ self._dict[envname] = {}
+
+ self._dict[envname][name] = nv
+
+ def AppendUnique(self, **kw):
+ """Append values to existing construction variables
+ in an Environment, if they're not already there.
+ """
+ kw = copy_non_reserved_keywords(kw)
+ for key, val in kw.items():
+ if not self._dict.has_key(key):
+ self._dict[key] = val
+ elif SCons.Util.is_Dict(self._dict[key]) and \
+ SCons.Util.is_Dict(val):
+ self._dict[key].update(val)
+ elif SCons.Util.is_List(val):
+ dk = self._dict[key]
+ if not SCons.Util.is_List(dk):
+ dk = [dk]
+ val = filter(lambda x, dk=dk: x not in dk, val)
+ self._dict[key] = dk + val
+ else:
+ dk = self._dict[key]
+ if SCons.Util.is_List(dk):
+ if not val in dk:
+ self._dict[key] = dk + val
+ else:
+ self._dict[key] = self._dict[key] + val
+ self.scanner_map_delete(kw)
+
+ def Copy(self, tools=None, toolpath=[], **kw):
+ """Return a copy of a construction Environment. The
+ copy is like a Python "deep copy"--that is, independent
+ copies are made recursively of each objects--except that
+ a reference is copied when an object is not deep-copyable
+ (like a function). There are no references to any mutable
+ objects in the original Environment.
+ """
+ clone = copy.copy(self)
+ clone._dict = our_deepcopy(self._dict)
+ clone['__env__'] = clone
+ try:
+ cbd = clone._dict['BUILDERS']
+ clone._dict['BUILDERS'] = BuilderDict(cbd, clone)
+ except KeyError:
+ pass
+
+ apply_tools(clone, tools, toolpath)
+
+ # Apply passed-in variables after the new tools.
+ kw = copy_non_reserved_keywords(kw)
+ new = {}
+ for key, value in kw.items():
+ new[key] = SCons.Util.scons_subst_once(value, self, key)
+ apply(clone.Replace, (), new)
+ return clone
+
+ def Detect(self, progs):
+ """Return the first available program in progs.
+ """
+ if not SCons.Util.is_List(progs):
+ progs = [ progs ]
+ for prog in progs:
+ path = self.WhereIs(prog)
+ if path: return prog
+ return None
+
+ def Dictionary(self, *args):
+ if not args:
+ return self._dict
+ dlist = map(lambda x, s=self: s._dict[x], args)
+ if len(dlist) == 1:
+ dlist = dlist[0]
+ return dlist
+
+ def FindIxes(self, paths, prefix, suffix):
+ """
+ Search a list of paths for something that matches the prefix and suffix.
+
+ paths - the list of paths or nodes.
+ prefix - construction variable for the prefix.
+ suffix - construction variable for the suffix.
+ """
+
+ suffix = self.subst('$'+suffix)
+ prefix = self.subst('$'+prefix)
+
+ for path in paths:
+ dir,name = os.path.split(str(path))
+ if name[:len(prefix)] == prefix and name[-len(suffix):] == suffix:
+ return path
+
+ def Override(self, overrides):
+ """
+ Produce a modified environment whose variables
+ are overriden by the overrides dictionaries.
+
+ overrides - a dictionary that will override
+ the variables of this environment.
+
+ This function is much more efficient than Copy()
+ or creating a new Environment because it doesn't do
+ a deep copy of the dictionary, and doesn't do a copy
+ at all if there are no overrides.
+ """
+
+ if overrides:
+ env = copy.copy(self)
+ env._dict = copy.copy(self._dict)
+ env['__env__'] = env
+ overrides = copy_non_reserved_keywords(overrides)
+ new = {}
+ for key, value in overrides.items():
+ new[key] = SCons.Util.scons_subst_once(value, self, key)
+ env._dict.update(new)
+ return env
+ else:
+ return self
+
+ def ParseConfig(self, command, function=None):
+ """
+ Use the specified function to parse the output of the command
+ in order to modify the current environment. The 'command' can
+ be a string or a list of strings representing a command and
+ it's arguments. 'Function' is an optional argument that takes
+ the environment and the output of the command. If no function is
+ specified, the output will be treated as the output of a typical
+ 'X-config' command (i.e. gtk-config) and used to append to the
+ ASFLAGS, CCFLAGS, CPPFLAGS, CPPPATH, LIBPATH, LIBS, LINKFLAGS
+ and CCFLAGS variables.
+ """
+
+ # the default parse function
+ def parse_conf(env, output):
+ dict = {
+ 'ASFLAGS' : [],
+ 'CCFLAGS' : [],
+ 'CPPFLAGS' : [],
+ 'CPPPATH' : [],
+ 'LIBPATH' : [],
+ 'LIBS' : [],
+ 'LINKFLAGS' : [],
+ }
+ static_libs = []
+
+ params = string.split(output)
+ for arg in params:
+ if arg[0] != '-':
+ static_libs.append(arg)
+ elif arg[:2] == '-L':
+ dict['LIBPATH'].append(arg[2:])
+ elif arg[:2] == '-l':
+ dict['LIBS'].append(arg[2:])
+ elif arg[:2] == '-I':
+ dict['CPPPATH'].append(arg[2:])
+ elif arg[:4] == '-Wa,':
+ dict['ASFLAGS'].append(arg)
+ elif arg[:4] == '-Wl,':
+ dict['LINKFLAGS'].append(arg)
+ elif arg[:4] == '-Wp,':
+ dict['CPPFLAGS'].append(arg)
+ elif arg == '-pthread':
+ dict['CCFLAGS'].append(arg)
+ dict['LINKFLAGS'].append(arg)
+ else:
+ dict['CCFLAGS'].append(arg)
+ apply(env.Append, (), dict)
+ return static_libs
+
+ if function is None:
+ function = parse_conf
+ if type(command) is type([]):
+ command = string.join(command)
+ command = self.subst(command)
+ return function(self, os.popen(command).read())
+
+ def Platform(self, platform):
+ platform = self.subst(platform)
+ return SCons.Platform.Platform(platform)(self)
+
+ def Prepend(self, **kw):
+ """Prepend values to existing construction variables
+ in an Environment.
+ """
+ kw = copy_non_reserved_keywords(kw)
+ for key, val in kw.items():
+ # It would be easier on the eyes to write this using
+ # "continue" statements whenever we finish processing an item,
+ # but Python 1.5.2 apparently doesn't let you use "continue"
+ # within try:-except: blocks, so we have to nest our code.
+ try:
+ orig = self._dict[key]
+ except KeyError:
+ # No existing variable in the environment, so just set
+ # it to the new value.
+ self._dict[key] = val
+ else:
+ try:
+ # Most straightforward: just try to add them
+ # together. This will work in most cases, when the
+ # original and new values are of compatible types.
+ self._dict[key] = val + orig
+ except TypeError:
+ try:
+ # Try to update a dictionary value with another.
+ # If orig isn't a dictionary, it won't have an
+ # update() method; if val isn't a dictionary,
+ # it won't have a keys() method. Either way,
+ # it's an AttributeError.
+ orig.update(val)
+ except AttributeError:
+ try:
+ # Check if the added value is a list.
+ add_to_val = val.append
+ except AttributeError:
+ # The added value isn't a list, but the
+ # original is (by process of elimination),
+ # so insert the the new value in the original
+ # (if there's one to insert).
+ if val:
+ orig.insert(0, val)
+ else:
+ # The added value is a list, so append
+ # the original to it (if there's a value
+ # to append).
+ if orig:
+ add_to_val(orig)
+ self._dict[key] = val
+ self.scanner_map_delete(kw)
+
+ def PrependENVPath(self, name, newpath, envname = 'ENV', sep = os.pathsep):
+ """Prepend path elements to the path 'name' in the 'ENV'
+ dictionary for this environment. Will only add any particular
+ path once, and will normpath and normcase all paths to help
+ assure this. This can also handle the case where the env
+ variable is a list instead of a string.
+ """
+
+ orig = ''
+ if self._dict.has_key(envname) and self._dict[envname].has_key(name):
+ orig = self._dict[envname][name]
+
+ nv = SCons.Util.PrependPath(orig, newpath, sep)
+
+ if not self._dict.has_key(envname):
+ self._dict[envname] = {}
+
+ self._dict[envname][name] = nv
+
+ def PrependUnique(self, **kw):
+ """Append values to existing construction variables
+ in an Environment, if they're not already there.
+ """
+ kw = copy_non_reserved_keywords(kw)
+ for key, val in kw.items():
+ if not self._dict.has_key(key):
+ self._dict[key] = val
+ elif SCons.Util.is_Dict(self._dict[key]) and \
+ SCons.Util.is_Dict(val):
+ self._dict[key].update(val)
+ elif SCons.Util.is_List(val):
+ dk = self._dict[key]
+ if not SCons.Util.is_List(dk):
+ dk = [dk]
+ val = filter(lambda x, dk=dk: x not in dk, val)
+ self._dict[key] = val + dk
+ else:
+ dk = self._dict[key]
+ if SCons.Util.is_List(dk):
+ if not val in dk:
+ self._dict[key] = val + dk
+ else:
+ self._dict[key] = val + dk
+ self.scanner_map_delete(kw)
+
+ def Replace(self, **kw):
+ """Replace existing construction variables in an Environment
+ with new construction variables and/or values.
+ """
+ try:
+ kwbd = our_deepcopy(kw['BUILDERS'])
+ del kw['BUILDERS']
+ self.__setitem__('BUILDERS', kwbd)
+ except KeyError:
+ pass
+ kw = copy_non_reserved_keywords(kw)
+ self._dict.update(our_deepcopy(kw))
+ self.scanner_map_delete(kw)
+
+ def ReplaceIxes(self, path, old_prefix, old_suffix, new_prefix, new_suffix):
+ """
+ Replace old_prefix with new_prefix and old_suffix with new_suffix.
+
+ env - Environment used to interpolate variables.
+ path - the path that will be modified.
+ old_prefix - construction variable for the old prefix.
+ old_suffix - construction variable for the old suffix.
+ new_prefix - construction variable for the new prefix.
+ new_suffix - construction variable for the new suffix.
+ """
+ old_prefix = self.subst('$'+old_prefix)
+ old_suffix = self.subst('$'+old_suffix)
+
+ new_prefix = self.subst('$'+new_prefix)
+ new_suffix = self.subst('$'+new_suffix)
+
+ dir,name = os.path.split(str(path))
+ if name[:len(old_prefix)] == old_prefix:
+ name = name[len(old_prefix):]
+ if name[-len(old_suffix):] == old_suffix:
+ name = name[:-len(old_suffix)]
+ return os.path.join(dir, new_prefix+name+new_suffix)
+
+ def Tool(self, tool, toolpath=[]):
+ tool = self.subst(tool)
+ return SCons.Tool.Tool(tool, map(self.subst, toolpath))(self)
+
+ def WhereIs(self, prog, path=None, pathext=None, reject=[]):
+ """Find prog in the path.
+ """
+ if path is None:
+ try:
+ path = self['ENV']['PATH']
+ except KeyError:
+ pass
+ elif SCons.Util.is_String(path):
+ path = self.subst(path)
+ if pathext is None:
+ try:
+ pathext = self['ENV']['PATHEXT']
+ except KeyError:
+ pass
+ elif SCons.Util.is_String(pathext):
+ pathext = self.subst(pathext)
+ path = SCons.Util.WhereIs(prog, path, pathext, reject)
+ if path: return path
+ return None
+
+ #######################################################################
+ # Public methods for doing real "SCons stuff" (manipulating
+ # dependencies, setting attributes on targets, etc.). These begin
+ # with upper-case letters. The essential characteristic of methods
+ # in this section is that they all *should* have corresponding
+ # same-named global functions.
+ #######################################################################
+
+ def Action(self, *args, **kw):
+ nargs = self.subst(args)
+ nkw = self.subst_kw(kw)
+ return apply(SCons.Action.Action, nargs, nkw)
+
+ def AddPreAction(self, files, action):
+ nodes = self.arg2nodes(files, self.fs.Entry)
+ action = SCons.Action.Action(action)
+ for n in nodes:
+ n.add_pre_action(action)
+ return nodes
+
+ def AddPostAction(self, files, action):
+ nodes = self.arg2nodes(files, self.fs.Entry)
+ action = SCons.Action.Action(action)
+ for n in nodes:
+ n.add_post_action(action)
+ return nodes
+
+ def Alias(self, target, *source, **kw):
+ if not SCons.Util.is_List(target):
+ target = [target]
+ tlist = []
+ for t in target:
+ if not isinstance(t, SCons.Node.Alias.Alias):
+ t = self.arg2nodes(self.subst(t), self.ans.Alias)[0]
+ tlist.append(t)
+ try:
+ s = kw['source']
+ except KeyError:
+ try:
+ s = source[0]
+ except IndexError:
+ s = None
+ if s:
+ if not SCons.Util.is_List(s):
+ s = [s]
+ s = filter(None, s)
+ s = self.arg2nodes(s, self.fs.Entry)
+ for t in tlist:
+ AliasBuilder(self, t, s)
+ return tlist
+
+ def AlwaysBuild(self, *targets):
+ tlist = []
+ for t in targets:
+ tlist.extend(self.arg2nodes(t, self.fs.File))
+ for t in tlist:
+ t.set_always_build()
+ return tlist
+
+ def BuildDir(self, build_dir, src_dir, duplicate=1):
+ build_dir = self.arg2nodes(build_dir, self.fs.Dir)[0]
+ src_dir = self.arg2nodes(src_dir, self.fs.Dir)[0]
+ self.fs.BuildDir(build_dir, src_dir, duplicate)
+
+ def Builder(self, **kw):
+ nkw = self.subst_kw(kw)
+ return apply(SCons.Builder.Builder, [], nkw)
+
+ def CacheDir(self, path):
+ self.fs.CacheDir(self.subst(path))
+
+ def Clean(self, targets, files):
+ global CleanTargets
+ tlist = self.arg2nodes(targets, self.fs.Entry)
+ flist = self.arg2nodes(files, self.fs.Entry)
+ for t in tlist:
+ try:
+ CleanTargets[t].extend(flist)
+ except KeyError:
+ CleanTargets[t] = flist
+
+ def Configure(self, *args, **kw):
+ nargs = [self]
+ if args:
+ nargs = nargs + self.subst_list(args)[0]
+ nkw = self.subst_kw(kw)
+ try:
+ nkw['custom_tests'] = self.subst_kw(nkw['custom_tests'])
+ except KeyError:
+ pass
+ return apply(SCons.SConf.SConf, nargs, nkw)
+
+ def Command(self, target, source, action, **kw):
+ """Builds the supplied target files from the supplied
+ source files using the supplied action. Action may
+ be any type that the Builder constructor will accept
+ for an action."""
+ nkw = self.subst_kw(kw)
+ nkw['action'] = action
+ nkw['source_factory'] = self.fs.Entry
+ bld = apply(SCons.Builder.Builder, (), nkw)
+ return bld(self, target, source)
+
+ def Depends(self, target, dependency):
+ """Explicity specify that 'target's depend on 'dependency'."""
+ tlist = self.arg2nodes(target, self.fs.Entry)
+ dlist = self.arg2nodes(dependency, self.fs.Entry)
+ for t in tlist:
+ t.add_dependency(dlist)
+ return tlist
+
+ def Dir(self, name, *args, **kw):
+ """
+ """
+ return apply(self.fs.Dir, (self.subst(name),) + args, kw)
+
+ def Environment(self, **kw):
+ return apply(SCons.Environment.Environment, [], self.subst_kw(kw))
+
+ def Execute(self, action, *args, **kw):
+ """Directly execute an action through an Environment
+ """
+ action = apply(self.Action, (action,) + args, kw)
+ return action([], [], self)
+
+ def File(self, name, *args, **kw):
+ """
+ """
+ return apply(self.fs.File, (self.subst(name),) + args, kw)
+
+ def FindFile(self, file, dirs):
+ file = self.subst(file)
+ nodes = self.arg2nodes(dirs, self.fs.Dir)
+ return SCons.Node.FS.find_file(file, nodes, self.fs.File)
+
+ def Flatten(self, sequence):
+ return SCons.Util.flatten(sequence)
+
+ def GetBuildPath(self, files):
+ result = map(str, self.arg2nodes(files, self.fs.Entry))
+ if SCons.Util.is_List(files):
+ return result
+ else:
+ return result[0]
+
+ def Ignore(self, target, dependency):
+ """Ignore a dependency."""
+ tlist = self.arg2nodes(target, self.fs.Entry)
+ dlist = self.arg2nodes(dependency, self.fs.Entry)
+ for t in tlist:
+ t.add_ignore(dlist)
+ return tlist
+
+ def Install(self, dir, source):
+ """Install specified files in the given directory."""
+ try:
+ dnodes = self.arg2nodes(dir, self.fs.Dir)
+ except TypeError:
+ raise SCons.Errors.UserError, "Target `%s' of Install() is a file, but should be a directory. Perhaps you have the Install() arguments backwards?" % str(dir)
+ try:
+ sources = self.arg2nodes(source, self.fs.File)
+ except TypeError:
+ if SCons.Util.is_List(source):
+ raise SCons.Errors.UserError, "Source `%s' of Install() contains one or more non-files. Install() source must be one or more files." % repr(map(str, source))
+ else:
+ raise SCons.Errors.UserError, "Source `%s' of Install() is not a file. Install() source must be one or more files." % str(source)
+ tgt = []
+ for dnode in dnodes:
+ for src in sources:
+ target = self.fs.File(src.name, dnode)
+ tgt.extend(InstallBuilder(self, target, src))
+ return tgt
+
+ def InstallAs(self, target, source):
+ """Install sources as targets."""
+ sources = self.arg2nodes(source, self.fs.File)
+ targets = self.arg2nodes(target, self.fs.File)
+ result = []
+ for src, tgt in map(lambda x, y: (x, y), sources, targets):
+ result.extend(InstallBuilder(self, tgt, src))
+ return result
+
+ def Literal(self, string):
+ return SCons.Util.Literal(string)
+
+ def Local(self, *targets):
+ ret = []
+ for targ in targets:
+ if isinstance(targ, SCons.Node.Node):
+ targ.set_local()
+ ret.append(targ)
+ else:
+ for t in self.arg2nodes(targ, self.fs.Entry):
+ t.set_local()
+ ret.append(t)
+ return ret
+
+ def Precious(self, *targets):
+ tlist = []
+ for t in targets:
+ tlist.extend(self.arg2nodes(t, self.fs.Entry))
+ for t in tlist:
+ t.set_precious()
+ return tlist
+
+ def Repository(self, *dirs, **kw):
+ dirs = self.arg2nodes(list(dirs), self.fs.Dir)
+ apply(self.fs.Repository, dirs, kw)
+
+ def Scanner(self, *args, **kw):
+ nargs = []
+ for arg in args:
+ if SCons.Util.is_String(arg):
+ arg = self.subst(arg)
+ nargs.append(arg)
+ nkw = self.subst_kw(kw)
+ return apply(SCons.Scanner.Scanner, nargs, nkw)
+
+ def SConsignFile(self, name=".sconsign", dbm_module=None):
+ name = self.subst(name)
+ if not os.path.isabs(name):
+ name = os.path.join(str(self.fs.SConstruct_dir), name)
+ SCons.SConsign.File(name, dbm_module)
+
+ def SideEffect(self, side_effect, target):
+ """Tell scons that side_effects are built as side
+ effects of building targets."""
+ side_effects = self.arg2nodes(side_effect, self.fs.Entry)
+ targets = self.arg2nodes(target, self.fs.Entry)
+
+ for side_effect in side_effects:
+ if side_effect.multiple_side_effect_has_builder():
+ raise SCons.Errors.UserError, "Multiple ways to build the same target were specified for: %s" % str(side_effect)
+ side_effect.add_source(targets)
+ side_effect.side_effect = 1
+ self.Precious(side_effect)
+ for target in targets:
+ target.side_effects.append(side_effect)
+ return side_effects
+
+ def SourceCode(self, entry, builder):
+ """Arrange for a source code builder for (part of) a tree."""
+ entries = self.arg2nodes(entry, self.fs.Entry)
+ for entry in entries:
+ entry.set_src_builder(builder)
+ return entries
+
+ def SourceSignatures(self, type):
+ type = self.subst(type)
+ if type == 'MD5':
+ import SCons.Sig.MD5
+ self._calc_module = SCons.Sig.MD5
+ elif type == 'timestamp':
+ import SCons.Sig.TimeStamp
+ self._calc_module = SCons.Sig.TimeStamp
+ else:
+ raise UserError, "Unknown source signature type '%s'"%type
+
+ def Split(self, arg):
+ """This function converts a string or list into a list of strings
+ or Nodes. This makes things easier for users by allowing files to
+ be specified as a white-space separated list to be split.
+ The input rules are:
+ - A single string containing names separated by spaces. These will be
+ split apart at the spaces.
+ - A single Node instance
+ - A list containing either strings or Node instances. Any strings
+ in the list are not split at spaces.
+ In all cases, the function returns a list of Nodes and strings."""
+ if SCons.Util.is_List(arg):
+ return map(self.subst, arg)
+ elif SCons.Util.is_String(arg):
+ return string.split(self.subst(arg))
+ else:
+ return [self.subst(arg)]
+
+ def TargetSignatures(self, type):
+ type = self.subst(type)
+ if type == 'build':
+ self._build_signature = 1
+ elif type == 'content':
+ self._build_signature = 0
+ else:
+ raise SCons.Errors.UserError, "Unknown target signature type '%s'"%type
+
+ def Value(self, value):
+ """
+ """
+ return SCons.Node.Python.Value(value)
+
+# The entry point that will be used by the external world
+# to refer to a construction environment. This allows the wrapper
+# interface to extend a construction environment for its own purposes
+# by subclassing SCons.Environment.Base and then assigning the
+# class to SCons.Environment.Environment.
+
+Environment = Base
+
+# An entry point for returning a proxy subclass instance that overrides
+# the subst*() methods so they don't actually perform construction
+# variable substitution. This is specifically intended to be the shim
+# layer in between global function calls (which don't want construction
+# variable substitution) and the DefaultEnvironment() (which would
+# substitute variables if left to its own devices)."""
+#
+# We have to wrap this in a function that allows us to delay definition of
+# the class until it's necessary, so that when it subclasses Environment
+# it will pick up whatever Environment subclass the wrapper interface
+# might have assigned to SCons.Environment.Environment.
+
+def NoSubstitutionProxy(subject):
+ class _NoSubstitutionProxy(Environment):
+ def __init__(self, subject):
+ self.__dict__['__subject'] = subject
+ def __getattr__(self, name):
+ return getattr(self.__dict__['__subject'], name)
+ def __setattr__(self, name, value):
+ return setattr(self.__dict__['__subject'], name, value)
+ def raw_to_mode(self, dict):
+ try:
+ raw = dict['raw']
+ except KeyError:
+ pass
+ else:
+ del dict['raw']
+ dict['mode'] = raw
+ def subst(self, string, *args, **kwargs):
+ return string
+ def subst_kw(self, kw, *args, **kwargs):
+ return kw
+ def subst_list(self, string, *args, **kwargs):
+ nargs = (string, self,) + args
+ nkw = kwargs.copy()
+ nkw['gvars'] = {}
+ self.raw_to_mode(nkw)
+ return apply(SCons.Util.scons_subst_list, nargs, nkw)
+ def subst_target_source(self, string, *args, **kwargs):
+ nargs = (string, self,) + args
+ nkw = kwargs.copy()
+ nkw['gvars'] = {}
+ self.raw_to_mode(nkw)
+ return apply(SCons.Util.scons_subst, nargs, nkw)
+ return _NoSubstitutionProxy(subject)
Added: development/support/scons/scons-local-0.96.1/SCons/Errors.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Errors.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Errors.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,60 @@
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+"""SCons.Errors
+
+This file contains the exception classes used to handle internal
+and user errors in SCons.
+
+"""
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Errors.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+
+
+class BuildError(Exception):
+ def __init__(self, node=None, errstr="Unknown error", *args):
+ self.node = node
+ self.errstr = errstr
+ apply(Exception.__init__, (self,) + args)
+
+class InternalError(Exception):
+ pass
+
+class UserError(Exception):
+ pass
+
+class StopError(Exception):
+ pass
+
+class ExplicitExit(Exception):
+ def __init__(self, node=None, status=None, *args):
+ self.node = node
+ self.status = status
+ apply(Exception.__init__, (self,) + args)
+
+class ConfigureDryRunError(UserError):
+ """Raised when a file needs to be updated during a Configure process,
+ but the user requested a dry-run"""
+ def __init__(self,file):
+ UserError.__init__(self,"Cannot update configure test (%s) within a dry-run." % str(file))
Added: development/support/scons/scons-local-0.96.1/SCons/Executor.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Executor.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Executor.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,175 @@
+"""SCons.Executor
+
+A module for executing actions with specific lists of target and source
+Nodes.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Executor.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+
+from SCons.Debug import logInstanceCreation
+import SCons.Util
+
+
+class Executor:
+ """A class for controlling instances of executing an action.
+
+ This largely exists to hold a single association of an action,
+ environment, list of environment override dictionaries, targets
+ and sources for later processing as needed.
+ """
+
+ def __init__(self, action, env=None, overridelist=[], targets=[], sources=[]):
+ if __debug__: logInstanceCreation(self)
+ self.action = action
+ self.env = env
+ self.overridelist = overridelist
+ self.targets = targets
+ self.sources = sources[:]
+
+ def get_build_env(self):
+ """Fetch or create the appropriate build Environment
+ for this Executor.
+ """
+ try:
+ return self.build_env
+ except AttributeError:
+ # Create the build environment instance with appropriate
+ # overrides. These get evaluated against the current
+ # environment's construction variables so that users can
+ # add to existing values by referencing the variable in
+ # the expansion.
+ overrides = {}
+ for odict in self.overridelist:
+ overrides.update(odict)
+ try:
+ generate_build_dict = self.targets[0].generate_build_dict
+ except (AttributeError, IndexError):
+ pass
+ else:
+ overrides.update(generate_build_dict())
+
+ import SCons.Defaults
+ env = self.env or SCons.Defaults.DefaultEnvironment()
+ self.build_env = env.Override(overrides)
+
+ # Now update the build environment with the things that we
+ # don't want expanded against the current construction
+ # variables.
+ self.build_env._update(SCons.Util.subst_dict(self.targets,
+ self.sources))
+ return self.build_env
+
+ def get_action_list(self, target):
+ """Fetch or create the appropriate action list (for this target).
+
+ There is an architectural mistake here: we cache the action list
+ for the Executor and re-use it regardless of which target is
+ being asked for. In practice, this doesn't seem to be a problem
+ because executing the action list will update all of the targets
+ involved, so only one target's pre- and post-actions will win,
+ anyway. This is probably a bug we should fix...
+ """
+ try:
+ al = self.action_list
+ except AttributeError:
+ al = self.action.get_actions()
+ self.action_list = al
+ try:
+ # XXX shouldn't reach into node attributes like this
+ return target.pre_actions + al + target.post_actions
+ except AttributeError:
+ return al
+
+ def __call__(self, target, errfunc, **kw):
+ """Actually execute the action list."""
+ action_list = self.get_action_list(target)
+ if not action_list:
+ return
+ env = self.get_build_env()
+ for action in action_list:
+ apply(action, (self.targets, self.sources, env, errfunc), kw)
+
+ def cleanup(self):
+ try:
+ del self.build_env
+ except AttributeError:
+ pass
+
+ def add_sources(self, sources):
+ """Add source files to this Executor's list. This is necessary
+ for "multi" Builders that can be called repeatedly to build up
+ a source file list for a given target."""
+ slist = filter(lambda x, s=self.sources: x not in s, sources)
+ self.sources.extend(slist)
+
+ def __str__(self):
+ try:
+ return self.string
+ except AttributeError:
+ action = self.action
+ self.string = action.genstring(self.targets,
+ self.sources,
+ self.get_build_env())
+ return self.string
+
+ def get_raw_contents(self):
+ """Fetch the raw signature contents. This, along with
+ get_contents(), is the real reason this class exists, so we can
+ compute this once and cache it regardless of how many target or
+ source Nodes there are.
+ """
+ try:
+ return self.raw_contents
+ except AttributeError:
+ action = self.action
+ self.raw_contents = action.get_raw_contents(self.targets,
+ self.sources,
+ self.get_build_env())
+ return self.raw_contents
+
+ def get_contents(self):
+ """Fetch the signature contents. This, along with
+ get_raw_contents(), is the real reason this class exists, so we
+ can compute this once and cache it regardless of how many target
+ or source Nodes there are.
+ """
+ try:
+ return self.contents
+ except AttributeError:
+ action = self.action
+ self.contents = action.get_contents(self.targets,
+ self.sources,
+ self.get_build_env())
+ return self.contents
+
+ def get_timestamp(self):
+ """Fetch a time stamp for this Executor. We don't have one, of
+ course (only files do), but this is the interface used by the
+ timestamp module.
+ """
+ return 0
Added: development/support/scons/scons-local-0.96.1/SCons/Job.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Job.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Job.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,259 @@
+"""SCons.Job
+
+This module defines the Serial and Parallel classes that execute tasks to
+complete a build. The Jobs class provides a higher level interface to start,
+stop, and wait on jobs.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Job.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+class Jobs:
+ """An instance of this class initializes N jobs, and provides
+ methods for starting, stopping, and waiting on all N jobs.
+ """
+
+ def __init__(self, num, taskmaster):
+ """
+ create 'num' jobs using the given taskmaster.
+
+ If 'num' is 1 or less, then a serial job will be used,
+ otherwise a parallel job with 'num' worker threads will
+ be used.
+
+ The 'num_jobs' attribute will be set to the actual number of jobs
+ allocated. If more than one job is requested but the Parallel
+ class can't do it, it gets reset to 1. Wrapping interfaces that
+ care should check the value of 'num_jobs' after initialization.
+ """
+
+ self.job = None
+ if num > 1:
+ try:
+ self.job = Parallel(taskmaster, num)
+ self.num_jobs = num
+ except NameError:
+ pass
+ if self.job is None:
+ self.job = Serial(taskmaster)
+ self.num_jobs = 1
+
+ def run(self):
+ """run the job"""
+ try:
+ self.job.start()
+ except KeyboardInterrupt:
+ # mask any further keyboard interrupts so that scons
+ # can shutdown cleanly:
+ # (this only masks the keyboard interrupt for Python,
+ # child processes can still get the keyboard interrupt)
+ import signal
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
+ raise
+
+class Serial:
+ """This class is used to execute tasks in series, and is more efficient
+ than Parallel, but is only appropriate for non-parallel builds. Only
+ one instance of this class should be in existence at a time.
+
+ This class is not thread safe.
+ """
+
+ def __init__(self, taskmaster):
+ """Create a new serial job given a taskmaster.
+
+ The taskmaster's next_task() method should return the next task
+ that needs to be executed, or None if there are no more tasks. The
+ taskmaster's executed() method will be called for each task when it
+ is successfully executed or failed() will be called if it failed to
+ execute (e.g. execute() raised an exception). The taskmaster's
+ is_blocked() method will not be called. """
+
+ self.taskmaster = taskmaster
+
+ def start(self):
+ """Start the job. This will begin pulling tasks from the taskmaster
+ and executing them, and return when there are no more tasks. If a task
+ fails to execute (i.e. execute() raises an exception), then the job will
+ stop."""
+
+ while 1:
+ task = self.taskmaster.next_task()
+
+ if task is None:
+ break
+
+ try:
+ task.prepare()
+ task.execute()
+ except KeyboardInterrupt:
+ raise
+ except:
+ task.exception_set()
+ # Let the failed() callback function arrange for the
+ # build to stop if that's appropriate.
+ task.failed()
+ else:
+ task.executed()
+
+ task.postprocess()
+
+
+# Trap import failure so that everything in the Job module but the
+# Parallel class (and its dependent classes) will work if the interpreter
+# doesn't support threads.
+try:
+ import Queue
+ import threading
+except ImportError:
+ pass
+else:
+ class Worker(threading.Thread):
+ """A worker thread waits on a task to be posted to its request queue,
+ dequeues the task, executes it, and posts a tuple including the task
+ and a boolean indicating whether the task executed successfully. """
+
+ def __init__(self, requestQueue, resultsQueue):
+ threading.Thread.__init__(self)
+ self.setDaemon(1)
+ self.requestQueue = requestQueue
+ self.resultsQueue = resultsQueue
+ self.start()
+
+ def run(self):
+ while 1:
+ task = self.requestQueue.get()
+
+ try:
+ task.execute()
+ except KeyboardInterrupt:
+ # be explicit here for test/interrupts.py
+ ok = False
+ except:
+ task.exception_set()
+ ok = 0
+ else:
+ ok = 1
+
+ self.resultsQueue.put((task, ok))
+
+ class ThreadPool:
+ """This class is responsible for spawning and managing worker threads."""
+
+ def __init__(self, num):
+ """Create the request and reply queues, and 'num' worker threads."""
+ self.requestQueue = Queue.Queue(0)
+ self.resultsQueue = Queue.Queue(0)
+
+ # Create worker threads
+ for i in range(num):
+ Worker(self.requestQueue, self.resultsQueue)
+
+ def put(self, obj):
+ """Put task into request queue."""
+ self.requestQueue.put(obj)
+
+ def get(self, block = 1):
+ """Remove and return a result tuple from the results queue."""
+ return self.resultsQueue.get(block)
+
+ def get_nowait(self):
+ """Remove and result a result tuple from the results queue
+ without blocking."""
+ return self.get(0)
+
+ class Parallel:
+ """This class is used to execute tasks in parallel, and is somewhat
+ less efficient than Serial, but is appropriate for parallel builds.
+
+ This class is thread safe.
+ """
+
+ def __init__(self, taskmaster, num):
+ """Create a new parallel job given a taskmaster.
+
+ The taskmaster's next_task() method should return the next task
+ that needs to be executed, or None if there are no more tasks. The
+ taskmaster's executed() method will be called for each task when it
+ is successfully executed or failed() will be called if the task
+ failed to execute (i.e. execute() raised an exception). The
+ taskmaster's is_blocked() method should return true iff there are
+ more tasks, but they can't be executed until one or more other
+ tasks have been executed. next_task() will be called iff
+ is_blocked() returned false.
+
+ Note: calls to taskmaster are serialized, but calls to execute() on
+ distinct tasks are not serialized, because that is the whole point
+ of parallel jobs: they can execute multiple tasks
+ simultaneously. """
+
+ self.taskmaster = taskmaster
+ self.tp = ThreadPool(num)
+
+ self.jobs = 0
+ self.maxjobs = num
+
+ def start(self):
+ """Start the job. This will begin pulling tasks from the
+ taskmaster and executing them, and return when there are no
+ more tasks. If a task fails to execute (i.e. execute() raises
+ an exception), then the job will stop."""
+
+ while 1:
+ if self.jobs < self.maxjobs:
+ task = self.taskmaster.next_task()
+ if task is None:
+ break
+
+ # prepare task for execution
+ try:
+ task.prepare()
+ except KeyboardInterrupt:
+ raise
+ except:
+ # Let the failed() callback function arrange for the
+ # build to stop if that's appropriate.
+ task.failed()
+
+ # dispatch task
+ self.tp.put(task)
+ self.jobs = self.jobs + 1
+
+ while 1:
+ try:
+ task, ok = self.tp.get_nowait()
+ except Queue.Empty:
+ if not (self.jobs is self.maxjobs or self.taskmaster.is_blocked()):
+ break
+ task, ok = self.tp.get()
+
+ self.jobs = self.jobs - 1
+ if ok:
+ task.executed()
+ else:
+ task.failed()
+
+ task.postprocess()
Added: development/support/scons/scons-local-0.96.1/SCons/Node/Alias.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Node/Alias.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Node/Alias.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,88 @@
+
+"""scons.Node.Alias
+
+Alias nodes.
+
+This creates a hash of global Aliases (dummy targets).
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Node/Alias.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import UserDict
+
+import SCons.Errors
+import SCons.Node
+import SCons.Util
+
+class AliasNameSpace(UserDict.UserDict):
+ def Alias(self, name):
+ if self.has_key(name):
+ raise SCons.Errors.UserError
+ self[name] = SCons.Node.Alias.Alias(name)
+ return self[name]
+
+ def lookup(self, name):
+ try:
+ return self[name]
+ except KeyError:
+ return None
+
+class Alias(SCons.Node.Node):
+ def __init__(self, name):
+ SCons.Node.Node.__init__(self)
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+ def build(self):
+ """A "builder" for aliases."""
+ pass
+
+ current = SCons.Node.Node.children_are_up_to_date
+
+ 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
+
+ def get_contents(self):
+ """The contents of an alias is the concatenation
+ of all the contents of its sources"""
+ contents = ""
+ for kid in self.children(None):
+ contents = contents + kid.get_contents()
+ return contents
+
+default_ans = AliasNameSpace()
+
+SCons.Node.arg2nodes_lookups.append(default_ans.lookup)
Added: development/support/scons/scons-local-0.96.1/SCons/Node/FS.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Node/FS.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Node/FS.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,1867 @@
+"""scons.Node.FS
+
+File system nodes.
+
+These Nodes represent the canonical external objects that people think
+of when they think of building software: files and directories.
+
+This initializes a "default_fs" Node with an FS at the current directory
+for its own purposes, and for use by scripts or modules looking for the
+canonical default.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Node/FS.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+import os.path
+import shutil
+import stat
+import string
+import sys
+import time
+import cStringIO
+
+import SCons.Action
+from SCons.Debug import logInstanceCreation
+import SCons.Errors
+import SCons.Node
+import SCons.Sig.MD5
+import SCons.Util
+import SCons.Warnings
+
+#
+# We stringify these file system Nodes a lot. Turning a file system Node
+# into a string is non-trivial, because the final string representation
+# can depend on a lot of factors: whether it's a derived target or not,
+# whether it's linked to a repository or source directory, and whether
+# there's duplication going on. The normal technique for optimizing
+# calculations like this is to memoize (cache) the string value, so you
+# only have to do the calculation once.
+#
+# A number of the above factors, however, can be set after we've already
+# been asked to return a string for a Node, because a Repository() or
+# BuildDir() call or the like may not occur until later in SConscript
+# files. So this variable controls whether we bother trying to save
+# string values for Nodes. The wrapper interface can set this whenever
+# they're done mucking with Repository and BuildDir and the other stuff,
+# to let this module know it can start returning saved string values
+# for Nodes.
+#
+Save_Strings = None
+
+def save_strings(val):
+ global Save_Strings
+ Save_Strings = val
+
+#
+# SCons.Action objects for interacting with the outside world.
+#
+# The Node.FS methods in this module should use these actions to
+# create and/or remove files and directories; they should *not* use
+# os.{link,symlink,unlink,mkdir}(), etc., directly.
+#
+# Using these SCons.Action objects ensures that descriptions of these
+# external activities are properly displayed, that the displays are
+# suppressed when the -s (silent) option is used, and (most importantly)
+# the actions are disabled when the the -n option is used, in which case
+# there should be *no* changes to the external file system(s)...
+#
+
+def _copy_func(src, dest):
+ shutil.copy2(src, dest)
+ st=os.stat(src)
+ os.chmod(dest, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE)
+
+Valid_Duplicates = ['hard-soft-copy', 'soft-hard-copy',
+ 'hard-copy', 'soft-copy', 'copy']
+
+Link_Funcs = [] # contains the callables of the specified duplication style
+
+def set_duplicate(duplicate):
+ # Fill in the Link_Funcs list according to the argument
+ # (discarding those not available on the platform).
+
+ # Set up the dictionary that maps the argument names to the
+ # underlying implementations. We do this inside this function,
+ # not in the top-level module code, so that we can remap os.link
+ # and os.symlink for testing purposes.
+ try:
+ _hardlink_func = os.link
+ except AttributeError:
+ _hardlink_func = None
+
+ try:
+ _softlink_func = os.symlink
+ except AttributeError:
+ _softlink_func = None
+
+ link_dict = {
+ 'hard' : _hardlink_func,
+ 'soft' : _softlink_func,
+ 'copy' : _copy_func
+ }
+
+ if not duplicate in Valid_Duplicates:
+ raise SCons.Errors.InternalError, ("The argument of set_duplicate "
+ "should be in Valid_Duplicates")
+ global Link_Funcs
+ Link_Funcs = []
+ for func in string.split(duplicate,'-'):
+ if link_dict[func]:
+ Link_Funcs.append(link_dict[func])
+
+def LinkFunc(target, source, env):
+ # Relative paths cause problems with symbolic links, so
+ # we use absolute paths, which may be a problem for people
+ # who want to move their soft-linked src-trees around. Those
+ # people should use the 'hard-copy' mode, softlinks cannot be
+ # used for that; at least I have no idea how ...
+ src = source[0].abspath
+ dest = target[0].abspath
+ dir, file = os.path.split(dest)
+ if dir and not os.path.isdir(dir):
+ os.makedirs(dir)
+ if not Link_Funcs:
+ # Set a default order of link functions.
+ set_duplicate('hard-soft-copy')
+ # Now link the files with the previously specified order.
+ for func in Link_Funcs:
+ try:
+ func(src,dest)
+ break
+ except OSError:
+ if func == Link_Funcs[-1]:
+ # exception of the last link method (copy) are fatal
+ raise
+ else:
+ pass
+ return 0
+
+Link = SCons.Action.Action(LinkFunc, None)
+def LocalString(target, source, env):
+ return 'Local copy of %s from %s' % (target[0], source[0])
+
+LocalCopy = SCons.Action.Action(LinkFunc, LocalString)
+
+def UnlinkFunc(target, source, env):
+ t = target[0]
+ t.fs.unlink(t.abspath)
+ return 0
+
+Unlink = SCons.Action.Action(UnlinkFunc, None)
+
+def MkdirFunc(target, source, env):
+ t = target[0]
+ p = t.abspath
+ if not t.fs.exists(p):
+ t.fs.mkdir(p)
+ return 0
+
+Mkdir = SCons.Action.Action(MkdirFunc, None, presub=None)
+
+MkdirBuilder = None
+
+def get_MkdirBuilder():
+ global MkdirBuilder
+ if MkdirBuilder is None:
+ import SCons.Builder
+ # "env" will get filled in by Executor.get_build_env()
+ # calling SCons.Defaults.DefaultEnvironment() when necessary.
+ MkdirBuilder = SCons.Builder.Builder(action = Mkdir,
+ env = None,
+ explain = None)
+ return MkdirBuilder
+
+def CacheRetrieveFunc(target, source, env):
+ t = target[0]
+ fs = t.fs
+ cachedir, cachefile = t.cachepath()
+ if fs.exists(cachefile):
+ fs.copy2(cachefile, t.path)
+ st = fs.stat(cachefile)
+ fs.chmod(t.path, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE)
+ return 0
+ return 1
+
+def CacheRetrieveString(target, source, env):
+ t = target[0]
+ cachedir, cachefile = t.cachepath()
+ if t.fs.exists(cachefile):
+ return "Retrieved `%s' from cache" % t.path
+ return None
+
+CacheRetrieve = SCons.Action.Action(CacheRetrieveFunc, CacheRetrieveString)
+
+CacheRetrieveSilent = SCons.Action.Action(CacheRetrieveFunc, None)
+
+def CachePushFunc(target, source, env):
+ t = target[0]
+ fs = t.fs
+ cachedir, cachefile = t.cachepath()
+ if fs.exists(cachefile):
+ # Don't bother copying it if it's already there.
+ return
+
+ if not fs.isdir(cachedir):
+ fs.makedirs(cachedir)
+
+ tempfile = cachefile+'.tmp'
+ try:
+ fs.copy2(t.path, tempfile)
+ fs.rename(tempfile, cachefile)
+ st = fs.stat(t.path)
+ fs.chmod(cachefile, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE)
+ except OSError:
+ # It's possible someone else tried writing the file at the same
+ # time we did. Print a warning but don't stop the build, since
+ # it doesn't affect the correctness of the build.
+ SCons.Warnings.warn(SCons.Warnings.CacheWriteErrorWarning,
+ "Unable to copy %s to cache. Cache file is %s"
+ % (str(target), cachefile))
+ return
+
+CachePush = SCons.Action.Action(CachePushFunc, None)
+
+class _Null:
+ pass
+
+_null = _Null()
+
+DefaultSCCSBuilder = None
+DefaultRCSBuilder = None
+
+def get_DefaultSCCSBuilder():
+ global DefaultSCCSBuilder
+ if DefaultSCCSBuilder is None:
+ import SCons.Builder
+ # "env" will get filled in by Executor.get_build_env()
+ # calling SCons.Defaults.DefaultEnvironment() when necessary.
+ DefaultSCCSBuilder = SCons.Builder.Builder(action = '$SCCSCOM',
+ env = None)
+ return DefaultSCCSBuilder
+
+def get_DefaultRCSBuilder():
+ global DefaultRCSBuilder
+ if DefaultRCSBuilder is None:
+ import SCons.Builder
+ # "env" will get filled in by Executor.get_build_env()
+ # calling SCons.Defaults.DefaultEnvironment() when necessary.
+ DefaultRCSBuilder = SCons.Builder.Builder(action = '$RCS_COCOM',
+ env = None)
+ return DefaultRCSBuilder
+
+#
+class ParentOfRoot:
+ """
+ An instance of this class is used as the parent of the root of a
+ filesystem (POSIX) or drive (Win32). This isn't actually a node,
+ but it looks enough like one so that we don't have to have
+ special purpose code everywhere to deal with dir being None.
+ This class is an instance of the Null object pattern.
+ """
+ def __init__(self):
+ self.abspath = ''
+ self.path = ''
+ self.name=''
+ self.duplicate=0
+ self.srcdir=None
+ self.build_dirs=[]
+
+ def is_under(self, dir):
+ return 0
+
+ def up(self):
+ return None
+
+ def getRepositories(self):
+ return []
+
+ def get_dir(self):
+ return None
+
+ def src_builder(self):
+ return _null
+
+ def entry_abspath(self, name):
+ return name
+
+ def entry_path(self, name):
+ return name
+
+# Cygwin's os.path.normcase pretends it's on a case-sensitive filesystem.
+_is_cygwin = sys.platform == "cygwin"
+if os.path.normcase("TeSt") == os.path.normpath("TeSt") and not _is_cygwin:
+ def _my_normcase(x):
+ return x
+else:
+ def _my_normcase(x):
+ return string.upper(x)
+
+class EntryProxy(SCons.Util.Proxy):
+ def __get_abspath(self):
+ entry = self.get()
+ return SCons.Util.SpecialAttrWrapper(entry.get_abspath(),
+ entry.name + "_abspath")
+
+ def __get_filebase(self):
+ name = self.get().name
+ return SCons.Util.SpecialAttrWrapper(SCons.Util.splitext(name)[0],
+ name + "_filebase")
+
+ def __get_suffix(self):
+ name = self.get().name
+ return SCons.Util.SpecialAttrWrapper(SCons.Util.splitext(name)[1],
+ name + "_suffix")
+
+ def __get_file(self):
+ name = self.get().name
+ return SCons.Util.SpecialAttrWrapper(name, name + "_file")
+
+ def __get_base_path(self):
+ """Return the file's directory and file name, with the
+ suffix stripped."""
+ entry = self.get()
+ return SCons.Util.SpecialAttrWrapper(SCons.Util.splitext(entry.get_path())[0],
+ entry.name + "_base")
+
+ def __get_posix_path(self):
+ """Return the path with / as the path separator,
+ regardless of platform."""
+ if os.sep == '/':
+ return self
+ else:
+ entry = self.get()
+ r = string.replace(entry.get_path(), os.sep, '/')
+ return SCons.Util.SpecialAttrWrapper(r, entry.name + "_posix")
+
+ def __get_win32_path(self):
+ """Return the path with \ as the path separator,
+ regardless of platform."""
+ if os.sep == '\\':
+ return self
+ else:
+ entry = self.get()
+ r = string.replace(entry.get_path(), os.sep, '\\')
+ return SCons.Util.SpecialAttrWrapper(r, entry.name + "_win32")
+
+ def __get_srcnode(self):
+ return EntryProxy(self.get().srcnode())
+
+ def __get_srcdir(self):
+ """Returns the directory containing the source node linked to this
+ node via BuildDir(), or the directory of this node if not linked."""
+ return EntryProxy(self.get().srcnode().dir)
+
+ def __get_rsrcnode(self):
+ return EntryProxy(self.get().srcnode().rfile())
+
+ def __get_rsrcdir(self):
+ """Returns the directory containing the source node linked to this
+ node via BuildDir(), or the directory of this node if not linked."""
+ return EntryProxy(self.get().srcnode().rfile().dir)
+
+ def __get_dir(self):
+ return EntryProxy(self.get().dir)
+
+ dictSpecialAttrs = { "base" : __get_base_path,
+ "posix" : __get_posix_path,
+ "win32" : __get_win32_path,
+ "srcpath" : __get_srcnode,
+ "srcdir" : __get_srcdir,
+ "dir" : __get_dir,
+ "abspath" : __get_abspath,
+ "filebase" : __get_filebase,
+ "suffix" : __get_suffix,
+ "file" : __get_file,
+ "rsrcpath" : __get_rsrcnode,
+ "rsrcdir" : __get_rsrcdir,
+ }
+
+ def __getattr__(self, name):
+ # This is how we implement the "special" attributes
+ # such as base, posix, srcdir, etc.
+ try:
+ return self.dictSpecialAttrs[name](self)
+ except KeyError:
+ try:
+ attr = SCons.Util.Proxy.__getattr__(self, name)
+ except AttributeError:
+ entry = self.get()
+ classname = string.split(str(entry.__class__), '.')[-1]
+ raise AttributeError, "%s instance '%s' has no attribute '%s'" % (classname, entry.name, name)
+ return attr
+
+class Base(SCons.Node.Node):
+ """A generic class for file system entries. This class is for
+ when we don't know yet whether the entry being looked up is a file
+ or a directory. Instances of this class can morph into either
+ Dir or File objects by a later, more precise lookup.
+
+ Note: this class does not define __cmp__ and __hash__ for
+ efficiency reasons. SCons does a lot of comparing of
+ Node.FS.{Base,Entry,File,Dir} objects, so those operations must be
+ as fast as possible, which means we want to use Python's built-in
+ object identity comparisons.
+ """
+
+ def __init__(self, name, directory, fs):
+ """Initialize a generic Node.FS.Base object.
+
+ Call the superclass initialization, take care of setting up
+ our relative and absolute paths, identify our parent
+ directory, and indicate that this node should use
+ signatures."""
+ if __debug__: logInstanceCreation(self, 'Node.FS.Base')
+ SCons.Node.Node.__init__(self)
+
+ self.name = name
+ self.fs = fs
+ self.relpath = {self : '.'}
+
+ assert directory, "A directory must be provided"
+
+ self.abspath = directory.entry_abspath(name)
+ if directory.path == '.':
+ self.path = name
+ else:
+ self.path = directory.entry_path(name)
+
+ self.dir = directory
+ self.cwd = None # will hold the SConscript directory for target nodes
+ self.duplicate = directory.duplicate
+
+ def clear(self):
+ """Completely clear a Node.FS.Base object of all its cached
+ state (so that it can be re-evaluated by interfaces that do
+ continuous integration builds).
+ """
+ SCons.Node.Node.clear(self)
+ try:
+ delattr(self, '_exists')
+ except AttributeError:
+ pass
+ try:
+ delattr(self, '_rexists')
+ except AttributeError:
+ pass
+ try:
+ delattr(self, '_str_val')
+ except AttributeError:
+ pass
+ self.relpath = {self : '.'}
+
+ def get_dir(self):
+ return self.dir
+
+ def get_suffix(self):
+ return SCons.Util.splitext(self.name)[1]
+
+ def rfile(self):
+ return self
+
+ def __str__(self):
+ """A Node.FS.Base object's string representation is its path
+ name."""
+ try:
+ return self._str_val
+ except AttributeError:
+ global Save_Strings
+ if self.duplicate or self.is_derived():
+ str_val = self.get_path()
+ else:
+ str_val = self.srcnode().get_path()
+ if Save_Strings:
+ self._str_val = str_val
+ return str_val
+
+ rstr = __str__
+
+ def exists(self):
+ try:
+ return self._exists
+ except AttributeError:
+ self._exists = self.fs.exists(self.abspath)
+ return self._exists
+
+ def rexists(self):
+ try:
+ return self._rexists
+ except AttributeError:
+ self._rexists = self.rfile().exists()
+ return self._rexists
+
+ def is_under(self, dir):
+ if self is dir:
+ return 1
+ else:
+ return self.dir.is_under(dir)
+
+ def set_local(self):
+ self._local = 1
+
+ def srcnode(self):
+ """If this node is in a build path, return the node
+ corresponding to its source file. Otherwise, return
+ ourself."""
+ try:
+ return self._srcnode
+ except AttributeError:
+ dir=self.dir
+ name=self.name
+ while dir:
+ if dir.srcdir:
+ self._srcnode = self.fs.Entry(name, dir.srcdir,
+ klass=self.__class__)
+ return self._srcnode
+ name = dir.name + os.sep + name
+ dir=dir.get_dir()
+ self._srcnode = self
+ return self._srcnode
+
+ def get_path(self, dir=None):
+ """Return path relative to the current working directory of the
+ Node.FS.Base object that owns us."""
+ if not dir:
+ dir = self.fs.getcwd()
+ try:
+ return self.relpath[dir]
+ except KeyError:
+ path_elems = []
+ d = self
+ while d != dir and not isinstance(d, ParentOfRoot):
+ path_elems.append(d.name)
+ d = d.dir
+ path_elems.reverse()
+ ret = string.join(path_elems, os.sep)
+ self.relpath[dir] = ret
+ return ret
+
+ def set_src_builder(self, builder):
+ """Set the source code builder for this node."""
+ self.sbuilder = builder
+ if not self.has_builder():
+ self.builder_set(builder)
+
+ def src_builder(self):
+ """Fetch the source code builder for this node.
+
+ If there isn't one, we cache the source code builder specified
+ for the directory (which in turn will cache the value from its
+ parent directory, and so on up to the file system root).
+ """
+ try:
+ scb = self.sbuilder
+ except AttributeError:
+ scb = self.dir.src_builder()
+ self.sbuilder = scb
+ return scb
+
+ def get_abspath(self):
+ """Get the absolute path of the file."""
+ return self.abspath
+
+ def for_signature(self):
+ # Return just our name. Even an absolute path would not work,
+ # because that can change thanks to symlinks or remapped network
+ # paths.
+ return self.name
+
+ def get_subst_proxy(self):
+ try:
+ return self._proxy
+ except AttributeError:
+ ret = EntryProxy(self)
+ self._proxy = ret
+ return ret
+
+class Entry(Base):
+ """This is the class for generic Node.FS entries--that is, things
+ that could be a File or a Dir, but we're just not sure yet.
+ Consequently, the methods in this class really exist just to
+ transform their associated object into the right class when the
+ time comes, and then call the same-named method in the transformed
+ class."""
+
+ def rfile(self):
+ """We're a generic Entry, but the caller is actually looking for
+ a File at this point, so morph into one."""
+ self.__class__ = File
+ self._morph()
+ self.clear()
+ return File.rfile(self)
+
+ def get_found_includes(self, env, scanner, target):
+ """If we're looking for included files, it's because this Entry
+ is really supposed to be a File itself."""
+ node = self.rfile()
+ return node.get_found_includes(env, scanner, target)
+
+ def scanner_key(self):
+ return self.get_suffix()
+
+ def get_contents(self):
+ """Fetch the contents of the entry.
+
+ Since this should return the real contents from the file
+ system, we check to see into what sort of subclass we should
+ morph this Entry."""
+ if self.fs.isfile(self.abspath):
+ self.__class__ = File
+ self._morph()
+ return File.get_contents(self)
+ if self.fs.isdir(self.abspath):
+ self.__class__ = Dir
+ self._morph()
+ return Dir.get_contents(self)
+ if self.fs.islink(self.abspath):
+ return '' # avoid errors for dangling symlinks
+ raise AttributeError
+
+ def exists(self):
+ """Return if the Entry exists. Check the file system to see
+ what we should turn into first. Assume a file if there's no
+ directory."""
+ if self.fs.isdir(self.abspath):
+ self.__class__ = Dir
+ self._morph()
+ return Dir.exists(self)
+ else:
+ self.__class__ = File
+ self._morph()
+ self.clear()
+ return File.exists(self)
+
+ def calc_signature(self, calc=None):
+ """Return the Entry's calculated signature. Check the file
+ system to see what we should turn into first. Assume a file if
+ there's no directory."""
+ if self.fs.isdir(self.abspath):
+ self.__class__ = Dir
+ self._morph()
+ return Dir.calc_signature(self, calc)
+ else:
+ self.__class__ = File
+ self._morph()
+ self.clear()
+ return File.calc_signature(self, calc)
+
+ def must_be_a_Dir(self):
+ """Called to make sure a Node is a Dir. Since we're an
+ Entry, we can morph into one."""
+ self.__class__ = Dir
+ self._morph()
+
+# This is for later so we can differentiate between Entry the class and Entry
+# the method of the FS class.
+_classEntry = Entry
+
+
+class LocalFS:
+ # This class implements an abstraction layer for operations involving
+ # a local file system. Essentially, this wraps any function in
+ # the os, os.path or shutil modules that we use to actually go do
+ # anything with or to the local file system.
+ #
+ # Note that there's a very good chance we'll refactor this part of
+ # the architecture in some way as we really implement the interface(s)
+ # for remote file system Nodes. For example, the right architecture
+ # might be to have this be a subclass instead of a base class.
+ # Nevertheless, we're using this as a first step in that direction.
+ #
+ # We're not using chdir() yet because the calling subclass method
+ # needs to use os.chdir() directly to avoid recursion. Will we
+ # really need this one?
+ #def chdir(self, path):
+ # return os.chdir(path)
+ def chmod(self, path, mode):
+ return os.chmod(path, mode)
+ def copy2(self, src, dst):
+ return shutil.copy2(src, dst)
+ def exists(self, path):
+ return os.path.exists(path)
+ def getmtime(self, path):
+ return os.path.getmtime(path)
+ def isdir(self, path):
+ return os.path.isdir(path)
+ def isfile(self, path):
+ return os.path.isfile(path)
+ def link(self, src, dst):
+ return os.link(src, dst)
+ def listdir(self, path):
+ return os.listdir(path)
+ def makedirs(self, path):
+ return os.makedirs(path)
+ def mkdir(self, path):
+ return os.mkdir(path)
+ def rename(self, old, new):
+ return os.rename(old, new)
+ def stat(self, path):
+ return os.stat(path)
+ def symlink(self, src, dst):
+ return os.symlink(src, dst)
+ def open(self, path):
+ return open(path)
+ def unlink(self, path):
+ return os.unlink(path)
+
+ if hasattr(os, 'symlink'):
+ def islink(self, path):
+ return os.path.islink(path)
+ def exists_or_islink(self, path):
+ return os.path.exists(path) or os.path.islink(path)
+ else:
+ def islink(self, path):
+ return 0 # no symlinks
+ exists_or_islink = exists
+
+#class RemoteFS:
+# # Skeleton for the obvious methods we might need from the
+# # abstraction layer for a remote filesystem.
+# def upload(self, local_src, remote_dst):
+# pass
+# def download(self, remote_src, local_dst):
+# pass
+
+
+class FS(LocalFS):
+ def __init__(self, path = None):
+ """Initialize the Node.FS subsystem.
+
+ The supplied path is the top of the source tree, where we
+ expect to find the top-level build file. If no path is
+ supplied, the current directory is the default.
+
+ The path argument must be a valid absolute path.
+ """
+ if __debug__: logInstanceCreation(self)
+ self.Top = None
+ if path == None:
+ self.pathTop = os.getcwd()
+ else:
+ self.pathTop = path
+ self.Root = {}
+ self.SConstruct_dir = None
+ self.CachePath = None
+ self.cache_force = None
+ self.cache_show = None
+
+ def set_toplevel_dir(self, path):
+ assert not self.Top, "You can only set the top-level path on an FS object that has not had its File, Dir, or Entry methods called yet."
+ self.pathTop = path
+
+ def set_SConstruct_dir(self, dir):
+ self.SConstruct_dir = dir
+
+ def __setTopLevelDir(self):
+ if not self.Top:
+ self.Top = self.__doLookup(Dir, os.path.normpath(self.pathTop))
+ self.Top.path = '.'
+ self._cwd = self.Top
+
+ def getcwd(self):
+ self.__setTopLevelDir()
+ return self._cwd
+
+ def __checkClass(self, node, klass):
+ if isinstance(node, klass) or klass == Entry:
+ return node
+ if node.__class__ == Entry:
+ node.__class__ = klass
+ node._morph()
+ return node
+ raise TypeError, "Tried to lookup %s '%s' as a %s." % \
+ (node.__class__.__name__, node.path, klass.__name__)
+
+ def __doLookup(self, fsclass, name, directory = None, create = 1):
+ """This method differs from the File and Dir factory methods in
+ one important way: the meaning of the directory parameter.
+ In this method, if directory is None or not supplied, the supplied
+ name is expected to be an absolute path. If you try to look up a
+ relative path with directory=None, then an AssertionError will be
+ raised."""
+
+ if not name:
+ # This is a stupid hack to compensate for the fact
+ # that the POSIX and Win32 versions of os.path.normpath()
+ # behave differently. In particular, in POSIX:
+ # os.path.normpath('./') == '.'
+ # in Win32
+ # os.path.normpath('./') == ''
+ # os.path.normpath('.\\') == ''
+ #
+ # This is a definite bug in the Python library, but we have
+ # to live with it.
+ name = '.'
+ path_comp = string.split(name, os.sep)
+ drive, path_first = os.path.splitdrive(path_comp[0])
+ if not path_first:
+ # Absolute path
+ drive = _my_normcase(drive)
+ try:
+ directory = self.Root[drive]
+ except KeyError:
+ if not create:
+ raise SCons.Errors.UserError
+ directory = RootDir(drive, ParentOfRoot(), self)
+ self.Root[drive] = directory
+ path_comp = path_comp[1:]
+ else:
+ path_comp = [ path_first, ] + path_comp[1:]
+
+ if not path_comp:
+ path_comp = ['']
+
+ # Lookup the directory
+ for path_name in path_comp[:-1]:
+ path_norm = _my_normcase(path_name)
+ try:
+ d = directory.entries[path_norm]
+ except KeyError:
+ if not create:
+ raise SCons.Errors.UserError
+
+ # look at the actual filesystem and make sure there isn't
+ # a file already there
+ path = directory.entry_path(path_name)
+ if self.isfile(path):
+ raise TypeError, \
+ "File %s found where directory expected." % path
+
+ dir_temp = Dir(path_name, directory, self)
+ directory.entries[path_norm] = dir_temp
+ directory.add_wkid(dir_temp)
+ directory = dir_temp
+ else:
+ d.must_be_a_Dir()
+ directory = d
+
+ entry_norm = _my_normcase(path_comp[-1])
+ try:
+ e = directory.entries[entry_norm]
+ except KeyError:
+ if not create:
+ raise SCons.Errors.UserError
+
+ # make sure we don't create File nodes when there is actually
+ # a directory at that path on the disk, and vice versa
+ path = directory.entry_path(path_comp[-1])
+ if fsclass == File:
+ if self.isdir(path):
+ raise TypeError, \
+ "Directory %s found where file expected." % path
+ elif fsclass == Dir:
+ if self.isfile(path):
+ raise TypeError, \
+ "File %s found where directory expected." % path
+
+ result = fsclass(path_comp[-1], directory, self)
+ directory.entries[entry_norm] = result
+ directory.add_wkid(result)
+ else:
+ result = self.__checkClass(e, fsclass)
+ return result
+
+ def __transformPath(self, name, directory):
+ """Take care of setting up the correct top-level directory,
+ usually in preparation for a call to doLookup().
+
+ If the path name is prepended with a '#', then it is unconditionally
+ interpreted as relative to the top-level directory of this FS.
+
+ If directory is None, and name is a relative path,
+ then the same applies.
+ """
+ self.__setTopLevelDir()
+ if name and name[0] == '#':
+ directory = self.Top
+ name = name[1:]
+ if name and (name[0] == os.sep or name[0] == '/'):
+ # Correct such that '#/foo' is equivalent
+ # to '#foo'.
+ name = name[1:]
+ name = os.path.join('.', os.path.normpath(name))
+ elif not directory:
+ directory = self._cwd
+ return (os.path.normpath(name), directory)
+
+ def chdir(self, dir, change_os_dir=0):
+ """Change the current working directory for lookups.
+ If change_os_dir is true, we will also change the "real" cwd
+ to match.
+ """
+ self.__setTopLevelDir()
+ curr=self._cwd
+ try:
+ if not dir is None:
+ self._cwd = dir
+ if change_os_dir:
+ os.chdir(dir.abspath)
+ except OSError:
+ self._cwd = curr
+ raise
+
+ def Entry(self, name, directory = None, create = 1, klass=None):
+ """Lookup or create a generic Entry node with the specified name.
+ If the name is a relative path (begins with ./, ../, or a file
+ name), then it is looked up relative to the supplied directory
+ node, or to the top level directory of the FS (supplied at
+ construction time) if no directory is supplied.
+ """
+
+ if not klass:
+ klass = Entry
+
+ if isinstance(name, Base):
+ return self.__checkClass(name, klass)
+ else:
+ if directory and not isinstance(directory, Dir):
+ directory = self.Dir(directory)
+ name, directory = self.__transformPath(name, directory)
+ return self.__doLookup(klass, name, directory, create)
+
+ def File(self, name, directory = None, create = 1):
+ """Lookup or create a File node with the specified name. If
+ the name is a relative path (begins with ./, ../, or a file name),
+ then it is looked up relative to the supplied directory node,
+ or to the top level directory of the FS (supplied at construction
+ time) if no directory is supplied.
+
+ This method will raise TypeError if a directory is found at the
+ specified path.
+ """
+
+ return self.Entry(name, directory, create, File)
+
+ def Dir(self, name, directory = None, create = 1):
+ """Lookup or create a Dir node with the specified name. If
+ the name is a relative path (begins with ./, ../, or a file name),
+ then it is looked up relative to the supplied directory node,
+ or to the top level directory of the FS (supplied at construction
+ time) if no directory is supplied.
+
+ This method will raise TypeError if a normal file is found at the
+ specified path.
+ """
+
+ return self.Entry(name, directory, create, Dir)
+
+ def BuildDir(self, build_dir, src_dir, duplicate=1):
+ """Link the supplied build directory to the source directory
+ for purposes of building files."""
+
+ self.__setTopLevelDir()
+ if not isinstance(src_dir, SCons.Node.Node):
+ src_dir = self.Dir(src_dir)
+ if not isinstance(build_dir, SCons.Node.Node):
+ build_dir = self.Dir(build_dir)
+ if not src_dir.is_under(self.Top):
+ raise SCons.Errors.UserError, "Source directory must be under top of build tree."
+ if src_dir.is_under(build_dir):
+ raise SCons.Errors.UserError, "Source directory cannot be under build directory."
+ if build_dir.srcdir:
+ if build_dir.srcdir == src_dir:
+ return # We already did this.
+ raise SCons.Errors.UserError, "'%s' already has a source directory: '%s'."%(build_dir, build_dir.srcdir)
+ build_dir.link(src_dir, duplicate)
+
+ def Repository(self, *dirs):
+ """Specify Repository directories to search."""
+ for d in dirs:
+ if not isinstance(d, SCons.Node.Node):
+ d = self.Dir(d)
+ self.__setTopLevelDir()
+ self.Top.addRepository(d)
+
+ def Rsearch(self, path, clazz=_classEntry, cwd=None):
+ """Search for something in a Repository. Returns the first
+ one found in the list, or None if there isn't one."""
+ if isinstance(path, SCons.Node.Node):
+ return path
+ else:
+ name, d = self.__transformPath(path, cwd)
+ n = self.__doLookup(clazz, name, d)
+ if n.exists():
+ return n
+ if isinstance(n, Dir):
+ # If n is a Directory that has Repositories directly
+ # attached to it, then any of those is a valid Repository
+ # path. Return the first one that exists.
+ reps = filter(lambda x: x.exists(), n.getRepositories())
+ if len(reps):
+ return reps[0]
+ d = n.get_dir()
+ name = n.name
+ # Search repositories of all directories that this file is under.
+ while d:
+ for rep in d.getRepositories():
+ try:
+ rnode = self.__doLookup(clazz, name, rep)
+ # Only find the node if it exists and it is not
+ # a derived file. If for some reason, we are
+ # explicitly building a file IN a Repository, we
+ # don't want it to show up in the build tree.
+ # This is usually the case with BuildDir().
+ # We only want to find pre-existing files.
+ if rnode.exists() and \
+ (isinstance(rnode, Dir) or not rnode.is_derived()):
+ return rnode
+ except TypeError:
+ pass # Wrong type of node.
+ # Prepend directory name
+ name = d.name + os.sep + name
+ # Go up one directory
+ d = d.get_dir()
+ return None
+
+ def Rsearchall(self, pathlist, must_exist=1, clazz=_classEntry, cwd=None):
+ """Search for a list of somethings in the Repository list."""
+ ret = []
+ if SCons.Util.is_String(pathlist):
+ pathlist = string.split(pathlist, os.pathsep)
+ if not SCons.Util.is_List(pathlist):
+ pathlist = [pathlist]
+ for path in filter(None, pathlist):
+ if isinstance(path, SCons.Node.Node):
+ ret.append(path)
+ else:
+ name, d = self.__transformPath(path, cwd)
+ n = self.__doLookup(clazz, name, d)
+ if not must_exist or n.exists():
+ ret.append(n)
+ if isinstance(n, Dir):
+ # If this node is a directory, then any repositories
+ # attached to this node can be repository paths.
+ ret.extend(filter(lambda x, me=must_exist, clazz=clazz: isinstance(x, clazz) and (not me or x.exists()),
+ n.getRepositories()))
+
+ d = n.get_dir()
+ name = n.name
+ # Search repositories of all directories that this file
+ # is under.
+ while d:
+ for rep in d.getRepositories():
+ try:
+ rnode = self.__doLookup(clazz, name, rep)
+ # Only find the node if it exists (or
+ # must_exist is zero) and it is not a
+ # derived file. If for some reason, we
+ # are explicitly building a file IN a
+ # Repository, we don't want it to show up in
+ # the build tree. This is usually the case
+ # with BuildDir(). We only want to find
+ # pre-existing files.
+ if (not must_exist or rnode.exists()) and \
+ (not rnode.is_derived() or isinstance(rnode, Dir)):
+ ret.append(rnode)
+ except TypeError:
+ pass # Wrong type of node.
+ # Prepend directory name
+ name = d.name + os.sep + name
+ # Go up one directory
+ d = d.get_dir()
+ return ret
+
+ def CacheDir(self, path):
+ self.CachePath = path
+
+ def build_dir_target_climb(self, dir, tail):
+ """Create targets in corresponding build directories
+
+ Climb the directory tree, and look up path names
+ relative to any linked build directories we find.
+ """
+ targets = []
+ message = None
+ while dir:
+ for bd in dir.build_dirs:
+ p = apply(os.path.join, [bd.path] + tail)
+ targets.append(self.Entry(p))
+ tail = [dir.name] + tail
+ dir = dir.up()
+ if targets:
+ message = "building associated BuildDir targets: %s" % string.join(map(str, targets))
+ return targets, message
+
+class DummyExecutor:
+ """Dummy executor class returned by Dir nodes to bamboozle SCons
+ into thinking we are an actual derived node, where our sources are
+ our directory entries."""
+ def cleanup(self):
+ pass
+ def get_raw_contents(self):
+ return ''
+ def get_contents(self):
+ return ''
+ def get_timestamp(self):
+ return 0
+ def get_build_env(self):
+ return None
+
+class Dir(Base):
+ """A class for directories in a file system.
+ """
+
+ def __init__(self, name, directory, fs):
+ if __debug__: logInstanceCreation(self, 'Node.FS.Dir')
+ Base.__init__(self, name, directory, fs)
+ self._morph()
+
+ def _morph(self):
+ """Turn a file system Node (either a freshly initialized directory
+ object or a separate Entry object) into a proper directory object.
+
+ Set up this directory's entries and hook it into the file
+ system tree. Specify that directories (this Node) don't use
+ signatures for calculating whether they're current."""
+
+ self.repositories = []
+ self.srcdir = None
+
+ self.entries = {}
+ self.entries['.'] = self
+ self.entries['..'] = self.dir
+ self.cwd = self
+ self.builder = get_MkdirBuilder()
+ self.searched = 0
+ self._sconsign = None
+ self.build_dirs = []
+
+ def __clearRepositoryCache(self, duplicate=None):
+ """Called when we change the repository(ies) for a directory.
+ This clears any cached information that is invalidated by changing
+ the repository."""
+
+ for node in self.entries.values():
+ if node != self.dir:
+ if node != self and isinstance(node, Dir):
+ node.__clearRepositoryCache(duplicate)
+ else:
+ try:
+ del node._srcreps
+ except AttributeError:
+ pass
+ try:
+ del node._rfile
+ except AttributeError:
+ pass
+ try:
+ del node._rexists
+ except AttributeError:
+ pass
+ try:
+ del node._exists
+ except AttributeError:
+ pass
+ try:
+ del node._srcnode
+ except AttributeError:
+ pass
+ try:
+ del node._str_val
+ except AttributeError:
+ pass
+ if duplicate != None:
+ node.duplicate=duplicate
+
+ def __resetDuplicate(self, node):
+ if node != self:
+ node.duplicate = node.get_dir().duplicate
+
+ def Entry(self, name):
+ """Create an entry node named 'name' relative to this directory."""
+ return self.fs.Entry(name, self)
+
+ def Dir(self, name):
+ """Create a directory node named 'name' relative to this directory."""
+ return self.fs.Dir(name, self)
+
+ def File(self, name):
+ """Create a file node named 'name' relative to this directory."""
+ return self.fs.File(name, self)
+
+ def link(self, srcdir, duplicate):
+ """Set this directory as the build directory for the
+ supplied source directory."""
+ self.srcdir = srcdir
+ self.duplicate = duplicate
+ self.__clearRepositoryCache(duplicate)
+ srcdir.build_dirs.append(self)
+
+ def getRepositories(self):
+ """Returns a list of repositories for this directory."""
+ if self.srcdir and not self.duplicate:
+ try:
+ return self._srcreps
+ except AttributeError:
+ self._srcreps = self.fs.Rsearchall(self.srcdir.path,
+ clazz=Dir,
+ must_exist=0,
+ cwd=self.fs.Top) \
+ + self.repositories
+ return self._srcreps
+ return self.repositories
+
+ def addRepository(self, dir):
+ if not dir in self.repositories and dir != self:
+ self.repositories.append(dir)
+ self.__clearRepositoryCache()
+
+ def up(self):
+ return self.entries['..']
+
+ def root(self):
+ if not self.entries['..']:
+ return self
+ else:
+ return self.entries['..'].root()
+
+ def scan(self):
+ if not self.implicit is None:
+ return
+ self.implicit = []
+ self.implicit_dict = {}
+ self._children_reset()
+ try:
+ for filename in self.fs.listdir(self.abspath):
+ if filename != '.sconsign':
+ self.Entry(filename)
+ except OSError:
+ # Directory does not exist. No big deal
+ pass
+ keys = filter(lambda k: k != '.' and k != '..', self.entries.keys())
+ kids = map(lambda x, s=self: s.entries[x], keys)
+ def c(one, two):
+ return cmp(one.abspath, two.abspath)
+ kids.sort(c)
+ self._add_child(self.implicit, self.implicit_dict, kids)
+
+ def get_actions(self):
+ """A null "builder" for directories."""
+ return []
+
+ def build(self, **kw):
+ """A null "builder" for directories."""
+ global MkdirBuilder
+ if not self.builder is MkdirBuilder:
+ apply(SCons.Node.Node.build, [self,], kw)
+
+ def multiple_side_effect_has_builder(self):
+ global MkdirBuilder
+ return not self.builder is MkdirBuilder and self.has_builder()
+
+ def alter_targets(self):
+ """Return any corresponding targets in a build directory.
+ """
+ return self.fs.build_dir_target_climb(self, [])
+
+ def scanner_key(self):
+ """A directory does not get scanned."""
+ return None
+
+ def get_contents(self):
+ """Return aggregate contents of all our children."""
+ contents = cStringIO.StringIO()
+ for kid in self.children():
+ contents.write(kid.get_contents())
+ return contents.getvalue()
+
+ def prepare(self):
+ pass
+
+ def current(self, calc=None):
+ """If all of our children were up-to-date, then this
+ directory was up-to-date, too."""
+ if not self.builder is MkdirBuilder and not self.exists():
+ return 0
+ state = 0
+ for kid in self.children():
+ s = kid.get_state()
+ if s and (not state or s > state):
+ state = s
+ import SCons.Node
+ if state == 0 or state == SCons.Node.up_to_date:
+ return 1
+ else:
+ return 0
+
+ def rdir(self):
+ try:
+ return self._rdir
+ except AttributeError:
+ self._rdir = self
+ if not self.exists():
+ n = self.fs.Rsearch(self.path, clazz=Dir, cwd=self.fs.Top)
+ if n:
+ self._rdir = n
+ return self._rdir
+
+ def sconsign(self):
+ """Return the .sconsign file info for this directory,
+ creating it first if necessary."""
+ if not self._sconsign:
+ import SCons.SConsign
+ self._sconsign = SCons.SConsign.ForDirectory(self)
+ return self._sconsign
+
+ def srcnode(self):
+ """Dir has a special need for srcnode()...if we
+ have a srcdir attribute set, then that *is* our srcnode."""
+ if self.srcdir:
+ return self.srcdir
+ return Base.srcnode(self)
+
+ def get_timestamp(self):
+ """Return the latest timestamp from among our children"""
+ stamp = 0
+ for kid in self.children():
+ if kid.get_timestamp() > stamp:
+ stamp = kid.get_timestamp()
+ return stamp
+
+ def entry_abspath(self, name):
+ return self.abspath + os.sep + name
+
+ def entry_path(self, name):
+ return self.path + os.sep + name
+
+ def must_be_a_Dir(self):
+ """Called to make sure a Node is a Dir. Since we're already
+ one, this is a no-op for us."""
+ pass
+
+class RootDir(Dir):
+ """A class for the root directory of a file system.
+
+ This is the same as a Dir class, except that the path separator
+ ('/' or '\\') is actually part of the name, so we don't need to
+ add a separator when creating the path names of entries within
+ this directory.
+ """
+ def __init__(self, name, directory, fs):
+ if __debug__: logInstanceCreation(self, 'Node.FS.RootDir')
+ Base.__init__(self, name, directory, fs)
+ self.path = self.path + os.sep
+ self.abspath = self.abspath + os.sep
+ self._morph()
+
+ def entry_abspath(self, name):
+ return self.abspath + name
+
+ def entry_path(self, name):
+ return self.path + name
+
+class BuildInfo:
+ bsig = None
+ def __cmp__(self, other):
+ try:
+ return cmp(self.bsig, other.bsig)
+ except AttributeError:
+ return 1
+
+class File(Base):
+ """A class for files in a file system.
+ """
+ def __init__(self, name, directory, fs):
+ if __debug__: logInstanceCreation(self, 'Node.FS.File')
+ Base.__init__(self, name, directory, fs)
+ self._morph()
+
+ def Entry(self, name):
+ """Create an entry node named 'name' relative to
+ the SConscript directory of this file."""
+ return self.fs.Entry(name, self.cwd)
+
+ def Dir(self, name):
+ """Create a directory node named 'name' relative to
+ the SConscript directory of this file."""
+ return self.fs.Dir(name, self.cwd)
+
+ def File(self, name):
+ """Create a file node named 'name' relative to
+ the SConscript directory of this file."""
+ return self.fs.File(name, self.cwd)
+
+ def RDirs(self, pathlist):
+ """Search for a list of directories in the Repository list."""
+ return self.fs.Rsearchall(pathlist, clazz=Dir, must_exist=0,
+ cwd=self.cwd)
+
+ def generate_build_dict(self):
+ """Return an appropriate dictionary of values for building
+ this File."""
+ return {'Dir' : self.Dir,
+ 'File' : self.File,
+ 'RDirs' : self.RDirs}
+
+ def _morph(self):
+ """Turn a file system node into a File object."""
+ self.scanner_paths = {}
+ self.found_includes = {}
+ if not hasattr(self, '_local'):
+ self._local = 0
+
+ def root(self):
+ return self.dir.root()
+
+ def scanner_key(self):
+ return self.get_suffix()
+
+ def get_contents(self):
+ if not self.rexists():
+ return ''
+ return open(self.rfile().abspath, "rb").read()
+
+ def get_timestamp(self):
+ if self.rexists():
+ return self.fs.getmtime(self.rfile().abspath)
+ else:
+ return 0
+
+ def store_info(self, obj):
+ # Merge our build information into the already-stored entry.
+ # This accomodates "chained builds" where a file that's a target
+ # in one build (SConstruct file) is a source in a different build.
+ # See test/chained-build.py for the use case.
+ entry = self.get_stored_info()
+ for key, val in obj.__dict__.items():
+ entry.__dict__[key] = val
+ self.dir.sconsign().set_entry(self.name, entry)
+
+ def get_stored_info(self):
+ try:
+ stored = self.dir.sconsign().get_entry(self.name)
+ if isinstance(stored, BuildInfo):
+ return stored
+ # The stored build information isn't a BuildInfo object.
+ # This probably means it's an old SConsignEntry from SCons
+ # 0.95 or before. The relevant attribute names are the same,
+ # though, so just copy the attributes over to an object of
+ # the correct type.
+ binfo = BuildInfo()
+ for key, val in stored.__dict__.items():
+ setattr(binfo, key, val)
+ return binfo
+ except:
+ return BuildInfo()
+
+ def get_stored_implicit(self):
+ binfo = self.get_stored_info()
+ try:
+ return binfo.bimplicit
+ except AttributeError:
+ return None
+
+ def get_found_includes(self, env, scanner, target):
+ """Return the included implicit dependencies in this file.
+ Cache results so we only scan the file once regardless of
+ how many times this information is requested."""
+ if not scanner:
+ return []
+
+ try:
+ path = target.scanner_paths[scanner]
+ except AttributeError:
+ # The target had no scanner_paths attribute, which means
+ # it's an Alias or some other node that's not actually a
+ # file. In that case, back off and use the path for this
+ # node itself.
+ try:
+ path = self.scanner_paths[scanner]
+ except KeyError:
+ path = scanner.path(env, self.cwd)
+ self.scanner_paths[scanner] = path
+ except KeyError:
+ path = scanner.path(env, target.cwd)
+ target.scanner_paths[scanner] = path
+
+ try:
+ includes = self.found_includes[path]
+ except KeyError:
+ includes = scanner(self, env, path)
+ self.found_includes[path] = includes
+
+ return includes
+
+ def _createDir(self):
+ # ensure that the directories for this node are
+ # created.
+
+ listDirs = []
+ parent=self.dir
+ while parent:
+ if parent.exists():
+ break
+ listDirs.append(parent)
+ p = parent.up()
+ if isinstance(p, ParentOfRoot):
+ raise SCons.Errors.StopError, parent.path
+ parent = p
+ listDirs.reverse()
+ for dirnode in listDirs:
+ try:
+ # Don't call dirnode.build(), call the base Node method
+ # directly because we definitely *must* create this
+ # directory. The dirnode.build() method will suppress
+ # the build if it's the default builder.
+ SCons.Node.Node.build(dirnode)
+ # The build() action may or may not have actually
+ # created the directory, depending on whether the -n
+ # option was used or not. Delete the _exists and
+ # _rexists attributes so they can be reevaluated.
+ try:
+ delattr(dirnode, '_exists')
+ except AttributeError:
+ pass
+ try:
+ delattr(dirnode, '_rexists')
+ except AttributeError:
+ pass
+ except OSError:
+ pass
+
+ def retrieve_from_cache(self):
+ """Try to retrieve the node's content from a cache
+
+ This method is called from multiple threads in a parallel build,
+ so only do thread safe stuff here. Do thread unsafe stuff in
+ built().
+
+ Returns true iff the node was successfully retrieved.
+ """
+ b = self.is_derived()
+ if not b and not self.has_src_builder():
+ return None
+ if b and self.fs.CachePath:
+ if self.fs.cache_show:
+ if CacheRetrieveSilent(self, [], None) == 0:
+ self.build(presub=0, execute=0)
+ return 1
+ elif CacheRetrieve(self, [], None) == 0:
+ return 1
+ return None
+
+ def built(self):
+ """Called just after this node is sucessfully built."""
+ # Push this file out to cache before the superclass Node.built()
+ # method has a chance to clear the build signature, which it
+ # will do if this file has a source scanner.
+ if self.fs.CachePath and self.fs.exists(self.path):
+ CachePush(self, [], None)
+ SCons.Node.Node.built(self)
+ self.found_includes = {}
+ try:
+ delattr(self, '_exists')
+ except AttributeError:
+ pass
+ try:
+ delattr(self, '_rexists')
+ except AttributeError:
+ pass
+
+ def visited(self):
+ if self.fs.CachePath and self.fs.cache_force and self.fs.exists(self.path):
+ CachePush(self, None, None)
+
+ def has_src_builder(self):
+ """Return whether this Node has a source builder or not.
+
+ If this Node doesn't have an explicit source code builder, this
+ is where we figure out, on the fly, if there's a transparent
+ source code builder for it.
+
+ Note that if we found a source builder, we also set the
+ self.builder attribute, so that all of the methods that actually
+ *build* this file don't have to do anything different.
+ """
+ try:
+ scb = self.sbuilder
+ except AttributeError:
+ if self.rexists():
+ scb = None
+ else:
+ scb = self.dir.src_builder()
+ if scb is _null:
+ scb = None
+ dir = self.dir.path
+ sccspath = os.path.join('SCCS', 's.' + self.name)
+ if dir != '.':
+ sccspath = os.path.join(dir, sccspath)
+ if self.fs.exists(sccspath):
+ scb = get_DefaultSCCSBuilder()
+ else:
+ rcspath = os.path.join('RCS', self.name + ',v')
+ if dir != '.':
+ rcspath = os.path.join(dir, rcspath)
+ if os.path.exists(rcspath):
+ scb = get_DefaultRCSBuilder()
+ self.builder = scb
+ self.sbuilder = scb
+ return not scb is None
+
+ def alter_targets(self):
+ """Return any corresponding targets in a build directory.
+ """
+ if self.is_derived():
+ return [], None
+ return self.fs.build_dir_target_climb(self.dir, [self.name])
+
+ def is_pseudo_derived(self):
+ return self.has_src_builder()
+
+ def prepare(self):
+ """Prepare for this file to be created."""
+ SCons.Node.Node.prepare(self)
+
+ if self.get_state() != SCons.Node.up_to_date:
+ if self.exists():
+ if self.is_derived() and not self.precious:
+ try:
+ Unlink(self, [], None)
+ except OSError, e:
+ raise SCons.Errors.BuildError(node = self,
+ errstr = e.strerror)
+ try:
+ delattr(self, '_exists')
+ except AttributeError:
+ pass
+ else:
+ try:
+ self._createDir()
+ except SCons.Errors.StopError, drive:
+ desc = "No drive `%s' for target `%s'." % (drive, self)
+ raise SCons.Errors.StopError, desc
+
+ def remove(self):
+ """Remove this file."""
+ if self.fs.exists_or_islink(self.path):
+ self.fs.unlink(self.path)
+ return 1
+ return None
+
+ def exists(self):
+ # Duplicate from source path if we are set up to do this.
+ if self.duplicate and not self.is_derived() and not self.linked:
+ src=self.srcnode().rfile()
+ if src.exists() and src.abspath != self.abspath:
+ self._createDir()
+ try:
+ Unlink(self, None, None)
+ except OSError:
+ pass
+ try:
+ Link(self, src, None)
+ except IOError, e:
+ desc = "Cannot duplicate `%s' in `%s': %s." % (src, self.dir, e.strerror)
+ raise SCons.Errors.StopError, desc
+ self.linked = 1
+ # The Link() action may or may not have actually
+ # created the file, depending on whether the -n
+ # option was used or not. Delete the _exists and
+ # _rexists attributes so they can be reevaluated.
+ try:
+ delattr(self, '_exists')
+ except AttributeError:
+ pass
+ try:
+ delattr(self, '_rexists')
+ except AttributeError:
+ pass
+ return Base.exists(self)
+
+ def new_binfo(self):
+ return BuildInfo()
+
+ def del_cinfo(self):
+ try:
+ del self.binfo.csig
+ except AttributeError:
+ pass
+ try:
+ del self.binfo.timestamp
+ except AttributeError:
+ pass
+
+ def calc_csig(self, calc=None):
+ """
+ Generate a node's content signature, the digested signature
+ of its content.
+
+ node - the node
+ cache - alternate node to use for the signature cache
+ returns - the content signature
+ """
+ if calc is None:
+ calc = self.calculator()
+
+ try:
+ return self.binfo.csig
+ except AttributeError:
+ pass
+
+ if calc.max_drift >= 0:
+ old = self.get_stored_info()
+ else:
+ old = BuildInfo()
+
+ try:
+ mtime = self.get_timestamp()
+ except:
+ mtime = 0
+ raise SCons.Errors.UserError, "no such %s" % self
+
+ try:
+ if (old.timestamp and old.csig and old.timestamp == mtime):
+ # use the signature stored in the .sconsign file
+ csig = old.csig
+ else:
+ csig = calc.module.signature(self)
+ except AttributeError:
+ csig = calc.module.signature(self)
+
+ if calc.max_drift >= 0 and (time.time() - mtime) > calc.max_drift:
+ try:
+ binfo = self.binfo
+ except AttributeError:
+ binfo = self.binfo = self.new_binfo()
+ binfo.csig = csig
+ binfo.timestamp = mtime
+ self.store_info(binfo)
+
+ return csig
+
+ def current(self, calc=None, scan=1):
+ self.binfo = self.gen_binfo(calc)
+ if self.always_build:
+ return None
+ if not self.exists():
+ # The file doesn't exist locally...
+ r = self.rfile()
+ if r != self:
+ # ...but there is one in a Repository...
+ old = r.get_stored_info()
+ if old == self.binfo:
+ # ...and it's even up-to-date...
+ if self._local:
+ # ...and they'd like a local copy.
+ LocalCopy(self, r, None)
+ self.store_info(self.binfo)
+ return 1
+ self._rfile = self
+ return None
+ else:
+ old = self.get_stored_info()
+ return (old == self.binfo)
+
+ def rfile(self):
+ try:
+ return self._rfile
+ except AttributeError:
+ self._rfile = self
+ if not self.exists():
+ n = self.fs.Rsearch(self.path, clazz=File,
+ cwd=self.fs.Top)
+ if n:
+ self._rfile = n
+ return self._rfile
+
+ def rstr(self):
+ return str(self.rfile())
+
+ def cachepath(self):
+ if not self.fs.CachePath:
+ return None, None
+ if self.binfo.bsig is None:
+ raise SCons.Errors.InternalError, "cachepath(%s) found a bsig of None" % self.path
+ # Add the path to the cache signature, because multiple
+ # targets built by the same action will all have the same
+ # build signature, and we have to differentiate them somehow.
+ cache_sig = SCons.Sig.MD5.collect([self.binfo.bsig, self.path])
+ subdir = string.upper(cache_sig[0])
+ dir = os.path.join(self.fs.CachePath, subdir)
+ return dir, os.path.join(dir, cache_sig)
+
+ def target_from_source(self, prefix, suffix, splitext=SCons.Util.splitext):
+ return self.dir.File(prefix + splitext(self.name)[0] + suffix)
+
+ def must_be_a_Dir(self):
+ """Called to make sure a Node is a Dir. Since we're already a
+ File, this is a TypeError..."""
+ raise TypeError, "Tried to lookup File '%s' as a Dir." % self.path
+
+default_fs = FS()
+
+
+def find_file(filename, paths, node_factory = default_fs.File):
+ """
+ find_file(str, [Dir()]) -> [nodes]
+
+ filename - a filename to find
+ paths - a list of directory path *nodes* to search in
+
+ returns - the node created from the found file.
+
+ Find a node corresponding to either a derived file or a file
+ that exists already.
+
+ Only the first file found is returned, and none is returned
+ if no file is found.
+ """
+ retval = None
+ for dir in paths:
+ try:
+ node = node_factory(filename, dir)
+ # Return true if the node exists or is a derived node.
+ if node.is_derived() or \
+ node.is_pseudo_derived() or \
+ (isinstance(node, SCons.Node.FS.Base) and node.exists()):
+ retval = node
+ break
+ except TypeError:
+ # If we find a directory instead of a file, we don't care
+ pass
+
+ return retval
+
+def find_files(filenames, paths, node_factory = default_fs.File):
+ """
+ find_files([str], [Dir()]) -> [nodes]
+
+ filenames - a list of filenames to find
+ paths - a list of directory path *nodes* to search in
+
+ returns - the nodes created from the found files.
+
+ Finds nodes corresponding to either derived files or files
+ that exist already.
+
+ Only the first file found is returned for each filename,
+ and any files that aren't found are ignored.
+ """
+ nodes = map(lambda x, paths=paths, node_factory=node_factory:
+ find_file(x, paths, node_factory),
+ filenames)
+ return filter(lambda x: x != None, nodes)
Added: development/support/scons/scons-local-0.96.1/SCons/Node/Python.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Node/Python.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Node/Python.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,78 @@
+"""scons.Node.Python
+
+Python nodes.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Node/Python.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Node
+
+class Value(SCons.Node.Node):
+ """A class for Python variables, typically passed on the command line
+ or generated by a script, but not from a file or some other source.
+ """
+ def __init__(self, value):
+ SCons.Node.Node.__init__(self)
+ self.value = value
+
+ def __str__(self):
+ return repr(self.value)
+
+ def build(self):
+ """A "builder" for Values."""
+ pass
+
+ current = SCons.Node.Node.children_are_up_to_date
+
+ def is_under(self, dir):
+ # Make Value nodes get built regardless of
+ # what directory scons was run from. Value nodes
+ # are outside the filesystem:
+ return 1
+
+ def get_contents(self):
+ """The contents of a Value are the concatenation
+ of all the contents of its sources with the node's value itself."""
+ contents = str(self.value)
+ for kid in self.children(None):
+ contents = contents + kid.get_contents()
+ return contents
+
+ def calc_csig(self, calc=None):
+ """Because we're a Python value node and don't have a real
+ timestamp, we get to ignore the calculator and just use the
+ value contents."""
+ try:
+ binfo = self.binfo
+ except:
+ binfo = self.binfo = self.new_binfo()
+ try:
+ return binfo.csig
+ except AttributeError:
+ binfo.csig = self.get_contents()
+ self.store_info(binfo)
+ return binfo.csig
Added: development/support/scons/scons-local-0.96.1/SCons/Node/__init__.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Node/__init__.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Node/__init__.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,980 @@
+"""SCons.Node
+
+The Node package for the SCons software construction utility.
+
+This is, in many ways, the heart of SCons.
+
+A Node is where we encapsulate all of the dependency information about
+any thing that SCons can build, or about any thing which SCons can use
+to build some other thing. The canonical "thing," of course, is a file,
+but a Node can also represent something remote (like a web page) or
+something completely abstract (like an Alias).
+
+Each specific type of "thing" is specifically represented by a subclass
+of the Node base class: Node.FS.File for files, Node.Alias for aliases,
+etc. Dependency information is kept here in the base class, and
+information specific to files/aliases/etc. is in the subclass. The
+goal, if we've done this correctly, is that any type of "thing" should
+be able to depend on any other type of "thing."
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Node/__init__.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+
+
+import copy
+import string
+
+from SCons.Debug import logInstanceCreation
+import SCons.SConsign
+import SCons.Util
+
+# Node states
+#
+# These are in "priority" order, so that the maximum value for any
+# child/dependency of a node represents the state of that node if
+# it has no builder of its own. The canonical example is a file
+# system directory, which is only up to date if all of its children
+# were up to date.
+pending = 1
+executing = 2
+up_to_date = 3
+executed = 4
+failed = 5
+stack = 6 # nodes that are in the current Taskmaster execution stack
+
+# controls whether implicit depedencies are cached:
+implicit_cache = 0
+
+# controls whether implicit dep changes are ignored:
+implicit_deps_unchanged = 0
+
+# controls whether the cached implicit deps are ignored:
+implicit_deps_changed = 0
+
+# A variable that can be set to an interface-specific function be called
+# to annotate a Node with information about its creation.
+def do_nothing(node): pass
+
+Annotate = do_nothing
+
+class BuildInfo:
+ def __cmp__(self, other):
+ return cmp(self.__dict__, other.__dict__)
+
+class Node:
+ """The base Node class, for entities that we know how to
+ build, or use to build other Nodes.
+ """
+
+ class Attrs:
+ pass
+
+ def __init__(self):
+ if __debug__: logInstanceCreation(self, 'Node')
+ # Note that we no longer explicitly initialize a self.builder
+ # attribute to None here. That's because the self.builder
+ # attribute may be created on-the-fly later by a subclass (the
+ # canonical example being a builder to fetch a file from a
+ # source code system like CVS or Subversion).
+
+ # Each list of children that we maintain is accompanied by a
+ # dictionary used to look up quickly whether a node is already
+ # present in the list. Empirical tests showed that it was
+ # fastest to maintain them as side-by-side Node attributes in
+ # this way, instead of wrapping up each list+dictionary pair in
+ # a class. (Of course, we could always still do that in the
+ # future if we had a good reason to...).
+ self.sources = [] # source files used to build node
+ self.sources_dict = {}
+ self.depends = [] # explicit dependencies (from Depends)
+ self.depends_dict = {}
+ self.ignore = [] # dependencies to ignore
+ self.ignore_dict = {}
+ self.implicit = None # implicit (scanned) dependencies (None means not scanned yet)
+ self.waiting_parents = []
+ self.wkids = None # Kids yet to walk, when it's an array
+ self.target_scanner = None # explicit scanner from this node's Builder
+ self.source_scanner = None
+ self.backup_source_scanner = None
+
+ self.env = None
+ self.state = None
+ self.precious = None
+ self.always_build = None
+ self.found_includes = {}
+ self.includes = None
+ self.overrides = {} # construction variable overrides for building this node
+ self.attributes = self.Attrs() # Generic place to stick information about the Node.
+ self.side_effect = 0 # true iff this node is a side effect
+ self.side_effects = [] # the side effects of building this target
+ self.pre_actions = []
+ self.post_actions = []
+ self.linked = 0 # is this node linked to the build directory?
+
+ # Let the interface in which the build engine is embedded
+ # annotate this Node with its own info (like a description of
+ # what line in what file created the node, for example).
+ Annotate(self)
+
+ def get_suffix(self):
+ return ''
+
+ def generate_build_dict(self):
+ """Return an appropriate dictionary of values for building
+ this Node."""
+ return {}
+
+ def get_build_env(self):
+ """Fetch the appropriate Environment to build this node."""
+ executor = self.get_executor()
+ return executor.get_build_env()
+
+ def set_executor(self, executor):
+ """Set the action executor for this node."""
+ self.executor = executor
+
+ def get_executor(self, create=1):
+ """Fetch the action executor for this node. Create one if
+ there isn't already one, and requested to do so."""
+ try:
+ executor = self.executor
+ except AttributeError:
+ if not create:
+ raise
+ import SCons.Executor
+ executor = SCons.Executor.Executor(self.builder.action,
+ self.builder.env,
+ [self.builder.overrides],
+ [self],
+ self.sources)
+ self.executor = executor
+ return executor
+
+ def retrieve_from_cache(self):
+ """Try to retrieve the node's content from a cache
+
+ This method is called from multiple threads in a parallel build,
+ so only do thread safe stuff here. Do thread unsafe stuff in
+ built().
+
+ Returns true iff the node was successfully retrieved.
+ """
+ return 0
+
+ def build(self, **kw):
+ """Actually build the node.
+
+ This method is called from multiple threads in a parallel build,
+ so only do thread safe stuff here. Do thread unsafe stuff in
+ built().
+ """
+ if not self.has_builder():
+ return
+ def errfunc(stat, node=self):
+ raise SCons.Errors.BuildError(node=node, errstr="Error %d" % stat)
+ executor = self.get_executor()
+ apply(executor, (self, errfunc), kw)
+
+ def built(self):
+ """Called just after this node is sucessfully built."""
+ try:
+ new_binfo = self.binfo
+ except AttributeError:
+ pass
+ else:
+ self.store_info(new_binfo)
+
+ # Clear our scanned included files.
+ self.found_includes = {}
+ self.includes = None
+
+ # Clear the implicit dependency caches of any Nodes
+ # waiting for this Node to be built.
+ for parent in self.waiting_parents:
+ parent.implicit = None
+ parent.del_binfo()
+ self.waiting_parents = []
+
+ # The content just changed, delete any cached info
+ # so it will get recalculated.
+ self.del_cinfo()
+
+ def add_to_waiting_parents(self, node):
+ self.waiting_parents.append(node)
+
+ def call_for_all_waiting_parents(self, func):
+ func(self)
+ for parent in self.waiting_parents:
+ parent.call_for_all_waiting_parents(func)
+
+ def postprocess(self):
+ """Clean up anything we don't need to hang onto after we've
+ been built."""
+ try:
+ executor = self.get_executor(create=None)
+ except AttributeError:
+ pass
+ else:
+ executor.cleanup()
+
+ def clear(self):
+ """Completely clear a Node of all its cached state (so that it
+ can be re-evaluated by interfaces that do continuous integration
+ builds).
+ """
+ self.set_state(None)
+ self.del_binfo()
+ self.del_cinfo()
+ try:
+ delattr(self, '_calculated_sig')
+ except AttributeError:
+ pass
+ self.includes = None
+ self.found_includes = {}
+ self.implicit = None
+
+ self.waiting_parents = []
+
+ def visited(self):
+ """Called just after this node has been visited
+ without requiring a build.."""
+ pass
+
+ def depends_on(self, nodes):
+ """Does this node depend on any of 'nodes'?"""
+ for node in nodes:
+ if node in self.children():
+ return 1
+
+ return 0
+
+ def builder_set(self, builder):
+ self.builder = builder
+
+ def has_builder(self):
+ """Return whether this Node has a builder or not.
+
+ In Boolean tests, this turns out to be a *lot* more efficient
+ than simply examining the builder attribute directly ("if
+ node.builder: ..."). When the builder attribute is examined
+ directly, it ends up calling __getattr__ for both the __len__
+ and __nonzero__ attributes on instances of our Builder Proxy
+ class(es), generating a bazillion extra calls and slowing
+ things down immensely.
+ """
+ try:
+ b = self.builder
+ except AttributeError:
+ # There was no explicit builder for this Node, so initialize
+ # the self.builder attribute to None now.
+ self.builder = None
+ b = self.builder
+ return not b is None
+
+ multiple_side_effect_has_builder = has_builder
+
+ def is_derived(self):
+ """
+ Returns true iff this node is derived (i.e. built).
+
+ This should return true only for nodes whose path should be in
+ the build directory when duplicate=0 and should contribute their build
+ signatures when they are used as source files to other derived files. For
+ example: source with source builders are not derived in this sense,
+ and hence should not return true.
+ """
+ return self.has_builder() or self.side_effect
+
+ def is_pseudo_derived(self):
+ """
+ Returns true iff this node is built, but should use a source path
+ when duplicate=0 and should contribute a content signature (i.e.
+ source signature) when used as a source for other derived files.
+ """
+ return 0
+
+ def alter_targets(self):
+ """Return a list of alternate targets for this Node.
+ """
+ return [], None
+
+ def get_found_includes(self, env, scanner, target):
+ """Return the scanned include lines (implicit dependencies)
+ found in this node.
+
+ The default is no implicit dependencies. We expect this method
+ to be overridden by any subclass that can be scanned for
+ implicit dependencies.
+ """
+ return []
+
+ def get_implicit_deps(self, env, scanner, target):
+ """Return a list of implicit dependencies for this node.
+
+ This method exists to handle recursive invocation of the scanner
+ on the implicit dependencies returned by the scanner, if the
+ scanner's recursive flag says that we should.
+ """
+ if not scanner:
+ return []
+
+ # Give the scanner a chance to select a more specific scanner
+ # for this Node.
+ scanner = scanner.select(self)
+
+ try:
+ recurse = scanner.recursive
+ except AttributeError:
+ recurse = None
+
+ nodes = [self]
+ seen = {}
+ seen[self] = 1
+ deps = []
+ while nodes:
+ n = nodes.pop(0)
+ d = filter(lambda x, seen=seen: not seen.has_key(x),
+ n.get_found_includes(env, scanner, target))
+ if d:
+ deps.extend(d)
+ for n in d:
+ seen[n] = 1
+ if recurse:
+ nodes.extend(d)
+
+ return deps
+
+ # cache used to make implicit_factory fast.
+ implicit_factory_cache = {}
+
+ def implicit_factory(self, path):
+ """
+ Turn a cache implicit dependency path into a node.
+ This is called so many times that doing caching
+ here is a significant perforamnce boost.
+ """
+ try:
+ return self.implicit_factory_cache[path]
+ except KeyError:
+ n = self.builder.source_factory(path)
+ self.implicit_factory_cache[path] = n
+ return n
+
+ def get_source_scanner(self, node):
+ """Fetch the source scanner for the specified node
+
+ NOTE: "self" is the target being built, "node" is
+ the source file for which we want to fetch the scanner.
+ """
+ if self.source_scanner:
+ return self.source_scanner
+ try:
+ scanner = node.builder.source_scanner
+ if scanner:
+ return scanner
+ except AttributeError:
+ pass
+ return node.backup_source_scanner or None
+
+ def scan(self):
+ """Scan this node's dependents for implicit dependencies."""
+ # Don't bother scanning non-derived files, because we don't
+ # care what their dependencies are.
+ # Don't scan again, if we already have scanned.
+ if not self.implicit is None:
+ return
+ self.implicit = []
+ self.implicit_dict = {}
+ self._children_reset()
+ if not self.has_builder():
+ return
+
+ build_env = self.get_build_env()
+
+ # Here's where we implement --implicit-cache.
+ if implicit_cache and not implicit_deps_changed:
+ implicit = self.get_stored_implicit()
+ if implicit is not None:
+ implicit = map(self.implicit_factory, implicit)
+ self._add_child(self.implicit, self.implicit_dict, implicit)
+ calc = build_env.get_calculator()
+ if implicit_deps_unchanged or self.current(calc, scan=0):
+ return
+ else:
+ # one of this node's sources has changed, so
+ # we need to recalculate the implicit deps,
+ # and the bsig:
+ self.implicit = []
+ self.implicit_dict = {}
+ self._children_reset()
+ self.del_binfo()
+
+ for child in self.children(scan=0):
+ scanner = self.get_source_scanner(child)
+ if scanner:
+ deps = child.get_implicit_deps(build_env, scanner, self)
+ self._add_child(self.implicit, self.implicit_dict, deps)
+
+ # scan this node itself for implicit dependencies
+ deps = self.get_implicit_deps(build_env, self.target_scanner, self)
+ self._add_child(self.implicit, self.implicit_dict, deps)
+
+ # XXX See note above re: --implicit-cache.
+ #if implicit_cache:
+ # self.store_implicit()
+
+ def scanner_key(self):
+ return None
+
+ def env_set(self, env, safe=0):
+ if safe and self.env:
+ return
+ self.env = env
+
+ def calculator(self):
+ import SCons.Defaults
+
+ env = self.env or SCons.Defaults.DefaultEnvironment()
+ return env.get_calculator()
+
+ def calc_signature(self, calc=None):
+ """
+ Select and calculate the appropriate build signature for a node.
+
+ self - the node
+ calc - the signature calculation module
+ returns - the signature
+ """
+ try:
+ return self._calculated_sig
+ except AttributeError:
+ if self.is_derived():
+ import SCons.Defaults
+
+ env = self.env or SCons.Defaults.DefaultEnvironment()
+ if env.use_build_signature():
+ sig = self.calc_bsig(calc)
+ else:
+ sig = self.calc_csig(calc)
+ elif not self.rexists():
+ sig = None
+ else:
+ sig = self.calc_csig(calc)
+ self._calculated_sig = sig
+ return sig
+
+ def new_binfo(self):
+ return BuildInfo()
+
+ def del_binfo(self):
+ """Delete the bsig from this node."""
+ try:
+ delattr(self, 'binfo')
+ except AttributeError:
+ pass
+
+ def calc_bsig(self, calc=None):
+ try:
+ return self.binfo.bsig
+ except AttributeError:
+ self.binfo = self.gen_binfo(calc)
+ return self.binfo.bsig
+
+ def gen_binfo(self, calc=None, scan=1):
+ """
+ Generate a node's build signature, the digested signatures
+ of its dependency files and build information.
+
+ node - the node whose sources will be collected
+ cache - alternate node to use for the signature cache
+ returns - the build signature
+
+ This no longer handles the recursive descent of the
+ node's children's signatures. We expect that they're
+ already built and updated by someone else, if that's
+ what's wanted.
+ """
+
+ if calc is None:
+ calc = self.calculator()
+
+ binfo = self.new_binfo()
+
+ if scan:
+ self.scan()
+
+ sources = self.filter_ignore(self.sources)
+ depends = self.filter_ignore(self.depends)
+ if self.implicit is None:
+ implicit = []
+ else:
+ implicit = self.filter_ignore(self.implicit)
+
+ def calc_signature(node, calc=calc):
+ return node.calc_signature(calc)
+ sourcesigs = map(calc_signature, sources)
+ dependsigs = map(calc_signature, depends)
+ implicitsigs = map(calc_signature, implicit)
+
+ sigs = sourcesigs + dependsigs + implicitsigs
+
+ if self.has_builder():
+ executor = self.get_executor()
+ binfo.bact = executor.get_contents()
+ binfo.bactsig = calc.module.signature(executor)
+ sigs.append(binfo.bactsig)
+
+ binfo.bsources = map(str, sources)
+ binfo.bdepends = map(str, depends)
+ binfo.bimplicit = map(str, implicit)
+
+ binfo.bsourcesigs = sourcesigs
+ binfo.bdependsigs = dependsigs
+ binfo.bimplicitsigs = implicitsigs
+
+ binfo.bsig = calc.module.collect(filter(None, sigs))
+
+ return binfo
+
+ def del_cinfo(self):
+ try:
+ del self.binfo.csig
+ except AttributeError:
+ pass
+
+ def calc_csig(self, calc=None):
+ try:
+ binfo = self.binfo
+ except AttributeError:
+ binfo = self.binfo = self.new_binfo()
+ try:
+ return binfo.csig
+ except AttributeError:
+ if calc is None:
+ calc = self.calculator()
+ binfo.csig = calc.module.signature(self)
+ self.store_info(binfo)
+ return binfo.csig
+
+ def store_info(self, obj):
+ """Make the build signature permanent (that is, store it in the
+ .sconsign file or equivalent)."""
+ pass
+
+ def get_stored_info(self):
+ return None
+
+ def get_stored_implicit(self):
+ """Fetch the stored implicit dependencies"""
+ return None
+
+ def set_precious(self, precious = 1):
+ """Set the Node's precious value."""
+ self.precious = precious
+
+ def set_always_build(self, always_build = 1):
+ """Set the Node's always_build value."""
+ self.always_build = always_build
+
+ def exists(self):
+ """Does this node exists?"""
+ # All node exist by default:
+ return 1
+
+ def rexists(self):
+ """Does this node exist locally or in a repositiory?"""
+ # There are no repositories by default:
+ return self.exists()
+
+ def prepare(self):
+ """Prepare for this Node to be created.
+ The default implemenation checks that all children either exist
+ or are derived.
+ """
+ def missing(node):
+ return not node.is_derived() and \
+ not node.is_pseudo_derived() and \
+ not node.linked and \
+ not node.rexists()
+ missing_sources = filter(missing, self.children())
+ if missing_sources:
+ desc = "Source `%s' not found, needed by target `%s'." % (missing_sources[0], self)
+ raise SCons.Errors.StopError, desc
+
+ def remove(self):
+ """Remove this Node: no-op by default."""
+ return None
+
+ def add_dependency(self, depend):
+ """Adds dependencies."""
+ try:
+ self._add_child(self.depends, self.depends_dict, depend)
+ except TypeError, e:
+ e = e.args[0]
+ if SCons.Util.is_List(e):
+ s = map(str, e)
+ else:
+ s = str(e)
+ raise SCons.Errors.UserError("attempted to add a non-Node dependency to %s:\n\t%s is a %s, not a Node" % (str(self), s, type(e)))
+
+ def add_ignore(self, depend):
+ """Adds dependencies to ignore."""
+ try:
+ self._add_child(self.ignore, self.ignore_dict, depend)
+ except TypeError, e:
+ e = e.args[0]
+ if SCons.Util.is_List(e):
+ s = map(str, e)
+ else:
+ s = str(e)
+ raise SCons.Errors.UserError("attempted to ignore a non-Node dependency of %s:\n\t%s is a %s, not a Node" % (str(self), s, type(e)))
+
+ def add_source(self, source):
+ """Adds sources."""
+ try:
+ self._add_child(self.sources, self.sources_dict, source)
+ except TypeError, e:
+ e = e.args[0]
+ if SCons.Util.is_List(e):
+ s = map(str, e)
+ else:
+ s = str(e)
+ raise SCons.Errors.UserError("attempted to add a non-Node as source of %s:\n\t%s is a %s, not a Node" % (str(self), s, type(e)))
+
+ def _add_child(self, collection, dict, child):
+ """Adds 'child' to 'collection', first checking 'dict' to see
+ if it's already present."""
+ if type(child) is not type([]):
+ child = [child]
+ for c in child:
+ if not isinstance(c, Node):
+ raise TypeError, c
+ added = None
+ for c in child:
+ if not dict.has_key(c):
+ collection.append(c)
+ dict[c] = 1
+ added = 1
+ if added:
+ self._children_reset()
+
+ def add_wkid(self, wkid):
+ """Add a node to the list of kids waiting to be evaluated"""
+ if self.wkids != None:
+ self.wkids.append(wkid)
+
+ def _children_reset(self):
+ try:
+ delattr(self, '_children')
+ except AttributeError:
+ pass
+
+ def filter_ignore(self, nodelist):
+ ignore = self.ignore
+ result = []
+ for node in nodelist:
+ if node not in ignore:
+ result.append(node)
+ return result
+
+ def children(self, scan=1):
+ """Return a list of the node's direct children, minus those
+ that are ignored by this node."""
+ if scan:
+ self.scan()
+ try:
+ return self._children
+ except AttributeError:
+ c = self.all_children(scan=0)
+ self._children = self.filter_ignore(c)
+ return self._children
+
+ def all_children(self, scan=1):
+ """Return a list of all the node's direct children."""
+ # The return list may contain duplicate Nodes, especially in
+ # source trees where there are a lot of repeated #includes
+ # of a tangle of .h files. Profiling shows, however, that
+ # eliminating the duplicates with a brute-force approach that
+ # preserves the order (that is, something like:
+ #
+ # u = []
+ # for n in list:
+ # if n not in u:
+ # u.append(n)"
+ #
+ # takes more cycles than just letting the underlying methods
+ # hand back cached values if a Node's information is requested
+ # multiple times. (Other methods of removing duplicates, like
+ # using dictionary keys, lose the order, and the only ordered
+ # dictionary patterns I found all ended up using "not in"
+ # internally anyway...)
+ if scan:
+ self.scan()
+ if self.implicit is None:
+ return self.sources + self.depends
+ else:
+ return self.sources + self.depends + self.implicit
+
+ def set_state(self, state):
+ self.state = state
+
+ def get_state(self):
+ return self.state
+
+ def current(self, calc=None):
+ """Default check for whether the Node is current: unknown Node
+ subtypes are always out of date, so they will always get built."""
+ return None
+
+ def children_are_up_to_date(self, calc=None):
+ """Alternate check for whether the Node is current: If all of
+ our children were up-to-date, then this Node was up-to-date, too.
+
+ The SCons.Node.Alias and SCons.Node.Python.Value subclasses
+ rebind their current() method to this method."""
+ # Allow the children to calculate their signatures.
+ self.binfo = self.gen_binfo(calc)
+ state = 0
+ for kid in self.children(None):
+ s = kid.get_state()
+ if s and (not state or s > state):
+ state = s
+ return (state == 0 or state == SCons.Node.up_to_date)
+
+ def is_literal(self):
+ """Always pass the string representation of a Node to
+ the command interpreter literally."""
+ return 1
+
+ def add_pre_action(self, act):
+ """Adds an Action performed on this Node only before
+ building it."""
+ self.pre_actions.append(act)
+
+ def add_post_action(self, act):
+ """Adds and Action performed on this Node only after
+ building it."""
+ self.post_actions.append(act)
+
+ def render_include_tree(self):
+ """
+ Return a text representation, suitable for displaying to the
+ user, of the include tree for the sources of this node.
+ """
+ if self.is_derived() and self.env:
+ env = self.get_build_env()
+ for s in self.sources:
+ scanner = s.get_source_scanner(self)
+ def f(node, env=env, scanner=scanner, target=self):
+ return node.get_found_includes(env, scanner, target)
+ return SCons.Util.render_tree(s, f, 1)
+ else:
+ return None
+
+ def get_abspath(self):
+ """
+ Return an absolute path to the Node. This will return simply
+ str(Node) by default, but for Node types that have a concept of
+ relative path, this might return something different.
+ """
+ return str(self)
+
+ def for_signature(self):
+ """
+ Return a string representation of the Node that will always
+ be the same for this particular Node, no matter what. This
+ is by contrast to the __str__() method, which might, for
+ instance, return a relative path for a file Node. The purpose
+ of this method is to generate a value to be used in signature
+ calculation for the command line used to build a target, and
+ we use this method instead of str() to avoid unnecessary
+ rebuilds. This method does not need to return something that
+ would actually work in a command line; it can return any kind of
+ nonsense, so long as it does not change.
+ """
+ return str(self)
+
+ def get_string(self, for_signature):
+ """This is a convenience function designed primarily to be
+ used in command generators (i.e., CommandGeneratorActions or
+ Environment variables that are callable), which are called
+ with a for_signature argument that is nonzero if the command
+ generator is being called to generate a signature for the
+ command line, which determines if we should rebuild or not.
+
+ Such command generators shoud use this method in preference
+ to str(Node) when converting a Node to a string, passing
+ in the for_signature parameter, such that we will call
+ Node.for_signature() or str(Node) properly, depending on whether
+ we are calculating a signature or actually constructing a
+ command line."""
+ if for_signature:
+ return self.for_signature()
+ return str(self)
+
+ def get_subst_proxy(self):
+ """
+ This method is expected to return an object that will function
+ exactly like this Node, except that it implements any additional
+ special features that we would like to be in effect for
+ Environment variable substitution. The principle use is that
+ some Nodes would like to implement a __getattr__() method,
+ but putting that in the Node type itself has a tendency to kill
+ performance. We instead put it in a proxy and return it from
+ this method. It is legal for this method to return self
+ if no new functionality is needed for Environment substitution.
+ """
+ return self
+
+ def explain(self):
+ if not self.exists():
+ return "building `%s' because it doesn't exist\n" % self
+
+ old = self.get_stored_info()
+ if old is None:
+ return None
+
+ def dictify(result, kids, sigs):
+ for k, s in zip(kids, sigs):
+ result[k] = s
+
+ try:
+ old_bkids = old.bsources + old.bdepends + old.bimplicit
+ except AttributeError:
+ return "Cannot explain why `%s' is being rebuilt: No previous build information found\n" % self
+
+ osig = {}
+ dictify(osig, old.bsources, old.bsourcesigs)
+ dictify(osig, old.bdepends, old.bdependsigs)
+ dictify(osig, old.bimplicit, old.bimplicitsigs)
+
+ new_bsources = map(str, self.binfo.bsources)
+ new_bdepends = map(str, self.binfo.bdepends)
+ new_bimplicit = map(str, self.binfo.bimplicit)
+
+ nsig = {}
+ dictify(nsig, new_bsources, self.binfo.bsourcesigs)
+ dictify(nsig, new_bdepends, self.binfo.bdependsigs)
+ dictify(nsig, new_bimplicit, self.binfo.bimplicitsigs)
+
+ new_bkids = new_bsources + new_bdepends + new_bimplicit
+ lines = map(lambda x: "`%s' is no longer a dependency\n" % x,
+ filter(lambda x, nk=new_bkids: not x in nk, old_bkids))
+
+ for k in new_bkids:
+ if not k in old_bkids:
+ lines.append("`%s' is a new dependency\n" % k)
+ elif osig[k] != nsig[k]:
+ lines.append("`%s' changed\n" % k)
+
+ if len(lines) == 0 and old_bkids != new_bkids:
+ lines.append("the dependency order changed:\n" +
+ "%sold: %s\n" % (' '*15, old_bkids) +
+ "%snew: %s\n" % (' '*15, new_bkids))
+
+ if len(lines) == 0:
+ newact, newactsig = self.binfo.bact, self.binfo.bactsig
+ if old.bact != newact:
+ lines.append("the build action changed:\n" +
+ "%sold: %s\n" % (' '*15, old.bact) +
+ "%snew: %s\n" % (' '*15, newact))
+
+ if len(lines) == 0:
+ return "rebuilding `%s' for unknown reasons" % self
+
+ preamble = "rebuilding `%s' because" % self
+ if len(lines) == 1:
+ return "%s %s" % (preamble, lines[0])
+ else:
+ lines = ["%s:\n" % preamble] + lines
+ return string.join(lines, ' '*11)
+
+def get_children(node, parent): return node.children()
+def ignore_cycle(node, stack): pass
+def do_nothing(node, parent): pass
+
+class Walker:
+ """An iterator for walking a Node tree.
+
+ This is depth-first, children are visited before the parent.
+ The Walker object can be initialized with any node, and
+ returns the next node on the descent with each next() call.
+ 'kids_func' is an optional function that will be called to
+ get the children of a node instead of calling 'children'.
+ 'cycle_func' is an optional function that will be called
+ when a cycle is detected.
+
+ This class does not get caught in node cycles caused, for example,
+ by C header file include loops.
+ """
+ def __init__(self, node, kids_func=get_children,
+ cycle_func=ignore_cycle,
+ eval_func=do_nothing):
+ self.kids_func = kids_func
+ self.cycle_func = cycle_func
+ self.eval_func = eval_func
+ node.wkids = copy.copy(kids_func(node, None))
+ self.stack = [node]
+ self.history = {} # used to efficiently detect and avoid cycles
+ self.history[node] = None
+
+ def next(self):
+ """Return the next node for this walk of the tree.
+
+ This function is intentionally iterative, not recursive,
+ to sidestep any issues of stack size limitations.
+ """
+
+ while self.stack:
+ if self.stack[-1].wkids:
+ node = self.stack[-1].wkids.pop(0)
+ if not self.stack[-1].wkids:
+ self.stack[-1].wkids = None
+ if self.history.has_key(node):
+ self.cycle_func(node, self.stack)
+ else:
+ node.wkids = copy.copy(self.kids_func(node, self.stack[-1]))
+ self.stack.append(node)
+ self.history[node] = None
+ else:
+ node = self.stack.pop()
+ del self.history[node]
+ if node:
+ if self.stack:
+ parent = self.stack[-1]
+ else:
+ parent = None
+ self.eval_func(node, parent)
+ return node
+ return None
+
+ def is_done(self):
+ return not self.stack
+
+
+arg2nodes_lookups = []
Added: development/support/scons/scons-local-0.96.1/SCons/Optik/__init__.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Optik/__init__.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Optik/__init__.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,32 @@
+"""optik
+
+A powerful, extensible, and easy-to-use command-line parser for Python.
+
+By Greg Ward <gward at python.net>
+
+See http://optik.sourceforge.net/
+"""
+
+# Copyright (c) 2001 Gregory P. Ward. All rights reserved.
+# See the README.txt distributed with Optik for licensing terms.
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Optik/__init__.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+# Original Optik revision this is based on:
+__Optik_revision__ = "__init__.py,v 1.11 2002/04/11 19:17:34 gward Exp"
+
+__version__ = "1.3"
+
+
+# Re-import these for convenience
+from SCons.Optik.option import Option
+from SCons.Optik.option_parser import \
+ OptionParser, SUPPRESS_HELP, SUPPRESS_USAGE
+from SCons.Optik.errors import OptionValueError
+
+
+# Some day, there might be many Option classes. As of Optik 1.3, the
+# preferred way to instantiate Options is indirectly, via make_option(),
+# which will become a factory function when there are many Option
+# classes.
+make_option = Option
Added: development/support/scons/scons-local-0.96.1/SCons/Optik/errors.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Optik/errors.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Optik/errors.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,55 @@
+"""optik.errors
+
+Exception classes used by Optik.
+"""
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Optik/errors.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+# Original Optik revision this is based on:
+__Optik_revision__ = "errors.py,v 1.5 2002/02/13 23:29:47 gward Exp"
+
+# Copyright (c) 2001 Gregory P. Ward. All rights reserved.
+# See the README.txt distributed with Optik for licensing terms.
+
+# created 2001/10/17 GPW (from optik.py)
+
+
+class OptikError (Exception):
+ def __init__ (self, msg):
+ self.msg = msg
+
+ def __str__ (self):
+ return self.msg
+
+
+class OptionError (OptikError):
+ """
+ Raised if an Option instance is created with invalid or
+ inconsistent arguments.
+ """
+
+ def __init__ (self, msg, option):
+ self.msg = msg
+ self.option_id = str(option)
+
+ def __str__ (self):
+ if self.option_id:
+ return "option %s: %s" % (self.option_id, self.msg)
+ else:
+ return self.msg
+
+class OptionConflictError (OptionError):
+ """
+ Raised if conflicting options are added to an OptionParser.
+ """
+
+class OptionValueError (OptikError):
+ """
+ Raised if an invalid option value is encountered on the command
+ line.
+ """
+
+class BadOptionError (OptikError):
+ """
+ Raised if an invalid or ambiguous option is seen on the command-line.
+ """
Added: development/support/scons/scons-local-0.96.1/SCons/Optik/option.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Optik/option.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Optik/option.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,388 @@
+"""optik.option
+
+Defines the Option class and some standard value-checking functions.
+"""
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Optik/option.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+# Original Optik revision this is based on:
+__Optik_revision__ = "option.py,v 1.19.2.1 2002/07/23 01:51:14 gward Exp"
+
+# Copyright (c) 2001 Gregory P. Ward. All rights reserved.
+# See the README.txt distributed with Optik for licensing terms.
+
+# created 2001/10/17, GPW (from optik.py)
+
+import sys
+import string
+from types import TupleType, ListType, DictType
+from SCons.Optik.errors import OptionError, OptionValueError
+
+_builtin_cvt = { "int" : (int, "integer"),
+ "long" : (long, "long integer"),
+ "float" : (float, "floating-point"),
+ "complex" : (complex, "complex") }
+
+def check_builtin (option, opt, value):
+ (cvt, what) = _builtin_cvt[option.type]
+ try:
+ return cvt(value)
+ except ValueError:
+ raise OptionValueError(
+ #"%s: invalid %s argument %s" % (opt, what, repr(value)))
+ "option %s: invalid %s value: %s" % (opt, what, repr(value)))
+
+def check_choice(option, opt, value):
+ if value in option.choices:
+ return value
+ else:
+ choices = string.join(map(repr, option.choices),", ")
+ raise OptionValueError(
+ "option %s: invalid choice: %s (choose from %s)"
+ % (opt, repr(value), choices))
+
+# Not supplying a default is different from a default of None,
+# so we need an explicit "not supplied" value.
+NO_DEFAULT = "NO"+"DEFAULT"
+
+
+class Option:
+ """
+ Instance attributes:
+ _short_opts : [string]
+ _long_opts : [string]
+
+ action : string
+ type : string
+ dest : string
+ default : any
+ nargs : int
+ const : any
+ choices : [string]
+ callback : function
+ callback_args : (any*)
+ callback_kwargs : { string : any }
+ help : string
+ metavar : string
+ """
+
+ # The list of instance attributes that may be set through
+ # keyword args to the constructor.
+ ATTRS = ['action',
+ 'type',
+ 'dest',
+ 'default',
+ 'nargs',
+ 'const',
+ 'choices',
+ 'callback',
+ 'callback_args',
+ 'callback_kwargs',
+ 'help',
+ 'metavar']
+
+ # The set of actions allowed by option parsers. Explicitly listed
+ # here so the constructor can validate its arguments.
+ ACTIONS = ("store",
+ "store_const",
+ "store_true",
+ "store_false",
+ "append",
+ "count",
+ "callback",
+ "help",
+ "version")
+
+ # The set of actions that involve storing a value somewhere;
+ # also listed just for constructor argument validation. (If
+ # the action is one of these, there must be a destination.)
+ STORE_ACTIONS = ("store",
+ "store_const",
+ "store_true",
+ "store_false",
+ "append",
+ "count")
+
+ # The set of actions for which it makes sense to supply a value
+ # type, ie. where we expect an argument to this option.
+ TYPED_ACTIONS = ("store",
+ "append",
+ "callback")
+
+ # The set of known types for option parsers. Again, listed here for
+ # constructor argument validation.
+ TYPES = ("string", "int", "long", "float", "complex", "choice")
+
+ # Dictionary of argument checking functions, which convert and
+ # validate option arguments according to the option type.
+ #
+ # Signature of checking functions is:
+ # check(option : Option, opt : string, value : string) -> any
+ # where
+ # option is the Option instance calling the checker
+ # opt is the actual option seen on the command-line
+ # (eg. "-a", "--file")
+ # value is the option argument seen on the command-line
+ #
+ # The return value should be in the appropriate Python type
+ # for option.type -- eg. an integer if option.type == "int".
+ #
+ # If no checker is defined for a type, arguments will be
+ # unchecked and remain strings.
+ TYPE_CHECKER = { "int" : check_builtin,
+ "long" : check_builtin,
+ "float" : check_builtin,
+ "complex" : check_builtin,
+ "choice" : check_choice,
+ }
+
+
+ # CHECK_METHODS is a list of unbound method objects; they are called
+ # by the constructor, in order, after all attributes are
+ # initialized. The list is created and filled in later, after all
+ # the methods are actually defined. (I just put it here because I
+ # like to define and document all class attributes in the same
+ # place.) Subclasses that add another _check_*() method should
+ # define their own CHECK_METHODS list that adds their check method
+ # to those from this class.
+ CHECK_METHODS = None
+
+
+ # -- Constructor/initialization methods ----------------------------
+
+ def __init__ (self, *opts, **attrs):
+ # Set _short_opts, _long_opts attrs from 'opts' tuple
+ opts = self._check_opt_strings(opts)
+ self._set_opt_strings(opts)
+
+ # Set all other attrs (action, type, etc.) from 'attrs' dict
+ self._set_attrs(attrs)
+
+ # Check all the attributes we just set. There are lots of
+ # complicated interdependencies, but luckily they can be farmed
+ # out to the _check_*() methods listed in CHECK_METHODS -- which
+ # could be handy for subclasses! The one thing these all share
+ # is that they raise OptionError if they discover a problem.
+ for checker in self.CHECK_METHODS:
+ checker(self)
+
+ def _check_opt_strings (self, opts):
+ # Filter out None because early versions of Optik had exactly
+ # one short option and one long option, either of which
+ # could be None.
+ opts = filter(None, opts)
+ if not opts:
+ raise OptionError("at least one option string must be supplied",
+ self)
+ return opts
+
+ def _set_opt_strings (self, opts):
+ self._short_opts = []
+ self._long_opts = []
+ for opt in opts:
+ if len(opt) < 2:
+ raise OptionError(
+ "invalid option string %s: "
+ "must be at least two characters long" % (`opt`,), self)
+ elif len(opt) == 2:
+ if not (opt[0] == "-" and opt[1] != "-"):
+ raise OptionError(
+ "invalid short option string %s: "
+ "must be of the form -x, (x any non-dash char)" % (`opt`,),
+ self)
+ self._short_opts.append(opt)
+ else:
+ if not (opt[0:2] == "--" and opt[2] != "-"):
+ raise OptionError(
+ "invalid long option string %s: "
+ "must start with --, followed by non-dash" % (`opt`,),
+ self)
+ self._long_opts.append(opt)
+
+ def _set_attrs (self, attrs):
+ for attr in self.ATTRS:
+ if attrs.has_key(attr):
+ setattr(self, attr, attrs[attr])
+ del attrs[attr]
+ else:
+ if attr == 'default':
+ setattr(self, attr, NO_DEFAULT)
+ else:
+ setattr(self, attr, None)
+ if attrs:
+ raise OptionError(
+ "invalid keyword arguments: %s" % string.join(attrs.keys(),", "),
+ self)
+
+
+ # -- Constructor validation methods --------------------------------
+
+ def _check_action (self):
+ if self.action is None:
+ self.action = "store"
+ elif self.action not in self.ACTIONS:
+ raise OptionError("invalid action: %s" % (`self.action`,), self)
+
+ def _check_type (self):
+ if self.type is None:
+ # XXX should factor out another class attr here: list of
+ # actions that *require* a type
+ if self.action in ("store", "append"):
+ if self.choices is not None:
+ # The "choices" attribute implies "choice" type.
+ self.type = "choice"
+ else:
+ # No type given? "string" is the most sensible default.
+ self.type = "string"
+ else:
+ if self.type not in self.TYPES:
+ raise OptionError("invalid option type: %s" % (`self.type`,), self)
+ if self.action not in self.TYPED_ACTIONS:
+ raise OptionError(
+ "must not supply a type for action %s" % (`self.action`,), self)
+
+ def _check_choice(self):
+ if self.type == "choice":
+ if self.choices is None:
+ raise OptionError(
+ "must supply a list of choices for type 'choice'", self)
+ elif type(self.choices) not in (TupleType, ListType):
+ raise OptionError(
+ "choices must be a list of strings ('%s' supplied)"
+ % string.split(str(type(self.choices)),"'")[1], self)
+ elif self.choices is not None:
+ raise OptionError(
+ "must not supply choices for type %s" % (repr(self.type),), self)
+
+ def _check_dest (self):
+ if self.action in self.STORE_ACTIONS and self.dest is None:
+ # No destination given, and we need one for this action.
+ # Glean a destination from the first long option string,
+ # or from the first short option string if no long options.
+ if self._long_opts:
+ # eg. "--foo-bar" -> "foo_bar"
+ self.dest = string.replace(self._long_opts[0][2:],'-', '_')
+ else:
+ self.dest = self._short_opts[0][1]
+
+ def _check_const (self):
+ if self.action != "store_const" and self.const is not None:
+ raise OptionError(
+ "'const' must not be supplied for action %s" % (repr(self.action),),
+ self)
+
+ def _check_nargs (self):
+ if self.action in self.TYPED_ACTIONS:
+ if self.nargs is None:
+ self.nargs = 1
+ elif self.nargs is not None:
+ raise OptionError(
+ "'nargs' must not be supplied for action %s" % (repr(self.action),),
+ self)
+
+ def _check_callback (self):
+ if self.action == "callback":
+ if not callable(self.callback):
+ raise OptionError(
+ "callback not callable: %s" % (repr(self.callback),), self)
+ if (self.callback_args is not None and
+ type(self.callback_args) is not TupleType):
+ raise OptionError(
+ "callback_args, if supplied, must be a tuple: not %s"
+ % (repr(self.callback_args),), self)
+ if (self.callback_kwargs is not None and
+ type(self.callback_kwargs) is not DictType):
+ raise OptionError(
+ "callback_kwargs, if supplied, must be a dict: not %s"
+ % (repr(self.callback_kwargs),), self)
+ else:
+ if self.callback is not None:
+ raise OptionError(
+ "callback supplied (%s) for non-callback option"
+ % (repr(self.callback),), self)
+ if self.callback_args is not None:
+ raise OptionError(
+ "callback_args supplied for non-callback option", self)
+ if self.callback_kwargs is not None:
+ raise OptionError(
+ "callback_kwargs supplied for non-callback option", self)
+
+
+ CHECK_METHODS = [_check_action,
+ _check_type,
+ _check_choice,
+ _check_dest,
+ _check_const,
+ _check_nargs,
+ _check_callback]
+
+
+ # -- Miscellaneous methods -----------------------------------------
+
+ def __str__ (self):
+ if self._short_opts or self._long_opts:
+ return string.join(self._short_opts + self._long_opts,"/")
+ else:
+ raise RuntimeError, "short_opts and long_opts both empty!"
+
+ def takes_value (self):
+ return self.type is not None
+
+
+ # -- Processing methods --------------------------------------------
+
+ def check_value (self, opt, value):
+ checker = self.TYPE_CHECKER.get(self.type)
+ if checker is None:
+ return value
+ else:
+ return checker(self, opt, value)
+
+ def process (self, opt, value, values, parser):
+
+ # First, convert the value(s) to the right type. Howl if any
+ # value(s) are bogus.
+ if value is not None:
+ if self.nargs == 1:
+ value = self.check_value(opt, value)
+ else:
+ def cv(v,check=self.check_value,o=opt):
+ return check(o,v)
+
+ value = tuple(map(cv,value))
+
+ # And then take whatever action is expected of us.
+ # This is a separate method to make life easier for
+ # subclasses to add new actions.
+ return self.take_action(
+ self.action, self.dest, opt, value, values, parser)
+
+ def take_action (self, action, dest, opt, value, values, parser):
+ if action == "store":
+ setattr(values, dest, value)
+ elif action == "store_const":
+ setattr(values, dest, self.const)
+ elif action == "store_true":
+ setattr(values, dest, 1)
+ elif action == "store_false":
+ setattr(values, dest, 0)
+ elif action == "append":
+ values.ensure_value(dest, []).append(value)
+ elif action == "count":
+ setattr(values, dest, values.ensure_value(dest, 0) + 1)
+ elif action == "callback":
+ args = self.callback_args or ()
+ kwargs = self.callback_kwargs or {}
+ apply( self.callback, (self, opt, value, parser,)+ args, kwargs)
+ elif action == "help":
+ parser.print_help()
+ sys.exit(0)
+ elif action == "version":
+ parser.print_version()
+ sys.exit(0)
+ else:
+ raise RuntimeError, "unknown action %s" % (repr(self.action),)
+
+ return 1
+
+# class Option
Added: development/support/scons/scons-local-0.96.1/SCons/Optik/option_parser.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Optik/option_parser.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Optik/option_parser.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,730 @@
+"""optik.option_parser
+
+Provides the OptionParser and Values classes.
+"""
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Optik/option_parser.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+# Original Optik revision this is based on:
+__Optik_revision__ = "option_parser.py,v 1.38.2.1 2002/07/23 01:51:14 gward Exp"
+
+# Copyright (c) 2001 Gregory P. Ward. All rights reserved.
+# See the README.txt distributed with Optik for licensing terms.
+
+# created 2001/10/17, GPW (from optik.py)
+
+import sys, os
+import string
+import types
+from SCons.Optik.option import Option, NO_DEFAULT
+from SCons.Optik.errors import OptionConflictError, OptionValueError, BadOptionError
+
+def get_prog_name ():
+ return os.path.basename(sys.argv[0])
+
+
+SUPPRESS_HELP = "SUPPRESS"+"HELP"
+SUPPRESS_USAGE = "SUPPRESS"+"USAGE"
+
+class Values:
+
+ def __init__ (self, defaults=None):
+ if defaults:
+ for (attr, val) in defaults.items():
+ setattr(self, attr, val)
+
+
+ def _update_careful (self, dict):
+ """
+ Update the option values from an arbitrary dictionary, but only
+ use keys from dict that already have a corresponding attribute
+ in self. Any keys in dict without a corresponding attribute
+ are silently ignored.
+ """
+ for attr in dir(self):
+ if dict.has_key(attr):
+ dval = dict[attr]
+ if dval is not None:
+ setattr(self, attr, dval)
+
+ def _update_loose (self, dict):
+ """
+ Update the option values from an arbitrary dictionary,
+ using all keys from the dictionary regardless of whether
+ they have a corresponding attribute in self or not.
+ """
+ self.__dict__.update(dict)
+
+ def _update (self, dict, mode):
+ if mode == "careful":
+ self._update_careful(dict)
+ elif mode == "loose":
+ self._update_loose(dict)
+ else:
+ raise ValueError, "invalid update mode: %s" % (repr(mode),)
+
+ def read_module (self, modname, mode="careful"):
+ __import__(modname)
+ mod = sys.modules[modname]
+ self._update(vars(mod), mode)
+
+ def read_file (self, filename, mode="careful"):
+ vars = {}
+ execfile(filename, vars)
+ self._update(vars, mode)
+
+ def ensure_value (self, attr, value):
+ if not hasattr(self, attr) or getattr(self, attr) is None:
+ setattr(self, attr, value)
+ return getattr(self, attr)
+
+
+class OptionParser:
+ """
+ Class attributes:
+ standard_option_list : [Option]
+ list of standard options that will be accepted by all instances
+ of this parser class (intended to be overridden by subclasses).
+
+ Instance attributes:
+ usage : string
+ a usage string for your program. Before it is displayed
+ to the user, "%prog" will be expanded to the name of
+ your program (os.path.basename(sys.argv[0])).
+ option_list : [Option]
+ the list of all options accepted on the command-line of
+ this program
+ _short_opt : { string : Option }
+ dictionary mapping short option strings, eg. "-f" or "-X",
+ to the Option instances that implement them. If an Option
+ has multiple short option strings, it will appears in this
+ dictionary multiple times.
+ _long_opt : { string : Option }
+ dictionary mapping long option strings, eg. "--file" or
+ "--exclude", to the Option instances that implement them.
+ Again, a given Option can occur multiple times in this
+ dictionary.
+ defaults : { string : any }
+ dictionary mapping option destination names to default
+ values for each destination.
+
+ allow_interspersed_args : boolean = true
+ if true, positional arguments may be interspersed with options.
+ Assuming -a and -b each take a single argument, the command-line
+ -ablah foo bar -bboo baz
+ will be interpreted the same as
+ -ablah -bboo -- foo bar baz
+ If this flag were false, that command line would be interpreted as
+ -ablah -- foo bar -bboo baz
+ -- ie. we stop processing options as soon as we see the first
+ non-option argument. (This is the tradition followed by
+ Python's getopt module, Perl's Getopt::Std, and other argument-
+ parsing libraries, but it is generally annoying to users.)
+
+ rargs : [string]
+ the argument list currently being parsed. Only set when
+ parse_args() is active, and continually trimmed down as
+ we consume arguments. Mainly there for the benefit of
+ callback options.
+ largs : [string]
+ the list of leftover arguments that we have skipped while
+ parsing options. If allow_interspersed_args is false, this
+ list is always empty.
+ values : Values
+ the set of option values currently being accumulated. Only
+ set when parse_args() is active. Also mainly for callbacks.
+
+ Because of the 'rargs', 'largs', and 'values' attributes,
+ OptionParser is not thread-safe. If, for some perverse reason, you
+ need to parse command-line arguments simultaneously in different
+ threads, use different OptionParser instances.
+
+ """
+
+ standard_option_list = []
+
+
+ def __init__ (self,
+ usage=None,
+ option_list=None,
+ option_class=Option,
+ version=None,
+ conflict_handler="error"):
+ self.set_usage(usage)
+ self.option_class = option_class
+ self.version = version
+ self.set_conflict_handler(conflict_handler)
+ self.allow_interspersed_args = 1
+
+ # Create the various lists and dicts that constitute the
+ # "option list". See class docstring for details about
+ # each attribute.
+ self._create_option_list()
+
+ # Populate the option list; initial sources are the
+ # standard_option_list class attribute, the 'option_list'
+ # argument, and the STD_VERSION_OPTION global (if 'version'
+ # supplied).
+ self._populate_option_list(option_list)
+
+ self._init_parsing_state()
+
+ # -- Private methods -----------------------------------------------
+ # (used by the constructor)
+
+ def _create_option_list (self):
+ self.option_list = []
+ self._short_opt = {} # single letter -> Option instance
+ self._long_opt = {} # long option -> Option instance
+ self.defaults = {} # maps option dest -> default value
+
+ def _populate_option_list (self, option_list):
+ if self.standard_option_list:
+ self.add_options(self.standard_option_list)
+ if option_list:
+ self.add_options(option_list)
+
+ def _init_parsing_state (self):
+ # These are set in parse_args() for the convenience of callbacks.
+ self.rargs = None
+ self.largs = None
+ self.values = None
+
+
+ # -- Simple modifier methods ---------------------------------------
+
+ def set_usage (self, usage):
+ if usage is None:
+ self.usage = "usage: %prog [options]"
+ elif usage is SUPPRESS_USAGE:
+ self.usage = None
+ else:
+ self.usage = usage
+
+ def enable_interspersed_args (self):
+ self.allow_interspersed_args = 1
+
+ def disable_interspersed_args (self):
+ self.allow_interspersed_args = 0
+
+ def set_conflict_handler (self, handler):
+ if handler not in ("ignore", "error", "resolve"):
+ raise ValueError, "invalid conflict_resolution value %s" % (repr(handler),)
+ self.conflict_handler = handler
+
+ def set_default (self, dest, value):
+ self.defaults[dest] = value
+
+ def set_defaults (self, **kwargs):
+ self.defaults.update(kwargs)
+
+ def get_default_values(self):
+ return Values(self.defaults)
+
+
+ # -- Option-adding methods -----------------------------------------
+
+ def _check_conflict (self, option):
+ conflict_opts = []
+ for opt in option._short_opts:
+ if self._short_opt.has_key(opt):
+ conflict_opts.append((opt, self._short_opt[opt]))
+ for opt in option._long_opts:
+ if self._long_opt.has_key(opt):
+ conflict_opts.append((opt, self._long_opt[opt]))
+
+ if conflict_opts:
+ handler = self.conflict_handler
+ if handler == "ignore": # behaviour for Optik 1.0, 1.1
+ pass
+ elif handler == "error": # new in 1.2
+ raise OptionConflictError(
+ "conflicting option string(s): %s"
+ % string.join( map( lambda x: x[0], conflict_opts),", "),
+ option)
+ elif handler == "resolve": # new in 1.2
+ for (opt, c_option) in conflict_opts:
+ if len(opt)>2 and opt[:2]=="--":
+ c_option._long_opts.remove(opt)
+ del self._long_opt[opt]
+ else:
+ c_option._short_opts.remove(opt)
+ del self._short_opt[opt]
+ if not (c_option._short_opts or c_option._long_opts):
+ self.option_list.remove(c_option)
+
+
+ def add_option (self, *args, **kwargs):
+ """add_option(Option)
+ add_option(opt_str, ..., kwarg=val, ...)
+ """
+ if type(args[0]) is types.StringType:
+ option = apply(self.option_class,args, kwargs)
+ elif len(args) == 1 and not kwargs:
+ option = args[0]
+ if not isinstance(option, Option):
+ raise TypeError, "not an Option instance: %s" % (repr(option),)
+ else:
+ raise TypeError, "invalid arguments"
+
+ self._check_conflict(option)
+
+ self.option_list.append(option)
+ for opt in option._short_opts:
+ self._short_opt[opt] = option
+ for opt in option._long_opts:
+ self._long_opt[opt] = option
+
+ if option.dest is not None: # option has a dest, we need a default
+ if option.default is not NO_DEFAULT:
+ self.defaults[option.dest] = option.default
+ elif not self.defaults.has_key(option.dest):
+ self.defaults[option.dest] = None
+
+ def add_options (self, option_list):
+ for option in option_list:
+ self.add_option(option)
+
+
+ # -- Option query/removal methods ----------------------------------
+
+ def get_option (self, opt_str):
+ return (self._short_opt.get(opt_str) or
+ self._long_opt.get(opt_str))
+
+ def has_option (self, opt_str):
+ return (self._short_opt.has_key(opt_str) or
+ self._long_opt.has_key(opt_str))
+
+
+ def remove_option (self, opt_str):
+ option = self._short_opt.get(opt_str)
+ if option is None:
+ option = self._long_opt.get(opt_str)
+ if option is None:
+ raise ValueError("no such option %s" % (repr(opt_str),))
+
+ for opt in option._short_opts:
+ del self._short_opt[opt]
+ for opt in option._long_opts:
+ del self._long_opt[opt]
+ self.option_list.remove(option)
+
+
+ # -- Option-parsing methods ----------------------------------------
+
+ def _get_args (self, args):
+ if args is None:
+ return sys.argv[1:]
+ else:
+ return args[:] # don't modify caller's list
+
+ def parse_args (self, args=None, values=None):
+ """
+ parse_args(args : [string] = sys.argv[1:],
+ values : Values = None)
+ -> (values : Values, args : [string])
+
+ Parse the command-line options found in 'args' (default:
+ sys.argv[1:]). Any errors result in a call to 'error()', which
+ by default prints the usage message to stderr and calls
+ sys.exit() with an error message. On success returns a pair
+ (values, args) where 'values' is an Values instance (with all
+ your option values) and 'args' is the list of arguments left
+ over after parsing options.
+ """
+ rargs = self._get_args(args)
+ if values is None:
+ values = self.get_default_values()
+
+ # Store the halves of the argument list as attributes for the
+ # convenience of callbacks:
+ # rargs
+ # the rest of the command-line (the "r" stands for
+ # "remaining" or "right-hand")
+ # largs
+ # the leftover arguments -- ie. what's left after removing
+ # options and their arguments (the "l" stands for "leftover"
+ # or "left-hand")
+ self.rargs = rargs
+ self.largs = largs = []
+ self.values = values
+
+ try:
+ stop = self._process_args(largs, rargs, values)
+ except (BadOptionError, OptionValueError), err:
+ self.error(err.msg)
+
+ args = largs + rargs
+ return self.check_values(values, args)
+
+ def check_values (self, values, args):
+ """
+ check_values(values : Values, args : [string])
+ -> (values : Values, args : [string])
+
+ Check that the supplied option values and leftover arguments are
+ valid. Returns the option values and leftover arguments
+ (possibly adjusted, possibly completely new -- whatever you
+ like). Default implementation just returns the passed-in
+ values; subclasses may override as desired.
+ """
+ return (values, args)
+
+ def _process_args (self, largs, rargs, values):
+ """_process_args(largs : [string],
+ rargs : [string],
+ values : Values)
+
+ Process command-line arguments and populate 'values', consuming
+ options and arguments from 'rargs'. If 'allow_interspersed_args' is
+ false, stop at the first non-option argument. If true, accumulate any
+ interspersed non-option arguments in 'largs'.
+ """
+ while rargs:
+ arg = rargs[0]
+ # We handle bare "--" explicitly, and bare "-" is handled by the
+ # standard arg handler since the short arg case ensures that the
+ # len of the opt string is greater than 1.
+ if arg == "--":
+ del rargs[0]
+ return
+ elif arg[0:2] == "--":
+ # process a single long option (possibly with value(s))
+ self._process_long_opt(rargs, values)
+ elif arg[:1] == "-" and len(arg) > 1:
+ # process a cluster of short options (possibly with
+ # value(s) for the last one only)
+ self._process_short_opts(rargs, values)
+ elif self.allow_interspersed_args:
+ largs.append(arg)
+ del rargs[0]
+ else:
+ return # stop now, leave this arg in rargs
+
+ # Say this is the original argument list:
+ # [arg0, arg1, ..., arg(i-1), arg(i), arg(i+1), ..., arg(N-1)]
+ # ^
+ # (we are about to process arg(i)).
+ #
+ # Then rargs is [arg(i), ..., arg(N-1)] and largs is a *subset* of
+ # [arg0, ..., arg(i-1)] (any options and their arguments will have
+ # been removed from largs).
+ #
+ # The while loop will usually consume 1 or more arguments per pass.
+ # If it consumes 1 (eg. arg is an option that takes no arguments),
+ # then after _process_arg() is done the situation is:
+ #
+ # largs = subset of [arg0, ..., arg(i)]
+ # rargs = [arg(i+1), ..., arg(N-1)]
+ #
+ # If allow_interspersed_args is false, largs will always be
+ # *empty* -- still a subset of [arg0, ..., arg(i-1)], but
+ # not a very interesting subset!
+
+ def _match_long_opt (self, opt):
+ """_match_long_opt(opt : string) -> string
+
+ Determine which long option string 'opt' matches, ie. which one
+ it is an unambiguous abbrevation for. Raises BadOptionError if
+ 'opt' doesn't unambiguously match any long option string.
+ """
+ return _match_abbrev(opt, self._long_opt)
+
+ def _process_long_opt (self, rargs, values):
+ arg = rargs.pop(0)
+
+ # Value explicitly attached to arg? Pretend it's the next
+ # argument.
+ if "=" in arg:
+ (opt, next_arg) = string.split(arg,"=", 1)
+ rargs.insert(0, next_arg)
+ had_explicit_value = 1
+ else:
+ opt = arg
+ had_explicit_value = 0
+
+ opt = self._match_long_opt(opt)
+ option = self._long_opt[opt]
+ if option.takes_value():
+ nargs = option.nargs
+ if len(rargs) < nargs:
+ if nargs == 1:
+ self.error("%s option requires a value" % opt)
+ else:
+ self.error("%s option requires %d values"
+ % (opt, nargs))
+ elif nargs == 1:
+ value = rargs.pop(0)
+ else:
+ value = tuple(rargs[0:nargs])
+ del rargs[0:nargs]
+
+ elif had_explicit_value:
+ self.error("%s option does not take a value" % opt)
+
+ else:
+ value = None
+
+ option.process(opt, value, values, self)
+
+ def _process_short_opts (self, rargs, values):
+ arg = rargs.pop(0)
+ stop = 0
+ i = 1
+ for ch in arg[1:]:
+ opt = "-" + ch
+ option = self._short_opt.get(opt)
+ i = i+1 # we have consumed a character
+
+ if not option:
+ self.error("no such option: %s" % opt)
+ if option.takes_value():
+ # Any characters left in arg? Pretend they're the
+ # next arg, and stop consuming characters of arg.
+ if i < len(arg):
+ rargs.insert(0, arg[i:])
+ stop = 1
+
+ nargs = option.nargs
+ if len(rargs) < nargs:
+ if nargs == 1:
+ self.error("%s option requires a value" % opt)
+ else:
+ self.error("%s option requires %s values"
+ % (opt, nargs))
+ elif nargs == 1:
+ value = rargs.pop(0)
+ else:
+ value = tuple(rargs[0:nargs])
+ del rargs[0:nargs]
+
+ else: # option doesn't take a value
+ value = None
+
+ option.process(opt, value, values, self)
+
+ if stop:
+ break
+
+
+ # -- Output/error methods ------------------------------------------
+
+ def error (self, msg):
+ """error(msg : string)
+
+ Print a usage message incorporating 'msg' to stderr and exit.
+ If you override this in a subclass, it should not return -- it
+ should either exit or raise an exception.
+ """
+ self.print_usage(sys.stderr)
+ sys.stderr.write("\nSCons error: %s\n" % msg)
+ sys.exit(2)
+
+ def print_usage (self, file=None):
+ """print_usage(file : file = stdout)
+
+ Print the usage message for the current program (self.usage) to
+ 'file' (default stdout). Any occurence of the string "%prog" in
+ self.usage is replaced with the name of the current program
+ (basename of sys.argv[0]). Does nothing if self.usage is empty
+ or not defined.
+ """
+ if file is None:
+ file = sys.stdout
+ if self.usage:
+ usage = string.replace(self.usage,"%prog", get_prog_name())
+ file.write(usage + "\n")
+
+ def print_version (self, file=None):
+ """print_version(file : file = stdout)
+
+ Print the version message for this program (self.version) to
+ 'file' (default stdout). As with print_usage(), any occurence
+ of "%prog" in self.version is replaced by the current program's
+ name. Does nothing if self.version is empty or undefined.
+ """
+ if file is None:
+ file = sys.stdout
+ if self.version:
+ version = string.replace(self.version,"%prog", get_prog_name())
+ file.write(version+"\n")
+
+ def print_help (self, file=None):
+ """print_help(file : file = stdout)
+
+ Print an extended help message, listing all options and any
+ help text provided with them, to 'file' (default stdout).
+ """
+ # SCons: don't import wrap_text from distutils, use the
+ # copy we've included below, so we can avoid being dependent
+ # on having the right version of distutils installed.
+ #from distutils.fancy_getopt import wrap_text
+
+ if file is None:
+ file = sys.stdout
+
+ self.print_usage(file)
+
+ # The help for each option consists of two parts:
+ # * the opt strings and metavars
+ # eg. ("-x", or "-fFILENAME, --file=FILENAME")
+ # * the user-supplied help string
+ # eg. ("turn on expert mode", "read data from FILENAME")
+ #
+ # If possible, we write both of these on the same line:
+ # -x turn on expert mode
+ #
+ # But if the opt string list is too long, we put the help
+ # string on a second line, indented to the same column it would
+ # start in if it fit on the first line.
+ # -fFILENAME, --file=FILENAME
+ # read data from FILENAME
+
+ file.write("Options:\n")
+ width = 78 # assume 80 cols for now
+
+ option_help = [] # list of (string, string) tuples
+ lengths = []
+
+ for option in self.option_list:
+ takes_value = option.takes_value()
+ if takes_value:
+ metavar = option.metavar or string.upper(option.dest)
+
+ opts = [] # list of "-a" or "--foo=FILE" strings
+ if option.help is SUPPRESS_HELP:
+ continue
+
+ if takes_value:
+ for sopt in option._short_opts:
+ opts.append(sopt + ' ' + metavar)
+ for lopt in option._long_opts:
+ opts.append(lopt + "=" + metavar)
+ else:
+ for opt in option._short_opts + option._long_opts:
+ opts.append(opt)
+
+ opts = string.join(opts,", ")
+ option_help.append((opts, option.help))
+ lengths.append(len(opts))
+
+ max_opts = min(max(lengths), 26)
+
+ for (opts, help) in option_help:
+ # how much to indent lines 2 .. N of help text
+ indent_rest = 2 + max_opts + 2
+ help_width = width - indent_rest
+
+ if len(opts) > max_opts:
+ opts = " " + opts + "\n"
+ indent_first = indent_rest
+ else: # start help on same line as opts
+ opts = " %-*s " % (max_opts, opts)
+ indent_first = 0
+
+ file.write(opts)
+
+ if help:
+ help_lines = wrap_text(help, help_width)
+ file.write( "%*s%s\n" % (indent_first, "", help_lines[0]))
+ for line in help_lines[1:]:
+ file.write(" %*s%s\n" % (indent_rest, "", line))
+ elif opts[-1] != "\n":
+ file.write("\n")
+
+# class OptionParser
+
+
+def _match_abbrev (s, wordmap):
+ """_match_abbrev(s : string, wordmap : {string : Option}) -> string
+
+ Return the string key in 'wordmap' for which 's' is an unambiguous
+ abbreviation. If 's' is found to be ambiguous or doesn't match any of
+ 'words', raise BadOptionError.
+ """
+ # Is there an exact match?
+ if wordmap.has_key(s):
+ return s
+ else:
+ # Isolate all words with s as a prefix.
+ possibilities = []
+ ls = len(s)
+ for word in wordmap.keys():
+ if len(word)>=ls and word[:ls]==s:
+ possibilities.append(word)
+ # No exact match, so there had better be just one possibility.
+ if len(possibilities) == 1:
+ return possibilities[0]
+ elif not possibilities:
+ raise BadOptionError("no such option: %s" % s)
+ else:
+ # More than one possible completion: ambiguous prefix.
+ raise BadOptionError("ambiguous option: %s (%s?)"
+ % (s, string.join(possibilities,", ")))
+
+# SCons: Include a snarfed copy of wrap_text(), so we're not dependent
+# on the right version of distutils being installed.
+import re
+
+WS_TRANS = string.maketrans(string.whitespace, ' ' * len(string.whitespace))
+
+def wrap_text (text, width):
+ """wrap_text(text : string, width : int) -> [string]
+
+ Split 'text' into multiple lines of no more than 'width' characters
+ each, and return the list of strings that results.
+ """
+
+ if text is None:
+ return []
+ if len(text) <= width:
+ return [text]
+
+ text = string.expandtabs(text)
+ text = string.translate(text, WS_TRANS)
+ chunks = re.split(r'( +|-+)', text)
+ chunks = filter(None, chunks) # ' - ' results in empty strings
+ lines = []
+
+ while chunks:
+
+ cur_line = [] # list of chunks (to-be-joined)
+ cur_len = 0 # length of current line
+
+ while chunks:
+ l = len(chunks[0])
+ if cur_len + l <= width: # can squeeze (at least) this chunk in
+ cur_line.append(chunks[0])
+ del chunks[0]
+ cur_len = cur_len + l
+ else: # this line is full
+ # drop last chunk if all space
+ if cur_line and cur_line[-1][0] == ' ':
+ del cur_line[-1]
+ break
+
+ if chunks: # any chunks left to process?
+
+ # if the current line is still empty, then we had a single
+ # chunk that's too big too fit on a line -- so we break
+ # down and break it up at the line width
+ if cur_len == 0:
+ cur_line.append(chunks[0][0:width])
+ chunks[0] = chunks[0][width:]
+
+ # all-whitespace chunks at the end of a line can be discarded
+ # (and we know from the re.split above that if a chunk has
+ # *any* whitespace, it is *all* whitespace)
+ if chunks[0][0] == ' ':
+ del chunks[0]
+
+ # and store this line in the list-of-all-lines -- as a single
+ # string, of course!
+ lines.append(string.join(cur_line, ''))
+
+ # while chunks
+
+ return lines
+
+# wrap_text ()
Added: development/support/scons/scons-local-0.96.1/SCons/Options/BoolOption.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Options/BoolOption.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Options/BoolOption.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,88 @@
+"""engine.SCons.Options.BoolOption
+
+This file defines the option type for SCons implementing true/false values.
+
+Usage example:
+
+ opts = Options()
+ opts.Add(BoolOption('embedded', 'build for an embedded system', 0))
+ ...
+ if env['embedded'] == 1:
+ ...
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Options/BoolOption.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+__all__ = ('BoolOption', 'True', 'False')
+
+import string
+
+import SCons.Errors
+
+__true_strings = ('y', 'yes', 'true', 't', '1', 'on' , 'all' )
+__false_strings = ('n', 'no', 'false', 'f', '0', 'off', 'none')
+
+# we need this since SCons should work version indepentant
+True, False = 1, 0
+
+
+def _text2bool(val):
+ """
+ Converts strings to True/False depending on the 'truth' expressed by
+ the string. If the string can't be converted, the original value
+ will be returned.
+
+ See '__true_strings' and '__false_strings' for values considered
+ 'true' or 'false respectivly.
+
+ This is usable as 'converter' for SCons' Options.
+ """
+ lval = string.lower(val)
+ if lval in __true_strings: return True
+ if lval in __false_strings: return False
+ raise ValueError("Invalid value for boolean option: %s" % val)
+
+
+def _validator(key, val, env):
+ """
+ Validates the given value to be either '0' or '1'.
+
+ This is usable as 'validator' for SCons' Options.
+ """
+ if not env[key] in (True, False):
+ raise SCons.Errors.UserError(
+ 'Invalid value for boolean option %s: %s' % (key, env[key]))
+
+
+def BoolOption(key, help, default):
+ """
+ The input parameters describe a boolen option, thus they are
+ returned with the correct converter and validator appended. The
+ 'help' text will by appended by '(yes|no) to show the valid
+ valued. The result is usable for input to opts.Add().
+ """
+ return (key, '%s (yes|no)' % help, default,
+ _validator, _text2bool)
Added: development/support/scons/scons-local-0.96.1/SCons/Options/EnumOption.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Options/EnumOption.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Options/EnumOption.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,101 @@
+"""engine.SCons.Options.EnumOption
+
+This file defines the option type for SCons allowing only specified
+input-values.
+
+Usage example:
+
+ opts = Options()
+ opts.Add(EnumOption('debug', 'debug output and symbols', 'no',
+ allowed_values=('yes', 'no', 'full'),
+ map={}, ignorecase=2))
+ ...
+ if env['debug'] == 'full':
+ ...
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Options/EnumOption.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+__all__ = ('EnumOption',)
+
+import string
+
+import SCons.Errors
+
+def _validator(key, val, env, vals):
+ if not val in vals:
+ raise SCons.Errors.UserError(
+ 'Invalid value for option %s: %s' % (key, val))
+
+
+def EnumOption(key, help, default, allowed_values, map={}, ignorecase=0):
+ """
+ The input parameters describe a option with only certain values
+ allowed. They are returned with an appropriate converter and
+ validator appended. The result is usable for input to
+ Options.Add().
+
+ 'key' and 'default' are the values to be passed on to Options.Add().
+
+ 'help' will be appended by the allowed values automatically
+
+ 'allowed_values' is a list of strings, which are allowed as values
+ for this option.
+
+ The 'map'-dictionary may be used for converting the input value
+ into canonical values (eg. for aliases).
+
+ 'ignorecase' defines the behaviour of the validator:
+
+ If ignorecase == 0, the validator/converter are case-sensitive.
+ If ignorecase == 1, the validator/converter are case-insensitive.
+ If ignorecase == 2, the validator/converter is case-insensitive and
+ the converted value will always be lower-case.
+
+ The 'validator' tests whether the value is in the list of allowed
+ values. The 'converter' converts input values according to the
+ given 'map'-dictionary (unmapped input values are returned
+ unchanged).
+ """
+ help = '%s (%s)' % (help, string.join(allowed_values, '|'))
+ # define validator
+ if ignorecase >= 1:
+ validator = lambda key, val, env, vals=allowed_values: \
+ _validator(key, string.lower(val), env, vals)
+ else:
+ validator = lambda key, val, env, vals=allowed_values: \
+ _validator(key, val, env, vals)
+ # define converter
+ if ignorecase == 2:
+ converter = lambda val, map=map: \
+ string.lower(map.get(string.lower(val), val))
+ elif ignorecase == 1:
+ converter = lambda val, map=map: \
+ map.get(string.lower(val), val)
+ else:
+ converter = lambda val, map=map: \
+ map.get(val, val)
+ return (key, help, default, validator, converter)
Added: development/support/scons/scons-local-0.96.1/SCons/Options/ListOption.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Options/ListOption.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Options/ListOption.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,131 @@
+"""engine.SCons.Options.ListOption
+
+This file defines the option type for SCons implementing 'lists'.
+
+A 'list' option may either be 'all', 'none' or a list of names
+separated by comma. After the option has been processed, the option
+value holds either the named list elements, all list elemens or no
+list elements at all.
+
+Usage example:
+
+ list_of_libs = Split('x11 gl qt ical')
+
+ opts = Options()
+ opts.Add(ListOption('shared',
+ 'libraries to build as shared libraries',
+ 'all',
+ elems = list_of_libs))
+ ...
+ for lib in list_of_libs:
+ if lib in env['shared']:
+ env.SharedObject(...)
+ else:
+ env.Object(...)
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/branch.96/baseline/src/engine/SCons/Options/ListOption.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+# Know Bug: This should behave like a Set-Type, but does not really,
+# since elements can occur twice.
+
+__all__ = ('ListOption',)
+
+import string
+import UserList
+
+
+class _ListOption(UserList.UserList):
+ def __init__(self, initlist=[], allowedElems=[]):
+ UserList.UserList.__init__(self, filter(None, initlist))
+ self.allowedElems = allowedElems[:]
+ self.allowedElems.sort()
+
+ def __cmp__(self, other):
+ raise NotImplementedError
+ def __eq__(self, other):
+ raise NotImplementedError
+ def __ge__(self, other):
+ raise NotImplementedError
+ def __gt__(self, other):
+ raise NotImplementedError
+ def __le__(self, other):
+ raise NotImplementedError
+ def __lt__(self, other):
+ raise NotImplementedError
+ def __str__(self):
+ if len(self) == 0:
+ return 'none'
+ self.data.sort()
+ if self.data == self.allowedElems:
+ return 'all'
+ else:
+ return string.join(self, ',')
+ #def __repr__(self):
+ # todo: implement this
+
+def _converter(val, allowedElems):
+ """
+ """
+ if val == 'none':
+ val = []
+ elif val == 'all':
+ val = allowedElems
+ else:
+ val = filter(None, string.split(val, ','))
+ notAllowed = []
+ for v in val:
+ if not v in allowedElems:
+ notAllowed.append(v)
+ if notAllowed:
+ raise ValueError("Invalid value(s) for option: %s" %
+ string.join(notAllowed, ','))
+ return _ListOption(val, allowedElems)
+
+
+## def _validator(key, val, env):
+## """
+## """
+## # todo: write validater for pgk list
+## return 1
+
+
+def ListOption(key, help, default, names):
+ """
+ The input parameters describe a 'package list' option, thus they
+ are returned with the correct converter and validater appended. The
+ result is usable for input to opts.Add() .
+
+ A 'package list' option may either be 'all', 'none' or a list of
+ package names (separated by space).
+ """
+ names_str = 'allowed names: %s' % string.join(names, ' ')
+ help = string.join(
+ (help, '(all|none|comma-separated list of names)', names_str),
+ '\n ')
+ return (key, help, default,
+ None, #_validator,
+ lambda val, elems=names: _converter(val, elems))
Added: development/support/scons/scons-local-0.96.1/SCons/Options/PackageOption.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Options/PackageOption.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Options/PackageOption.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,106 @@
+"""engine.SCons.Options.PackageOption
+
+This file defines the option type for SCons implementing 'package
+activation'.
+
+To be used whenever a 'package' may be enabled/disabled and the
+package path may be specified.
+
+Usage example:
+
+ Examples:
+ x11=no (disables X11 support)
+ x11=yes (will search for the package installation dir)
+ x11=/usr/local/X11 (will check this path for existance)
+
+ To replace autoconf's --with-xxx=yyy
+
+ opts = Options()
+ opts.Add(PackageOption('x11',
+ 'use X11 installed here (yes = search some places',
+ 'yes'))
+ ...
+ if env['x11'] == True:
+ dir = ... search X11 in some standard places ...
+ env['x11'] = dir
+ if env['x11']:
+ ... build with x11 ...
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Options/PackageOption.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+__all__ = ('PackageOption', 'True', 'False')
+
+import string
+
+from BoolOption import True, False
+import SCons.Errors
+
+__enable_strings = (str(True), 'yes', 'true', 'on', 'enable', 'search')
+__disable_strings = (str(False), 'no', 'false', 'off', 'disable')
+
+def _converter(val):
+ """
+ """
+ lval = string.lower(val)
+ if lval in __enable_strings: return True
+ if lval in __disable_strings: return False
+ #raise ValueError("Invalid value for boolean option: %s" % val)
+ return val
+
+
+def _validator(key, val, env, searchfunc):
+ # NB: searchfunc is currenty undocumented and unsupported
+ """
+ """
+ # todo: write validator, check for path
+ import os
+ if env[key] == False:
+ pass
+ elif env[key] == True:
+ if searchfunc:
+ env[key] = searchfunc(key, val)
+ elif not os.path.exists(val):
+ raise SCons.Errors.UserError(
+ 'Path does not exist for option %s: %s' % (key, val))
+
+
+def PackageOption(key, help, default, searchfunc=None):
+ # NB: searchfunc is currenty undocumented and unsupported
+ """
+ The input parameters describe a 'package list' option, thus they
+ are returned with the correct converter and validator appended. The
+ result is usable for input to opts.Add() .
+
+ A 'package list' option may either be 'all', 'none' or a list of
+ package names (seperated by space).
+ """
+ help = string.join(
+ (help, '( yes | no | /path/to/%s )' % key),
+ '\n ')
+ return (key, help, default,
+ lambda k, v, e, f=searchfunc: _validator(k,v,e,f),
+ _converter)
Added: development/support/scons/scons-local-0.96.1/SCons/Options/PathOption.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Options/PathOption.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Options/PathOption.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,85 @@
+"""engine.SCons.Options.PathOption
+
+This file defines an option type for SCons implementing 'package
+activation'.
+
+To be used whenever a 'package' may be enabled/disabled and the
+package path may be specified.
+
+Usage example:
+
+ Examples:
+ x11=no (disables X11 support)
+ x11=yes (will search for the package installation dir)
+ x11=/usr/local/X11 (will check this path for existance)
+
+ To replace autoconf's --with-xxx=yyy
+
+ opts = Options()
+
+ opts = Options()
+ opts.Add(PathOption('qtdir',
+ 'where the root of Qt is installed',
+ qtdir))
+ opts.Add(PathOption('qt_includes',
+ 'where the Qt includes are installed',
+ '$qtdir/includes'))
+ opts.Add(PathOption('qt_libraries',
+ 'where the Qt library is installed',
+ '$qtdir/lib'))
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Options/PathOption.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+__all__ = ('PathOption',)
+
+import os
+
+import SCons.Errors
+
+def _validator(key, val, env):
+ """
+ """
+ # todo: write validator, check for path
+ if not os.path.exists(val):
+ raise SCons.Errors.UserError(
+ 'Path does not exist for option %s: %s' % (key, val))
+
+
+def PathOption(key, help, default):
+ # NB: searchfunc is currenty undocumented and unsupported
+ """
+ The input parameters describe a 'path list' option, thus they
+ are returned with the correct converter and validator appended. The
+ result is usable for input to opts.Add() .
+
+ A 'package list' option may either be 'all', 'none' or a list of
+ package names (seperated by space).
+ """
+ return (key, '%s ( /path/to/%s )' % (help, key), default,
+ _validator, None)
+
Added: development/support/scons/scons-local-0.96.1/SCons/Options/__init__.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Options/__init__.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Options/__init__.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,240 @@
+"""engine.SCons.Options
+
+This file defines the Options class that is used to add user-friendly
+customizable variables to an SCons build.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Options/__init__.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+
+import SCons.Errors
+import SCons.Util
+import SCons.Warnings
+
+from BoolOption import BoolOption, True, False # okay
+from EnumOption import EnumOption # okay
+from ListOption import ListOption # naja
+from PackageOption import PackageOption # naja
+from PathOption import PathOption # okay
+
+
+class Options:
+ """
+ Holds all the options, updates the environment with the variables,
+ and renders the help text.
+ """
+ def __init__(self, files=None, args={}):
+ """
+ files - [optional] List of option configuration files to load
+ (backward compatibility) If a single string is passed it is
+ automatically placed in a file list
+ """
+
+ self.options = []
+ self.args = args
+ self.files = None
+ if SCons.Util.is_String(files):
+ self.files = [ files ]
+ elif files:
+ self.files = files
+
+ def _do_add(self, key, help="", default=None, validator=None, converter=None):
+ class Option:
+ pass
+
+ option = Option()
+ option.key = key
+ option.help = help
+ option.default = default
+ option.validator = validator
+ option.converter = converter
+
+ self.options.append(option)
+
+
+ def Add(self, key, help="", default=None, validator=None, converter=None, **kw):
+ """
+ Add an option.
+
+ key - the name of the variable, or a list or tuple of arguments
+ help - optional help text for the options
+ default - optional default value
+ validator - optional function that is called to validate the option's value
+ Called with (key, value, environment)
+ converter - optional function that is called to convert the option's value before
+ putting it in the environment.
+ """
+
+ if SCons.Util.is_List(key) or type(key) == type(()):
+ apply(self._do_add, key)
+ return
+
+ if not SCons.Util.is_String(key) or \
+ not SCons.Util.is_valid_construction_var(key):
+ raise SCons.Errors.UserError, "Illegal Options.Add() key `%s'" % str(key)
+
+ if kw.has_key('validater'):
+ SCons.Warnings.warn(SCons.Warnings.DeprecatedWarning,
+ "The 'validater' keyword of the Options.Add() method is deprecated\n" +\
+ "and should be changed to 'validator'.")
+ if validator is None:
+ validator = kw['validater']
+
+ self._do_add(key, help, default, validator, converter)
+
+
+ def AddOptions(self, *optlist):
+ """
+ Add a list of options.
+
+ Each list element is a tuple/list of arguments to be passed on
+ to the underlying method for adding options.
+
+ Example:
+ opt.AddOptions(
+ ('debug', '', 0),
+ ('CC', 'The C compiler'),
+ ('VALIDATE', 'An option for testing validation', 'notset',
+ validator, None),
+ )
+ """
+ for o in optlist:
+ apply(self._do_add, o)
+
+
+ def Update(self, env, args=None):
+ """
+ Update an environment with the option variables.
+
+ env - the environment to update.
+ """
+
+ values = {}
+
+ # first set the defaults:
+ for option in self.options:
+ if not option.default is None:
+ values[option.key] = option.default
+
+ # next set the value specified in the options file
+ if self.files:
+ for filename in self.files:
+ if os.path.exists(filename):
+ execfile(filename, values)
+
+ # finally set the values specified on the command line
+ if args is None:
+ args = self.args
+ values.update(args)
+
+ # put the variables in the environment:
+ # (don't copy over variables that are not declared
+ # as options)
+ for option in self.options:
+ try:
+ env[option.key] = values[option.key]
+ except KeyError:
+ pass
+
+ # Call the convert functions:
+ for option in self.options:
+ if option.converter and values.has_key(option.key):
+ value = env.subst('${%s}'%option.key)
+ try:
+ env[option.key] = option.converter(value)
+ except ValueError, x:
+ raise SCons.Errors.UserError, 'Error converting option: %s\n%s'%(option.key, x)
+
+
+ # Finally validate the values:
+ for option in self.options:
+ if option.validator:
+ option.validator(option.key, env.subst('${%s}'%option.key), env)
+
+ def Save(self, filename, env):
+ """
+ Saves all the options in the given file. This file can
+ then be used to load the options next run. This can be used
+ to create an option cache file.
+
+ filename - Name of the file to save into
+ env - the environment get the option values from
+ """
+
+ # Create the file and write out the header
+ try:
+ fh = open(filename, 'w')
+
+ try:
+ # Make an assignment in the file for each option within the environment
+ # that was assigned a value other than the default.
+ for option in self.options:
+ try:
+ value = env[option.key]
+ try:
+ eval(repr(value))
+ except KeyboardInterrupt:
+ raise
+ except:
+ # Convert stuff that has a repr() that
+ # cannot be evaluated into a string
+ value = SCons.Util.to_String(value)
+ if env.subst('${%s}' % option.key) != \
+ env.subst(SCons.Util.to_String(option.default)):
+ fh.write('%s = %s\n' % (option.key, repr(value)))
+ except KeyError:
+ pass
+ finally:
+ fh.close()
+
+ except IOError, x:
+ raise SCons.Errors.UserError, 'Error writing options to file: %s\n%s' % (filename, x)
+
+ def GenerateHelpText(self, env, sort=None):
+ """
+ Generate the help text for the options.
+
+ env - an environment that is used to get the current values
+ of the options.
+ """
+
+ help_text = ""
+
+ if sort:
+ options = self.options[:]
+ options.sort(lambda x,y,func=sort: func(x.key,y.key))
+ else:
+ options = self.options
+
+ for option in options:
+ help_text = help_text + '\n%s: %s\n default: %s\n'%(option.key, option.help, option.default)
+ if env.has_key(option.key):
+ help_text = help_text + ' actual: %s\n'%env.subst('${%s}'%option.key)
+ else:
+ help_text = help_text + ' actual: None\n'
+
+ return help_text
Added: development/support/scons/scons-local-0.96.1/SCons/Platform/__init__.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Platform/__init__.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Platform/__init__.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,126 @@
+"""SCons.Platform
+
+SCons platform selection.
+
+This looks for modules that define a callable object that can modify a
+construction environment as appropriate for a given platform.
+
+Note that we take a more simplistic view of "platform" than Python does.
+We're looking for a single string that determines a set of
+tool-independent variables with which to initialize a construction
+environment. Consequently, we'll examine both sys.platform and os.name
+(and anything else that might come in to play) in order to return some
+specification which is unique enough for our purposes.
+
+Note that because this subsysem just *selects* a callable that can
+modify a construction environment, it's possible for people to define
+their own "platform specification" in an arbitrary callable function.
+No one needs to use or tie in to this subsystem in order to roll
+their own platform definition.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Platform/__init__.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import imp
+import os
+import string
+import sys
+
+import SCons.Errors
+import SCons.Tool
+
+def platform_default():
+ """Return the platform string for our execution environment.
+
+ The returned value should map to one of the SCons/Platform/*.py
+ files. Since we're architecture independent, though, we don't
+ care about the machine architecture.
+ """
+ osname = os.name
+ if osname == 'java':
+ osname = os._osType
+ if osname == 'posix':
+ if sys.platform == 'cygwin':
+ return 'cygwin'
+ elif string.find(sys.platform, 'irix') != -1:
+ return 'irix'
+ elif string.find(sys.platform, 'sunos') != -1:
+ return 'sunos'
+ elif string.find(sys.platform, 'hp-ux') != -1:
+ return 'hpux'
+ elif string.find(sys.platform, 'aix') != -1:
+ return 'aix'
+ elif string.find(sys.platform, 'darwin') != -1:
+ return 'darwin'
+ else:
+ return 'posix'
+ elif os.name == 'os2':
+ return 'os2'
+ else:
+ return sys.platform
+
+def platform_module(name = platform_default()):
+ """Return the imported module for the platform.
+
+ This looks for a module name that matches the specified argument.
+ If the name is unspecified, we fetch the appropriate default for
+ our execution environment.
+ """
+ full_name = 'SCons.Platform.' + name
+ if not sys.modules.has_key(full_name):
+ if os.name == 'java':
+ eval(full_name)
+ else:
+ try:
+ file, path, desc = imp.find_module(name,
+ sys.modules['SCons.Platform'].__path__)
+ mod = imp.load_module(full_name, file, path, desc)
+ setattr(SCons.Platform, name, mod)
+ except ImportError:
+ raise SCons.Errors.UserError, "No platform named '%s'" % name
+ if file:
+ file.close()
+ return sys.modules[full_name]
+
+def DefaultToolList(platform, env):
+ """Select a default tool list for the specified platform.
+ """
+ return SCons.Tool.tool_list(platform, env)
+
+class PlatformSpec:
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+def Platform(name = platform_default()):
+ """Select a canned Platform specification.
+ """
+ module = platform_module(name)
+ spec = PlatformSpec(name)
+ spec.__call__ = module.generate
+ return spec
Added: development/support/scons/scons-local-0.96.1/SCons/Platform/aix.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Platform/aix.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Platform/aix.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,59 @@
+"""engine.SCons.Platform.aix
+
+Platform-specific initialization for IBM AIX systems.
+
+There normally shouldn't be any need to import this module directly. It
+will usually be imported through the generic SCons.Platform.Platform()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Platform/aix.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+import string
+
+import posix
+
+def get_xlc(env, xlc, xlc_r, packages):
+ # Use the AIX package installer tool lslpp to figure out where a
+ # given xl* compiler is installed and what version it is.
+ xlcPath = None
+ xlcVersion = None
+
+ xlc = env.get('CC', 'xlc')
+ for package in packages:
+ cmd = "lslpp -fc " + package + " 2>/dev/null | egrep '" + xlc + "([^-_a-zA-Z0-9].*)?$'"
+ line = os.popen(cmd).readline()
+ if line:
+ v, p = string.split(line, ':')[1:3]
+ xlcVersion = string.split(v)[1]
+ xlcPath = string.split(p)[0]
+ xlcPath = xlcPath[:xlcPath.rindex('/')]
+ break
+ return (xlcPath, xlc, xlc_r, xlcVersion)
+
+def generate(env):
+ posix.generate(env)
Added: development/support/scons/scons-local-0.96.1/SCons/Platform/cygwin.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Platform/cygwin.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Platform/cygwin.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,47 @@
+"""SCons.Platform.cygwin
+
+Platform-specific initialization for Cygwin systems.
+
+There normally shouldn't be any need to import this module directly. It
+will usually be imported through the generic SCons.Platform.Platform()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Platform/cygwin.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import posix
+import win32
+
+def generate(env):
+ posix.generate(env)
+
+ env['PROGPREFIX'] = ''
+ env['PROGSUFFIX'] = '.exe'
+ env['SHLIBPREFIX'] = ''
+ env['SHLIBSUFFIX'] = '.dll'
+ env['LIBPREFIXES'] = [ '$LIBPREFIX', '$SHLIBPREFIX' ]
+ env['LIBSUFFIXES'] = [ '$LIBSUFFIX', '$SHLIBSUFFIX' ]
+ env['TEMPFILE'] = win32.TempFileMunge
Added: development/support/scons/scons-local-0.96.1/SCons/Platform/darwin.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Platform/darwin.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Platform/darwin.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,40 @@
+"""engine.SCons.Platform.darwin
+
+Platform-specific initialization for Mac OS X systems.
+
+There normally shouldn't be any need to import this module directly. It
+will usually be imported through the generic SCons.Platform.Platform()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Platform/darwin.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import posix
+import os
+
+def generate(env):
+ posix.generate(env)
+ env['SHLIBSUFFIX'] = '.dylib'
Added: development/support/scons/scons-local-0.96.1/SCons/Platform/hpux.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Platform/hpux.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Platform/hpux.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,38 @@
+"""engine.SCons.Platform.hpux
+
+Platform-specific initialization for HP-UX systems.
+
+There normally shouldn't be any need to import this module directly. It
+will usually be imported through the generic SCons.Platform.Platform()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Platform/hpux.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import posix
+
+def generate(env):
+ posix.generate(env)
Added: development/support/scons/scons-local-0.96.1/SCons/Platform/irix.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Platform/irix.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Platform/irix.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,38 @@
+"""SCons.Platform.irix
+
+Platform-specific initialization for SGI IRIX systems.
+
+There normally shouldn't be any need to import this module directly. It
+will usually be imported through the generic SCons.Platform.Platform()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Platform/irix.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import posix
+
+def generate(env):
+ posix.generate(env)
Added: development/support/scons/scons-local-0.96.1/SCons/Platform/os2.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Platform/os2.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Platform/os2.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,49 @@
+"""SCons.Platform.os2
+
+Platform-specific initialization for OS/2 systems.
+
+There normally shouldn't be any need to import this module directly. It
+will usually be imported through the generic SCons.Platform.Platform()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Platform/os2.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+def generate(env):
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+ env['OBJPREFIX'] = ''
+ env['OBJSUFFIX'] = '.obj'
+ env['SHOBJPREFIX'] = '$OBJPREFIX'
+ env['SHOBJSUFFIX'] = '$OBJSUFFIX'
+ env['PROGPREFIX'] = ''
+ env['PROGSUFFIX'] = '.exe'
+ env['LIBPREFIX'] = ''
+ env['LIBSUFFIX'] = '.lib'
+ env['SHLIBPREFIX'] = ''
+ env['SHLIBSUFFIX'] = '.dll'
+ env['LIBPREFIXES'] = '$LIBPREFIX'
+ env['LIBSUFFIXES'] = [ '$LIBSUFFIX', '$SHLIBSUFFIX' ]
Added: development/support/scons/scons-local-0.96.1/SCons/Platform/posix.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Platform/posix.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Platform/posix.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,234 @@
+"""SCons.Platform.posix
+
+Platform-specific initialization for POSIX (Linux, UNIX, etc.) systems.
+
+There normally shouldn't be any need to import this module directly. It
+will usually be imported through the generic SCons.Platform.Platform()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Platform/posix.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+import os.path
+import popen2
+import string
+import sys
+import select
+
+import SCons.Util
+
+exitvalmap = {
+ 2 : 127,
+ 13 : 126,
+}
+
+def escape(arg):
+ "escape shell special characters"
+ slash = '\\'
+ special = '"$'
+
+ arg = string.replace(arg, slash, slash+slash)
+ for c in special:
+ arg = string.replace(arg, c, slash+c)
+
+ return '"' + arg + '"'
+
+def _get_env_command(sh, escape, cmd, args, env):
+ if env:
+ s = 'env - '
+ for key in env.keys():
+ s = s + '%s=%s '%(key, escape(env[key]))
+ s = s + sh + ' -c '
+ s = s + escape(string.join(args))
+ else:
+ s = string.join(args)
+ return s
+
+def env_spawn(sh, escape, cmd, args, env):
+ s = _get_env_command( sh, escape, cmd, args, env)
+ stat = os.system(s)
+ if stat & 0xff:
+ return stat | 0x80
+ return stat >> 8
+
+def spawn_spawn(sh, escape, cmd, args, env):
+ args = [sh, '-c', string.join(args)]
+ stat = os.spawnvpe(os.P_WAIT, sh, args, env)
+ # os.spawnvpe() returns the actual exit code, not the encoding
+ # returned by os.waitpid() or os.system().
+ return stat
+
+def fork_spawn(sh, escape, cmd, args, env):
+ pid = os.fork()
+ if not pid:
+ # Child process.
+ exitval = 127
+ args = [sh, '-c', string.join(args)]
+ try:
+ os.execvpe(sh, args, env)
+ except OSError, e:
+ exitval = exitvalmap[e[0]]
+ sys.stderr.write("scons: %s: %s\n" % (cmd, e[1]))
+ os._exit(exitval)
+ else:
+ # Parent process.
+ pid, stat = os.waitpid(pid, 0)
+ if stat & 0xff:
+ return stat | 0x80
+ return stat >> 8
+
+def process_cmd_output(cmd_stdout, cmd_stderr, stdout, stderr):
+ stdout_eof = stderr_eof = 0
+ while not (stdout_eof and stderr_eof):
+ (i,o,e) = select.select([cmd_stdout, cmd_stderr], [], [])
+ if cmd_stdout in i:
+ str = cmd_stdout.read()
+ if len(str) == 0:
+ stdout_eof = 1
+ elif stdout != None:
+ stdout.write(str)
+ if cmd_stderr in i:
+ str = cmd_stderr.read()
+ if len(str) == 0:
+ #sys.__stderr__.write( "stderr_eof=1\n" )
+ stderr_eof = 1
+ else:
+ #sys.__stderr__.write( "str(stderr) = %s\n" % str )
+ stderr.write(str)
+
+
+def piped_env_spawn(sh, escape, cmd, args, env, stdout, stderr):
+ # spawn using Popen3 combined with the env command
+ # the command name and the command's stdout is written to stdout
+ # the command's stderr is written to stderr
+ s = _get_env_command( sh, escape, cmd, args, env)
+ proc = popen2.Popen3(s, 1)
+ process_cmd_output(proc.fromchild, proc.childerr, stdout, stderr)
+ stat = proc.wait()
+ if stat & 0xff:
+ return stat | 0x80
+ return stat >> 8
+
+def piped_fork_spawn(sh, escape, cmd, args, env, stdout, stderr):
+ # spawn using fork / exec and providing a pipe for the command's
+ # stdout / stderr stream
+ if stdout != stderr:
+ (rFdOut, wFdOut) = os.pipe()
+ (rFdErr, wFdErr) = os.pipe()
+ else:
+ (rFdOut, wFdOut) = os.pipe()
+ rFdErr = rFdOut
+ wFdErr = wFdOut
+ # do the fork
+ pid = os.fork()
+ if not pid:
+ # Child process
+ os.close( rFdOut )
+ if rFdOut != rFdErr:
+ os.close( rFdErr )
+ os.dup2( wFdOut, 1 ) # is there some symbolic way to do that ?
+ os.dup2( wFdErr, 2 )
+ os.close( wFdOut )
+ if stdout != stderr:
+ os.close( wFdErr )
+ exitval = 127
+ args = [sh, '-c', string.join(args)]
+ try:
+ os.execvpe(sh, args, env)
+ except OSError, e:
+ exitval = exitvalmap[e[0]]
+ stderr.write("scons: %s: %s\n" % (cmd, e[1]))
+ os._exit(exitval)
+ else:
+ # Parent process
+ pid, stat = os.waitpid(pid, 0)
+ os.close( wFdOut )
+ if stdout != stderr:
+ os.close( wFdErr )
+ childOut = os.fdopen( rFdOut )
+ if stdout != stderr:
+ childErr = os.fdopen( rFdErr )
+ else:
+ childErr = childOut
+ process_cmd_output(childOut, childErr, stdout, stderr)
+ os.close( rFdOut )
+ if stdout != stderr:
+ os.close( rFdErr )
+ if stat & 0xff:
+ return stat | 0x80
+ return stat >> 8
+
+
+
+def generate(env):
+ # If os.spawnvpe() exists, we use it to spawn commands. Otherwise
+ # if the env utility exists, we use os.system() to spawn commands,
+ # finally we fall back on os.fork()/os.exec().
+ #
+ # os.spawnvpe() is prefered because it is the most efficient. But
+ # for Python versions without it, os.system() is prefered because it
+ # is claimed that it works better with threads (i.e. -j) and is more
+ # efficient than forking Python.
+ #
+ # NB: Other people on the scons-users mailing list have claimed that
+ # os.fork()/os.exec() works better than os.system(). There may just
+ # not be a default that works best for all users.
+
+ if os.__dict__.has_key('spawnvpe'):
+ spawn = spawn_spawn
+ elif env.Detect('env'):
+ spawn = env_spawn
+ else:
+ spawn = fork_spawn
+
+ if env.Detect('env'):
+ pspawn = piped_env_spawn
+ else:
+ pspawn = piped_fork_spawn
+
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+ env['ENV']['PATH'] = '/usr/local/bin:/bin:/usr/bin'
+ env['OBJPREFIX'] = ''
+ env['OBJSUFFIX'] = '.o'
+ env['SHOBJPREFIX'] = '$OBJPREFIX'
+ env['SHOBJSUFFIX'] = '$OBJSUFFIX'
+ env['PROGPREFIX'] = ''
+ env['PROGSUFFIX'] = ''
+ env['LIBPREFIX'] = 'lib'
+ env['LIBSUFFIX'] = '.a'
+ env['SHLIBPREFIX'] = '$LIBPREFIX'
+ env['SHLIBSUFFIX'] = '.so'
+ env['LIBPREFIXES'] = '$LIBPREFIX'
+ env['LIBSUFFIXES'] = [ '$LIBSUFFIX', '$SHLIBSUFFIX' ]
+ env['PSPAWN'] = pspawn
+ env['SPAWN'] = spawn
+ env['SHELL'] = 'sh'
+ env['ESCAPE'] = escape
+
+ # This platform supports RPATH specifications.
+ env['__RPATH'] = '$_RPATH'
Added: development/support/scons/scons-local-0.96.1/SCons/Platform/sunos.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Platform/sunos.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Platform/sunos.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,38 @@
+"""engine.SCons.Platform.sunos
+
+Platform-specific initialization for Sun systems.
+
+There normally shouldn't be any need to import this module directly. It
+will usually be imported through the generic SCons.Platform.Platform()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Platform/sunos.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import posix
+
+def generate(env):
+ posix.generate(env)
Added: development/support/scons/scons-local-0.96.1/SCons/Platform/win32.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Platform/win32.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Platform/win32.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,327 @@
+"""SCons.Platform.win32
+
+Platform-specific initialization for Win32 systems.
+
+There normally shouldn't be any need to import this module directly. It
+will usually be imported through the generic SCons.Platform.Platform()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Platform/win32.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+import os.path
+import string
+import sys
+import tempfile
+from SCons.Platform.posix import exitvalmap
+
+# XXX See note below about why importing SCons.Action should be
+# eventually refactored.
+import SCons.Action
+import SCons.Util
+
+class TempFileMunge:
+ """A callable class. You can set an Environment variable to this,
+ then call it with a string argument, then it will perform temporary
+ file substitution on it. This is used to circumvent the win32 long command
+ line limitation.
+
+ Example usage:
+ env["TEMPFILE"] = TempFileMunge
+ env["LINKCOM"] = "${TEMPFILE('$LINK $TARGET $SOURCES')}"
+ """
+ def __init__(self, cmd):
+ self.cmd = cmd
+
+ def __call__(self, target, source, env, for_signature):
+ if for_signature:
+ return self.cmd
+ cmd = env.subst_list(self.cmd, 0, target, source)[0]
+ try:
+ maxline = int(env.subst('$MAXLINELENGTH'))
+ except ValueError:
+ maxline = 2048
+ if (reduce(lambda x, y: x + len(y), cmd, 0) + len(cmd)) <= maxline:
+ return self.cmd
+ else:
+ # We do a normpath because mktemp() has what appears to be
+ # a bug in Win32 that will use a forward slash as a path
+ # delimiter. Win32's link mistakes that for a command line
+ # switch and barfs.
+ #
+ # We use the .lnk suffix for the benefit of the Phar Lap
+ # linkloc linker, which likes to append an .lnk suffix if
+ # none is given.
+ tmp = os.path.normpath(tempfile.mktemp('.lnk'))
+ native_tmp = SCons.Util.get_native_path(tmp)
+
+ if env['SHELL'] and env['SHELL'] == 'sh':
+ # The sh shell will try to escape the backslashes in the
+ # path, so unescape them.
+ native_tmp = string.replace(native_tmp, '\\', r'\\\\')
+ # In Cygwin, we want to use rm to delete the temporary
+ # file, because del does not exist in the sh shell.
+ rm = env.Detect('rm') or 'del'
+ else:
+ # Don't use 'rm' if the shell is not sh, because rm won't
+ # work with the win32 shells (cmd.exe or command.com) or
+ # win32 path names.
+ rm = 'del'
+
+ args = map(SCons.Util.quote_spaces, cmd[1:])
+ open(tmp, 'w').write(string.join(args, " ") + "\n")
+ # XXX Using the SCons.Action.print_actions value directly
+ # like this is bogus, but expedient. This class should
+ # really be rewritten as an Action that defines the
+ # __call__() and strfunction() methods and lets the
+ # normal action-execution logic handle whether or not to
+ # print/execute the action. The problem, though, is all
+ # of that is decided before we execute this method as
+ # part of expanding the $TEMPFILE construction variable.
+ # Consequently, refactoring this will have to wait until
+ # we get more flexible with allowing Actions to exist
+ # independently and get strung together arbitrarily like
+ # Ant tasks. In the meantime, it's going to be more
+ # user-friendly to not let obsession with architectural
+ # purity get in the way of just being helpful, so we'll
+ # reach into SCons.Action directly.
+ if SCons.Action.print_actions:
+ print("Using tempfile "+native_tmp+" for command line:\n"+
+ str(cmd[0]) + " " + string.join(args," "))
+ return [ cmd[0], '@' + native_tmp + '\n' + rm, native_tmp ]
+
+# The upshot of all this is that, if you are using Python 1.5.2,
+# you had better have cmd or command.com in your PATH when you run
+# scons.
+
+def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
+ # There is no direct way to do that in python. What we do
+ # here should work for most cases:
+ # In case stdout (stderr) is not redirected to a file,
+ # we redirect it into a temporary file tmpFileStdout
+ # (tmpFileStderr) and copy the contents of this file
+ # to stdout (stderr) given in the argument
+ if not sh:
+ sys.stderr.write("scons: Could not find command interpreter, is it in your PATH?\n")
+ return 127
+ else:
+ # one temporary file for stdout and stderr
+ tmpFileStdout = os.path.normpath(tempfile.mktemp())
+ tmpFileStderr = os.path.normpath(tempfile.mktemp())
+
+ # check if output is redirected
+ stdoutRedirected = 0
+ stderrRedirected = 0
+ for arg in args:
+ # are there more possibilities to redirect stdout ?
+ if (string.find( arg, ">", 0, 1 ) != -1 or
+ string.find( arg, "1>", 0, 2 ) != -1):
+ stdoutRedirected = 1
+ # are there more possibilities to redirect stderr ?
+ if string.find( arg, "2>", 0, 2 ) != -1:
+ stderrRedirected = 1
+
+ # redirect output of non-redirected streams to our tempfiles
+ if stdoutRedirected == 0:
+ args.append(">" + str(tmpFileStdout))
+ if stderrRedirected == 0:
+ args.append("2>" + str(tmpFileStderr))
+
+ # actually do the spawn
+ try:
+ args = [sh, '/C', escape(string.join(args)) ]
+ ret = os.spawnve(os.P_WAIT, sh, args, env)
+ except OSError, e:
+ # catch any error
+ ret = exitvalmap[e[0]]
+ if stderr != None:
+ stderr.write("scons: %s: %s\n" % (cmd, e[1]))
+ # copy child output from tempfiles to our streams
+ # and do clean up stuff
+ if stdout != None and stdoutRedirected == 0:
+ try:
+ stdout.write(open( tmpFileStdout, "r" ).read())
+ os.remove( tmpFileStdout )
+ except (IOError, OSError):
+ pass
+
+ if stderr != None and stderrRedirected == 0:
+ try:
+ stderr.write(open( tmpFileStderr, "r" ).read())
+ os.remove( tmpFileStderr )
+ except (IOError, OSError):
+ pass
+ return ret
+
+def spawn(sh, escape, cmd, args, env):
+ if not sh:
+ sys.stderr.write("scons: Could not find command interpreter, is it in your PATH?\n")
+ return 127
+ else:
+ try:
+ args = [sh, '/C', escape(string.join(args)) ]
+ ret = os.spawnve(os.P_WAIT, sh, args, env)
+ except OSError, e:
+ ret = exitvalmap[e[0]]
+ sys.stderr.write("scons: %s: %s\n" % (cmd, e[1]))
+ return ret
+
+# Windows does not allow special characters in file names anyway, so
+# no need for a complex escape function, we will just quote the arg.
+escape = lambda x: '"' + x + '"'
+
+# Get the windows system directory name
+def get_system_root():
+ # A resonable default if we can't read the registry
+ try:
+ val = os.environ['SYSTEMROOT']
+ except KeyError:
+ val = "C:/WINDOWS"
+ pass
+
+ # First see if we can look in the registry...
+ if SCons.Util.can_read_reg:
+ try:
+ # Look for Windows NT system root
+ k=SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,
+ 'Software\\Microsoft\\Windows NT\\CurrentVersion')
+ val, tok = SCons.Util.RegQueryValueEx(k, 'SystemRoot')
+ except SCons.Util.RegError:
+ try:
+ # Okay, try the Windows 9x system root
+ k=SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,
+ 'Software\\Microsoft\\Windows\\CurrentVersion')
+ val, tok = SCons.Util.RegQueryValueEx(k, 'SystemRoot')
+ except KeyboardInterrupt:
+ raise
+ except:
+ pass
+ return val
+
+# Get the location of the program files directory
+def get_program_files_dir():
+ # Now see if we can look in the registry...
+ val = ''
+ if SCons.Util.can_read_reg:
+ try:
+ # Look for Windows Program Files directory
+ k=SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,
+ 'Software\\Microsoft\\Windows\\CurrentVersion')
+ val, tok = SCons.Util.RegQueryValueEx(k, 'ProgramFilesDir')
+ except SCons.Util.RegError:
+ val = ''
+ pass
+
+ if val == '':
+ # A reasonable default if we can't read the registry
+ # (Actually, it's pretty reasonable even if we can :-)
+ val = os.path.join(os.path.dirname(get_system_root()),"Program Files")
+
+ return val
+
+def generate(env):
+ # Attempt to find cmd.exe (for WinNT/2k/XP) or
+ # command.com for Win9x
+ cmd_interp = ''
+ # First see if we can look in the registry...
+ if SCons.Util.can_read_reg:
+ try:
+ # Look for Windows NT system root
+ k=SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,
+ 'Software\\Microsoft\\Windows NT\\CurrentVersion')
+ val, tok = SCons.Util.RegQueryValueEx(k, 'SystemRoot')
+ cmd_interp = os.path.join(val, 'System32\\cmd.exe')
+ except SCons.Util.RegError:
+ try:
+ # Okay, try the Windows 9x system root
+ k=SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,
+ 'Software\\Microsoft\\Windows\\CurrentVersion')
+ val, tok = SCons.Util.RegQueryValueEx(k, 'SystemRoot')
+ cmd_interp = os.path.join(val, 'command.com')
+ except KeyboardInterrupt:
+ raise
+ except:
+ pass
+
+ # For the special case of not having access to the registry, we
+ # use a temporary path and pathext to attempt to find the command
+ # interpreter. If we fail, we try to find the interpreter through
+ # the env's PATH. The problem with that is that it might not
+ # contain an ENV and a PATH.
+ if not cmd_interp:
+ systemroot = r'C:\Windows'
+ if os.environ.has_key('SYSTEMROOT'):
+ systemroot = os.environ['SYSTEMROOT']
+ tmp_path = systemroot + os.pathsep + \
+ os.path.join(systemroot,'System32')
+ tmp_pathext = '.com;.exe;.bat;.cmd'
+ if os.environ.has_key('PATHEXT'):
+ tmp_pathext = os.environ['PATHEXT']
+ cmd_interp = SCons.Util.WhereIs('cmd', tmp_path, tmp_pathext)
+ if not cmd_interp:
+ cmd_interp = SCons.Util.WhereIs('command', tmp_path, tmp_pathext)
+
+ if not cmd_interp:
+ cmd_interp = env.Detect('cmd')
+ if not cmd_interp:
+ cmd_interp = env.Detect('command')
+
+
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+
+ # Import things from the external environment to the construction
+ # environment's ENV. This is a potential slippery slope, because we
+ # *don't* want to make builds dependent on the user's environment by
+ # default. We're doing this for SYSTEMROOT, though, because it's
+ # needed for anything that uses sockets, and seldom changes. Weigh
+ # the impact carefully before adding other variables to this list.
+ import_env = [ 'SYSTEMROOT' ]
+ for var in import_env:
+ v = os.environ.get(var)
+ if v:
+ env['ENV'][var] = v
+
+ env['ENV']['PATHEXT'] = '.COM;.EXE;.BAT;.CMD'
+ env['OBJPREFIX'] = ''
+ env['OBJSUFFIX'] = '.obj'
+ env['SHOBJPREFIX'] = '$OBJPREFIX'
+ env['SHOBJSUFFIX'] = '$OBJSUFFIX'
+ env['PROGPREFIX'] = ''
+ env['PROGSUFFIX'] = '.exe'
+ env['LIBPREFIX'] = ''
+ env['LIBSUFFIX'] = '.lib'
+ env['SHLIBPREFIX'] = ''
+ env['SHLIBSUFFIX'] = '.dll'
+ env['LIBPREFIXES'] = [ '$LIBPREFIX' ]
+ env['LIBSUFFIXES'] = [ '$LIBSUFFIX' ]
+ env['PSPAWN'] = piped_spawn
+ env['SPAWN'] = spawn
+ env['SHELL'] = cmd_interp
+ env['TEMPFILE'] = TempFileMunge
+ env['MAXLINELENGTH'] = 2048
+ env['ESCAPE'] = escape
Added: development/support/scons/scons-local-0.96.1/SCons/SConf.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/SConf.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/SConf.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,756 @@
+"""SCons.SConf
+
+Autoconf-like configuration support.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/SConf.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import cPickle
+import os
+import string
+import sys
+import traceback
+import types
+
+import SCons.Action
+import SCons.Builder
+import SCons.Errors
+import SCons.Node.FS
+import SCons.Taskmaster
+import SCons.Util
+import SCons.Warnings
+import SCons.Conftest
+
+# First i thought of using a different filesystem as the default_fs,
+# but it showed up that there are too many side effects in doing that.
+SConfFS=SCons.Node.FS.default_fs
+
+# to be set, if we are in dry-run mode
+dryrun = 0
+
+_ac_build_counter = 0
+_ac_config_counter = 0
+_activeSConfObjects = {}
+
+class SConfWarning(SCons.Warnings.Warning):
+ pass
+SCons.Warnings.enableWarningClass( SConfWarning )
+
+# action to create the source
+def _createSource( target, source, env ):
+ fd = open(str(target[0]), "w")
+ fd.write(env['SCONF_TEXT'])
+ fd.close()
+
+def _stringSource( target, source, env ):
+ import string
+ return (str(target[0]) + ' <- \n |' +
+ string.replace( env['SCONF_TEXT'], "\n", "\n |" ) )
+
+BooleanTypes = [types.IntType]
+if hasattr(types, 'BooleanType'): BooleanTypes.append(types.BooleanType)
+
+class SConf:
+ """This is simply a class to represent a configure context. After
+ creating a SConf object, you can call any tests. After finished with your
+ tests, be sure to call the Finish() method, which returns the modified
+ environment.
+ Some words about caching: In most cases, it is not necessary to cache
+ Test results explicitely. Instead, we use the scons dependency checking
+ mechanism. For example, if one wants to compile a test program
+ (SConf.TryLink), the compiler is only called, if the program dependencies
+ have changed. However, if the program could not be compiled in a former
+ SConf run, we need to explicitely cache this error.
+ """
+
+ def __init__(self, env, custom_tests = {}, conf_dir='#/.sconf_temp',
+ log_file='#/config.log'):
+ """Constructor. Pass additional tests in the custom_tests-dictinary,
+ e.g. custom_tests={'CheckPrivate':MyPrivateTest}, where MyPrivateTest
+ defines a custom test.
+ Note also the conf_dir and log_file arguments (you may want to
+ build tests in the BuildDir, not in the SourceDir)
+ """
+ import SCons.Script.SConscript
+ if not SCons.Script.SConscript.sconscript_reading:
+ raise SCons.Errors.UserError, "Calling Configure from Builders is not supported."
+ global SConfFS
+ if not SConfFS:
+ SConfFS = SCons.Node.FS.FS(SCons.Node.FS.default_fs.pathTop)
+ if len(_activeSConfObjects.keys()) > 0:
+ raise (SCons.Errors.UserError,
+ "Only one SConf object may be active at one time")
+ self.env = env
+ if log_file != None:
+ self.logfile = SConfFS.File(log_file)
+ else:
+ self.logfile = None
+ self.logstream = None
+ self.lastTarget = None
+
+ # add default tests
+ default_tests = {
+ 'CheckFunc' : CheckFunc,
+ 'CheckType' : CheckType,
+ 'CheckHeader' : CheckHeader,
+ 'CheckCHeader' : CheckCHeader,
+ 'CheckCXXHeader' : CheckCXXHeader,
+ 'CheckLib' : CheckLib,
+ 'CheckLibWithHeader' : CheckLibWithHeader
+ }
+ self.AddTests(default_tests)
+ self.AddTests(custom_tests)
+ self.confdir = SConfFS.Dir(conf_dir)
+ self.calc = None
+ self.cache = {}
+ self._startup()
+
+ def Finish(self):
+ """Call this method after finished with your tests:
+ env = sconf.Finish()"""
+ global _lastSConfObj
+ _lastSConfObj = None
+ self._shutdown()
+ return self.env
+
+ def _setCache(self, nodes, already_done = []):
+ # Set up actions used for caching errors
+ # Caching positive tests should not be necessary, cause
+ # the build system knows, if test objects/programs/outputs
+ # are up to date.
+ for n in nodes:
+ # The 'n in already_done' expression is not really efficient.
+ # We may do something more sophisticated in the future :-),
+ # but there should not be that many dependencies in configure
+ # tests
+ if (n.has_builder() and
+ not n in already_done):
+ n.add_pre_action(SCons.Action.Action(self._preCache,
+ self._stringCache))
+ n.add_post_action(SCons.Action.Action(self._postCache,
+ self._stringCache))
+ already_done.append( n )
+ self._setCache(n.children())
+
+ # Calling children() has set up the implicit cache (and
+ # other state), but we're not really building things yet,
+ # so generated files won't have been generated. Clear the
+ # state so we will, in fact, build everything that's necessary
+ # when we do the build.
+ #
+ # XXX - it would be good to find a better way to do this,
+ # maybe by doing something with the actions in the actual
+ # Taskmaster...?
+ n.clear()
+
+ def BuildNodes(self, nodes):
+ """
+ Tries to build the given nodes immediately. Returns 1 on success,
+ 0 on error.
+ """
+
+ global SCons
+ import SCons.Script # really ugly, but we need BuildTask :-(
+ # Is it better to provide a seperate Task for SConf builds ?
+ class SConfBuildTask(SCons.Script.BuildTask):
+ """Errors in SConf builds are not fatal, so we override
+ the do_failed method"""
+ def do_failed(self, status=2):
+ pass
+
+ class SConfDryRunTask(SConfBuildTask):
+ """Raise ConfiugreDryRunErrors whenever a target is to
+ be built. Pass these Errors to the main script."""
+ def execute(self):
+ target = self.targets[0]
+ if (target.get_state() != SCons.Node.up_to_date and
+ target.has_builder() and
+ not hasattr(target.builder, 'status')):
+
+ raise SCons.Errors.ConfigureDryRunError(target)
+
+ def failed(self):
+ exc_type, exc_value = self.exc_info()[:2]
+ if exc_type == SCons.Errors.ConfigureDryRunError:
+ raise exc_type, exc_value
+ # Should be SConfBuildTask.failed(), really,
+ # but that causes name errors in Python 1.5.2.
+ SCons.Script.BuildTask.failed(self)
+
+ if self.logstream != None:
+ # override stdout / stderr to write in log file
+ oldStdout = sys.stdout
+ sys.stdout = self.logstream
+ oldStderr = sys.stderr
+ sys.stderr = self.logstream
+
+ # the engine assumes the current path is the SConstruct directory ...
+ old_fs_dir = SConfFS.getcwd()
+ old_os_dir = os.getcwd()
+ SConfFS.chdir(SConfFS.Top, change_os_dir=1)
+
+ self._setCache( nodes )
+ ret = 1
+
+ try:
+ # ToDo: use user options for calc
+ self.calc = SCons.Sig.Calculator(max_drift=0)
+ if dryrun:
+ buildTask = SConfDryRunTask
+ else:
+ buildTask = SConfBuildTask
+ tm = SCons.Taskmaster.Taskmaster( nodes, buildTask )
+ # we don't want to build tests in parallel
+ jobs = SCons.Job.Jobs(1, tm )
+ try:
+ jobs.run()
+ except SCons.Errors.BuildError, e:
+ sys.stderr.write("scons: *** [%s] %s\n" % (e.node, e.errstr))
+ if e.errstr == 'Exception':
+ traceback.print_exception(e.args[0], e.args[1], e.args[2])
+
+ for n in nodes:
+ state = n.get_state()
+ if (state != SCons.Node.executed and
+ state != SCons.Node.up_to_date):
+ # the node could not be built. we return 0 in this case
+ ret = 0
+ finally:
+ os.chdir(old_os_dir)
+ SConfFS.chdir(old_fs_dir, change_os_dir=0)
+ if self.logstream != None:
+ # restore stdout / stderr
+ sys.stdout = oldStdout
+ sys.stderr = oldStderr
+ return ret
+
+
+ def TryBuild(self, builder, text = None, extension = ""):
+ """Low level TryBuild implementation. Normally you don't need to
+ call that - you can use TryCompile / TryLink / TryRun instead
+ """
+ global _ac_build_counter
+
+ nodesToBeBuilt = []
+
+ f = "conftest_" + str(_ac_build_counter)
+ pref = self.env.subst( builder.builder.prefix )
+ suff = self.env.subst( builder.builder.suffix )
+ target = self.confdir.File(pref + f + suff)
+ self.env['SCONF_TEXT'] = text
+ self.env['PIPE_BUILD'] = 1
+ self.env['PSTDOUT'] = self.logstream
+ self.env['PSTDERR'] = self.logstream
+ if text != None:
+ source = self.confdir.File(f + extension)
+ sourceNode = self.env.SConfSourceBuilder(target=source,
+ source=None)
+ nodesToBeBuilt.extend(sourceNode)
+ else:
+ source = None
+
+ nodes = builder(target = target, source = source)
+ if not SCons.Util.is_List(nodes):
+ nodes = [nodes]
+ nodesToBeBuilt.extend(nodes)
+ ret = self.BuildNodes(nodesToBeBuilt)
+
+ # clean up environment
+ del self.env['PIPE_BUILD']
+ del self.env['PSTDOUT']
+ del self.env['PSTDERR']
+ del self.env['SCONF_TEXT']
+
+ _ac_build_counter = _ac_build_counter + 1
+ if ret:
+ self.lastTarget = nodes[0]
+ else:
+ self.lastTarget = None
+
+ return ret
+
+ def TryAction(self, action, text = None, extension = ""):
+ """Tries to execute the given action with optional source file
+ contents <text> and optional source file extension <extension>,
+ Returns the status (0 : failed, 1 : ok) and the contents of the
+ output file.
+ """
+ builder = SCons.Builder.Builder(action=action)
+ self.env.Append( BUILDERS = {'SConfActionBuilder' : builder} )
+ ok = self.TryBuild(self.env.SConfActionBuilder, text, extension)
+ del self.env['BUILDERS']['SConfActionBuilder']
+ if ok:
+ outputStr = self.lastTarget.get_contents()
+ return (1, outputStr)
+ return (0, "")
+
+ def TryCompile( self, text, extension):
+ """Compiles the program given in text to an env.Object, using extension
+ as file extension (e.g. '.c'). Returns 1, if compilation was
+ successful, 0 otherwise. The target is saved in self.lastTarget (for
+ further processing).
+ """
+ return self.TryBuild(self.env.Object, text, extension)
+
+ def TryLink( self, text, extension ):
+ """Compiles the program given in text to an executable env.Program,
+ using extension as file extension (e.g. '.c'). Returns 1, if
+ compilation was successful, 0 otherwise. The target is saved in
+ self.lastTarget (for further processing).
+ """
+ return self.TryBuild(self.env.Program, text, extension )
+
+ def TryRun(self, text, extension ):
+ """Compiles and runs the program given in text, using extension
+ as file extension (e.g. '.c'). Returns (1, outputStr) on success,
+ (0, '') otherwise. The target (a file containing the program's stdout)
+ is saved in self.lastTarget (for further processing).
+ """
+ ok = self.TryLink(text, extension)
+ if( ok ):
+ prog = self.lastTarget
+ pname = str(prog)
+ output = SConfFS.File(pname+'.out')
+ node = self.env.Command(output, prog, [ [ pname, ">", "${TARGET}"] ])
+ ok = self.BuildNodes(node)
+ if ok:
+ outputStr = output.get_contents()
+ return( 1, outputStr)
+ return (0, "")
+
+ class TestWrapper:
+ """A wrapper around Tests (to ensure sanity)"""
+ def __init__(self, test, sconf):
+ self.test = test
+ self.sconf = sconf
+ def __call__(self, *args, **kw):
+ if not self.sconf.active:
+ raise (SCons.Errors.UserError,
+ "Test called after sconf.Finish()")
+ context = CheckContext(self.sconf)
+ ret = apply(self.test, (context,) + args, kw)
+ context.Result("error: no result")
+ return ret
+
+ def AddTest(self, test_name, test_instance):
+ """Adds test_class to this SConf instance. It can be called with
+ self.test_name(...)"""
+ setattr(self, test_name, SConf.TestWrapper(test_instance, self))
+
+ def AddTests(self, tests):
+ """Adds all the tests given in the tests dictionary to this SConf
+ instance
+ """
+ for name in tests.keys():
+ self.AddTest(name, tests[name])
+
+ def _preCache(self, target, source, env):
+ # Action before target is actually built
+ #
+ # We record errors in the cache. Only non-exisiting targets may
+ # have recorded errors
+ needs_rebuild = target[0].exists()
+ buildSig = target[0].calc_signature(self.calc)
+ for node in source:
+ if node.get_state() != SCons.Node.up_to_date:
+ # if any of the sources has changed, we cannot use our cache
+ needs_rebuild = 1
+ tname = str(target[0])
+ if not self.cache.has_key( tname ):
+ # We have no recorded error, so we try to build the target
+ needs_rebuild = 1
+ else:
+ lastBuildSig = self.cache[tname]['builder']
+ if lastBuildSig != buildSig:
+ needs_rebuild = 1
+ if not needs_rebuild:
+ # When we are here, we can savely pass the recorded error
+ print ('(cached): Building "%s" failed in a previous run.' %
+ target[0])
+ return 1
+ else:
+ # Otherwise, we try to record an error
+ self.cache[tname] = {
+ 'builder' : buildSig
+ }
+
+ def _postCache(self, target, source, env):
+ # Action after target is successfully built
+ #
+ # No error during build -> remove the recorded error
+ del self.cache[str(target[0])]
+
+ def _stringCache(self, target, source, env):
+ return None
+
+ def _loadCache(self):
+ # try to load build-error cache
+ try:
+ cacheDesc = cPickle.load(open(str(self.confdir.File(".cache"))))
+ if cacheDesc['scons_version'] != SCons.__version__:
+ raise Exception, "version mismatch"
+ self.cache = cacheDesc['data']
+ except KeyboardInterrupt:
+ raise
+ except:
+ self.cache = {}
+
+ def _dumpCache(self):
+ if dryrun:
+ return
+ # try to dump build-error cache
+ try:
+ cacheDesc = {'scons_version' : SCons.__version__,
+ 'data' : self.cache }
+ cPickle.dump(cacheDesc, open(str(self.confdir.File(".cache")),"w"))
+ except Exception, e:
+ # this is most likely not only an IO error, but an error
+ # inside SConf ...
+ SCons.Warnings.warn( SConfWarning, "Couldn't dump SConf cache" )
+
+ def _createDir( self, node ):
+ dirName = str(node)
+ if dryrun:
+ if not os.path.isdir( dirName ):
+ raise SCons.Errors.ConfigureDryRunError(dirName)
+ else:
+ if not os.path.isdir( dirName ):
+ os.makedirs( dirName )
+ node._exists = 1
+
+ def _startup(self):
+ """Private method. Set up logstream, and set the environment
+ variables necessary for a piped build
+ """
+ global _ac_config_counter
+ global _activeSConfObjects
+ global SConfFS
+
+ self.lastEnvFs = self.env.fs
+ self.env.fs = SConfFS
+ self._createDir(self.confdir)
+ self.confdir.up().add_ignore( [self.confdir] )
+
+ if self.logfile != None and not dryrun:
+ # truncate logfile, if SConf.Configure is called for the first time
+ # in a build
+ if _ac_config_counter == 0:
+ log_mode = "w"
+ else:
+ log_mode = "a"
+ self.logstream = open(str(self.logfile), log_mode)
+ # logfile may stay in a build directory, so we tell
+ # the build system not to override it with a eventually
+ # existing file with the same name in the source directory
+ self.logfile.dir.add_ignore( [self.logfile] )
+
+ tb = traceback.extract_stack()[-3]
+
+ self.logstream.write( '\nfile %s,line %d:\n\tConfigure( confdir = %s )\n\n' %
+ (tb[0], tb[1], str(self.confdir)) )
+ else:
+ self.logstream = None
+ # we use a special builder to create source files from TEXT
+ action = SCons.Action.Action(_createSource,
+ _stringSource,
+ varlist=['SCONF_TEXT'])
+ sconfSrcBld = SCons.Builder.Builder(action=action)
+ self.env.Append( BUILDERS={'SConfSourceBuilder':sconfSrcBld} )
+ self.active = 1
+ # only one SConf instance should be active at a time ...
+ _activeSConfObjects[self] = None
+ _ac_config_counter = _ac_config_counter + 1
+ self._loadCache()
+
+ def _shutdown(self):
+ """Private method. Reset to non-piped spawn"""
+ global _activeSConfObjets
+
+ if not self.active:
+ raise SCons.Errors.UserError, "Finish may be called only once!"
+ if self.logstream != None:
+ self.logstream.close()
+ self.logstream = None
+ # remove the SConfSourceBuilder from the environment
+ blds = self.env['BUILDERS']
+ del blds['SConfSourceBuilder']
+ self.env.Replace( BUILDERS=blds )
+ self.active = 0
+ del _activeSConfObjects[self]
+ self._dumpCache()
+ self.env.fs = self.lastEnvFs
+
+class CheckContext:
+ """Provides a context for configure tests. Defines how a test writes to the
+ screen and log file.
+
+ A typical test is just a callable with an instance of CheckContext as
+ first argument:
+
+ def CheckCustom(context, ...)
+ context.Message('Checking my weird test ... ')
+ ret = myWeirdTestFunction(...)
+ context.Result(ret)
+
+ Often, myWeirdTestFunction will be one of
+ context.TryCompile/context.TryLink/context.TryRun. The results of
+ those are cached, for they are only rebuild, if the dependencies have
+ changed.
+ """
+
+ def __init__(self, sconf):
+ """Constructor. Pass the corresponding SConf instance."""
+ self.sconf = sconf
+ self.cached = 0
+ self.did_show_result = 0
+
+ # for Conftest.py:
+ self.vardict = {}
+ self.havedict = {}
+ self.headerfilename = None # XXX may cause trouble!
+
+ def Message(self, text):
+ """Inform about what we are doing right now, e.g.
+ 'Checking for SOMETHING ... '
+ """
+ # write to config.log
+ if self.sconf.logstream != None:
+ self.sconf.logstream.write(text + '\n')
+ sys.stdout.write(text)
+ self.did_show_result = 0
+
+ def Result(self, res):
+ """Inform about the result of the test. res may be an integer or a
+ string. In case of an integer, the written text will be 'ok' or
+ 'failed'.
+ The result is only displayed when self.did_show_result is not set.
+ """
+ if type(res) in BooleanTypes:
+ if res:
+ text = "ok"
+ else:
+ text = "failed"
+ elif type(res) == types.StringType:
+ text = res
+ else:
+ raise TypeError, "Expected string, int or bool, got " + str(type(res))
+
+ if self.did_show_result == 0:
+ if self.cached:
+ text = text + " (cached)"
+
+ # Didn't show result yet, do it now.
+ if self.sconf.logstream != None:
+ self.sconf.logstream.write("Result: " + text + "\n\n")
+ sys.stdout.write(text + "\n")
+ self.did_show_result = 1
+
+
+ def TryBuild(self, *args, **kw):
+ return apply(self.sconf.TryBuild, args, kw)
+
+ def TryAction(self, *args, **kw):
+ return apply(self.sconf.TryAction, args, kw)
+
+ def TryCompile(self, *args, **kw):
+ return apply(self.sconf.TryCompile, args, kw)
+
+ def TryLink(self, *args, **kw):
+ return apply(self.sconf.TryLink, args, kw)
+
+ def TryRun(self, *args, **kw):
+ return apply(self.sconf.TryRun, args, kw)
+
+ def __getattr__( self, attr ):
+ if( attr == 'env' ):
+ return self.sconf.env
+ elif( attr == 'lastTarget' ):
+ return self.sconf.lastTarget
+ else:
+ raise AttributeError, "CheckContext instance has no attribute '%s'" % attr
+
+ #### Stuff used by Conftest.py (look there for explanations).
+
+ def BuildProg(self, text, ext):
+ # TODO: should use self.vardict for $CC, $CPPFLAGS, etc.
+ res = self.TryBuild(self.env.Program, text, ext)
+ if type(res) in BooleanTypes:
+ if res:
+ ret = ""
+ else:
+ ret = "failed to build test program"
+ elif type(res) == types.StringType:
+ ret = res
+ else:
+ raise TypeError, "Expected string or int"
+ return ret
+
+ def CompileProg(self, text, ext):
+ # TODO: should use self.vardict for $CC, $CPPFLAGS, etc.
+ res = self.TryBuild(self.env.Object, text, ext)
+ if type(res) in BooleanTypes:
+ if res:
+ ret = ""
+ else:
+ ret = "failed to compile test program"
+ elif type(res) == types.StringType:
+ ret = res
+ else:
+ raise TypeError, "Expected string or int"
+ return ret
+
+ def AppendLIBS(self, lib_name_list):
+ oldLIBS = self.env.get( 'LIBS', [] )
+ self.env.Append(LIBS = lib_name_list)
+ return oldLIBS
+
+ def SetLIBS(self, val):
+ oldLIBS = self.env.get( 'LIBS', [] )
+ self.env.Replace(LIBS = val)
+ return oldLIBS
+
+ def Display(self, msg):
+ sys.stdout.write(msg)
+ self.Log(msg)
+
+ def Log(self, msg):
+ if self.sconf.logstream != None:
+ self.sconf.logstream.write(msg)
+
+ #### End of stuff used by Conftest.py.
+
+
+def CheckFunc(context, function_name, language = None):
+ res = SCons.Conftest.CheckFunc(context, function_name, language = language)
+ context.did_show_result = 1
+ if not res:
+ return 1 # Ok
+ return 0 # Failed
+
+
+def CheckType(context, type_name, includes = "", language = None):
+ res = SCons.Conftest.CheckType(context, type_name,
+ header = includes, language = language)
+ context.did_show_result = 1
+ if not res:
+ return 1 # Ok
+ return 0 # Failed
+
+
+def CheckHeader(context, header, include_quotes = '<>', language = None):
+ """
+ A test for a C or C++ header file.
+ """
+ if not SCons.Util.is_List(header):
+ header = [header]
+ l = []
+ for s in header[:-1]:
+ l.append("#include %s%s%s\n" % (include_quotes[0], s, include_quotes[1]))
+ res = SCons.Conftest.CheckHeader(context, header[-1], string.join(l, ''),
+ language = language,
+ include_quotes = include_quotes)
+ context.did_show_result = 1
+ if not res:
+ return 1 # Ok
+ return 0 # Failed
+
+
+# Bram: Make this function obsolete? CheckHeader() is more generic.
+
+def CheckCHeader(context, header, include_quotes = '""'):
+ """
+ A test for a C header file.
+ """
+ return CheckHeader(context, header, include_quotes, language = "C")
+
+
+# Bram: Make this function obsolete? CheckHeader() is more generic.
+
+def CheckCXXHeader(context, header, include_quotes = '""'):
+ """
+ A test for a C++ header file.
+ """
+ return CheckHeader(context, header, include_quotes, language = "C++")
+
+
+def CheckLib(context, library = None, symbol = "main", autoadd = 1,
+ header = None, language = None):
+ """
+ A test for a library. See also CheckLibWithHeader.
+ Note that library may also be None to test whether the given symbol
+ compiles without flags.
+ """
+
+ if library == []:
+ library = [None]
+
+ if not SCons.Util.is_List(library):
+ library = [library]
+
+ # ToDo: accept path for the library
+ res = SCons.Conftest.CheckLib(context, library, symbol, header = header,
+ language = language, autoadd = autoadd)
+ context.did_show_result = 1
+ if not res:
+ return 1 # Ok
+ return 0 # Failed
+
+
+# XXX
+# Bram: Can only include one header and can't use #ifdef HAVE_HEADER_H.
+
+def CheckLibWithHeader(context, libs, header, language,
+ call = "main();", autoadd = 1):
+ # ToDo: accept path for library. Support system header files.
+ """
+ Another (more sophisticated) test for a library.
+ Checks, if library and header is available for language (maybe 'C'
+ or 'CXX'). Call maybe be a valid expression _with_ a trailing ';'.
+ As in CheckLib, we support library=None, to test if the call compiles
+ without extra link flags.
+ """
+
+ if not SCons.Util.is_List(header):
+ header = [header]
+ l = []
+ for s in header:
+ l.append('#include "%s"\n' % (s))
+
+
+ if libs == []:
+ libs = [None]
+
+ if not SCons.Util.is_List(libs):
+ libs = [libs]
+
+ res = SCons.Conftest.CheckLib(context, libs, "main", string.join(l, ''),
+ call = call, language = language, autoadd = autoadd)
+ context.did_show_result = 1
+ if not res:
+ return 1 # Ok
+ return 0 # Failed
+
+
Added: development/support/scons/scons-local-0.96.1/SCons/SConsign.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/SConsign.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/SConsign.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,223 @@
+"""SCons.SConsign
+
+Writing and reading information to the .sconsign file or files.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/SConsign.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import cPickle
+import os
+import os.path
+import time
+
+import SCons.Node
+import SCons.Sig
+import SCons.Warnings
+
+#XXX Get rid of the global array so this becomes re-entrant.
+sig_files = []
+
+database = None
+
+def write():
+ global sig_files
+ for sig_file in sig_files:
+ sig_file.write()
+
+class Base:
+ """
+ This is the controlling class for the signatures for the collection of
+ entries associated with a specific directory. The actual directory
+ association will be maintained by a subclass that is specific to
+ the underlying storage method. This class provides a common set of
+ methods for fetching and storing the individual bits of information
+ that make up signature entry.
+ """
+ def __init__(self, module=None):
+ """
+ module - the signature module being used
+ """
+
+ self.module = module or SCons.Sig.default_calc.module
+ self.entries = {}
+ self.dirty = 0
+
+ def get_entry(self, filename):
+ """
+ Fetch the specified entry attribute.
+ """
+ return self.entries[filename]
+
+ def set_entry(self, filename, obj):
+ """
+ Set the entry.
+ """
+ self.entries[filename] = obj
+ self.dirty = 1
+
+class DB(Base):
+ """
+ A Base subclass that reads and writes signature information
+ from a global .sconsign.dbm file.
+ """
+ def __init__(self, dir, module=None):
+ Base.__init__(self, module)
+
+ self.dir = dir
+
+ try:
+ global database
+ rawentries = database[self.dir.path]
+ except KeyError:
+ pass
+ else:
+ try:
+ self.entries = cPickle.loads(rawentries)
+ if type(self.entries) is not type({}):
+ self.entries = {}
+ raise TypeError
+ except KeyboardInterrupt:
+ raise
+ except:
+ SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning,
+ "Ignoring corrupt sconsign entry : %s"%self.dir.path)
+
+ global sig_files
+ sig_files.append(self)
+
+ def write(self):
+ if self.dirty:
+ global database
+ database[self.dir.path] = cPickle.dumps(self.entries, 1)
+ try:
+ database.sync()
+ except AttributeError:
+ # Not all anydbm modules have sync() methods.
+ pass
+
+class Dir(Base):
+ def __init__(self, fp=None, module=None):
+ """
+ fp - file pointer to read entries from
+ module - the signature module being used
+ """
+ Base.__init__(self, module)
+
+ if fp:
+ self.entries = cPickle.load(fp)
+ if type(self.entries) is not type({}):
+ self.entries = {}
+ raise TypeError
+
+class DirFile(Dir):
+ """
+ Encapsulates reading and writing a per-directory .sconsign file.
+ """
+ def __init__(self, dir, module=None):
+ """
+ dir - the directory for the file
+ module - the signature module being used
+ """
+
+ self.dir = dir
+ self.sconsign = os.path.join(dir.path, '.sconsign')
+
+ try:
+ fp = open(self.sconsign, 'rb')
+ except IOError:
+ fp = None
+
+ try:
+ Dir.__init__(self, fp, module)
+ except KeyboardInterrupt:
+ raise
+ except:
+ SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning,
+ "Ignoring corrupt .sconsign file: %s"%self.sconsign)
+
+ global sig_files
+ sig_files.append(self)
+
+ def write(self):
+ """
+ Write the .sconsign file to disk.
+
+ Try to write to a temporary file first, and rename it if we
+ succeed. If we can't write to the temporary file, it's
+ probably because the directory isn't writable (and if so,
+ how did we build anything in this directory, anyway?), so
+ try to write directly to the .sconsign file as a backup.
+ If we can't rename, try to copy the temporary contents back
+ to the .sconsign file. Either way, always try to remove
+ the temporary file at the end.
+ """
+ if self.dirty:
+ temp = os.path.join(self.dir.path, '.scons%d' % os.getpid())
+ try:
+ file = open(temp, 'wb')
+ fname = temp
+ except IOError:
+ try:
+ file = open(self.sconsign, 'wb')
+ fname = self.sconsign
+ except IOError:
+ return
+ cPickle.dump(self.entries, file, 1)
+ file.close()
+ if fname != self.sconsign:
+ try:
+ mode = os.stat(self.sconsign)[0]
+ os.chmod(self.sconsign, 0666)
+ os.unlink(self.sconsign)
+ except OSError:
+ pass
+ try:
+ os.rename(fname, self.sconsign)
+ except OSError:
+ open(self.sconsign, 'wb').write(open(fname, 'rb').read())
+ os.chmod(self.sconsign, mode)
+ try:
+ os.unlink(temp)
+ except OSError:
+ pass
+
+ForDirectory = DirFile
+
+def File(name, dbm_module=None):
+ """
+ Arrange for all signatures to be stored in a global .sconsign.dbm
+ file.
+ """
+ global database
+ if database is None:
+ if dbm_module is None:
+ import SCons.dblite
+ dbm_module = SCons.dblite
+ database = dbm_module.open(name, "c")
+
+ global ForDirectory
+ ForDirectory = DB
Added: development/support/scons/scons-local-0.96.1/SCons/Scanner/C.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Scanner/C.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Scanner/C.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,43 @@
+"""SCons.Scanner.C
+
+This module implements the depenency scanner for C/C++ code.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Scanner/C.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Node.FS
+import SCons.Scanner
+
+def CScan(fs = SCons.Node.FS.default_fs):
+ """Return a prototype Scanner instance for scanning source files
+ that use the C pre-processor"""
+ cs = SCons.Scanner.ClassicCPP("CScan",
+ "$CPPSUFFIXES",
+ "CPPPATH",
+ '^[ \t]*#[ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")',
+ fs = fs)
+ return cs
Added: development/support/scons/scons-local-0.96.1/SCons/Scanner/D.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Scanner/D.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Scanner/D.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,56 @@
+"""SCons.Scanner.D
+
+Scanner for the Digital Mars "D" programming language.
+
+Coded by Andy Friesen
+17 Nov 2003
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Scanner/D.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import string
+
+import SCons.Scanner
+
+def DScan(fs = SCons.Node.FS.default_fs):
+ """Return a prototype Scanner instance for scanning D source files"""
+ ds = DScanner(name = "DScan",
+ suffixes = '$DSUFFIXES',
+ path_variable = 'DPATH',
+ regex = 'import\s+([^\;]*)\;',
+ fs = fs)
+ return ds
+
+class DScanner(SCons.Scanner.Classic):
+ def find_include(self, include, source_dir, path):
+ # translate dots (package separators) to slashes
+ inc = string.replace(include, '.', '/')
+
+ i = SCons.Node.FS.find_file(inc + '.d',
+ (source_dir,) + path,
+ self.fs.File)
+ return i, include
Added: development/support/scons/scons-local-0.96.1/SCons/Scanner/Fortran.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Scanner/Fortran.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Scanner/Fortran.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,294 @@
+"""SCons.Scanner.Fortran
+
+This module implements the dependency scanner for Fortran code.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Scanner/Fortran.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import re
+import string
+
+import SCons.Node
+import SCons.Node.FS
+import SCons.Scanner
+import SCons.Util
+import SCons.Warnings
+
+class F90Scanner(SCons.Scanner.Classic):
+ """
+ A Classic Scanner subclass for Fortran source files which takes
+ into account both USE and INCLUDE statements. This scanner will
+ work for both F77 and F90 (and beyond) compilers.
+
+ Currently, this scanner assumes that the include files do not contain
+ USE statements. To enable the ability to deal with USE statements
+ in include files, add logic right after the module names are found
+ to loop over each include file, search for and locate each USE
+ statement, and append each module name to the list of dependencies.
+ Caching the search results in a common dictionary somewhere so that
+ the same include file is not searched multiple times would be a
+ smart thing to do.
+ """
+
+ def __init__(self, name, suffixes, path_variable, use_regex,
+ incl_regex, fs=SCons.Node.FS.default_fs, *args, **kw):
+
+ self.cre_use = re.compile(use_regex, re.M)
+ self.cre_incl = re.compile(incl_regex, re.M)
+ self.fs = fs
+
+ def _scan(node, env, path, self=self, fs=fs):
+ return self.scan(node, env, path)
+
+ kw['function'] = _scan
+ kw['path_function'] = SCons.Scanner.FindPathDirs(path_variable, fs)
+ kw['recursive'] = 1
+ kw['skeys'] = suffixes
+ kw['name'] = name
+
+ apply(SCons.Scanner.Current.__init__, (self,) + args, kw)
+
+ def scan(self, node, env, path=()):
+ node = node.rfile()
+
+ if not node.exists():
+ return []
+
+ # cache the includes list in node so we only scan it once:
+ if node.includes != None:
+ mods_and_includes = node.includes
+ else:
+ # retrieve all included filenames
+ includes = self.cre_incl.findall(node.get_contents())
+ # retrieve all USE'd module names
+ modules = self.cre_use.findall(node.get_contents())
+
+ # Convert module name to a .mod filename
+ suffix = env.subst('$FORTRANMODSUFFIX')
+ modules = map(lambda x, s=suffix: string.lower(x) + s, modules)
+ # Remove unique items from the list
+ mods_and_includes = SCons.Util.unique(includes+modules)
+ node.includes = mods_and_includes
+
+ nodes = []
+ source_dir = node.get_dir()
+ for dep in mods_and_includes:
+ n, i = self.find_include(dep, source_dir, path)
+
+ if not n is None:
+ nodes.append(n)
+ else:
+ SCons.Warnings.warn(SCons.Warnings.DependencyWarning,
+ "No dependency generated for file: %s (referenced by: %s) -- file not found" % (i, node))
+
+ # Sort the list of dependencies
+
+ # Schwartzian transform from the Python FAQ Wizard
+ def st(List, Metric):
+ def pairing(element, M = Metric):
+ return (M(element), element)
+ def stripit(pair):
+ return pair[1]
+ paired = map(pairing, List)
+ paired.sort()
+ return map(stripit, paired)
+
+ def normalize(node):
+ # We don't want the order of includes to be
+ # modified by case changes on case insensitive OSes, so
+ # normalize the case of the filename here:
+ # (see test/win32pathmadness.py for a test of this)
+ return SCons.Node.FS._my_normcase(str(node))
+
+ # Apply a Schwartzian transform to return the list of
+ # dependencies, sorted according to their normalized names
+ transformed = st(nodes, normalize)
+# print "ClassicF90: " + str(node) + " => " + str(map(lambda x: str(x),list(transformed)))
+ return transformed
+
+
+def FortranScan(path_variable="FORTRANPATH", fs=SCons.Node.FS.default_fs):
+ """Return a prototype Scanner instance for scanning source files
+ for Fortran USE & INCLUDE statements"""
+
+# The USE statement regex matches the following:
+#
+# USE module_name
+# USE :: module_name
+# USE, INTRINSIC :: module_name
+# USE, NON_INTRINSIC :: module_name
+#
+# Limitations
+#
+# -- While the regex can handle multiple USE statements on one line,
+# it cannot properly handle them if they are commented out.
+# In either of the following cases:
+#
+# ! USE mod_a ; USE mod_b [entire line is commented out]
+# USE mod_a ! ; USE mod_b [in-line comment of second USE statement]
+#
+# the second module name (mod_b) will be picked up as a dependency
+# even though it should be ignored. The only way I can see
+# to rectify this would be to modify the scanner to eliminate
+# the call to re.findall, read in the contents of the file,
+# treating the comment character as an end-of-line character
+# in addition to the normal linefeed, loop over each line,
+# weeding out the comments, and looking for the USE statements.
+# One advantage to this is that the regex passed to the scanner
+# would no longer need to match a semicolon.
+#
+# -- I question whether or not we need to detect dependencies to
+# INTRINSIC modules because these are built-in to the compiler.
+# If we consider them a dependency, will SCons look for them, not
+# find them, and kill the build? Or will we there be standard
+# compiler-specific directories we will need to point to so the
+# compiler and SCons can locate the proper object and mod files?
+
+# Here is a breakdown of the regex:
+#
+# (?i) : regex is case insensitive
+# ^ : start of line
+# (?: : group a collection of regex symbols without saving the match as a "group"
+# ^|; : matches either the start of the line or a semicolon - semicolon
+# ) : end the unsaved grouping
+# \s* : any amount of white space
+# USE : match the string USE, case insensitive
+# (?: : group a collection of regex symbols without saving the match as a "group"
+# \s+| : match one or more whitespace OR .... (the next entire grouped set of regex symbols)
+# (?: : group a collection of regex symbols without saving the match as a "group"
+# (?: : establish another unsaved grouping of regex symbols
+# \s* : any amount of white space
+# , : match a comma
+# \s* : any amount of white space
+# (?:NON_)? : optionally match the prefix NON_, case insensitive
+# INTRINSIC : match the string INTRINSIC, case insensitive
+# )? : optionally match the ", INTRINSIC/NON_INTRINSIC" grouped expression
+# \s* : any amount of white space
+# :: : match a double colon that must appear after the INTRINSIC/NON_INTRINSIC attribute
+# ) : end the unsaved grouping
+# ) : end the unsaved grouping
+# \s* : match any amount of white space
+# (\w+) : match the module name that is being USE'd
+#
+#
+ use_regex = "(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)"
+
+
+# The INCLUDE statement regex matches the following:
+#
+# INCLUDE 'some_Text'
+# INCLUDE "some_Text"
+# INCLUDE "some_Text" ; INCLUDE "some_Text"
+# INCLUDE kind_"some_Text"
+# INCLUDE kind_'some_Text"
+#
+# where some_Text can include any alphanumeric and/or special character
+# as defined by the Fortran 2003 standard.
+#
+# Limitations:
+#
+# -- The Fortran standard dictates that a " or ' in the INCLUDE'd
+# string must be represented as a "" or '', if the quotes that wrap
+# the entire string are either a ' or ", respectively. While the
+# regular expression below can detect the ' or " characters just fine,
+# the scanning logic, presently is unable to detect them and reduce
+# them to a single instance. This probably isn't an issue since,
+# in practice, ' or " are not generally used in filenames.
+#
+# -- This regex will not properly deal with multiple INCLUDE statements
+# when the entire line has been commented out, ala
+#
+# ! INCLUDE 'some_file' ; INCLUDE 'some_file'
+#
+# In such cases, it will properly ignore the first INCLUDE file,
+# but will actually still pick up the second. Interestingly enough,
+# the regex will properly deal with these cases:
+#
+# INCLUDE 'some_file'
+# INCLUDE 'some_file' !; INCLUDE 'some_file'
+#
+# To get around the above limitation, the FORTRAN programmer could
+# simply comment each INCLUDE statement separately, like this
+#
+# ! INCLUDE 'some_file' !; INCLUDE 'some_file'
+#
+# The way I see it, the only way to get around this limitation would
+# be to modify the scanning logic to replace the calls to re.findall
+# with a custom loop that processes each line separately, throwing
+# away fully commented out lines before attempting to match against
+# the INCLUDE syntax.
+#
+# Here is a breakdown of the regex:
+#
+# (?i) : regex is case insensitive
+# (?: : begin a non-saving group that matches the following:
+# ^ : either the start of the line
+# | : or
+# ['">]\s*; : a semicolon that follows a single quote,
+# double quote or greater than symbol (with any
+# amount of whitespace in between). This will
+# allow the regex to match multiple INCLUDE
+# statements per line (although it also requires
+# the positive lookahead assertion that is
+# used below). It will even properly deal with
+# (i.e. ignore) cases in which the additional
+# INCLUDES are part of an in-line comment, ala
+# " INCLUDE 'someFile' ! ; INCLUDE 'someFile2' "
+# ) : end of non-saving group
+# \s* : any amount of white space
+# INCLUDE : match the string INCLUDE, case insensitive
+# \s+ : match one or more white space characters
+# (?\w+_)? : match the optional "kind-param _" prefix allowed by the standard
+# [<"'] : match the include delimiter - an apostrophe, double quote, or less than symbol
+# (.+?) : match one or more characters that make up
+# the included path and file name and save it
+# in a group. The Fortran standard allows for
+# any non-control character to be used. The dot
+# operator will pick up any character, including
+# control codes, but I can't conceive of anyone
+# putting control codes in their file names.
+# The question mark indicates it is non-greedy so
+# that regex will match only up to the next quote,
+# double quote, or greater than symbol
+# (?=["'>]) : positive lookahead assertion to match the include
+# delimiter - an apostrophe, double quote, or
+# greater than symbol. This level of complexity
+# is required so that the include delimiter is
+# not consumed by the match, thus allowing the
+# sub-regex discussed above to uniquely match a
+# set of semicolon-separated INCLUDE statements
+# (as allowed by the F2003 standard)
+
+ include_regex = """(?i)(?:^|['">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])"""
+
+ scanner = F90Scanner("FortranScan",
+ "$FORTRANSUFFIXES",
+ path_variable,
+ use_regex,
+ include_regex,
+ fs = fs)
+ return scanner
Added: development/support/scons/scons-local-0.96.1/SCons/Scanner/IDL.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Scanner/IDL.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Scanner/IDL.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,43 @@
+"""SCons.Scanner.IDL
+
+This module implements the depenency scanner for IDL (Interface
+Definition Language) files.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Scanner/IDL.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Node.FS
+import SCons.Scanner
+
+def IDLScan(fs = SCons.Node.FS.default_fs):
+ """Return a prototype Scanner instance for scanning IDL source files"""
+ cs = SCons.Scanner.ClassicCPP("IDLScan",
+ "$IDLSUFFIXES",
+ "CPPPATH",
+ '^[ \t]*(?:#[ \t]*include|[ \t]*import)[ \t]+(<|")([^>"]+)(>|")',
+ fs = fs)
+ return cs
Added: development/support/scons/scons-local-0.96.1/SCons/Scanner/Prog.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Scanner/Prog.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Scanner/Prog.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,86 @@
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Scanner/Prog.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import string
+
+import SCons.Node
+import SCons.Node.FS
+import SCons.Scanner
+import SCons.Util
+
+def ProgScan(fs = SCons.Node.FS.default_fs):
+ """Return a prototype Scanner instance for scanning executable
+ files for static-lib dependencies"""
+ pf = SCons.Scanner.FindPathDirs('LIBPATH', fs)
+ ps = SCons.Scanner.Base(scan, "ProgScan", path_function = pf)
+ return ps
+
+def scan(node, env, libpath = (), fs = SCons.Node.FS.default_fs):
+ """
+ This scanner scans program files for static-library
+ dependencies. It will search the LIBPATH environment variable
+ for libraries specified in the LIBS variable, returning any
+ files it finds as dependencies.
+ """
+
+ try:
+ libs = env.Dictionary('LIBS')
+ except KeyError:
+ # There are no LIBS in this environment, so just return a null list:
+ return []
+ if SCons.Util.is_String(libs):
+ libs = string.split(libs)
+ elif not SCons.Util.is_List(libs):
+ libs = [libs]
+
+ try:
+ prefix = env.Dictionary('LIBPREFIXES')
+ if not SCons.Util.is_List(prefix):
+ prefix = [ prefix ]
+ except KeyError:
+ prefix = [ '' ]
+
+ try:
+ suffix = env.Dictionary('LIBSUFFIXES')
+ if not SCons.Util.is_List(suffix):
+ suffix = [ suffix ]
+ except KeyError:
+ suffix = [ '' ]
+
+ find_file = SCons.Node.FS.find_file
+ adjustixes = SCons.Util.adjustixes
+ result = []
+ for suf in map(env.subst, suffix):
+ for pref in map(env.subst, prefix):
+ for lib in libs:
+ if SCons.Util.is_String(lib):
+ lib = env.subst(lib)
+ lib = adjustixes(lib, pref, suf)
+ lib = find_file(lib, libpath, fs.File)
+ if lib:
+ result.append(lib)
+ else:
+ result.append(lib)
+ return result
Added: development/support/scons/scons-local-0.96.1/SCons/Scanner/__init__.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Scanner/__init__.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Scanner/__init__.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,339 @@
+"""SCons.Scanner
+
+The Scanner package for the SCons software construction utility.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Scanner/__init__.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import re
+
+import SCons.Node.FS
+import SCons.Sig
+import SCons.Util
+
+
+class _Null:
+ pass
+
+# This is used instead of None as a default argument value so None can be
+# used as an actual argument value.
+_null = _Null
+
+def Scanner(function, *args, **kw):
+ """Public interface factory function for creating different types
+ of Scanners based on the different types of "functions" that may
+ be supplied."""
+ if SCons.Util.is_Dict(function):
+ return apply(Selector, (function,) + args, kw)
+ else:
+ return apply(Base, (function,) + args, kw)
+
+class FindPathDirs:
+ """A class to bind a specific *PATH variable name and the fs object
+ to a function that will return all of the *path directories."""
+ def __init__(self, variable, fs):
+ self.variable = variable
+ self.fs = fs
+ def __call__(self, env, dir, argument=None):
+ try:
+ path = env[self.variable]
+ except KeyError:
+ return ()
+
+ return tuple(self.fs.Rsearchall(env.subst_path(path),
+ must_exist = 0,
+ clazz = SCons.Node.FS.Dir,
+ cwd = dir))
+
+class Base:
+ """
+ The base class for dependency scanners. This implements
+ straightforward, single-pass scanning of a single file.
+ """
+
+ def __init__(self,
+ function,
+ name = "NONE",
+ argument = _null,
+ skeys = [],
+ path_function = None,
+ node_class = SCons.Node.FS.Entry,
+ node_factory = SCons.Node.FS.default_fs.File,
+ scan_check = None,
+ recursive = None):
+ """
+ Construct a new scanner object given a scanner function.
+
+ 'function' - a scanner function taking two or three
+ arguments and returning a list of strings.
+
+ 'name' - a name for identifying this scanner object.
+
+ 'argument' - an optional argument that, if specified, will be
+ passed to both the scanner function and the path_function.
+
+ 'skeys' - an optional list argument that can be used to determine
+ which scanner should be used for a given Node. In the case of File
+ nodes, for example, the 'skeys' would be file suffixes.
+
+ 'path_function' - a function that takes one to three arguments
+ (a construction environment, optional directory, and optional
+ argument for this instance) and returns a tuple of the
+ directories that can be searched for implicit dependency files.
+
+ 'node_class' - the class of Nodes which this scan will return.
+ If node_class is None, then this scanner will not enforce any
+ Node conversion and will return the raw results from the
+ underlying scanner function.
+
+ 'node_factory' - the factory function to be called to translate
+ the raw results returned by the scanner function into the
+ expected node_class objects.
+
+ 'scan_check' - a function to be called to first check whether
+ this node really needs to be scanned.
+
+ 'recursive' - specifies that this scanner should be invoked
+ recursively on the implicit dependencies it returns (the
+ canonical example being #include lines in C source files).
+
+ The scanner function's first argument will be the name of a file
+ that should be scanned for dependencies, the second argument will
+ be an Environment object, the third argument will be the value
+ passed into 'argument', and the returned list should contain the
+ Nodes for all the direct dependencies of the file.
+
+ Examples:
+
+ s = Scanner(my_scanner_function)
+
+ s = Scanner(function = my_scanner_function)
+
+ s = Scanner(function = my_scanner_function, argument = 'foo')
+
+ """
+
+ # Note: this class could easily work with scanner functions that take
+ # something other than a filename as an argument (e.g. a database
+ # node) and a dependencies list that aren't file names. All that
+ # would need to be changed is the documentation.
+
+ self.function = function
+ self.path_function = path_function
+ self.name = name
+ self.argument = argument
+ self.skeys = skeys
+ self.node_class = node_class
+ self.node_factory = node_factory
+ self.scan_check = scan_check
+ self.recursive = recursive
+
+ def path(self, env, dir = None):
+ if not self.path_function:
+ return ()
+ if not self.argument is _null:
+ return self.path_function(env, dir, self.argument)
+ else:
+ return self.path_function(env, dir)
+
+ def __call__(self, node, env, path = ()):
+ """
+ This method scans a single object. 'node' is the node
+ that will be passed to the scanner function, and 'env' is the
+ environment that will be passed to the scanner function. A list of
+ direct dependency nodes for the specified node will be returned.
+ """
+ if self.scan_check and not self.scan_check(node, env):
+ return []
+
+ if not self.argument is _null:
+ list = self.function(node, env, path, self.argument)
+ else:
+ list = self.function(node, env, path)
+ kw = {}
+ if hasattr(node, 'dir'):
+ kw['directory'] = node.dir
+ nodes = []
+ for l in list:
+ if self.node_class and not isinstance(l, self.node_class):
+ l = apply(self.node_factory, (l,), kw)
+ nodes.append(l)
+ return nodes
+
+ def __cmp__(self, other):
+ return cmp(self.__dict__, other.__dict__)
+
+ def __hash__(self):
+ return hash(repr(self))
+
+ def add_skey(self, skey):
+ """Add a skey to the list of skeys"""
+ self.skeys.append(skey)
+
+ def get_skeys(self, env=None):
+ if SCons.Util.is_String(self.skeys):
+ return env.subst_list(self.skeys)[0]
+ return self.skeys
+
+ def select(self, node):
+ return self
+
+
+class Selector(Base):
+ """
+ A class for selecting a more specific scanner based on the
+ scanner_key() (suffix) for a specific Node.
+ """
+ def __init__(self, dict, *args, **kw):
+ Base.__init__(self, (None,)+args, kw)
+ self.dict = dict
+
+ def __call__(self, node, env, path = ()):
+ return self.select(node)(node, env, path)
+
+ def select(self, node):
+ try:
+ return self.dict[node.scanner_key()]
+ except KeyError:
+ return None
+
+ def add_scanner(self, skey, scanner):
+ self.dict[skey] = scanner
+
+
+class Current(Base):
+ """
+ A class for scanning files that are source files (have no builder)
+ or are derived files and are current (which implies that they exist,
+ either locally or in a repository).
+ """
+
+ def __init__(self, *args, **kw):
+ def current_check(node, env):
+ c = not node.has_builder() or node.current(env.get_calculator())
+ return c
+ kw['scan_check'] = current_check
+ apply(Base.__init__, (self,) + args, kw)
+
+class Classic(Current):
+ """
+ A Scanner subclass to contain the common logic for classic CPP-style
+ include scanning, but which can be customized to use different
+ regular expressions to find the includes.
+
+ Note that in order for this to work "out of the box" (without
+ overriding the find_include() method), the regular expression passed
+ to the constructor must return the name of the include file in group
+ 0.
+ """
+
+ def __init__(self, name, suffixes, path_variable, regex,
+ fs=SCons.Node.FS.default_fs, *args, **kw):
+
+ self.cre = re.compile(regex, re.M)
+ self.fs = fs
+
+ def _scan(node, env, path, self=self, fs=fs):
+ return self.scan(node, env, path)
+
+ kw['function'] = _scan
+ kw['path_function'] = FindPathDirs(path_variable, fs)
+ kw['recursive'] = 1
+ kw['skeys'] = suffixes
+ kw['name'] = name
+
+ apply(Current.__init__, (self,) + args, kw)
+
+ def find_include(self, include, source_dir, path):
+ n = SCons.Node.FS.find_file(include, (source_dir,) + path, self.fs.File)
+ return n, include
+
+ def scan(self, node, env, path=()):
+ node = node.rfile()
+
+ if not node.exists():
+ return []
+
+ # cache the includes list in node so we only scan it once:
+ if node.includes != None:
+ includes = node.includes
+ else:
+ includes = self.cre.findall(node.get_contents())
+ node.includes = includes
+
+ nodes = []
+ source_dir = node.get_dir()
+ for include in includes:
+ n, i = self.find_include(include, source_dir, path)
+
+ if not n is None:
+ nodes.append(n)
+ else:
+ SCons.Warnings.warn(SCons.Warnings.DependencyWarning,
+ "No dependency generated for file: %s (included from: %s) -- file not found" % (i, node))
+
+ # Schwartzian transform from the Python FAQ Wizard
+ def st(List, Metric):
+ def pairing(element, M = Metric):
+ return (M(element), element)
+ def stripit(pair):
+ return pair[1]
+ paired = map(pairing, List)
+ paired.sort()
+ return map(stripit, paired)
+
+ def normalize(node):
+ # We don't want the order of includes to be
+ # modified by case changes on case insensitive OSes, so
+ # normalize the case of the filename here:
+ # (see test/win32pathmadness.py for a test of this)
+ return SCons.Node.FS._my_normcase(str(node))
+
+ transformed = st(nodes, normalize)
+ # print "Classic: " + str(node) + " => " + str(map(lambda x: str(x),list(transformed)))
+ return transformed
+
+class ClassicCPP(Classic):
+ """
+ A Classic Scanner subclass which takes into account the type of
+ bracketing used to include the file, and uses classic CPP rules
+ for searching for the files based on the bracketing.
+
+ Note that in order for this to work, the regular expression passed
+ to the constructor must return the leading bracket in group 0, and
+ the contained filename in group 1.
+ """
+ def find_include(self, include, source_dir, path):
+ if include[0] == '"':
+ n = SCons.Node.FS.find_file(include[1],
+ (source_dir,) + path,
+ self.fs.File)
+ else:
+ n = SCons.Node.FS.find_file(include[1],
+ path + (source_dir,),
+ self.fs.File)
+ return n, include[1]
Added: development/support/scons/scons-local-0.96.1/SCons/Script/SConscript.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Script/SConscript.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Script/SConscript.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,717 @@
+"""SCons.Script.SConscript
+
+This module defines the Python API provided to SConscript and SConstruct
+files.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Script/SConscript.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons
+import SCons.Action
+import SCons.Builder
+import SCons.Defaults
+import SCons.Environment
+import SCons.Errors
+import SCons.Node
+import SCons.Node.Alias
+import SCons.Node.FS
+import SCons.Options
+import SCons.Platform
+import SCons.SConf
+import SCons.Script
+import SCons.Tool
+import SCons.Util
+
+import os
+import os.path
+import re
+import string
+import sys
+import traceback
+import types
+import UserList
+
+launch_dir = os.path.abspath(os.curdir)
+
+def do_nothing(text): pass
+HelpFunction = do_nothing
+
+Arguments = {}
+ArgList = []
+CommandLineTargets = []
+DefaultCalled = None
+DefaultTargets = []
+GlobalDict = {}
+
+class TargetList(UserList.UserList):
+ def _do_nothing(self, *args, **kw):
+ pass
+ def _add_Default(self, list):
+ self.extend(list)
+ def _clear(self):
+ del self[:]
+BuildTargets = TargetList()
+
+# global exports set by Export():
+global_exports = {}
+
+# chdir flag
+sconscript_chdir = 1
+
+# will be set to 1, if we are reading a SConscript
+sconscript_reading = 0
+
+def _scons_add_args(alist):
+ for arg in alist:
+ a, b = string.split(arg, '=', 1)
+ Arguments[a] = b
+ ArgList.append((a, b))
+
+def _scons_add_targets(tlist):
+ if tlist:
+ CommandLineTargets.extend(tlist)
+ BuildTargets.extend(tlist)
+ BuildTargets._add_Default = BuildTargets._do_nothing
+ BuildTargets._clear = BuildTargets._do_nothing
+
+def get_calling_namespaces():
+ """Return the locals and globals for the function that called
+ into this module in the current callstack."""
+ try: 1/0
+ except ZeroDivisionError: frame = sys.exc_info()[2].tb_frame
+
+ while frame.f_globals.get("__name__") == __name__: frame = frame.f_back
+
+ return frame.f_locals, frame.f_globals
+
+
+def compute_exports(exports):
+ """Compute a dictionary of exports given one of the parameters
+ to the Export() function or the exports argument to SConscript()."""
+
+ loc, glob = get_calling_namespaces()
+
+ retval = {}
+ try:
+ for export in exports:
+ if SCons.Util.is_Dict(export):
+ retval.update(export)
+ else:
+ try:
+ retval[export] = loc[export]
+ except KeyError:
+ retval[export] = glob[export]
+ except KeyError, x:
+ raise SCons.Errors.UserError, "Export of non-existent variable '%s'"%x
+
+ return retval
+
+
+class Frame:
+ """A frame on the SConstruct/SConscript call stack"""
+ def __init__(self, exports, sconscript):
+ self.globals = BuildDefaultGlobals()
+ self.retval = None
+ self.prev_dir = SCons.Node.FS.default_fs.getcwd()
+ self.exports = compute_exports(exports) # exports from the calling SConscript
+ # make sure the sconscript attr is a Node.
+ if isinstance(sconscript, SCons.Node.Node):
+ self.sconscript = sconscript
+ else:
+ self.sconscript = SCons.Node.FS.default_fs.File(str(sconscript))
+
+# the SConstruct/SConscript call stack:
+stack = []
+
+# For documentation on the methods in this file, see the scons man-page
+
+def Return(*vars):
+ retval = []
+ try:
+ for var in vars:
+ for v in string.split(var):
+ retval.append(stack[-1].globals[v])
+ except KeyError, x:
+ raise SCons.Errors.UserError, "Return of non-existent variable '%s'"%x
+
+ if len(retval) == 1:
+ stack[-1].retval = retval[0]
+ else:
+ stack[-1].retval = tuple(retval)
+
+def _SConscript(fs, *files, **kw):
+ top = fs.Top
+ sd = fs.SConstruct_dir.rdir()
+ exports = kw.get('exports', [])
+
+ # evaluate each SConscript file
+ results = []
+ for fn in files:
+ stack.append(Frame(exports,fn))
+ old_sys_path = sys.path
+ try:
+ global sconscript_reading
+ sconscript_reading = 1
+ if fn == "-":
+ exec sys.stdin in stack[-1].globals
+ else:
+ if isinstance(fn, SCons.Node.Node):
+ f = fn
+ else:
+ f = fs.File(str(fn))
+ _file_ = None
+
+ # Change directory to the top of the source
+ # tree to make sure the os's cwd and the cwd of
+ # fs match so we can open the SConscript.
+ fs.chdir(top, change_os_dir=1)
+ if f.rexists():
+ _file_ = open(f.rstr(), "r")
+ elif f.has_src_builder():
+ # The SConscript file apparently exists in a source
+ # code management system. Build it, but then clear
+ # the builder so that it doesn't get built *again*
+ # during the actual build phase.
+ f.build()
+ f.builder_set(None)
+ s = str(f)
+ if os.path.exists(s):
+ _file_ = open(s, "r")
+ if _file_:
+ # Chdir to the SConscript directory. Use a path
+ # name relative to the SConstruct file so that if
+ # we're using the -f option, we're essentially
+ # creating a parallel SConscript directory structure
+ # in our local directory tree.
+ #
+ # XXX This is broken for multiple-repository cases
+ # where the SConstruct and SConscript files might be
+ # in different Repositories. For now, cross that
+ # bridge when someone comes to it.
+ ldir = fs.Dir(f.dir.get_path(sd))
+ try:
+ fs.chdir(ldir, change_os_dir=sconscript_chdir)
+ except OSError:
+ # There was no local directory, so we should be
+ # able to chdir to the Repository directory.
+ # Note that we do this directly, not through
+ # fs.chdir(), because we still need to
+ # interpret the stuff within the SConscript file
+ # relative to where we are logically.
+ fs.chdir(ldir, change_os_dir=0)
+ os.chdir(f.rfile().dir.get_abspath())
+
+ # Append the SConscript directory to the beginning
+ # of sys.path so Python modules in the SConscript
+ # directory can be easily imported.
+ sys.path = [ f.dir.get_abspath() ] + sys.path
+
+ # This is the magic line that actually reads up and
+ # executes the stuff in the SConscript file. We
+ # look for the "exec _file_ " from the beginning
+ # of this line to find the right stack frame (the
+ # next one) describing the SConscript file and line
+ # number that creates a node.
+ exec _file_ in stack[-1].globals
+ else:
+ SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning,
+ "Ignoring missing SConscript '%s'" % f.path)
+
+ finally:
+ sconscript_reading = 0
+ sys.path = old_sys_path
+ frame = stack.pop()
+ try:
+ fs.chdir(frame.prev_dir, change_os_dir=sconscript_chdir)
+ except OSError:
+ # There was no local directory, so chdir to the
+ # Repository directory. Like above, we do this
+ # directly.
+ fs.chdir(frame.prev_dir, change_os_dir=0)
+ os.chdir(frame.prev_dir.rdir().get_abspath())
+
+ results.append(frame.retval)
+
+ # if we only have one script, don't return a tuple
+ if len(results) == 1:
+ return results[0]
+ else:
+ return tuple(results)
+
+def is_our_exec_statement(line):
+ return not line is None and line[:12] == "exec _file_ "
+
+def SConscript_exception(file=sys.stderr):
+ """Print an exception stack trace just for the SConscript file(s).
+ This will show users who have Python errors where the problem is,
+ without cluttering the output with all of the internal calls leading
+ up to where we exec the SConscript."""
+ exc_type, exc_value, exc_tb = sys.exc_info()
+ stack = traceback.extract_tb(exc_tb)
+ last_text = ""
+ found = 0
+ i = 0
+ for frame in stack:
+ if is_our_exec_statement(last_text):
+ found = 1
+ break
+ i = i + 1
+ last_text = frame[3]
+ if not found:
+ # We did not find our exec statement, so this was actually a bug
+ # in SCons itself. Show the whole stack.
+ i = 0
+ type = str(exc_type)
+ if type[:11] == "exceptions.":
+ type = type[11:]
+ file.write('%s: %s:\n' % (type, exc_value))
+ for fname, line, func, text in stack[i:]:
+ file.write(' File "%s", line %d:\n' % (fname, line))
+ file.write(' %s\n' % text)
+
+def annotate(node):
+ """Annotate a node with the stack frame describing the
+ SConscript file and line number that created it."""
+ stack = traceback.extract_stack()
+ last_text = ""
+ for frame in stack:
+ # If the script text of the previous frame begins with the
+ # magic "exec _file_ " string, then this frame describes the
+ # SConscript file and line number that caused this node to be
+ # created. Record the tuple and carry on.
+ if is_our_exec_statement(last_text):
+ node.creator = frame
+ return
+ last_text = frame[3]
+
+# The following line would cause each Node to be annotated using the
+# above function. Unfortunately, this is a *huge* performance hit, so
+# leave this disabled until we find a more efficient mechanism.
+#SCons.Node.Annotate = annotate
+
+class SConsEnvironment(SCons.Environment.Base):
+ """An Environment subclass that contains all of the methods that
+ are particular to the wrapper SCons interface and which aren't
+ (or shouldn't be) part of the build engine itself.
+
+ Note that not all of the methods of this class have corresponding
+ global functions, there are some private methods.
+ """
+
+ #
+ # Private methods of an SConsEnvironment.
+ #
+ def _exceeds_version(self, major, minor, v_major, v_minor):
+ """Return 1 if 'major' and 'minor' are greater than the version
+ in 'v_major' and 'v_minor', and 0 otherwise."""
+ return (major > v_major or (major == v_major and minor > v_minor))
+
+ def _get_major_minor(self, version_string):
+ """Split a version string into major and minor parts. This
+ is complicated by the fact that a version string can be something
+ like 3.2b1."""
+ version = string.split(string.split(version_string, ' ')[0], '.')
+ v_major = int(version[0])
+ v_minor = int(re.match('\d+', version[1]).group())
+ return v_major, v_minor
+
+ def _get_SConscript_filenames(self, ls, kw):
+ """
+ Convert the parameters passed to # SConscript() calls into a list
+ of files and export variables. If the parameters are invalid,
+ throws SCons.Errors.UserError. Returns a tuple (l, e) where l
+ is a list of SConscript filenames and e is a list of exports.
+ """
+ exports = []
+
+ if len(ls) == 0:
+ try:
+ dirs = kw["dirs"]
+ except KeyError:
+ raise SCons.Errors.UserError, \
+ "Invalid SConscript usage - no parameters"
+
+ if not SCons.Util.is_List(dirs):
+ dirs = [ dirs ]
+ dirs = map(str, dirs)
+
+ name = kw.get('name', 'SConscript')
+
+ files = map(lambda n, name = name: os.path.join(n, name), dirs)
+
+ elif len(ls) == 1:
+
+ files = ls[0]
+
+ elif len(ls) == 2:
+
+ files = ls[0]
+ exports = self.Split(ls[1])
+
+ else:
+
+ raise SCons.Errors.UserError, \
+ "Invalid SConscript() usage - too many arguments"
+
+ if not SCons.Util.is_List(files):
+ files = [ files ]
+
+ if kw.get('exports'):
+ exports.extend(self.Split(kw['exports']))
+
+ build_dir = kw.get('build_dir')
+ if build_dir:
+ if len(files) != 1:
+ raise SCons.Errors.UserError, \
+ "Invalid SConscript() usage - can only specify one SConscript with a build_dir"
+ duplicate = kw.get('duplicate', 1)
+ src_dir = kw.get('src_dir')
+ if not src_dir:
+ src_dir, fname = os.path.split(str(files[0]))
+ else:
+ if not isinstance(src_dir, SCons.Node.Node):
+ src_dir = self.fs.Dir(src_dir)
+ fn = files[0]
+ if not isinstance(fn, SCons.Node.Node):
+ fn = self.fs.File(fn)
+ if fn.is_under(src_dir):
+ # Get path relative to the source directory.
+ fname = fn.get_path(src_dir)
+ else:
+ # Fast way to only get the terminal path component of a Node.
+ fname = fn.get_path(fn.dir)
+ self.fs.BuildDir(build_dir, src_dir, duplicate)
+ files = [os.path.join(str(build_dir), fname)]
+
+ return (files, exports)
+
+ #
+ # Public methods of an SConsEnvironment. These get
+ # entry points in the global name space so they can be called
+ # as global functions.
+ #
+
+ def Default(self, *targets):
+ global DefaultCalled
+ global DefaultTargets
+ DefaultCalled = 1
+ for t in targets:
+ if t is None:
+ # Delete the elements from the list in-place, don't
+ # reassign an empty list to DefaultTargets, so that the
+ # DEFAULT_TARGETS variable will still point to the
+ # same object we point to.
+ del DefaultTargets[:]
+ BuildTargets._clear()
+ elif isinstance(t, SCons.Node.Node):
+ DefaultTargets.append(t)
+ BuildTargets._add_Default([t])
+ else:
+ nodes = self.arg2nodes(t, self.fs.Entry)
+ DefaultTargets.extend(nodes)
+ BuildTargets._add_Default(nodes)
+
+ def EnsureSConsVersion(self, major, minor):
+ """Exit abnormally if the SCons version is not late enough."""
+ v_major, v_minor = self._get_major_minor(SCons.__version__)
+ if self._exceeds_version(major, minor, v_major, v_minor):
+ print "SCons %d.%d or greater required, but you have SCons %s" %(major,minor,SCons.__version__)
+ sys.exit(2)
+
+ def EnsurePythonVersion(self, major, minor):
+ """Exit abnormally if the Python version is not late enough."""
+ try:
+ v_major, v_minor, v_micro, release, serial = sys.version_info
+ except AttributeError:
+ v_major, v_minor = self._get_major_minor(sys.version)
+ if self._exceeds_version(major, minor, v_major, v_minor):
+ v = string.split(sys.version, " ", 1)[0]
+ print "Python %d.%d or greater required, but you have Python %s" %(major,minor,v)
+ sys.exit(2)
+
+ def Exit(self, value=0):
+ sys.exit(value)
+
+ def Export(self, *vars):
+ for var in vars:
+ global_exports.update(compute_exports(self.Split(var)))
+
+ def GetLaunchDir(self):
+ global launch_dir
+ return launch_dir
+
+ def GetOption(self, name):
+ name = self.subst(name)
+ return SCons.Script.ssoptions.get(name)
+
+ def Help(self, text):
+ text = self.subst(text, raw=1)
+ HelpFunction(text)
+
+ def Import(self, *vars):
+ try:
+ for var in vars:
+ var = self.Split(var)
+ for v in var:
+ if v == '*':
+ stack[-1].globals.update(global_exports)
+ stack[-1].globals.update(stack[-1].exports)
+ else:
+ if stack[-1].exports.has_key(v):
+ stack[-1].globals[v] = stack[-1].exports[v]
+ else:
+ stack[-1].globals[v] = global_exports[v]
+ except KeyError,x:
+ raise SCons.Errors.UserError, "Import of non-existent variable '%s'"%x
+
+ def SConscript(self, *ls, **kw):
+ ls = map(lambda l, self=self: self.subst(l), ls)
+ subst_kw = {}
+ for key, val in kw.items():
+ if SCons.Util.is_String(val):
+ val = self.subst(val)
+ elif SCons.Util.is_List(val):
+ result = []
+ for v in val:
+ if SCons.Util.is_String(v):
+ v = self.subst(v)
+ result.append(v)
+ val = result
+ subst_kw[key] = val
+
+ files, exports = self._get_SConscript_filenames(ls, subst_kw)
+
+ return apply(_SConscript, [self.fs,] + files, {'exports' : exports})
+
+ def SConscriptChdir(self, flag):
+ global sconscript_chdir
+ sconscript_chdir = flag
+
+ def SetOption(self, name, value):
+ name = self.subst(name)
+ SCons.Script.ssoptions.set(name, value)
+
+#
+#
+#
+SCons.Environment.Environment = SConsEnvironment
+
+def Options(files=None, args=Arguments):
+ return SCons.Options.Options(files, args)
+
+def SetBuildSignatureType(type):
+ SCons.Warnings.warn(SCons.Warnings.DeprecatedWarning,
+ "The SetBuildSignatureType() function has been deprecated;\n" +\
+ "\tuse the TargetSignatures() function instead.")
+ SCons.Defaults.DefaultEnvironment().TargetSignatures(type)
+
+def SetContentSignatureType(type):
+ SCons.Warnings.warn(SCons.Warnings.DeprecatedWarning,
+ "The SetContentSignatureType() function has been deprecated;\n" +\
+ "\tuse the SourceSignatures() function instead.")
+ SCons.Defaults.DefaultEnvironment().SourceSignatures(type)
+
+def GetJobs():
+ SCons.Warnings.warn(SCons.Warnings.DeprecatedWarning,
+ "The GetJobs() function has been deprecated;\n" +\
+ "\tuse GetOption('num_jobs') instead.")
+
+ return GetOption('num_jobs')
+
+def SetJobs(num):
+ SCons.Warnings.warn(SCons.Warnings.DeprecatedWarning,
+ "The SetJobs() function has been deprecated;\n" +\
+ "\tuse SetOption('num_jobs', num) instead.")
+ SetOption('num_jobs', num)
+
+def ParseConfig(env, command, function=None):
+ SCons.Warnings.warn(SCons.Warnings.DeprecatedWarning,
+ "The ParseConfig() function has been deprecated;\n" +\
+ "\tuse the env.ParseConfig() method instead.")
+ return env.ParseConfig(command, function)
+
+#
+_DefaultEnvironmentProxy = None
+
+def get_DefaultEnvironmentProxy():
+ global _DefaultEnvironmentProxy
+ if not _DefaultEnvironmentProxy:
+ default_env = SCons.Defaults.DefaultEnvironment()
+ _DefaultEnvironmentProxy = SCons.Environment.NoSubstitutionProxy(default_env)
+ return _DefaultEnvironmentProxy
+
+class DefaultEnvironmentCall:
+ """A class that implements "global function" calls of
+ Environment methods by fetching the specified method from the
+ DefaultEnvironment's class. Note that this uses an intermediate
+ proxy class instead of calling the DefaultEnvironment method
+ directly so that the proxy can override the subst() method and
+ thereby prevent expansion of construction variables (since from
+ the user's point of view this was called as a global function,
+ with no associated construction environment)."""
+ def __init__(self, method_name):
+ self.method_name = method_name
+ def __call__(self, *args, **kw):
+ proxy = get_DefaultEnvironmentProxy()
+ method = getattr(proxy, self.method_name)
+ return apply(method, args, kw)
+
+# The list of global functions to add to the SConscript name space
+# that end up calling corresponding methods or Builders in the
+# DefaultEnvironment().
+GlobalDefaultEnvironmentFunctions = [
+ # Methods from the SConsEnvironment class, above.
+ 'Default',
+ 'EnsurePythonVersion',
+ 'EnsureSConsVersion',
+ 'Exit',
+ 'Export',
+ 'GetLaunchDir',
+ 'GetOption',
+ 'Help',
+ 'Import',
+ 'SConscript',
+ 'SConscriptChdir',
+ 'SetOption',
+
+ # Methods from the Environment.Base class.
+ 'AddPostAction',
+ 'AddPreAction',
+ 'Alias',
+ 'AlwaysBuild',
+ 'BuildDir',
+ 'CacheDir',
+ 'Clean',
+ 'Command',
+ 'Depends',
+ 'Dir',
+ 'Execute',
+ 'File',
+ 'FindFile',
+ 'Flatten',
+ 'GetBuildPath',
+ 'Ignore',
+ 'Install',
+ 'InstallAs',
+ 'Literal',
+ 'Local',
+ 'Precious',
+ 'Repository',
+ 'SConsignFile',
+ 'SideEffect',
+ 'SourceCode',
+ 'SourceSignatures',
+ 'Split',
+ 'TargetSignatures',
+ 'Value',
+]
+
+GlobalDefaultBuilders = [
+ # Supported builders.
+ 'CFile',
+ 'CXXFile',
+ 'DVI',
+ 'Jar',
+ 'Java',
+ 'JavaH',
+ 'Library',
+ 'M4',
+ 'MSVSProject',
+ 'Object',
+ 'PCH',
+ 'PDF',
+ 'PostScript',
+ 'Program',
+ 'RES',
+ 'RMIC',
+ 'SharedLibrary',
+ 'SharedObject',
+ 'StaticLibrary',
+ 'StaticObject',
+ 'Tar',
+ 'TypeLibrary',
+ 'Zip',
+]
+
+for name in GlobalDefaultEnvironmentFunctions + GlobalDefaultBuilders:
+ GlobalDict[name] = DefaultEnvironmentCall(name)
+
+def BuildDefaultGlobals():
+ """
+ Create a dictionary containing all the default globals for
+ SConstruct and SConscript files.
+ """
+
+ globals = {
+ # Global functions that don't get executed through the
+ # default Environment.
+ 'Action' : SCons.Action.Action,
+ 'BoolOption' : SCons.Options.BoolOption,
+ 'Builder' : SCons.Builder.Builder,
+ 'Configure' : SCons.SConf.SConf,
+ 'EnumOption' : SCons.Options.EnumOption,
+ 'Environment' : SCons.Environment.Environment,
+ 'ListOption' : SCons.Options.ListOption,
+ 'Options' : Options,
+ 'PackageOption' : SCons.Options.PackageOption,
+ 'PathOption' : SCons.Options.PathOption,
+ 'Platform' : SCons.Platform.Platform,
+ 'Return' : Return,
+ 'Scanner' : SCons.Scanner.Base,
+ 'Tool' : SCons.Tool.Tool,
+ 'WhereIs' : SCons.Util.WhereIs,
+
+ # Action factories.
+ 'Chmod' : SCons.Defaults.Chmod,
+ 'Copy' : SCons.Defaults.Copy,
+ 'Delete' : SCons.Defaults.Delete,
+ 'Mkdir' : SCons.Defaults.Mkdir,
+ 'Move' : SCons.Defaults.Move,
+ 'Touch' : SCons.Defaults.Touch,
+
+ # Other variables we provide.
+ 'ARGUMENTS' : Arguments,
+ 'ARGLIST' : ArgList,
+ 'BUILD_TARGETS' : BuildTargets,
+ 'COMMAND_LINE_TARGETS' : CommandLineTargets,
+ 'DEFAULT_TARGETS' : DefaultTargets,
+ }
+
+ # Functions we might still convert to Environment methods.
+ globals['CScan'] = SCons.Defaults.CScan
+ globals['DefaultEnvironment'] = SCons.Defaults.DefaultEnvironment
+
+ # Deprecated functions, leave these here for now.
+ globals['GetJobs'] = GetJobs
+ globals['ParseConfig'] = ParseConfig
+ globals['SetBuildSignatureType'] = SetBuildSignatureType
+ globals['SetContentSignatureType'] = SetContentSignatureType
+ globals['SetJobs'] = SetJobs
+
+ globals.update(GlobalDict)
+
+ return globals
Added: development/support/scons/scons-local-0.96.1/SCons/Script/__init__.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Script/__init__.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Script/__init__.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,1133 @@
+"""SCons.Script
+
+This file implements the main() function used by the scons script.
+
+Architecturally, this *is* the scons script, and will likely only be
+called from the external "scons" wrapper. Consequently, anything here
+should not be, or be considered, part of the build engine. If it's
+something that we expect other software to want to use, it should go in
+some other module. If it's specific to the "scons" script invocation,
+it goes here.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Script/__init__.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import time
+start_time = time.time()
+
+import os
+import os.path
+import random
+import string
+import sys
+import traceback
+
+# Strip the script directory from sys.path() so on case-insensitive
+# (WIN32) systems Python doesn't think that the "scons" script is the
+# "SCons" package. Replace it with our own version directory so, if
+# if they're there, we pick up the right version of the build engine
+# modules.
+#sys.path = [os.path.join(sys.prefix,
+# 'lib',
+# 'scons-%d' % SCons.__version__)] + sys.path[1:]
+
+import SCons.Debug
+import SCons.Defaults
+import SCons.Environment
+import SCons.Errors
+import SCons.Job
+import SCons.Node
+import SCons.Node.FS
+from SCons.Optik import OptionParser, SUPPRESS_HELP, OptionValueError
+import SCons.Script.SConscript
+import SCons.Sig
+import SCons.Taskmaster
+import SCons.Util
+import SCons.Warnings
+
+#
+import __builtin__
+try:
+ __builtin__.zip
+except AttributeError:
+ def zip(l1, l2):
+ result = []
+ for i in xrange(len(l1)):
+ result.append((l1[i], l2[i]))
+ return result
+ __builtin__.zip = zip
+
+#
+display = SCons.Util.display
+progress_display = SCons.Util.DisplayEngine()
+
+# Task control.
+#
+class BuildTask(SCons.Taskmaster.Task):
+ """An SCons build task."""
+ def display(self, message):
+ display('scons: ' + message)
+
+ def execute(self):
+ target = self.targets[0]
+ if target.get_state() == SCons.Node.up_to_date:
+ if self.top and target.has_builder():
+ display("scons: `%s' is up to date." % str(self.node))
+ elif target.has_builder() and not hasattr(target.builder, 'status'):
+ if print_time:
+ start_time = time.time()
+ SCons.Taskmaster.Task.execute(self)
+ if print_time:
+ finish_time = time.time()
+ global command_time
+ command_time = command_time+finish_time-start_time
+ print "Command execution time: %f seconds"%(finish_time-start_time)
+
+ def do_failed(self, status=2):
+ global exit_status
+ if ignore_errors:
+ SCons.Taskmaster.Task.executed(self)
+ elif keep_going_on_error:
+ SCons.Taskmaster.Task.fail_continue(self)
+ exit_status = status
+ else:
+ SCons.Taskmaster.Task.fail_stop(self)
+ exit_status = status
+
+ def executed(self):
+ t = self.targets[0]
+ if self.top and not t.has_builder() and not t.side_effect:
+ if not t.exists():
+ sys.stderr.write("scons: *** Do not know how to make target `%s'." % t)
+ if not keep_going_on_error:
+ sys.stderr.write(" Stop.")
+ sys.stderr.write("\n")
+ self.do_failed()
+ else:
+ print "scons: Nothing to be done for `%s'." % t
+ SCons.Taskmaster.Task.executed(self)
+ else:
+ SCons.Taskmaster.Task.executed(self)
+
+ # print the tree here instead of in execute() because
+ # this method is serialized, but execute isn't:
+ if print_tree and self.top:
+ print
+ print SCons.Util.render_tree(self.targets[0], get_all_children)
+ if print_dtree and self.top:
+ print
+ print SCons.Util.render_tree(self.targets[0], get_derived_children)
+ if print_includes and self.top:
+ t = self.targets[0]
+ tree = t.render_include_tree()
+ if tree:
+ print
+ print tree
+
+ def failed(self):
+ # Handle the failure of a build task. The primary purpose here
+ # is to display the various types of Errors and Exceptions
+ # appropriately.
+ status = 2
+ t, e = self.exc_info()[:2]
+ tb = None
+ if t is None:
+ # The Taskmaster didn't record an exception for this Task;
+ # see if the sys module has one.
+ t, e = sys.exc_info()[:2]
+
+ if t == SCons.Errors.BuildError:
+ sys.stderr.write("scons: *** [%s] %s\n" % (e.node, e.errstr))
+ if e.errstr == 'Exception':
+ traceback.print_exception(e.args[0], e.args[1], e.args[2])
+ elif t == SCons.Errors.ExplicitExit:
+ status = e.status
+ sys.stderr.write("scons: *** [%s] Explicit exit, status %s\n" % (e.node, e.status))
+ else:
+ if e is None:
+ e = t
+ s = str(e)
+ if t == SCons.Errors.StopError and not keep_going_on_error:
+ s = s + ' Stop.'
+ sys.stderr.write("scons: *** %s\n" % s)
+
+ if tb:
+ sys.stderr.write("scons: internal stack trace:\n")
+ traceback.print_tb(tb, file=sys.stderr)
+
+ self.do_failed(status)
+
+ self.exc_clear()
+
+ def make_ready(self):
+ """Make a task ready for execution"""
+ SCons.Taskmaster.Task.make_ready(self)
+ if self.out_of_date and print_explanations:
+ explanation = self.out_of_date[0].explain()
+ if explanation:
+ sys.stdout.write("scons: " + explanation)
+
+class CleanTask(SCons.Taskmaster.Task):
+ """An SCons clean task."""
+ def show(self):
+ if (self.targets[0].has_builder() or self.targets[0].side_effect) \
+ and not os.path.isdir(str(self.targets[0])):
+ display("Removed " + str(self.targets[0]))
+ if SCons.Environment.CleanTargets.has_key(self.targets[0]):
+ files = SCons.Environment.CleanTargets[self.targets[0]]
+ for f in files:
+ SCons.Util.fs_delete(str(f), 0)
+
+ def remove(self):
+ if self.targets[0].has_builder() or self.targets[0].side_effect:
+ for t in self.targets:
+ try:
+ removed = t.remove()
+ except OSError, e:
+ print "scons: Could not remove '%s':" % str(t), e.strerror
+ else:
+ if removed:
+ display("Removed " + str(t))
+ if SCons.Environment.CleanTargets.has_key(self.targets[0]):
+ files = SCons.Environment.CleanTargets[self.targets[0]]
+ for f in files:
+ SCons.Util.fs_delete(str(f))
+
+ execute = remove
+
+ # Have the taskmaster arrange to "execute" all of the targets, because
+ # we'll figure out ourselves (in remove() or show() above) whether
+ # anything really needs to be done.
+ make_ready = SCons.Taskmaster.Task.make_ready_all
+
+ def prepare(self):
+ pass
+
+class QuestionTask(SCons.Taskmaster.Task):
+ """An SCons task for the -q (question) option."""
+ def prepare(self):
+ pass
+
+ def execute(self):
+ if self.targets[0].get_state() != SCons.Node.up_to_date:
+ global exit_status
+ exit_status = 1
+ self.tm.stop()
+
+ def executed(self):
+ pass
+
+# Global variables
+
+keep_going_on_error = 0
+print_count = 0
+print_dtree = 0
+print_explanations = 0
+print_includes = 0
+print_objects = 0
+print_time = 0
+print_tree = 0
+memory_stats = None
+ignore_errors = 0
+sconscript_time = 0
+command_time = 0
+exit_status = 0 # exit status, assume success by default
+profiling = 0
+repositories = []
+num_jobs = 1 # this is modifed by SConscript.SetJobs()
+
+# Exceptions for this module
+class PrintHelp(Exception):
+ pass
+
+# utility functions
+
+def get_all_children(node): return node.all_children(None)
+
+def get_derived_children(node):
+ children = node.all_children(None)
+ return filter(lambda x: x.has_builder(), children)
+
+def _scons_syntax_error(e):
+ """Handle syntax errors. Print out a message and show where the error
+ occurred.
+ """
+ etype, value, tb = sys.exc_info()
+ lines = traceback.format_exception_only(etype, value)
+ for line in lines:
+ sys.stderr.write(line+'\n')
+ sys.exit(2)
+
+def find_deepest_user_frame(tb):
+ """
+ Find the deepest stack frame that is not part of SCons.
+
+ Input is a "pre-processed" stack trace in the form
+ returned by traceback.extract_tb() or traceback.extract_stack()
+ """
+
+ tb.reverse()
+
+ # find the deepest traceback frame that is not part
+ # of SCons:
+ for frame in tb:
+ filename = frame[0]
+ if string.find(filename, os.sep+'SCons'+os.sep) == -1:
+ return frame
+ return tb[0]
+
+def _scons_user_error(e):
+ """Handle user errors. Print out a message and a description of the
+ error, along with the line number and routine where it occured.
+ The file and line number will be the deepest stack frame that is
+ not part of SCons itself.
+ """
+ etype, value, tb = sys.exc_info()
+ filename, lineno, routine, dummy = find_deepest_user_frame(traceback.extract_tb(tb))
+ sys.stderr.write("\nscons: *** %s\n" % value)
+ sys.stderr.write('File "%s", line %d, in %s\n' % (filename, lineno, routine))
+ sys.exit(2)
+
+def _scons_user_warning(e):
+ """Handle user warnings. Print out a message and a description of
+ the warning, along with the line number and routine where it occured.
+ The file and line number will be the deepest stack frame that is
+ not part of SCons itself.
+ """
+ etype, value, tb = sys.exc_info()
+ filename, lineno, routine, dummy = find_deepest_user_frame(traceback.extract_tb(tb))
+ sys.stderr.write("\nscons: warning: %s\n" % e)
+ sys.stderr.write('File "%s", line %d, in %s\n' % (filename, lineno, routine))
+
+def _scons_internal_warning(e):
+ """Slightly different from _scons_user_warning in that we use the
+ *current call stack* rather than sys.exc_info() to get our stack trace.
+ This is used by the warnings framework to print warnings."""
+ filename, lineno, routine, dummy = find_deepest_user_frame(traceback.extract_stack())
+ sys.stderr.write("\nscons: warning: %s\n" % e[0])
+ sys.stderr.write('File "%s", line %d, in %s\n' % (filename, lineno, routine))
+
+def _scons_internal_error():
+ """Handle all errors but user errors. Print out a message telling
+ the user what to do in this case and print a normal trace.
+ """
+ print 'internal error'
+ traceback.print_exc()
+ sys.exit(2)
+
+def _varargs(option, parser):
+ value = None
+ if parser.rargs:
+ arg = parser.rargs[0]
+ if arg[0] != "-":
+ value = arg
+ del parser.rargs[0]
+ return value
+
+def _setup_warn(arg):
+ """The --warn option. An argument to this option
+ should be of the form <warning-class> or no-<warning-class>.
+ The warning class is munged in order to get an actual class
+ name from the SCons.Warnings module to enable or disable.
+ The supplied <warning-class> is split on hyphens, each element
+ is captialized, then smushed back together. Then the string
+ "SCons.Warnings." is added to the front and "Warning" is added
+ to the back to get the fully qualified class name.
+
+ For example, --warn=deprecated will enable the
+ SCons.Warnings.DeprecatedWarning class.
+
+ --warn=no-dependency will disable the
+ SCons.Warnings.DependencyWarning class.
+
+ As a special case, --warn=all and --warn=no-all
+ will enable or disable (respectively) the base
+ class of all warnings, which is SCons.Warning.Warning."""
+
+ elems = string.split(string.lower(arg), '-')
+ enable = 1
+ if elems[0] == 'no':
+ enable = 0
+ del elems[0]
+
+ if len(elems) == 1 and elems[0] == 'all':
+ class_name = "Warning"
+ else:
+ def _capitalize(s):
+ if s[:5] == "scons":
+ return "SCons" + s[5:]
+ else:
+ return string.capitalize(s)
+ class_name = string.join(map(_capitalize, elems), '') + "Warning"
+ try:
+ clazz = getattr(SCons.Warnings, class_name)
+ except AttributeError:
+ sys.stderr.write("No warning type: '%s'\n" % arg)
+ else:
+ if enable:
+ SCons.Warnings.enableWarningClass(clazz)
+ else:
+ SCons.Warnings.suppressWarningClass(clazz)
+
+def _SConstruct_exists(dirname=''):
+ """This function checks that an SConstruct file exists in a directory.
+ If so, it returns the path of the file. By default, it checks the
+ current directory.
+ """
+ global repositories
+ for file in ['SConstruct', 'Sconstruct', 'sconstruct']:
+ sfile = os.path.join(dirname, file)
+ if os.path.isfile(sfile):
+ return sfile
+ if not os.path.isabs(sfile):
+ for rep in repositories:
+ if os.path.isfile(os.path.join(rep, sfile)):
+ return sfile
+ return None
+
+def _set_globals(options):
+ global repositories, keep_going_on_error, ignore_errors
+ global print_count, print_dtree
+ global print_explanations, print_includes
+ global print_objects, print_time, print_tree
+ global memory_outf, memory_stats
+
+ if options.repository:
+ repositories.extend(options.repository)
+ keep_going_on_error = options.keep_going
+ try:
+ if options.debug:
+ if options.debug == "count":
+ print_count = 1
+ elif options.debug == "dtree":
+ print_dtree = 1
+ elif options.debug == "explain":
+ print_explanations = 1
+ elif options.debug == "includes":
+ print_includes = 1
+ elif options.debug == "memory":
+ memory_stats = []
+ memory_outf = sys.stdout
+ elif options.debug == "objects":
+ print_objects = 1
+ elif options.debug == "presub":
+ SCons.Action.print_actions_presub = 1
+ elif options.debug == "time":
+ print_time = 1
+ elif options.debug == "tree":
+ print_tree = 1
+ except AttributeError:
+ pass
+ ignore_errors = options.ignore_errors
+
+def _create_path(plist):
+ path = '.'
+ for d in plist:
+ if os.path.isabs(d):
+ path = d
+ else:
+ path = path + '/' + d
+ return path
+
+
+class OptParser(OptionParser):
+ def __init__(self):
+ import __main__
+ import SCons
+ parts = ["SCons by Steven Knight et al.:\n"]
+ try:
+ parts.append("\tscript: v%s.%s, %s, by %s on %s\n" % (__main__.__version__,
+ __main__.__build__,
+ __main__.__date__,
+ __main__.__developer__,
+ __main__.__buildsys__))
+ except KeyboardInterrupt:
+ raise
+ except:
+ # On win32 there is no scons.py, so there is no __main__.__version__,
+ # hence there is no script version.
+ pass
+ parts.append("\tengine: v%s.%s, %s, by %s on %s\n" % (SCons.__version__,
+ SCons.__build__,
+ SCons.__date__,
+ SCons.__developer__,
+ SCons.__buildsys__))
+ parts.append("Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation")
+ OptionParser.__init__(self, version=string.join(parts, ''),
+ usage="usage: scons [OPTION] [TARGET] ...")
+
+ # options ignored for compatibility
+ def opt_ignore(option, opt, value, parser):
+ sys.stderr.write("Warning: ignoring %s option\n" % opt)
+ self.add_option("-b", "-m", "-S", "-t", "--no-keep-going", "--stop",
+ "--touch", action="callback", callback=opt_ignore,
+ help="Ignored for compatibility.")
+
+ self.add_option('-c', '--clean', '--remove', action="store_true",
+ dest="clean",
+ help="Remove specified targets and dependencies.")
+
+ self.add_option('-C', '--directory', type="string", action = "append",
+ metavar="DIR",
+ help="Change to DIR before doing anything.")
+
+ self.add_option('--cache-disable', '--no-cache',
+ action="store_true", dest='cache_disable', default=0,
+ help="Do not retrieve built targets from CacheDir.")
+
+ self.add_option('--cache-force', '--cache-populate',
+ action="store_true", dest='cache_force', default=0,
+ help="Copy already-built targets into the CacheDir.")
+
+ self.add_option('--cache-show',
+ action="store_true", dest='cache_show', default=0,
+ help="Print build actions for files from CacheDir.")
+
+ def opt_not_yet(option, opt, value, parser):
+ sys.stderr.write("Warning: the %s option is not yet implemented\n" % opt)
+ sys.exit(0)
+ self.add_option('-d', action="callback",
+ callback=opt_not_yet,
+ help = "Print file dependency information.")
+
+ self.add_option('-D', action="store_const", const=2, dest="climb_up",
+ help="Search up directory tree for SConstruct, "
+ "build all Default() targets.")
+
+ debug_options = ["count", "dtree", "explain",
+ "includes", "memory", "objects",
+ "pdb", "presub", "time", "tree"]
+
+ def opt_debug(option, opt, value, parser, debug_options=debug_options):
+ if value in debug_options:
+ parser.values.debug = value
+ else:
+ raise OptionValueError("Warning: %s is not a valid debug type" % value)
+ self.add_option('--debug', action="callback", type="string",
+ callback=opt_debug, nargs=1, dest="debug",
+ metavar="TYPE",
+ help="Print various types of debugging information: "
+ "%s." % string.join(debug_options, ", "))
+
+ def opt_duplicate(option, opt, value, parser):
+ if not value in SCons.Node.FS.Valid_Duplicates:
+ raise OptionValueError("`%s' is not a valid duplication style." % value)
+ parser.values.duplicate = value
+ # Set the duplicate style right away so it can affect linking
+ # of SConscript files.
+ SCons.Node.FS.set_duplicate(value)
+ self.add_option('--duplicate', action="callback", type="string",
+ callback=opt_duplicate, nargs=1, dest="duplicate",
+ help="Set the preferred duplication methods. Must be one of "
+ + string.join(SCons.Node.FS.Valid_Duplicates, ", "))
+
+ self.add_option('-f', '--file', '--makefile', '--sconstruct',
+ action="append", nargs=1,
+ help="Read FILE as the top-level SConstruct file.")
+
+ self.add_option('-h', '--help', action="store_true", default=0,
+ dest="help_msg",
+ help="Print defined help message, or this one.")
+
+ self.add_option("-H", "--help-options",
+ action="help",
+ help="Print this message and exit.")
+
+ self.add_option('-i', '--ignore-errors', action="store_true",
+ default=0, dest='ignore_errors',
+ help="Ignore errors from build actions.")
+
+ self.add_option('-I', '--include-dir', action="append",
+ dest='include_dir', metavar="DIR",
+ help="Search DIR for imported Python modules.")
+
+ self.add_option('--implicit-cache', action="store_true",
+ dest='implicit_cache',
+ help="Cache implicit dependencies")
+
+ self.add_option('--implicit-deps-changed', action="store_true",
+ default=0, dest='implicit_deps_changed',
+ help="Ignore cached implicit dependencies.")
+ self.add_option('--implicit-deps-unchanged', action="store_true",
+ default=0, dest='implicit_deps_unchanged',
+ help="Ignore changes in implicit dependencies.")
+
+ def opt_j(option, opt, value, parser):
+ value = int(value)
+ parser.values.num_jobs = value
+ self.add_option('-j', '--jobs', action="callback", type="int",
+ callback=opt_j, metavar="N",
+ help="Allow N jobs at once.")
+
+ self.add_option('-k', '--keep-going', action="store_true", default=0,
+ dest='keep_going',
+ help="Keep going when a target can't be made.")
+
+ self.add_option('--max-drift', type="int", action="store",
+ dest='max_drift', metavar="N",
+ help="Set maximum system clock drift to N seconds.")
+
+ self.add_option('-n', '--no-exec', '--just-print', '--dry-run',
+ '--recon', action="store_true", dest='noexec',
+ default=0, help="Don't build; just print commands.")
+
+ def opt_profile(option, opt, value, parser):
+ global profiling
+ if not profiling:
+ profiling = 1
+ import profile
+ profile.run('SCons.Script.main()', value)
+ sys.exit(exit_status)
+ self.add_option('--profile', nargs=1, action="callback",
+ callback=opt_profile, type="string", dest="profile",
+ metavar="FILE",
+ help="Profile SCons and put results in FILE.")
+
+ self.add_option('-q', '--question', action="store_true", default=0,
+ help="Don't build; exit status says if up to date.")
+
+ self.add_option('-Q', dest='no_progress', action="store_true",
+ default=0,
+ help="Suppress \"Reading/Building\" progress messages.")
+
+ self.add_option('--random', dest="random", action="store_true",
+ default=0, help="Build dependencies in random order.")
+
+ self.add_option('-s', '--silent', '--quiet', action="store_true",
+ default=0, help="Don't print commands.")
+
+ self.add_option('-u', '--up', '--search-up', action="store_const",
+ dest="climb_up", default=0, const=1,
+ help="Search up directory tree for SConstruct, "
+ "build targets at or below current directory.")
+ self.add_option('-U', action="store_const", dest="climb_up",
+ default=0, const=3,
+ help="Search up directory tree for SConstruct, "
+ "build Default() targets from local SConscript.")
+
+ self.add_option("-v", "--version",
+ action="version",
+ help="Print the SCons version number and exit.")
+
+ self.add_option('--warn', '--warning', nargs=1, action="store",
+ metavar="WARNING-SPEC",
+ help="Enable or disable warnings.")
+
+ self.add_option('-Y', '--repository', nargs=1, action="append",
+ help="Search REPOSITORY for source and target files.")
+
+ self.add_option('-e', '--environment-overrides', action="callback",
+ callback=opt_not_yet,
+ # help="Environment variables override makefiles."
+ help=SUPPRESS_HELP)
+ self.add_option('-l', '--load-average', '--max-load', action="callback",
+ callback=opt_not_yet, type="int", dest="load_average",
+ # action="store",
+ # help="Don't start multiple jobs unless load is below "
+ # "LOAD-AVERAGE."
+ # type="int",
+ help=SUPPRESS_HELP)
+ self.add_option('--list-derived', action="callback",
+ callback=opt_not_yet,
+ # help="Don't build; list files that would be built."
+ help=SUPPRESS_HELP)
+ self.add_option('--list-actions', action="callback",
+ callback=opt_not_yet,
+ # help="Don't build; list files and build actions."
+ help=SUPPRESS_HELP)
+ self.add_option('--list-where', action="callback",
+ callback=opt_not_yet,
+ # help="Don't build; list files and where defined."
+ help=SUPPRESS_HELP)
+ self.add_option('-o', '--old-file', '--assume-old', action="callback",
+ callback=opt_not_yet, type="string", dest="old_file",
+ # help = "Consider FILE to be old; don't rebuild it."
+ help=SUPPRESS_HELP)
+ self.add_option('--override', action="callback", dest="override",
+ callback=opt_not_yet, type="string",
+ # help="Override variables as specified in FILE."
+ help=SUPPRESS_HELP)
+ self.add_option('-p', action="callback",
+ callback=opt_not_yet,
+ # help="Print internal environments/objects."
+ help=SUPPRESS_HELP)
+ self.add_option('-r', '-R', '--no-builtin-rules',
+ '--no-builtin-variables', action="callback",
+ callback=opt_not_yet,
+ # help="Clear default environments and variables."
+ help=SUPPRESS_HELP)
+ self.add_option('-w', '--print-directory', action="callback",
+ callback=opt_not_yet,
+ # help="Print the current directory."
+ help=SUPPRESS_HELP)
+ self.add_option('--no-print-directory', action="callback",
+ callback=opt_not_yet,
+ # help="Turn off -w, even if it was turned on implicitly."
+ help=SUPPRESS_HELP)
+ self.add_option('--write-filenames', action="callback",
+ callback=opt_not_yet, type="string", dest="write_filenames",
+ # help="Write all filenames examined into FILE."
+ help=SUPPRESS_HELP)
+ self.add_option('-W', '--what-if', '--new-file', '--assume-new',
+ dest="new_file",
+ action="callback", callback=opt_not_yet, type="string",
+ # help="Consider FILE to be changed."
+ help=SUPPRESS_HELP)
+ self.add_option('--warn-undefined-variables', action="callback",
+ callback=opt_not_yet,
+ # help="Warn when an undefined variable is referenced."
+ help=SUPPRESS_HELP)
+
+ def parse_args(self, args=None, values=None):
+ opt, arglist = OptionParser.parse_args(self, args, values)
+ if opt.implicit_deps_changed or opt.implicit_deps_unchanged:
+ opt.implicit_cache = 1
+ return opt, arglist
+
+class SConscriptSettableOptions:
+ """This class wraps an OptParser instance and provides
+ uniform access to options that can be either set on the command
+ line or from a SConscript file. A value specified on the command
+ line always overrides a value set in a SConscript file.
+ Not all command line options are SConscript settable, and the ones
+ that are must be explicitly added to settable dictionary and optionally
+ validated and coerced in the set() method."""
+
+ def __init__(self, options):
+ self.options = options
+
+ # This dictionary stores the defaults for all the SConscript
+ # settable options, as well as indicating which options
+ # are SConscript settable.
+ self.settable = {'num_jobs':1,
+ 'max_drift':SCons.Sig.default_max_drift,
+ 'implicit_cache':0,
+ 'clean':0,
+ 'duplicate':'hard-soft-copy'}
+
+ def get(self, name):
+ if not self.settable.has_key(name):
+ raise SCons.Error.UserError, "This option is not settable from a SConscript file: %s"%name
+ if hasattr(self.options, name) and getattr(self.options, name) is not None:
+ return getattr(self.options, name)
+ else:
+ return self.settable[name]
+
+ def set(self, name, value):
+ if not self.settable.has_key(name):
+ raise SCons.Error.UserError, "This option is not settable from a SConscript file: %s"%name
+
+ if name == 'num_jobs':
+ try:
+ value = int(value)
+ if value < 1:
+ raise ValueError
+ except ValueError:
+ raise SCons.Errors.UserError, "A positive integer is required: %s"%repr(value)
+ elif name == 'max_drift':
+ try:
+ value = int(value)
+ except ValueError:
+ raise SCons.Errors.UserError, "An integer is required: %s"%repr(value)
+ elif name == 'duplicate':
+ try:
+ value = str(value)
+ except ValueError:
+ raise SCons.Errors.UserError, "A string is required: %s"%repr(value)
+ if not value in SCons.Node.FS.Valid_Duplicates:
+ raise SCons.Errors.UserError, "Not a valid duplication style: %s" % value
+ # Set the duplicate stye right away so it can affect linking
+ # of SConscript files.
+ SCons.Node.FS.set_duplicate(value)
+
+ self.settable[name] = value
+
+
+def _main(args, parser):
+ targets = []
+ fs = SCons.Node.FS.default_fs
+
+ # Enable deprecated warnings by default.
+ SCons.Warnings._warningOut = _scons_internal_warning
+ SCons.Warnings.enableWarningClass(SCons.Warnings.CorruptSConsignWarning)
+ SCons.Warnings.enableWarningClass(SCons.Warnings.DeprecatedWarning)
+ SCons.Warnings.enableWarningClass(SCons.Warnings.DuplicateEnvironmentWarning)
+ SCons.Warnings.enableWarningClass(SCons.Warnings.MissingSConscriptWarning)
+ SCons.Warnings.enableWarningClass(SCons.Warnings.NoParallelSupportWarning)
+ # This is good for newbies, and hopefully most everyone else too.
+ SCons.Warnings.enableWarningClass(SCons.Warnings.MisleadingKeywordsWarning)
+
+ global ssoptions
+ ssoptions = SConscriptSettableOptions(options)
+
+ if options.help_msg:
+ def raisePrintHelp(text):
+ raise PrintHelp, text
+ SCons.Script.SConscript.HelpFunction = raisePrintHelp
+
+ _set_globals(options)
+ SCons.Node.implicit_cache = options.implicit_cache
+ SCons.Node.implicit_deps_changed = options.implicit_deps_changed
+ SCons.Node.implicit_deps_unchanged = options.implicit_deps_unchanged
+ if options.warn:
+ _setup_warn(options.warn)
+ if options.noexec:
+ SCons.SConf.dryrun = 1
+ SCons.Action.execute_actions = None
+ CleanTask.execute = CleanTask.show
+ if options.question:
+ SCons.SConf.dryrun = 1
+
+ if options.no_progress or options.silent:
+ progress_display.set_mode(0)
+ if options.silent:
+ display.set_mode(0)
+ if options.silent:
+ SCons.Action.print_actions = None
+ if options.cache_disable:
+ def disable(self): pass
+ fs.CacheDir = disable
+ if options.cache_force:
+ fs.cache_force = 1
+ if options.cache_show:
+ fs.cache_show = 1
+ if options.directory:
+ cdir = _create_path(options.directory)
+ try:
+ os.chdir(cdir)
+ except OSError:
+ sys.stderr.write("Could not change directory to %s\n" % cdir)
+
+ xmit_args = []
+ for a in args:
+ if '=' in a:
+ xmit_args.append(a)
+ else:
+ targets.append(a)
+ SCons.Script.SConscript._scons_add_args(xmit_args)
+ SCons.Script.SConscript._scons_add_targets(targets)
+
+ target_top = None
+ if options.climb_up:
+ target_top = '.' # directory to prepend to targets
+ script_dir = os.getcwd() # location of script
+ while script_dir and not _SConstruct_exists(script_dir):
+ script_dir, last_part = os.path.split(script_dir)
+ if last_part:
+ target_top = os.path.join(last_part, target_top)
+ else:
+ script_dir = ''
+ if script_dir:
+ display("scons: Entering directory `%s'" % script_dir)
+ os.chdir(script_dir)
+ else:
+ raise SCons.Errors.UserError, "No SConstruct file found."
+
+ fs.set_toplevel_dir(os.getcwd())
+
+ scripts = []
+ if options.file:
+ scripts.extend(options.file)
+ if not scripts:
+ sfile = _SConstruct_exists()
+ if sfile:
+ scripts.append(sfile)
+
+ if options.help_msg:
+ if not scripts:
+ # There's no SConstruct, but they specified -h.
+ # Give them the options usage now, before we fail
+ # trying to read a non-existent SConstruct file.
+ parser.print_help()
+ sys.exit(0)
+ SCons.Script.SConscript.print_help = 1
+
+ if not scripts:
+ raise SCons.Errors.UserError, "No SConstruct file found."
+
+ if scripts[0] == "-":
+ d = fs.getcwd()
+ else:
+ d = fs.File(scripts[0]).dir
+ fs.set_SConstruct_dir(d)
+
+ class Unbuffered:
+ def __init__(self, file):
+ self.file = file
+ def write(self, arg):
+ self.file.write(arg)
+ self.file.flush()
+ def __getattr__(self, attr):
+ return getattr(self.file, attr)
+
+ sys.stdout = Unbuffered(sys.stdout)
+
+ if options.include_dir:
+ sys.path = options.include_dir + sys.path
+
+ global repositories
+ for rep in repositories:
+ fs.Repository(rep)
+
+ if not memory_stats is None: memory_stats.append(SCons.Debug.memory())
+
+ progress_display("scons: Reading SConscript files ...")
+ try:
+ start_time = time.time()
+ try:
+ for script in scripts:
+ SCons.Script.SConscript._SConscript(fs, script)
+ except SCons.Errors.StopError, e:
+ # We had problems reading an SConscript file, such as it
+ # couldn't be copied in to the BuildDir. Since we're just
+ # reading SConscript files and haven't started building
+ # things yet, stop regardless of whether they used -i or -k
+ # or anything else, but don't say "Stop." on the message.
+ global exit_status
+ sys.stderr.write("scons: *** %s\n" % e)
+ exit_status = 2
+ sys.exit(exit_status)
+ global sconscript_time
+ sconscript_time = time.time() - start_time
+ except PrintHelp, text:
+ progress_display("scons: done reading SConscript files.")
+ print text
+ print "Use scons -H for help about command-line options."
+ sys.exit(0)
+ progress_display("scons: done reading SConscript files.")
+
+ # Tell the Node.FS subsystem that we're all done reading the
+ # SConscript files and calling Repository() and BuildDir() and the
+ # like, so it can go ahead and start memoizing the string values of
+ # file system nodes.
+ SCons.Node.FS.save_strings(1)
+
+ if not memory_stats is None: memory_stats.append(SCons.Debug.memory())
+
+ fs.chdir(fs.Top)
+
+ if options.help_msg:
+ # They specified -h, but there was no Help() inside the
+ # SConscript files. Give them the options usage.
+ parser.print_help(sys.stdout)
+ sys.exit(0)
+
+ # Now that we've read the SConscripts we can set the options
+ # that are SConscript settable:
+ SCons.Node.implicit_cache = ssoptions.get('implicit_cache')
+ SCons.Node.FS.set_duplicate(ssoptions.get('duplicate'))
+
+ lookup_top = None
+ if targets:
+ # They specified targets on the command line, so if they
+ # used -u, -U or -D, we have to look up targets relative
+ # to the top, but we build whatever they specified.
+ if target_top:
+ lookup_top = fs.Dir(target_top)
+ target_top = None
+ else:
+ # There are no targets specified on the command line,
+ # so if they used -u, -U or -D, we may have to restrict
+ # what actually gets built.
+ d = None
+ if target_top:
+ if options.climb_up == 1:
+ # -u, local directory and below
+ target_top = fs.Dir(target_top)
+ lookup_top = target_top
+ elif options.climb_up == 2:
+ # -D, all Default() targets
+ target_top = None
+ lookup_top = None
+ elif options.climb_up == 3:
+ # -U, local SConscript Default() targets
+ target_top = fs.Dir(target_top)
+ def check_dir(x, target_top=target_top):
+ if hasattr(x, 'cwd') and not x.cwd is None:
+ cwd = x.cwd.srcnode()
+ return cwd == target_top
+ else:
+ # x doesn't have a cwd, so it's either not a target,
+ # or not a file, so go ahead and keep it as a default
+ # target and let the engine sort it out:
+ return 1
+ d = filter(check_dir, SCons.Script.SConscript.DefaultTargets)
+ SCons.Script.SConscript.DefaultTargets[:] = d
+ target_top = None
+ lookup_top = None
+
+ if SCons.Script.SConscript.DefaultCalled:
+ targets = SCons.Script.SConscript.DefaultTargets
+ else:
+ if d is None:
+ d = [fs.Dir('.')]
+ targets = d
+
+
+ if not targets:
+ sys.stderr.write("scons: *** No targets specified and no Default() targets found. Stop.\n")
+ sys.exit(2)
+
+ def Entry(x, ltop=lookup_top, ttop=target_top, fs=fs):
+ if isinstance(x, SCons.Node.Node):
+ node = x
+ else:
+ node = SCons.Node.Alias.default_ans.lookup(x)
+ if node is None:
+ node = fs.Entry(x, directory=ltop, create=1)
+ if ttop and not node.is_under(ttop):
+ if isinstance(node, SCons.Node.FS.Dir) and ttop.is_under(node):
+ node = ttop
+ else:
+ node = None
+ return node
+
+ nodes = filter(lambda x: x is not None, map(Entry, targets))
+
+ task_class = BuildTask # default action is to build targets
+ opening_message = "Building targets ..."
+ closing_message = "done building targets."
+ failure_message = "building terminated because of errors."
+ if options.question:
+ task_class = QuestionTask
+ try:
+ if ssoptions.get('clean'):
+ task_class = CleanTask
+ opening_message = "Cleaning targets ..."
+ closing_message = "done cleaning targets."
+ failure_message = "cleaning terminated because of errors."
+ except AttributeError:
+ pass
+
+ SCons.Environment.CalculatorArgs['max_drift'] = ssoptions.get('max_drift')
+
+ if options.random:
+ def order(dependencies):
+ """Randomize the dependencies."""
+ # This is cribbed from the implementation of
+ # random.shuffle() in Python 2.X.
+ d = dependencies
+ for i in xrange(len(d)-1, 0, -1):
+ j = int(random.random() * (i+1))
+ d[i], d[j] = d[j], d[i]
+ return d
+ else:
+ def order(dependencies):
+ """Leave the order of dependencies alone."""
+ return dependencies
+
+ progress_display("scons: " + opening_message)
+ taskmaster = SCons.Taskmaster.Taskmaster(nodes, task_class, order)
+
+ nj = ssoptions.get('num_jobs')
+ jobs = SCons.Job.Jobs(nj, taskmaster)
+ if nj > 1 and jobs.num_jobs == 1:
+ msg = "parallel builds are unsupported by this version of Python;\n" + \
+ "\tignoring -j or num_jobs option.\n"
+ SCons.Warnings.warn(SCons.Warnings.NoParallelSupportWarning, msg)
+
+ if not memory_stats is None: memory_stats.append(SCons.Debug.memory())
+
+ try:
+ jobs.run()
+ finally:
+ if exit_status:
+ progress_display("scons: " + failure_message)
+ else:
+ progress_display("scons: " + closing_message)
+ if not options.noexec:
+ SCons.SConsign.write()
+
+ if not memory_stats is None:
+ memory_stats.append(SCons.Debug.memory())
+ when = [
+ 'before SConscript files',
+ 'after SConscript files',
+ 'before building',
+ 'after building',
+ ]
+ for i in xrange(len(when)):
+ memory_outf.write('Memory %s: %d\n' % (when[i], memory_stats[i]))
+
+ if print_count:
+ SCons.Debug.countLoggedInstances('*')
+
+ if print_objects:
+ SCons.Debug.listLoggedInstances('*')
+ #SCons.Debug.dumpLoggedInstances('*')
+
+def _exec_main():
+ all_args = sys.argv[1:]
+ try:
+ all_args = string.split(os.environ['SCONSFLAGS']) + all_args
+ except KeyError:
+ # it's OK if there's no SCONSFLAGS
+ pass
+ parser = OptParser()
+ global options
+ options, args = parser.parse_args(all_args)
+ if options.debug == "pdb":
+ import pdb
+ pdb.Pdb().runcall(_main, args, parser)
+ else:
+ _main(args, parser)
+
+def main():
+ global exit_status
+
+ try:
+ _exec_main()
+ except SystemExit, s:
+ if s:
+ exit_status = s
+ except KeyboardInterrupt:
+ print "Build interrupted."
+ sys.exit(2)
+ except SyntaxError, e:
+ _scons_syntax_error(e)
+ except SCons.Errors.InternalError:
+ _scons_internal_error()
+ except SCons.Errors.UserError, e:
+ _scons_user_error(e)
+ except SCons.Errors.ConfigureDryRunError, e:
+ _scons_configure_dryrun_error(e)
+ except:
+ # An exception here is likely a builtin Python exception Python
+ # code in an SConscript file. Show them precisely what the
+ # problem was and where it happened.
+ SCons.Script.SConscript.SConscript_exception()
+ sys.exit(2)
+
+ if print_time:
+ total_time = time.time()-start_time
+ scons_time = total_time-sconscript_time-command_time
+ print "Total build time: %f seconds"%total_time
+ print "Total SConscript file execution time: %f seconds"%sconscript_time
+ print "Total SCons execution time: %f seconds"%scons_time
+ print "Total command execution time: %f seconds"%command_time
+
+ sys.exit(exit_status)
Added: development/support/scons/scons-local-0.96.1/SCons/Sig/MD5.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Sig/MD5.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Sig/MD5.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,93 @@
+"""SCons.Sig.MD5
+
+The MD5 signature package for the SCons software construction
+utility.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Sig/MD5.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import imp
+import string
+
+# Force Python to load the builtin "md5" module. If we do this with a
+# normal import statement, then case-insensitive systems (Win32) get
+# confused and thinks there's a case mismatch with *this* MD5.py module.
+file, name, desc = imp.find_module('md5')
+try:
+ md5 = imp.load_module('md5', file, name, desc)
+finally:
+ if file:
+ file.close()
+
+def current(new, old):
+ """Return whether a new signature is up-to-date with
+ respect to an old signature.
+ """
+ return new == old
+
+def hexdigest(s):
+ """Return a signature as a string of hex characters.
+ """
+ # NOTE: This routine is a method in the Python 2.0 interface
+ # of the native md5 module, but we want SCons to operate all
+ # the way back to at least Python 1.5.2, which doesn't have it.
+ h = string.hexdigits
+ r = ''
+ for c in s:
+ i = ord(c)
+ r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
+ return r
+
+def collect(signatures):
+ """
+ Collect a list of signatures into an aggregate signature.
+
+ signatures - a list of signatures
+ returns - the aggregate signature
+ """
+ if len(signatures) == 1:
+ return signatures[0]
+ else:
+ contents = string.join(signatures, ', ')
+ return hexdigest(md5.new(contents).digest())
+
+def signature(obj):
+ """Generate a signature for an object
+ """
+ try:
+ gc = obj.get_contents
+ except AttributeError:
+ raise AttributeError, "unable to fetch contents of '%s'" % str(obj)
+ return hexdigest(md5.new(str(gc())).digest())
+
+def to_string(signature):
+ """Convert a signature to a string"""
+ return signature
+
+def from_string(string):
+ """Convert a string to a signature"""
+ return string
Added: development/support/scons/scons-local-0.96.1/SCons/Sig/TimeStamp.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Sig/TimeStamp.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Sig/TimeStamp.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,75 @@
+"""SCons.Sig.TimeStamp
+
+The TimeStamp signature package for the SCons software construction
+utility.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Sig/TimeStamp.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+def current(new, old):
+ """Return whether a new timestamp is up-to-date with
+ respect to an old timestamp.
+ """
+ return not old is None and new <= old
+
+def collect(signatures):
+ """
+ Collect a list of timestamps, returning
+ the most-recent timestamp from the list
+
+ signatures - a list of timestamps
+ returns - the most recent timestamp
+ """
+
+ if len(signatures) == 0:
+ return 0
+ elif len(signatures) == 1:
+ return signatures[0]
+ else:
+ return max(signatures)
+
+def signature(obj):
+ """Generate a timestamp.
+ """
+ return obj.get_timestamp()
+
+def to_string(signature):
+ """Convert a timestamp to a string"""
+ return str(signature)
+
+def from_string(string):
+ """Convert a string to a timestamp"""
+ try:
+ return int(string)
+ except ValueError:
+ # if the signature isn't an int, then
+ # the user probably just switched from
+ # MD5 signatures to timestamp signatures,
+ # so ignore the error:
+ return None
+
+
Added: development/support/scons/scons-local-0.96.1/SCons/Sig/__init__.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Sig/__init__.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Sig/__init__.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,69 @@
+"""SCons.Sig
+
+The Signature package for the scons software construction utility.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Sig/__init__.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+try:
+ import MD5
+ default_module = MD5
+except ImportError:
+ import TimeStamp
+ default_module = TimeStamp
+
+# XXX We should move max_drift into Node/FS.py,
+# since it's really something about files.
+default_max_drift = 2*24*60*60
+
+class SConsignEntry:
+ """The old SConsignEntry format.
+ We keep this around to handle conversions from old .sconsign files."""
+ timestamp = None
+ bsig = None
+ csig = None
+ implicit = None
+
+class Calculator:
+ """
+ Encapsulates signature calculations and .sconsign file generating
+ for the build engine.
+ """
+
+ def __init__(self, module=default_module, max_drift=default_max_drift):
+ """
+ Initialize the calculator.
+
+ module - the signature module to use for signature calculations
+ max_drift - the maximum system clock drift used to determine when to
+ cache content signatures. A negative value means to never cache
+ content signatures. (defaults to 2 days)
+ """
+ self.module = module
+ self.max_drift = max_drift
+
+default_calc = Calculator()
Added: development/support/scons/scons-local-0.96.1/SCons/Taskmaster.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Taskmaster.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Taskmaster.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,452 @@
+"""SCons.Taskmaster
+
+Generic Taskmaster.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Taskmaster.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import string
+import sys
+import traceback
+
+import SCons.Node
+import SCons.Errors
+
+class Task:
+ """Default SCons build engine task.
+
+ This controls the interaction of the actual building of node
+ and the rest of the engine.
+
+ This is expected to handle all of the normally-customizable
+ aspects of controlling a build, so any given application
+ *should* be able to do what it wants by sub-classing this
+ class and overriding methods as appropriate. If an application
+ needs to customze something by sub-classing Taskmaster (or
+ some other build engine class), we should first try to migrate
+ that functionality into this class.
+
+ Note that it's generally a good idea for sub-classes to call
+ these methods explicitly to update state, etc., rather than
+ roll their own interaction with Taskmaster from scratch."""
+ def __init__(self, tm, targets, top, node):
+ self.tm = tm
+ self.targets = targets
+ self.top = top
+ self.node = node
+
+ def display(self, message):
+ """Allow the calling interface to display a message
+ """
+ pass
+
+ def prepare(self):
+ """Called just before the task is executed.
+
+ This unlinks all targets and makes all directories before
+ building anything."""
+
+ # Now that it's the appropriate time, give the TaskMaster a
+ # chance to raise any exceptions it encountered while preparing
+ # this task.
+ self.tm.exception_raise()
+
+ if self.tm.message:
+ self.display(self.tm.message)
+ self.tm.message = None
+
+ for t in self.targets:
+ t.prepare()
+ for s in t.side_effects:
+ s.prepare()
+
+ def execute(self):
+ """Called to execute the task.
+
+ This method is called from multiple threads in a parallel build,
+ so only do thread safe stuff here. Do thread unsafe stuff in
+ prepare(), executed() or failed()."""
+
+ try:
+ everything_was_cached = 1
+ for t in self.targets:
+ if not t.retrieve_from_cache():
+ everything_was_cached = 0
+ break
+ if not everything_was_cached:
+ self.targets[0].build()
+ except KeyboardInterrupt:
+ raise
+ except SystemExit:
+ exc_value = sys.exc_info()[1]
+ raise SCons.Errors.ExplicitExit(self.targets[0], exc_value.code)
+ except SCons.Errors.UserError:
+ raise
+ except SCons.Errors.BuildError:
+ raise
+ except:
+ exc_type, exc_value, exc_traceback = sys.exc_info()
+ raise SCons.Errors.BuildError(self.targets[0],
+ "Exception",
+ exc_type,
+ exc_value,
+ exc_traceback)
+
+ def get_target(self):
+ """Fetch the target being built or updated by this task.
+ """
+ return self.node
+
+ def executed(self):
+ """Called when the task has been successfully executed.
+
+ This may have been a do-nothing operation (to preserve
+ build order), so check the node's state before updating
+ things. Most importantly, this calls back to the
+ Taskmaster to put any node tasks waiting on this one
+ back on the pending list."""
+
+ if self.targets[0].get_state() == SCons.Node.executing:
+ for t in self.targets:
+ for side_effect in t.side_effects:
+ side_effect.set_state(None)
+ t.set_state(SCons.Node.executed)
+ t.built()
+ else:
+ for t in self.targets:
+ t.visited()
+
+ self.tm.executed(self.node)
+
+ def failed(self):
+ """Default action when a task fails: stop the build."""
+ self.fail_stop()
+
+ def fail_stop(self):
+ """Explicit stop-the-build failure."""
+ for t in self.targets:
+ t.set_state(SCons.Node.failed)
+ self.tm.failed(self.node)
+ self.tm.stop()
+
+ def fail_continue(self):
+ """Explicit continue-the-build failure.
+
+ This sets failure status on the target nodes and all of
+ their dependent parent nodes.
+ """
+ for t in self.targets:
+ # Set failure state on all of the parents that were dependent
+ # on this failed build.
+ def set_state(node): node.set_state(SCons.Node.failed)
+ t.call_for_all_waiting_parents(set_state)
+
+ self.tm.executed(self.node)
+
+ def mark_targets(self, state):
+ for t in self.targets:
+ t.set_state(state)
+
+ def mark_targets_and_side_effects(self, state):
+ for t in self.targets:
+ for side_effect in t.side_effects:
+ side_effect.set_state(state)
+ t.set_state(state)
+
+ def make_ready_all(self):
+ """Mark all targets in a task ready for execution.
+
+ This is used when the interface needs every target Node to be
+ visited--the canonical example being the "scons -c" option.
+ """
+ self.out_of_date = self.targets[:]
+ self.mark_targets_and_side_effects(SCons.Node.executing)
+
+ def make_ready_current(self):
+ """Mark all targets in a task ready for execution if any target
+ is not current.
+
+ This is the default behavior for building only what's necessary.
+ """
+ self.out_of_date = []
+ for t in self.targets:
+ if not t.current():
+ self.out_of_date.append(t)
+ if self.out_of_date:
+ self.mark_targets_and_side_effects(SCons.Node.executing)
+ else:
+ self.mark_targets(SCons.Node.up_to_date)
+
+ make_ready = make_ready_current
+
+ def postprocess(self):
+ """Post process a task after it's been executed."""
+ for t in self.targets:
+ t.postprocess()
+
+ def exc_info(self):
+ return self.tm.exception
+
+ def exc_clear(self):
+ self.tm.exception_clear()
+
+ def exception_set(self):
+ self.tm.exception_set()
+
+
+
+def order(dependencies):
+ """Re-order a list of dependencies (if we need to)."""
+ return dependencies
+
+
+class Taskmaster:
+ """A generic Taskmaster for handling a bunch of targets.
+
+ Classes that override methods of this class should call
+ the base class method, so this class can do its thing.
+ """
+
+ def __init__(self, targets=[], tasker=Task, order=order):
+ self.targets = targets # top level targets
+ self.candidates = targets[:] # nodes that might be ready to be executed
+ self.candidates.reverse()
+ self.executing = [] # nodes that are currently executing
+ self.pending = [] # nodes that depend on a currently executing node
+ self.tasker = tasker
+ self.ready = None # the next task that is ready to be executed
+ self.order = order
+ self.exception_clear()
+ self.message = None
+
+ def _find_next_ready_node(self):
+ """Find the next node that is ready to be built"""
+
+ if self.ready:
+ return
+
+ while self.candidates:
+ node = self.candidates[-1]
+ state = node.get_state()
+
+ # Skip this node if it has already been executed:
+ if state != None and state != SCons.Node.stack:
+ self.candidates.pop()
+ continue
+
+ # Mark this node as being on the execution stack:
+ node.set_state(SCons.Node.stack)
+
+ try:
+ children = node.children()
+ except SystemExit:
+ exc_value = sys.exc_info()[1]
+ e = SCons.Errors.ExplicitExit(node, exc_value.code)
+ self.exception_set((SCons.Errors.ExplicitExit, e))
+ self.candidates.pop()
+ self.ready = node
+ break
+ except KeyboardInterrupt:
+ raise
+ except:
+ # We had a problem just trying to figure out the
+ # children (like a child couldn't be linked in to a
+ # BuildDir, or a Scanner threw something). Arrange to
+ # raise the exception when the Task is "executed."
+ self.exception_set()
+ self.candidates.pop()
+ self.ready = node
+ break
+
+ # Detect dependency cycles:
+ def in_stack(node): return node.get_state() == SCons.Node.stack
+ cycle = filter(in_stack, children)
+ if cycle:
+ nodes = filter(in_stack, self.candidates) + cycle
+ nodes.reverse()
+ desc = "Dependency cycle: " + string.join(map(str, nodes), " -> ")
+ raise SCons.Errors.UserError, desc
+
+ # Find all of the derived dependencies (that is,
+ # children who have builders or are side effects):
+ try:
+ def derived_nodes(node): return node.is_derived() or node.is_pseudo_derived()
+ derived = filter(derived_nodes, children)
+ except KeyboardInterrupt:
+ raise
+ except:
+ # We had a problem just trying to figure out if any of
+ # the kids are derived (like a child couldn't be linked
+ # from a repository). Arrange to raise the exception
+ # when the Task is "executed."
+ self.exception_set()
+ self.candidates.pop()
+ self.ready = node
+ break
+
+ # If there aren't any children with builders and this
+ # was a top-level argument, then see if we can find any
+ # corresponding targets in linked build directories:
+ if not derived and node in self.targets:
+ alt, message = node.alter_targets()
+ if alt:
+ self.message = message
+ self.candidates.pop()
+ self.candidates.extend(alt)
+ continue
+
+ # Add derived files that have not been built
+ # to the candidates list:
+ def unbuilt_nodes(node): return node.get_state() == None
+ not_built = filter(unbuilt_nodes, derived)
+ if not_built:
+ # We're waiting on one more derived files that have not
+ # yet been built. Add this node to the waiting_parents
+ # list of each of those derived files.
+ def add_to_waiting_parents(child, parent=node):
+ child.add_to_waiting_parents(parent)
+ map(add_to_waiting_parents, not_built)
+ not_built.reverse()
+ self.candidates.extend(self.order(not_built))
+ continue
+
+ # Skip this node if it has side-effects that are
+ # currently being built:
+ cont = 0
+ for side_effect in node.side_effects:
+ if side_effect.get_state() == SCons.Node.executing:
+ self.pending.append(node)
+ node.set_state(SCons.Node.pending)
+ self.candidates.pop()
+ cont = 1
+ break
+ if cont: continue
+
+ # Skip this node if it is pending on a currently
+ # executing node:
+ if node.depends_on(self.executing) or node.depends_on(self.pending):
+ self.pending.append(node)
+ node.set_state(SCons.Node.pending)
+ self.candidates.pop()
+ continue
+
+ # The default when we've gotten through all of the checks above:
+ # this node is ready to be built.
+ self.candidates.pop()
+ self.ready = node
+ break
+
+ def next_task(self):
+ """Return the next task to be executed."""
+
+ self._find_next_ready_node()
+
+ node = self.ready
+
+ if node is None:
+ return None
+
+ try:
+ tlist = node.builder.targets(node)
+ except AttributeError:
+ tlist = [node]
+ self.executing.extend(tlist)
+ self.executing.extend(node.side_effects)
+
+ task = self.tasker(self, tlist, node in self.targets, node)
+ try:
+ task.make_ready()
+ except KeyboardInterrupt:
+ raise
+ except:
+ # We had a problem just trying to get this task ready (like
+ # a child couldn't be linked in to a BuildDir when deciding
+ # whether this node is current). Arrange to raise the
+ # exception when the Task is "executed."
+ self.exception_set()
+ self.ready = None
+
+ return task
+
+ def is_blocked(self):
+ self._find_next_ready_node()
+
+ return not self.ready and (self.pending or self.executing)
+
+ def stop(self):
+ """Stop the current build completely."""
+ self.candidates = []
+ self.ready = None
+ self.pending = []
+
+ def failed(self, node):
+ try:
+ tlist = node.builder.targets(node)
+ except AttributeError:
+ tlist = [node]
+ for t in tlist:
+ self.executing.remove(t)
+ for side_effect in node.side_effects:
+ self.executing.remove(side_effect)
+
+ def executed(self, node):
+ try:
+ tlist = node.builder.targets(node)
+ except AttributeError:
+ tlist = [node]
+ for t in tlist:
+ self.executing.remove(t)
+ for side_effect in node.side_effects:
+ self.executing.remove(side_effect)
+
+ # move the current pending nodes to the candidates list:
+ # (they may not all be ready to build, but _find_next_ready_node()
+ # will figure out which ones are really ready)
+ for node in self.pending:
+ node.set_state(None)
+ self.pending.reverse()
+ self.candidates.extend(self.pending)
+ self.pending = []
+
+ def exception_set(self, exception=None):
+ if exception is None:
+ exception = sys.exc_info()
+ self.exception = exception
+ self.exception_raise = self._exception_raise
+
+ def exception_clear(self):
+ self.exception = (None, None, None)
+ self.exception_raise = self._no_exception_to_raise
+
+ def _no_exception_to_raise(self):
+ pass
+
+ def _exception_raise(self):
+ """Raise a pending exception that was recorded while
+ getting a Task ready for execution."""
+ exc_type, exc_value = self.exception[:2]
+ raise exc_type, exc_value
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/386asm.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/386asm.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/386asm.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,54 @@
+"""SCons.Tool.386asm
+
+Tool specification for the 386ASM assembler for the Phar Lap ETS embedded
+operating system.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/386asm.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+from SCons.Tool.PharLapCommon import addPharLapPaths
+import SCons.Util
+
+import as
+
+def generate(env):
+ """Add Builders and construction variables for ar to an Environment."""
+ as.generate(env)
+
+ env['AS'] = '386asm'
+ env['ASFLAGS'] = SCons.Util.CLVar('')
+ env['ASCOM'] = '$AS $ASFLAGS $SOURCES -o $TARGET'
+ env['ASPPCOM'] = '$CC $ASFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS $SOURCES -o $TARGET'
+
+ addPharLapPaths(env)
+
+def exists(env):
+ return env.Detect('386asm')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/BitKeeper.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/BitKeeper.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/BitKeeper.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,59 @@
+"""SCons.Tool.BitKeeper.py
+
+Tool-specific initialization for the BitKeeper source code control
+system.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/BitKeeper.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+
+import SCons.Builder
+import SCons.Util
+
+def generate(env):
+ """Add a Builder factory function and construction variables for
+ BitKeeper to an Environment."""
+
+ def BitKeeperFactory(env=env):
+ """ """
+ return SCons.Builder.Builder(action = "$BITKEEPERCOM", env = env)
+
+ #setattr(env, 'BitKeeper', BitKeeperFactory)
+ env.BitKeeper = BitKeeperFactory
+
+ env['BITKEEPER'] = 'bk'
+ env['BITKEEPERGET'] = '$BITKEEPER get'
+ env['BITKEEPERGETFLAGS'] = SCons.Util.CLVar('')
+ env['BITKEEPERCOM'] = '$BITKEEPERGET $BITKEEPERGETFLAGS $TARGET'
+
+def exists(env):
+ return env.Detect('bk')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/CVS.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/CVS.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/CVS.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,65 @@
+"""SCons.Tool.CVS.py
+
+Tool-specific initialization for CVS.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/CVS.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Builder
+import SCons.Util
+
+def generate(env):
+ """Add a Builder factory function and construction variables for
+ CVS to an Environment."""
+
+ def CVSFactory(repos, module='', env=env):
+ """ """
+ # fail if repos is not an absolute path name?
+ if module != '':
+ # Don't use os.path.join() because the name we fetch might
+ # be across a network and must use POSIX slashes as separators.
+ module = module + '/'
+ env['CVSCOM'] = '$CVS $CVSFLAGS co $CVSCOFLAGS -d ${TARGET.dir} $CVSMODULE${TARGET.posix}'
+ return SCons.Builder.Builder(action = '$CVSCOM',
+ env = env,
+ CVSREPOSITORY = repos,
+ CVSMODULE = module)
+
+ #setattr(env, 'CVS', CVSFactory)
+ env.CVS = CVSFactory
+
+ env['CVS'] = 'cvs'
+ env['CVSFLAGS'] = SCons.Util.CLVar('-d $CVSREPOSITORY')
+ env['CVSCOFLAGS'] = SCons.Util.CLVar('')
+ env['CVSCOM'] = '$CVS $CVSFLAGS co $CVSCOFLAGS ${TARGET.posix}'
+
+def exists(env):
+ return env.Detect('cvs')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/JavaCommon.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/JavaCommon.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/JavaCommon.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,225 @@
+"""SCons.Tool.JavaCommon
+
+Stuff for processing Java.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/JavaCommon.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+import os.path
+import re
+import string
+
+java_parsing = 1
+
+if java_parsing:
+ # Parse Java files for class names.
+ #
+ # This is a really cool parser from Charles Crain
+ # that finds appropriate class names in Java source.
+
+ # A regular expression that will find, in a java file: newlines;
+ # any alphanumeric token (keyword, class name, specifier); open or
+ # close brackets; a single-line comment "//"; the multi-line comment
+ # begin and end tokens /* and */; single or double quotes; and
+ # single or double quotes preceeded by a backslash.
+ _reToken = re.compile(r'(\n|//|\\[\'"]|[\'"\{\}]|[A-Za-z_][\w\.]*|' +
+ r'/\*|\*/)')
+
+ class OuterState:
+ """The initial state for parsing a Java file for classes,
+ interfaces, and anonymous inner classes."""
+ def __init__(self):
+ self.listClasses = []
+ self.listOutputs = []
+ self.stackBrackets = []
+ self.brackets = 0
+ self.nextAnon = 1
+ self.package = None
+
+ def __getClassState(self):
+ try:
+ return self.classState
+ except AttributeError:
+ ret = ClassState(self)
+ self.classState = ret
+ return ret
+
+ def __getPackageState(self):
+ try:
+ return self.packageState
+ except AttributeError:
+ ret = PackageState(self)
+ self.packageState = ret
+ return ret
+
+ def __getAnonClassState(self):
+ try:
+ return self.anonState
+ except AttributeError:
+ ret = SkipState(1, AnonClassState(self))
+ self.anonState = ret
+ return ret
+
+ def __getSkipState(self):
+ try:
+ return self.skipState
+ except AttributeError:
+ ret = SkipState(1, self)
+ self.skipState = ret
+ return ret
+
+ def parseToken(self, token):
+ if token[:2] == '//':
+ return IgnoreState('\n', self)
+ elif token == '/*':
+ return IgnoreState('*/', self)
+ elif token == '{':
+ self.brackets = self.brackets + 1
+ elif token == '}':
+ self.brackets = self.brackets - 1
+ if len(self.stackBrackets) and \
+ self.brackets == self.stackBrackets[-1]:
+ self.listOutputs.append(string.join(self.listClasses, '$'))
+ self.listClasses.pop()
+ self.stackBrackets.pop()
+ elif token == '"' or token == "'":
+ return IgnoreState(token, self)
+ elif token == "new":
+ # anonymous inner class
+ if len(self.listClasses) > 0:
+ return self.__getAnonClassState()
+ return self.__getSkipState() # Skip the class name
+ elif token == 'class' or token == 'interface':
+ if len(self.listClasses) == 0:
+ self.nextAnon = 1
+ self.stackBrackets.append(self.brackets)
+ return self.__getClassState()
+ elif token == 'package':
+ return self.__getPackageState()
+ return self
+
+ def addAnonClass(self):
+ """Add an anonymous inner class"""
+ clazz = self.listClasses[0]
+ self.listOutputs.append('%s$%d' % (clazz, self.nextAnon))
+ self.brackets = self.brackets + 1
+ self.nextAnon = self.nextAnon + 1
+
+ def setPackage(self, package):
+ self.package = package
+
+ class AnonClassState:
+ """A state that looks for anonymous inner classes."""
+ def __init__(self, outer_state):
+ # outer_state is always an instance of OuterState
+ self.outer_state = outer_state
+ self.tokens_to_find = 2
+ def parseToken(self, token):
+ # This is an anonymous class if and only if the next token is a bracket
+ if token == '{':
+ self.outer_state.addAnonClass()
+ return self.outer_state
+
+ class SkipState:
+ """A state that will skip a specified number of tokens before
+ reverting to the previous state."""
+ def __init__(self, tokens_to_skip, old_state):
+ self.tokens_to_skip = tokens_to_skip
+ self.old_state = old_state
+ def parseToken(self, token):
+ self.tokens_to_skip = self.tokens_to_skip - 1
+ if self.tokens_to_skip < 1:
+ return self.old_state
+ return self
+
+ class ClassState:
+ """A state we go into when we hit a class or interface keyword."""
+ def __init__(self, outer_state):
+ # outer_state is always an instance of OuterState
+ self.outer_state = outer_state
+ def parseToken(self, token):
+ # the next non-whitespace token should be the name of the class
+ if token == '\n':
+ return self
+ self.outer_state.listClasses.append(token)
+ return self.outer_state
+
+ class IgnoreState:
+ """A state that will ignore all tokens until it gets to a
+ specified token."""
+ def __init__(self, ignore_until, old_state):
+ self.ignore_until = ignore_until
+ self.old_state = old_state
+ def parseToken(self, token):
+ if self.ignore_until == token:
+ return self.old_state
+ return self
+
+ class PackageState:
+ """The state we enter when we encounter the package keyword.
+ We assume the next token will be the package name."""
+ def __init__(self, outer_state):
+ # outer_state is always an instance of OuterState
+ self.outer_state = outer_state
+ def parseToken(self, token):
+ self.outer_state.setPackage(token)
+ return self.outer_state
+
+ def parse_java_file(fn):
+ return parse_java(open(fn, 'r').read())
+
+ def parse_java(contents):
+ """Parse a .java file and return a double of package directory,
+ plus a list of .class files that compiling that .java file will
+ produce"""
+ package = None
+ initial = OuterState()
+ currstate = initial
+ for token in _reToken.findall(contents):
+ # The regex produces a bunch of groups, but only one will
+ # have anything in it.
+ currstate = currstate.parseToken(token)
+ if initial.package:
+ package = string.replace(initial.package, '.', os.sep)
+ return (package, initial.listOutputs)
+
+else:
+ # Don't actually parse Java files for class names.
+ #
+ # We might make this a configurable option in the future if
+ # Java-file parsing takes too long (although it shouldn't relative
+ # to how long the Java compiler itself seems to take...).
+
+ def parse_java_file(fn):
+ """ "Parse" a .java file.
+
+ This actually just splits the file name, so the assumption here
+ is that the file name matches the public class name, and that
+ the path to the file is the same as the package name.
+ """
+ return os.path.split(file)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/Perforce.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/Perforce.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/Perforce.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,94 @@
+"""SCons.Tool.Perforce.py
+
+Tool-specific initialization for Perforce Source Code Management system.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/Perforce.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+
+import SCons.Builder
+import SCons.Node.FS
+import SCons.Util
+
+# This function should maybe be moved to SCons.Util?
+from SCons.Tool.PharLapCommon import addPathIfNotExists
+
+# Variables that we want to import from the base OS environment.
+_import_env = [ 'P4PORT', 'P4CLIENT', 'P4USER', 'USER', 'USERNAME', 'P4PASSWD',
+ 'P4CHARSET', 'P4LANGUAGE', 'SYSTEMROOT' ]
+
+def generate(env):
+ """Add a Builder factory function and construction variables for
+ Perforce to an Environment."""
+
+ def PerforceFactory(env=env):
+ """ """
+ return SCons.Builder.Builder(action = '$P4COM',
+ env = env)
+
+ #setattr(env, 'Perforce', PerforceFactory)
+ env.Perforce = PerforceFactory
+
+ env['P4'] = 'p4'
+ env['P4FLAGS'] = SCons.Util.CLVar('')
+ env['P4COM'] = '$P4 $P4FLAGS sync $TARGET'
+ try:
+ environ = env['ENV']
+ except KeyError:
+ environ = {}
+ env['ENV'] = environ
+
+ # Perforce seems to use the PWD environment variable rather than
+ # calling getcwd() for itself, which is odd. If no PWD variable
+ # is present, p4 WILL call getcwd, but this seems to cause problems
+ # with good ol' Win32's tilde-mangling for long file names.
+ environ['PWD'] = SCons.Node.FS.default_fs.Dir('#').get_abspath()
+
+ for var in _import_env:
+ v = os.environ.get(var)
+ if v:
+ environ[var] = v
+
+ if SCons.Util.can_read_reg:
+ # If we can read the registry, add the path to Perforce to our environment.
+ try:
+ k=SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,
+ 'Software\\Perforce\\environment')
+ val, tok = SCons.Util.RegQueryValueEx(k, 'P4INSTROOT')
+ addPathIfNotExists(environ, 'PATH', val)
+ except SCons.Util.RegError:
+ # Can't detect where Perforce is, hope the user has it set in the
+ # PATH.
+ pass
+
+def exists(env):
+ return env.Detect('p4')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/PharLapCommon.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/PharLapCommon.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/PharLapCommon.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,132 @@
+"""SCons.Tool.PharLapCommon
+
+This module contains common code used by all Tools for the
+Phar Lap ETS tool chain. Right now, this is linkloc and
+386asm.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/PharLapCommon.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+import os.path
+import SCons.Errors
+import SCons.Util
+import re
+import string
+
+def getPharLapPath():
+ """Reads the registry to find the installed path of the Phar Lap ETS
+ development kit.
+
+ Raises UserError if no installed version of Phar Lap can
+ be found."""
+
+ if not SCons.Util.can_read_reg:
+ raise SCons.Errors.InternalError, "No Windows registry module was found"
+ try:
+ k=SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,
+ 'SOFTWARE\\Pharlap\\ETS')
+ val, type = SCons.Util.RegQueryValueEx(k, 'BaseDir')
+
+ # The following is a hack...there is (not surprisingly)
+ # an odd issue in the Phar Lap plug in that inserts
+ # a bunch of junk data after the phar lap path in the
+ # registry. We must trim it.
+ idx=val.find('\0')
+ if idx >= 0:
+ val = val[:idx]
+
+ return os.path.normpath(val)
+ except SCons.Util.RegError:
+ raise SCons.Errors.UserError, "Cannot find Phar Lap ETS path in the registry. Is it installed properly?"
+
+REGEX_ETS_VER = re.compile(r'#define\s+ETS_VER\s+([0-9]+)')
+
+def getPharLapVersion():
+ """Returns the version of the installed ETS Tool Suite as a
+ decimal number. This version comes from the ETS_VER #define in
+ the embkern.h header. For example, '#define ETS_VER 1010' (which
+ is what Phar Lap 10.1 defines) would cause this method to return
+ 1010. Phar Lap 9.1 does not have such a #define, but this method
+ will return 910 as a default.
+
+ Raises UserError if no installed version of Phar Lap can
+ be found."""
+
+ include_path = os.path.join(getPharLapPath(), os.path.normpath("include/embkern.h"))
+ if not os.path.exists(include_path):
+ raise SCons.Errors.UserError, "Cannot find embkern.h in ETS include directory.\nIs Phar Lap ETS installed properly?"
+ mo = REGEX_ETS_VER.search(open(include_path, 'r').read())
+ if mo:
+ return int(mo.group(1))
+ # Default return for Phar Lap 9.1
+ return 910
+
+def addPathIfNotExists(env_dict, key, path, sep=os.pathsep):
+ """This function will take 'key' out of the dictionary
+ 'env_dict', then add the path 'path' to that key if it is not
+ already there. This treats the value of env_dict[key] as if it
+ has a similar format to the PATH variable...a list of paths
+ separated by tokens. The 'path' will get added to the list if it
+ is not already there."""
+ try:
+ is_list = 1
+ paths = env_dict[key]
+ if not SCons.Util.is_List(env_dict[key]):
+ paths = string.split(paths, sep)
+ is_list = 0
+ if not os.path.normcase(path) in map(os.path.normcase, paths):
+ paths = [ path ] + paths
+ if is_list:
+ env_dict[key] = paths
+ else:
+ env_dict[key] = string.join(paths, sep)
+ except KeyError:
+ env_dict[key] = path
+
+def addPharLapPaths(env):
+ """This function adds the path to the Phar Lap binaries, includes,
+ and libraries, if they are not already there."""
+ ph_path = getPharLapPath()
+
+ try:
+ env_dict = env['ENV']
+ except KeyError:
+ env_dict = {}
+ env['ENV'] = env_dict
+ addPathIfNotExists(env_dict, 'PATH',
+ os.path.join(ph_path, 'bin'))
+ addPathIfNotExists(env_dict, 'INCLUDE',
+ os.path.join(ph_path, 'include'))
+ addPathIfNotExists(env_dict, 'LIB',
+ os.path.join(ph_path, 'lib'))
+ addPathIfNotExists(env_dict, 'LIB',
+ os.path.join(ph_path, os.path.normpath('lib/vclib')))
+
+ env['PHARLAP_PATH'] = getPharLapPath()
+ env['PHARLAP_VERSION'] = str(getPharLapVersion())
+
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/RCS.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/RCS.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/RCS.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,56 @@
+"""SCons.Tool.RCS.py
+
+Tool-specific initialization for RCS.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/RCS.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Builder
+import SCons.Util
+
+def generate(env):
+ """Add a Builder factory function and construction variables for
+ RCS to an Environment."""
+
+ def RCSFactory(env=env):
+ """ """
+ return SCons.Builder.Builder(action = '$RCS_COCOM', env = env)
+
+ #setattr(env, 'RCS', RCSFactory)
+ env.RCS = RCSFactory
+
+ env['RCS'] = 'rcs'
+ env['RCS_CO'] = 'co'
+ env['RCS_COFLAGS'] = SCons.Util.CLVar('')
+ env['RCS_COCOM'] = '$RCS_CO $RCS_COFLAGS $TARGET'
+
+def exists(env):
+ return env.Detect('rcs')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/SCCS.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/SCCS.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/SCCS.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,56 @@
+"""SCons.Tool.SCCS.py
+
+Tool-specific initialization for SCCS.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/SCCS.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Builder
+import SCons.Util
+
+def generate(env):
+ """Add a Builder factory function and construction variables for
+ SCCS to an Environment."""
+
+ def SCCSFactory(env=env):
+ """ """
+ return SCons.Builder.Builder(action = '$SCCSCOM', env = env)
+
+ #setattr(env, 'SCCS', SCCSFactory)
+ env.SCCS = SCCSFactory
+
+ env['SCCS'] = 'sccs'
+ env['SCCSFLAGS'] = SCons.Util.CLVar('')
+ env['SCCSGETFLAGS'] = SCons.Util.CLVar('')
+ env['SCCSCOM'] = '$SCCS $SCCSFLAGS get $SCCSGETFLAGS $TARGET'
+
+def exists(env):
+ return env.Detect('sccs')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/Subversion.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/Subversion.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/Subversion.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,63 @@
+"""SCons.Tool.Subversion.py
+
+Tool-specific initialization for Subversion.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/Subversion.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+
+import SCons.Builder
+import SCons.Util
+
+def generate(env):
+ """Add a Builder factory function and construction variables for
+ Subversion to an Environment."""
+
+ def SubversionFactory(repos, module='', env=env):
+ """ """
+ # fail if repos is not an absolute path name?
+ if module != '':
+ module = os.path.join(module, '')
+ return SCons.Builder.Builder(action = '$SVNCOM',
+ env = env,
+ SVNREPOSITORY = repos,
+ SVNMODULE = module)
+
+ #setattr(env, 'Subversion', SubversionFactory)
+ env.Subversion = SubversionFactory
+
+ env['SVN'] = 'svn'
+ env['SVNFLAGS'] = SCons.Util.CLVar('')
+ env['SVNCOM'] = '$SVN $SVNFLAGS cat $SVNREPOSITORY/$SVNMODULE$TARGET > $TARGET'
+
+def exists(env):
+ return env.Detect('svn')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/__init__.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/__init__.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/__init__.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,342 @@
+"""SCons.Tool
+
+SCons tool selection.
+
+This looks for modules that define a callable object that can modify
+a construction environment as appropriate for a given tool (or tool
+chain).
+
+Note that because this subsystem just *selects* a callable that can
+modify a construction environment, it's possible for people to define
+their own "tool specification" in an arbitrary callable function. No
+one needs to use or tie in to this subsystem in order to roll their own
+tool definition.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/__init__.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import imp
+import sys
+
+import SCons.Errors
+import SCons.Defaults
+
+class ToolSpec:
+ def __init__(self, name):
+ self.name = name
+
+ def __call__(self, env, *args, **kw):
+ env.Append(TOOLS = [ self.name ])
+ apply(self.generate, ( env, ) + args, kw)
+
+ def __str__(self):
+ return self.name
+
+def Tool(name, toolpath=[]):
+ "Select a canned Tool specification, optionally searching in toolpath."
+
+ try:
+ file, path, desc = imp.find_module(name, toolpath)
+ try:
+ module = imp.load_module(name, file, path, desc)
+ spec = ToolSpec(name)
+ spec.generate = module.generate
+ spec.exists = module.exists
+ return spec
+ finally:
+ if file:
+ file.close()
+ except ImportError, e:
+ pass
+
+ full_name = 'SCons.Tool.' + name
+ if not sys.modules.has_key(full_name):
+ try:
+ file, path, desc = imp.find_module(name,
+ sys.modules['SCons.Tool'].__path__)
+ mod = imp.load_module(full_name, file, path, desc)
+ setattr(SCons.Tool, name, mod)
+ except ImportError, e:
+ raise SCons.Errors.UserError, "No tool named '%s': %s" % (name, e)
+ if file:
+ file.close()
+ spec = ToolSpec(name)
+ spec.generate = sys.modules[full_name].generate
+ spec.exists = sys.modules[full_name].exists
+ return spec
+
+def createProgBuilder(env):
+ """This is a utility function that creates the Program
+ Builder in an Environment if it is not there already.
+
+ If it is already there, we return the existing one.
+ """
+
+ try:
+ program = env['BUILDERS']['Program']
+ except KeyError:
+ program = SCons.Builder.Builder(action = SCons.Defaults.LinkAction,
+ emitter = '$PROGEMITTER',
+ prefix = '$PROGPREFIX',
+ suffix = '$PROGSUFFIX',
+ src_suffix = '$OBJSUFFIX',
+ src_builder = 'Object',
+ target_scanner = SCons.Defaults.ProgScan)
+ env['BUILDERS']['Program'] = program
+
+ return program
+
+def createStaticLibBuilder(env):
+ """This is a utility function that creates the StaticLibrary
+ Builder in an Environment if it is not there already.
+
+ If it is already there, we return the existing one.
+ """
+
+ try:
+ static_lib = env['BUILDERS']['StaticLibrary']
+ except KeyError:
+ static_lib = SCons.Builder.Builder(action = SCons.Defaults.ArAction,
+ emitter = '$LIBEMITTER',
+ prefix = '$LIBPREFIX',
+ suffix = '$LIBSUFFIX',
+ src_suffix = '$OBJSUFFIX',
+ src_builder = 'StaticObject')
+ env['BUILDERS']['StaticLibrary'] = static_lib
+ env['BUILDERS']['Library'] = static_lib
+
+ return static_lib
+
+def createSharedLibBuilder(env):
+ """This is a utility function that creates the SharedLibrary
+ Builder in an Environment if it is not there already.
+
+ If it is already there, we return the existing one.
+ """
+
+ try:
+ shared_lib = env['BUILDERS']['SharedLibrary']
+ except KeyError:
+ action_list = [ SCons.Defaults.SharedCheck,
+ SCons.Defaults.ShLinkAction ]
+ shared_lib = SCons.Builder.Builder(action = action_list,
+ emitter = "$SHLIBEMITTER",
+ prefix = '$SHLIBPREFIX',
+ suffix = '$SHLIBSUFFIX',
+ target_scanner = SCons.Defaults.ProgScan,
+ src_suffix = '$SHOBJSUFFIX',
+ src_builder = 'SharedObject')
+ env['BUILDERS']['SharedLibrary'] = shared_lib
+
+ return shared_lib
+
+def createObjBuilders(env):
+ """This is a utility function that creates the StaticObject
+ and SharedObject Builders in an Environment if they
+ are not there already.
+
+ If they are there already, we return the existing ones.
+
+ This is a separate function because soooo many Tools
+ use this functionality.
+
+ The return is a 2-tuple of (StaticObject, SharedObject)
+ """
+
+ try:
+ static_obj = env['BUILDERS']['StaticObject']
+ except KeyError:
+ static_obj = SCons.Builder.Builder(action = {},
+ emitter = {},
+ prefix = '$OBJPREFIX',
+ suffix = '$OBJSUFFIX',
+ src_builder = ['CFile', 'CXXFile'],
+ source_scanner = SCons.Defaults.ObjSourceScan, single_source=1)
+ env['BUILDERS']['StaticObject'] = static_obj
+ env['BUILDERS']['Object'] = static_obj
+
+ try:
+ shared_obj = env['BUILDERS']['SharedObject']
+ except KeyError:
+ shared_obj = SCons.Builder.Builder(action = {},
+ emitter = {},
+ prefix = '$SHOBJPREFIX',
+ suffix = '$SHOBJSUFFIX',
+ src_builder = ['CFile', 'CXXFile'],
+ source_scanner = SCons.Defaults.ObjSourceScan, single_source=1)
+ env['BUILDERS']['SharedObject'] = shared_obj
+
+ return (static_obj, shared_obj)
+
+def createCFileBuilders(env):
+ """This is a utility function that creates the CFile/CXXFile
+ Builders in an Environment if they
+ are not there already.
+
+ If they are there already, we return the existing ones.
+
+ This is a separate function because soooo many Tools
+ use this functionality.
+
+ The return is a 2-tuple of (CFile, CXXFile)
+ """
+
+ try:
+ c_file = env['BUILDERS']['CFile']
+ except KeyError:
+ c_file = SCons.Builder.Builder(action = {},
+ emitter = {},
+ suffix = {None:'$CFILESUFFIX'})
+ env['BUILDERS']['CFile'] = c_file
+ env['CFILESUFFIX'] = '.c'
+
+ try:
+ cxx_file = env['BUILDERS']['CXXFile']
+ except KeyError:
+ cxx_file = SCons.Builder.Builder(action = {},
+ emitter = {},
+ suffix = {None:'$CXXFILESUFFIX'})
+ env['BUILDERS']['CXXFile'] = cxx_file
+ env['CXXFILESUFFIX'] = '.cc'
+
+ return (c_file, cxx_file)
+
+def FindTool(tools, env):
+ for tool in tools:
+ t = Tool(tool)
+ if t.exists(env):
+ return tool
+ return None
+
+def FindAllTools(tools, env):
+ def ToolExists(tool, env=env):
+ return Tool(tool).exists(env)
+ return filter (ToolExists, tools)
+
+def tool_list(platform, env):
+
+ # XXX this logic about what tool to prefer on which platform
+ # should be moved into either the platform files or
+ # the tool files themselves.
+ # The search orders here are described in the man page. If you
+ # change these search orders, update the man page as well.
+ if str(platform) == 'win32':
+ "prefer Microsoft tools on Windows"
+ linkers = ['mslink', 'gnulink', 'ilink', 'linkloc', 'ilink32' ]
+ c_compilers = ['msvc', 'mingw', 'gcc', 'icl', 'icc', 'cc', 'bcc32' ]
+ cxx_compilers = ['msvc', 'icc', 'g++', 'c++', 'bcc32' ]
+ assemblers = ['masm', 'nasm', 'gas', '386asm' ]
+ fortran_compilers = ['g77', 'ifl', 'cvf', 'fortran']
+ ars = ['mslib', 'ar', 'tlib']
+ elif str(platform) == 'os2':
+ "prefer IBM tools on OS/2"
+ linkers = ['ilink', 'gnulink', 'mslink']
+ c_compilers = ['icc', 'gcc', 'msvc', 'cc']
+ cxx_compilers = ['icc', 'g++', 'msvc', 'c++']
+ assemblers = ['nasm', 'masm', 'gas']
+ fortran_compilers = ['ifl', 'g77']
+ ars = ['ar', 'mslib']
+ elif str(platform) == 'irix':
+ "prefer MIPSPro on IRIX"
+ linkers = ['sgilink', 'gnulink']
+ c_compilers = ['sgicc', 'gcc', 'cc']
+ cxx_compilers = ['sgic++', 'g++', 'c++']
+ assemblers = ['as', 'gas']
+ fortran_compilers = ['f77', 'g77', 'fortran']
+ ars = ['sgiar']
+ elif str(platform) == 'sunos':
+ "prefer Forte tools on SunOS"
+ linkers = ['sunlink', 'gnulink']
+ c_compilers = ['suncc', 'gcc', 'cc']
+ cxx_compilers = ['sunc++', 'g++', 'c++']
+ assemblers = ['as', 'gas']
+ fortran_compilers = ['f77', 'g77', 'fortran']
+ ars = ['sunar']
+ elif str(platform) == 'hpux':
+ "prefer aCC tools on HP-UX"
+ linkers = ['hplink', 'gnulink']
+ c_compilers = ['hpcc', 'gcc', 'cc']
+ cxx_compilers = ['hpc++', 'g++', 'c++']
+ assemblers = ['as', 'gas']
+ fortran_compilers = ['f77', 'g77', 'fortran']
+ ars = ['ar']
+ elif str(platform) == 'aix':
+ "prefer AIX Visual Age tools on AIX"
+ linkers = ['aixlink', 'gnulink']
+ c_compilers = ['aixcc', 'gcc', 'cc']
+ cxx_compilers = ['aixc++', 'g++', 'c++']
+ assemblers = ['as', 'gas']
+ fortran_compilers = ['aixf77', 'g77', 'fortran']
+ ars = ['ar']
+ else:
+ "prefer GNU tools on all other platforms"
+ linkers = ['gnulink', 'mslink', 'ilink']
+ c_compilers = ['gcc', 'msvc', 'icc', 'cc']
+ cxx_compilers = ['g++', 'msvc', 'icc', 'c++']
+ assemblers = ['gas', 'nasm', 'masm']
+ fortran_compilers = ['g77', 'ifort', 'ifl', 'fortran']
+ ars = ['ar', 'mslib']
+
+ c_compiler = FindTool(c_compilers, env) or c_compilers[0]
+
+ # XXX this logic about what tool provides what should somehow be
+ # moved into the tool files themselves.
+ if c_compiler and c_compiler == 'mingw':
+ # MinGW contains a linker, C compiler, C++ compiler,
+ # Fortran compiler, archiver and assembler:
+ cxx_compiler = None
+ linker = None
+ assembler = None
+ fortran_compiler = None
+ ar = None
+ else:
+ # Don't use g++ if the C compiler has built-in C++ support:
+ if c_compiler in ('msvc', 'icc'):
+ cxx_compiler = None
+ else:
+ cxx_compiler = FindTool(cxx_compilers, env) or cxx_compilers[0]
+ linker = FindTool(linkers, env) or linkers[0]
+ assembler = FindTool(assemblers, env) or assemblers[0]
+ fortran_compiler = FindTool(fortran_compilers, env) or fortran_compilers[0]
+ ar = FindTool(ars, env) or ars[0]
+
+ other_tools = FindAllTools(['BitKeeper', 'CVS',
+ 'dmd',
+ 'dvipdf', 'dvips', 'gs',
+ 'jar', 'javac', 'javah',
+ 'latex', 'lex', 'm4', 'midl', 'msvs',
+ 'pdflatex', 'pdftex', 'Perforce',
+ 'RCS', 'rmic', 'SCCS',
+ # 'Subversion',
+ 'swig',
+ 'tar', 'tex', 'yacc', 'zip'],
+ env)
+
+ tools = ([linker, c_compiler, cxx_compiler,
+ fortran_compiler, assembler, ar]
+ + other_tools)
+
+ return filter(lambda x: x, tools)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/aixc++.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/aixc++.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/aixc++.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,77 @@
+"""SCons.Tool.aixc++
+
+Tool-specific initialization for IBM xlC / Visual Age C++ compiler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/aixc++.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+
+import SCons.Platform.aix
+import SCons.Script.SConscript
+
+cplusplus = __import__('c++', globals(), locals(), [])
+
+packages = ['vacpp.cmp.core', 'vacpp.cmp.batch', 'vacpp.cmp.C', 'ibmcxx.cmp']
+
+def get_xlc(env):
+ xlc = env.get('CXX', 'xlC')
+ xlc_r = env.get('SHCXX', 'xlC_r')
+ return SCons.Platform.aix.get_xlc(env, xlc, xlc_r, packages)
+
+def smart_cxxflags(source, target, env, for_signature):
+ build_dir = SCons.Script.SConscript.GetBuildPath()
+ if build_dir:
+ return '-qtempinc=' + os.path.join(build_dir, 'tempinc')
+ return ''
+
+def generate(env):
+ """Add Builders and construction variables for xlC / Visual Age
+ suite to an Environment."""
+ path, _cxx, _shcxx, version = get_xlc(env)
+ if path:
+ _cxx = os.path.join(path, _cxx)
+ _shcxx = os.path.join(path, _shcxx)
+
+ cplusplus.generate(env)
+
+ env['CXX'] = _cxx
+ env['SHCXX'] = _shcxx
+ env['CXXVERSION'] = version
+ env['SHOBJSUFFIX'] = '.pic.o'
+
+def exists(env):
+ path, _cxx, _shcxx, version = get_xlc(env)
+ if path and _cxx:
+ xlc = os.path.join(path, _cxx)
+ if os.path.exists(xlc):
+ return xlc
+ return None
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/aixcc.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/aixcc.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/aixcc.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,68 @@
+"""SCons.Tool.aixcc
+
+Tool-specific initialization for IBM xlc / Visual Age C compiler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/aixcc.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+
+import SCons.Platform.aix
+
+import cc
+
+packages = ['vac.C', 'ibmcxx.cmp']
+
+def get_xlc(env):
+ xlc = env.get('CC', 'xlc')
+ xlc_r = env.get('SHCC', 'xlc_r')
+ return SCons.Platform.aix.get_xlc(env, xlc, xlc_r, packages)
+
+def generate(env):
+ """Add Builders and construction variables for xlc / Visual Age
+ suite to an Environment."""
+ path, _cc, _shcc, version = get_xlc(env)
+ if path:
+ _cc = os.path.join(path, _cc)
+ _shcc = os.path.join(path, _shcc)
+
+ cc.generate(env)
+
+ env['CC'] = _cc
+ env['SHCC'] = _shcc
+ env['CCVERSION'] = version
+
+def exists(env):
+ path, _cc, _shcc, version = get_xlc(env)
+ if path and _cc:
+ xlc = os.path.join(path, _cc)
+ if os.path.exists(xlc):
+ return xlc
+ return None
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/aixf77.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/aixf77.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/aixf77.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,74 @@
+"""engine.SCons.Tool.aixf77
+
+Tool-specific initialization for IBM Visual Age f77 Fortran compiler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/aixf77.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+
+#import SCons.Platform.aix
+
+import f77
+
+# It would be good to look for the AIX F77 package the same way we're now
+# looking for the C and C++ packages. This should be as easy as supplying
+# the correct package names in the following list and uncommenting the
+# SCons.Platform.aix_get_xlc() call the in the function below.
+packages = []
+
+def get_xlf77(env):
+ xlf77 = env.get('F77', 'xlf77')
+ xlf77_r = env.get('SHF77', 'xlf77_r')
+ #return SCons.Platform.aix.get_xlc(env, xlf77, xlf77_r, packages)
+ return (None, xlf77, xlf77_r, None)
+
+def generate(env):
+ """
+ Add Builders and construction variables for the Visual Age FORTRAN
+ compiler to an Environment.
+ """
+ path, _f77, _shf77, version = get_xlf77(env)
+ if path:
+ _f77 = os.path.join(path, _f77)
+ _shf77 = os.path.join(path, _shf77)
+
+ f77.generate(env)
+
+ env['F77'] = _f77
+ env['SHF77'] = _shf77
+
+def exists(env):
+ path, _f77, _shf77, version = get_xlf77(env)
+ if path and _f77:
+ xlf77 = os.path.join(path, _f77)
+ if os.path.exists(xlf77):
+ return xlf77
+ return None
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/aixlink.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/aixlink.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/aixlink.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,70 @@
+"""SCons.Tool.aixlink
+
+Tool-specific initialization for the IBM Visual Age linker.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/aixlink.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+import os.path
+
+import SCons.Util
+
+import aixcc
+import link
+
+cplusplus = __import__('c++', globals(), locals(), [])
+
+def smart_linkflags(source, target, env, for_signature):
+ if cplusplus.iscplusplus(source):
+ build_dir = env.subst('$BUILDDIR')
+ if build_dir:
+ return '-qtempinc=' + os.path.join(build_dir, 'tempinc')
+ return ''
+
+def generate(env):
+ """
+ Add Builders and construction variables for Visual Age linker to
+ an Environment.
+ """
+ link.generate(env)
+
+ env['SMARTLINKFLAGS'] = smart_linkflags
+ env['LINKFLAGS'] = SCons.Util.CLVar('$SMARTLINKFLAGS')
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -qmkshrobj -qsuppress=1501-218')
+ env['SHLIBSUFFIX'] = '.a'
+
+def exists(env):
+ path, _cc, _shcc, version = aixcc.get_xlc(env)
+ if path and _cc:
+ xlc = os.path.join(path, _cc)
+ if os.path.exists(xlc):
+ return xlc
+ return None
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/ar.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/ar.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/ar.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,58 @@
+"""SCons.Tool.ar
+
+Tool-specific initialization for ar (library archive).
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/ar.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+def generate(env):
+ """Add Builders and construction variables for ar to an Environment."""
+ SCons.Tool.createStaticLibBuilder(env)
+
+ arcom = '$AR $ARFLAGS $TARGET $SOURCES'
+ ranlib = 'ranlib'
+ if env.Detect(ranlib):
+ arcom = arcom + '\n$RANLIB $RANLIBFLAGS $TARGET'
+
+ env['AR'] = 'ar'
+ env['ARFLAGS'] = SCons.Util.CLVar('r')
+ env['RANLIB'] = ranlib
+ env['RANLIBFLAGS'] = SCons.Util.CLVar('')
+ env['ARCOM'] = arcom
+ env['LIBPREFIX'] = 'lib'
+ env['LIBSUFFIX'] = '.a'
+
+def exists(env):
+ return env.Detect('ar')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/as.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/as.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/as.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,67 @@
+"""SCons.Tool.as
+
+Tool-specific initialization for as, the generic Posix assembler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/as.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+assemblers = ['as']
+
+ASSuffixes = ['.s', '.asm', '.ASM']
+ASPPSuffixes = ['.spp', '.SPP']
+if SCons.Util.case_sensitive_suffixes('.s', '.S'):
+ ASPPSuffixes.extend(['.S'])
+else:
+ ASSuffixes.extend(['.S'])
+
+def generate(env):
+ """Add Builders and construction variables for as to an Environment."""
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ for suffix in ASSuffixes:
+ static_obj.add_action(suffix, SCons.Defaults.ASAction)
+ static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter)
+
+ for suffix in ASPPSuffixes:
+ static_obj.add_action(suffix, SCons.Defaults.ASPPAction)
+ static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter)
+
+ env['AS'] = env.Detect(assemblers) or 'as'
+ env['ASFLAGS'] = SCons.Util.CLVar('')
+ env['ASCOM'] = '$AS $ASFLAGS -o $TARGET $SOURCES'
+ env['ASPPCOM'] = '$CC $ASFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
+
+def exists(env):
+ return env.Detect(assemblers)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/bcc32.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/bcc32.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/bcc32.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,79 @@
+"""SCons.Tool.bcc32
+
+XXX
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/bcc32.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+import os.path
+import string
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+def findIt(program, env):
+ # First search in the SCons path and then the OS path:
+ borwin = env.WhereIs(program) or SCons.Util.WhereIs(program)
+ if borwin:
+ dir = os.path.dirname(borwin)
+ path = env['ENV'].get('PATH', [])
+ if not path:
+ path = []
+ if SCons.Util.is_String(path):
+ path = string.split(path, os.pathsep)
+ env['ENV']['PATH'] = string.join([dir]+path, os.pathsep)
+ return borwin
+
+def generate(env):
+ findIt('bcc32', env)
+ """Add Builders and construction variables for bcc to an
+ Environment."""
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+ for suffix in ['.c', '.cpp']:
+ static_obj.add_action(suffix, SCons.Defaults.CAction)
+ shared_obj.add_action(suffix, SCons.Defaults.ShCAction)
+ static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter)
+ shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter)
+
+ env['CC'] = 'bcc32'
+ env['CCFLAGS'] = SCons.Util.CLVar('')
+ env['CCCOM'] = '$CC -q $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
+ env['SHCC'] = '$CC'
+ env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
+ env['SHCCCOM'] = '$SHCC -WD $SHCCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
+ env['CPPDEFPREFIX'] = '-D'
+ env['CPPDEFSUFFIX'] = ''
+ env['INCPREFIX'] = '-I'
+ env['INCSUFFIX'] = ''
+ env['SHOBJSUFFIX'] = '.dll'
+ env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 0
+ env['CFILESUFFIX'] = '.cpp'
+
+def exists(env):
+ return findIt('bcc32', env)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/c++.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/c++.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/c++.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,89 @@
+"""SCons.Tool.c++
+
+Tool-specific initialization for generic Posix C++ compilers.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/c++.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+
+import SCons.Tool
+import SCons.Defaults
+import SCons.Util
+
+compilers = ['CC', 'c++']
+
+CXXSuffixes = ['.cpp', '.cc', '.cxx', '.c++', '.C++']
+if SCons.Util.case_sensitive_suffixes('.c', '.C'):
+ CXXSuffixes.append('.C')
+
+def iscplusplus(source):
+ if not source:
+ # Source might be None for unusual cases like SConf.
+ return 0
+ for s in source:
+ if s.sources:
+ ext = os.path.splitext(str(s.sources[0]))[1]
+ if ext in CXXSuffixes:
+ return 1
+ return 0
+
+def generate(env):
+ """
+ Add Builders and construction variables for Visual Age C++ compilers
+ to an Environment.
+ """
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ for suffix in CXXSuffixes:
+ static_obj.add_action(suffix, SCons.Defaults.CXXAction)
+ shared_obj.add_action(suffix, SCons.Defaults.ShCXXAction)
+ static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter)
+ shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter)
+
+ env['CXX'] = 'c++'
+ env['CXXFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
+ env['CXXCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
+ env['SHCXX'] = '$CXX'
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
+ env['SHCXXCOM'] = '$SHCXX $SHCXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
+
+ env['CPPDEFPREFIX'] = '-D'
+ env['CPPDEFSUFFIX'] = ''
+ env['INCPREFIX'] = '-I'
+ env['INCSUFFIX'] = ''
+ env['SHOBJSUFFIX'] = '.os'
+ env['OBJSUFFIX'] = '.o'
+ env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 0
+
+ env['CXXFILESUFFIX'] = '.cc'
+
+def exists(env):
+ return env.Detect(compilers)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/cc.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/cc.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/cc.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,72 @@
+"""SCons.Tool.cc
+
+Tool-specific initialization for generic Posix C compilers.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/cc.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Tool
+import SCons.Defaults
+import SCons.Util
+
+CSuffixes = ['.c']
+if not SCons.Util.case_sensitive_suffixes('.c', '.C'):
+ CSuffixes.append('.C')
+
+def generate(env):
+ """
+ Add Builders and construction variables for C compilers to an Environment.
+ """
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ for suffix in CSuffixes:
+ static_obj.add_action(suffix, SCons.Defaults.CAction)
+ shared_obj.add_action(suffix, SCons.Defaults.ShCAction)
+ static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter)
+ shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter)
+
+ env['CC'] = 'cc'
+ env['CCFLAGS'] = SCons.Util.CLVar('')
+ env['CCCOM'] = '$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
+ env['SHCC'] = '$CC'
+ env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
+ env['SHCCCOM'] = '$SHCC $SHCCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
+
+ env['CPPDEFPREFIX'] = '-D'
+ env['CPPDEFSUFFIX'] = ''
+ env['INCPREFIX'] = '-I'
+ env['INCSUFFIX'] = ''
+ env['SHOBJSUFFIX'] = '.os'
+ env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 0
+
+ env['CFILESUFFIX'] = '.c'
+
+def exists(env):
+ return env.Detect('cc')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/cvf.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/cvf.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/cvf.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,53 @@
+"""engine.SCons.Tool.cvf
+
+Tool-specific initialization for the Compaq Visual Fortran compiler.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/cvf.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Util
+import fortran
+
+compilers = ['f90']
+
+def generate(env):
+ """Add Builders and construction variables for compaq visual fortran to an Environment."""
+
+ fortran.generate(env)
+
+ env['FORTRAN'] = 'f90'
+ env['FORTRANCOM'] = '$FORTRAN $FORTRANFLAGS $_FORTRANMODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.win32} /object:${TARGET.win32}'
+ env['FORTRANPPCOM'] = '$FORTRAN $FORTRANFLAGS $CPPFLAGS $_CPPDEFFLAGS $_FORTRANMODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.win32} /object:${TARGET.win32}'
+ env['SHFORTRANCOM'] = '$SHFORTRAN $SHFORTRANFLAGS $_FORTRANMODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.win32} /object:${TARGET.win32}'
+ env['SHFORTRANPPCOM'] = '$SHFORTRAN $SHFORTRANFLAGS $CPPFLAGS $_CPPDEFFLAGS $_FORTRANMODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.win32} /object:${TARGET.win32}'
+ env['OBJSUFFIX'] = '.obj'
+ env['FORTRANMODDIR'] = '${TARGET.dir}'
+ env['FORTRANMODDIRPREFIX'] = '/module:'
+ env['FORTRANMODDIRSUFFIX'] = ''
+
+def exists(env):
+ return env.Detect(compilers)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/default.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/default.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/default.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,44 @@
+"""SCons.Tool.default
+
+Initialization with a default tool list.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/default.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Tool
+
+def generate(env):
+ """Add default tools."""
+ for t in SCons.Tool.tool_list(env['PLATFORM'], env):
+ SCons.Tool.Tool(t)(env)
+
+def exists(env):
+ return 1
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/dmd.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/dmd.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/dmd.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,199 @@
+"""SCons.Tool.dmd
+
+Tool-specific initialization for the Digital Mars D compiler.
+(http://digitalmars.com/d)
+
+Coded by Andy Friesen (andy at ikagames.com)
+15 November 2003
+
+There are a number of problems with this script at this point in time.
+The one that irritates me the most is the win32 linker setup. The D
+linker doesn't have a way to add lib paths on the commandline, as far
+as I can see. You have to specify paths relative to the SConscript or
+use absolute paths. To hack around it, add '#/blah'. This will link
+blah.lib from the directory where SConstruct resides.
+
+Compiler variables:
+ DC - The name of the D compiler to use. Defaults to dmd.
+ DPATH - List of paths to search for import modules.
+ DVERSIONS - List of version tags to enable when compiling.
+ DDEBUG - List of debug tags to enable when compiling.
+
+Linker related variables:
+ LIBS - List of library files to link in.
+ DLINK - Name of the linker to use. Defaults to dmd.
+ DLINKFLAGS - List of linker flags.
+
+Lib tool variables:
+ DLIB - Name of the lib tool to use. Defaults to lib.
+ DLIBFLAGS - List of flags to pass to the lib tool.
+ LIBS - Same as for the linker. (libraries to pull into the .lib)
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/dmd.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+import string
+
+import SCons.Tool
+import SCons.Scanner.D
+import SCons.Builder
+import SCons.Defaults
+
+# Adapted from c++.py
+def isD(source):
+ if not source:
+ return 0
+
+ for s in source:
+ if s.sources:
+ ext = os.path.splitext(str(s.sources[0]))[1]
+ if ext == '.d':
+ return 1
+ return 0
+
+smart_link = {}
+
+smart_lib = {}
+
+def generate(env):
+ global smart_link
+ global smart_lib
+
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ static_obj.add_action('.d', '$DCOM')
+ shared_obj.add_action('.d', '$DCOM')
+ static_obj.add_emitter('.d', SCons.Defaults.StaticObjectEmitter)
+ shared_obj.add_emitter('.d', SCons.Defaults.SharedObjectEmitter)
+
+ env['DC'] = 'dmd'
+ env['DCOM'] = '$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -c -of$TARGET $SOURCES'
+ env['_DINCFLAGS'] = '$( ${_concat(DINCPREFIX, DPATH, DINCSUFFIX, __env__, RDirs)} $)'
+ env['_DVERFLAGS'] = '$( ${_concat(DVERPREFIX, DVERSIONS, DVERSUFFIX, __env__)} $)'
+ env['_DDEBUGFLAGS'] = '$( ${_concat(DDEBUGPREFIX, DDEBUG, DDEBUGSUFFIX, __env__)} $)'
+ env['_DFLAGS'] = '$( ${_concat(DFLAGPREFIX, DFLAGS, DFLAGSUFFIX, __env__)} $)'
+
+ env['DPATH'] = ['#/']
+ env['DFLAGS'] = []
+ env['DVERSIONS'] = []
+ env['DDEBUG'] = []
+
+ # Add the path to the standard library.
+ # This is merely for the convenience of the dependency scanner.
+ dmd_path = env.WhereIs('dmd')
+ if dmd_path:
+ x = string.rindex(dmd_path, 'dmd')
+ phobosDir = dmd_path[:x] + '/../src/phobos'
+ if os.path.isdir(phobosDir):
+ env.Append(DPATH = [phobosDir])
+
+ env['DINCPREFIX'] = '-I'
+ env['DINCSUFFIX'] = ''
+ env['DVERPREFIX'] = '-version='
+ env['DVERSUFFIX'] = ''
+ env['DDEBUGPREFIX'] = '-debug='
+ env['DDEBUGSUFFIX'] = ''
+ env['DFLAGPREFIX'] = '-'
+ env['DFLAGSUFFIX'] = ''
+ env['DFILESUFFIX'] = '.d'
+
+ # Need to use the Digital Mars linker/lib on windows.
+ # *nix can just use GNU link.
+ if env['PLATFORM'] == 'win32':
+ env['DLINK'] = '$DC'
+ env['DLINKCOM'] = '$DLINK -of$TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
+ env['DLIB'] = 'lib'
+ env['DLIBCOM'] = '$DLIB $_DLIBFLAGS -c $TARGET $SOURCES $_DLINKLIBFLAGS'
+
+ env['_DLINKLIBFLAGS'] = '$( ${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs)} $)'
+ env['_DLIBFLAGS'] = '$( ${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)} $)'
+ env['DLINKFLAGS'] = []
+ env['DLIBLINKPREFIX'] = ''
+ env['DLIBLINKSUFFIX'] = '.lib'
+ env['DLIBFLAGPREFIX'] = '-'
+ env['DLIBFLAGSUFFIX'] = ''
+ env['DLINKFLAGPREFIX'] = '-'
+ env['DLINKFLAGSUFFIX'] = ''
+
+ SCons.Tool.createStaticLibBuilder(env)
+
+ # Basically, we hijack the link and ar builders with our own.
+ # these builders check for the presence of D source, and swap out
+ # the system's defaults for the Digital Mars tools. If there's no D
+ # source, then we silently return the previous settings.
+ linkcom = env.get('LINKCOM')
+ try:
+ env['SMART_LINKCOM'] = smart_link[linkcom]
+ except KeyError:
+ def _smartLink(source, target, env, for_signature,
+ defaultLinker=linkcom):
+ if isD(source):
+ return '$DLINKCOM'
+ else:
+ return defaultLinker
+ env['SMART_LINKCOM'] = smart_link[linkcom] = _smartLink
+
+ arcom = env.get('ARCOM')
+ try:
+ env['SMART_ARCOM'] = smart_lib[arcom]
+ except KeyError:
+ def _smartLib(source, target, env, for_signature,
+ defaultLib=arcom):
+ if isD(source):
+ return '$DLIBCOM'
+ else:
+ return defaultLib
+ env['SMART_ARCOM'] = smart_lib[arcom] = _smartLib
+
+ # It is worth noting that the final space in these strings is
+ # absolutely pivotal. SCons sees these as actions and not generators
+ # if it is not there. (very bad)
+ env['ARCOM'] = '$SMART_ARCOM '
+ env['LINKCOM'] = '$SMART_LINKCOM '
+ else: # assuming linux
+ linkcom = env.get('LINKCOM')
+ try:
+ env['SMART_LINKCOM'] = smart_link[linkcom]
+ except KeyError:
+ def _smartLink(source, target, env, for_signature,
+ defaultLinker=linkcom):
+ if isD(source):
+ try:
+ libs = env['LIBS']
+ except KeyError:
+ libs = []
+ if 'phobos' not in libs:
+ env.Append(LIBS = ['phobos'])
+ if 'pthread' not in libs:
+ env.Append(LIBS = ['pthread'])
+ return defaultLinker
+ env['SMART_LINKCOM'] = smart_link[linkcom] = _smartLink
+
+ env['LINKCOM'] = '$SMART_LINKCOM '
+
+def exists(env):
+ return env.Detect('dmd')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/dvipdf.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/dvipdf.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/dvipdf.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,56 @@
+"""SCons.Tool.dvipdf
+
+Tool-specific initialization for dvipdf.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/dvipdf.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Util
+
+def generate(env):
+ """Add Builders and construction variables for dvipdf to an Environment."""
+ try:
+ bld = env['BUILDERS']['PDF']
+ except KeyError:
+ bld = SCons.Defaults.PDF()
+ env['BUILDERS']['PDF'] = bld
+ bld.add_action('.dvi', '$PDFCOM')
+
+ env['DVIPDF'] = 'dvipdf'
+ env['DVIPDFFLAGS'] = SCons.Util.CLVar('')
+ env['DVIPDFCOM'] = '$DVIPDF $DVIPDFFLAGS $SOURCES $TARGET'
+
+ # Deprecated synonym.
+ env['PDFCOM'] = ['$DVIPDFCOM']
+
+def exists(env):
+ return env.Detect('dvipdf')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/dvips.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/dvips.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/dvips.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,55 @@
+"""SCons.Tool.dvips
+
+Tool-specific initialization for dvips.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/dvips.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Action
+import SCons.Defaults
+import SCons.Util
+
+PostScript = SCons.Builder.Builder(action = '$PSCOM',
+ prefix = '$PSPREFIX',
+ suffix = '$PSSUFFIX',
+ src_suffix = '.dvi',
+ src_builder = 'DVI')
+
+def generate(env):
+ """Add Builders and construction variables for dvips to an Environment."""
+ env['BUILDERS']['PostScript'] = PostScript
+
+ env['DVIPS'] = 'dvips'
+ env['DVIPSFLAGS'] = SCons.Util.CLVar('')
+ env['PSCOM'] = '$DVIPS $DVIPSFLAGS -o $TARGET $SOURCES'
+
+def exists(env):
+ return env.Detect('dvips')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/f77.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/f77.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/f77.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,126 @@
+"""engine.SCons.Tool.f77
+
+Tool-specific initialization for the generic Posix f77 Fortran compiler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/f77.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Scanner.Fortran
+import SCons.Tool
+import SCons.Util
+import fortran
+
+compilers = ['f77']
+
+#
+F77Suffixes = ['.f77']
+F77PPSuffixes = []
+if SCons.Util.case_sensitive_suffixes('.f77', '.F77'):
+ F77PPSuffixes.append('.F77')
+else:
+ F77Suffixes.append('.F77')
+
+#
+F77Scan = SCons.Scanner.Fortran.FortranScan("F77PATH")
+
+for suffix in F77Suffixes + F77PPSuffixes:
+ SCons.Defaults.ObjSourceScan.add_scanner(suffix, F77Scan)
+
+#
+fVLG = fortran.VariableListGenerator
+
+F77Generator = fVLG('F77', 'FORTRAN', '_FORTRAND')
+F77FlagsGenerator = fVLG('F77FLAGS', 'FORTRANFLAGS')
+F77CommandGenerator = fVLG('F77COM', 'FORTRANCOM', '_F77COMD')
+F77PPCommandGenerator = fVLG('F77PPCOM', 'FORTRANPPCOM', '_F77PPCOMD')
+ShF77Generator = fVLG('SHF77', 'SHFORTRAN', 'F77', 'FORTRAN', '_FORTRAND')
+ShF77FlagsGenerator = fVLG('SHF77FLAGS', 'SHFORTRANFLAGS')
+ShF77CommandGenerator = fVLG('SHF77COM', 'SHFORTRANCOM', '_SHF77COMD')
+ShF77PPCommandGenerator = fVLG('SHF77PPCOM', 'SHFORTRANPPCOM', '_SHF77PPCOMD')
+
+del fVLG
+
+#
+F77Action = SCons.Action.Action('$_F77COMG ')
+F77PPAction = SCons.Action.Action('$_F77PPCOMG ')
+ShF77Action = SCons.Action.Action('$_SHF77COMG ')
+ShF77PPAction = SCons.Action.Action('$_SHF77PPCOMG ')
+
+def add_to_env(env):
+ """Add Builders and construction variables for f77 to an Environment."""
+ env.AppendUnique(FORTRANSUFFIXES = F77Suffixes + F77PPSuffixes)
+
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ for suffix in F77Suffixes:
+ static_obj.add_action(suffix, F77Action)
+ shared_obj.add_action(suffix, ShF77Action)
+ static_obj.add_emitter(suffix, fortran.FortranEmitter)
+ shared_obj.add_emitter(suffix, fortran.ShFortranEmitter)
+
+ for suffix in F77PPSuffixes:
+ static_obj.add_action(suffix, F77PPAction)
+ shared_obj.add_action(suffix, ShF77PPAction)
+ static_obj.add_emitter(suffix, fortran.FortranEmitter)
+ shared_obj.add_emitter(suffix, fortran.ShFortranEmitter)
+
+ env['_F77G'] = F77Generator
+ env['_F77FLAGSG'] = F77FlagsGenerator
+ env['_F77COMG'] = F77CommandGenerator
+ env['_F77PPCOMG'] = F77PPCommandGenerator
+
+ env['_SHF77G'] = ShF77Generator
+ env['_SHF77FLAGSG'] = ShF77FlagsGenerator
+ env['_SHF77COMG'] = ShF77CommandGenerator
+ env['_SHF77PPCOMG'] = ShF77PPCommandGenerator
+
+ env['_F77INCFLAGS'] = '$( ${_concat(INCPREFIX, F77PATH, INCSUFFIX, __env__, RDirs)} $)'
+
+ env['_F77COMD'] = '$_F77G $_F77FLAGSG $_F77INCFLAGS -c -o $TARGET $SOURCES'
+ env['_F77PPCOMD'] = '$_F77G $_F77FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES'
+ env['_SHF77COMD'] = '$_SHF77G $_SHF77FLAGSG $_F77INCFLAGS -c -o $TARGET $SOURCES'
+ env['_SHF77PPCOMD'] = '$_SHF77G $_SHF77FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES'
+
+def generate(env):
+ fortran.add_to_env(env)
+
+ import f90
+ import f95
+ f90.add_to_env(env)
+ f95.add_to_env(env)
+
+ add_to_env(env)
+
+ env['_FORTRAND'] = env.Detect(compilers) or 'f77'
+
+def exists(env):
+ return env.Detect(compilers)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/f90.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/f90.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/f90.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,119 @@
+"""engine.SCons.Tool.f90
+
+Tool-specific initialization for the generic Posix f90 Fortran compiler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/f90.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Scanner.Fortran
+import SCons.Tool
+import SCons.Util
+import fortran
+
+compilers = ['f90']
+
+#
+F90Suffixes = ['.f90']
+F90PPSuffixes = []
+if SCons.Util.case_sensitive_suffixes('.f90', '.F90'):
+ F90PPSuffixes.append('.F90')
+else:
+ F90Suffixes.append('.F90')
+
+#
+F90Scan = SCons.Scanner.Fortran.FortranScan("F90PATH")
+
+for suffix in F90Suffixes + F90PPSuffixes:
+ SCons.Defaults.ObjSourceScan.add_scanner(suffix, F90Scan)
+
+#
+fVLG = fortran.VariableListGenerator
+
+F90Generator = fVLG('F90', 'FORTRAN', '_FORTRAND')
+F90FlagsGenerator = fVLG('F90FLAGS', 'FORTRANFLAGS')
+F90CommandGenerator = fVLG('F90COM', 'FORTRANCOM', '_F90COMD')
+F90PPCommandGenerator = fVLG('F90PPCOM', 'FORTRANPPCOM', '_F90PPCOMD')
+ShF90Generator = fVLG('SHF90', 'SHFORTRAN', 'F90', 'FORTRAN', '_FORTRAND')
+ShF90FlagsGenerator = fVLG('SHF90FLAGS', 'SHFORTRANFLAGS')
+ShF90CommandGenerator = fVLG('SHF90COM', 'SHFORTRANCOM', '_SHF90COMD')
+ShF90PPCommandGenerator = fVLG('SHF90PPCOM', 'SHFORTRANPPCOM', '_SHF90PPCOMD')
+
+del fVLG
+
+#
+F90Action = SCons.Action.Action('$_F90COMG ')
+F90PPAction = SCons.Action.Action('$_F90PPCOMG ')
+ShF90Action = SCons.Action.Action('$_SHF90COMG ')
+ShF90PPAction = SCons.Action.Action('$_SHF90PPCOMG ')
+
+def add_to_env(env):
+ """Add Builders and construction variables for f90 to an Environment."""
+ env.AppendUnique(FORTRANSUFFIXES = F90Suffixes + F90PPSuffixes)
+
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ for suffix in F90Suffixes:
+ static_obj.add_action(suffix, F90Action)
+ shared_obj.add_action(suffix, ShF90Action)
+ static_obj.add_emitter(suffix, fortran.FortranEmitter)
+ shared_obj.add_emitter(suffix, fortran.ShFortranEmitter)
+
+ for suffix in F90PPSuffixes:
+ static_obj.add_action(suffix, F90PPAction)
+ shared_obj.add_action(suffix, ShF90PPAction)
+ static_obj.add_emitter(suffix, fortran.FortranEmitter)
+ shared_obj.add_emitter(suffix, fortran.ShFortranEmitter)
+
+ env['_F90G'] = F90Generator
+ env['_F90FLAGSG'] = F90FlagsGenerator
+ env['_F90COMG'] = F90CommandGenerator
+ env['_F90PPCOMG'] = F90PPCommandGenerator
+
+ env['_SHF90G'] = ShF90Generator
+ env['_SHF90FLAGSG'] = ShF90FlagsGenerator
+ env['_SHF90COMG'] = ShF90CommandGenerator
+ env['_SHF90PPCOMG'] = ShF90PPCommandGenerator
+
+ env['_F90INCFLAGS'] = '$( ${_concat(INCPREFIX, F90PATH, INCSUFFIX, __env__, RDirs)} $)'
+ env['_F90COMD'] = '$_F90G $_F90FLAGSG $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+ env['_F90PPCOMD'] = '$_F90G $_F90FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+ env['_SHF90COMD'] = '$_SHF90G $_SHF90FLAGSG $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+ env['_SHF90PPCOMD'] = '$_SHF90G $_SHF90FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+
+def generate(env):
+ fortran.add_to_env(env)
+ add_to_env(env)
+
+ env['_FORTRAND'] = env.Detect(compilers) or 'f90'
+
+def exists(env):
+ return env.Detect(compilers)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/f95.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/f95.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/f95.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,119 @@
+"""engine.SCons.Tool.f95
+
+Tool-specific initialization for the generic Posix f95 Fortran compiler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/f95.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+import fortran
+
+compilers = ['f95']
+
+#
+F95Suffixes = ['.f95']
+F95PPSuffixes = []
+if SCons.Util.case_sensitive_suffixes('.f95', '.F95'):
+ F95PPSuffixes.append('.F95')
+else:
+ F95Suffixes.append('.F95')
+
+#
+F95Scan = SCons.Scanner.Fortran.FortranScan("F95PATH")
+
+for suffix in F95Suffixes + F95PPSuffixes:
+ SCons.Defaults.ObjSourceScan.add_scanner(suffix, F95Scan)
+
+#
+fVLG = fortran.VariableListGenerator
+
+F95Generator = fVLG('F95', 'FORTRAN', '_FORTRAND')
+F95FlagsGenerator = fVLG('F95FLAGS', 'FORTRANFLAGS')
+F95CommandGenerator = fVLG('F95COM', 'FORTRANCOM', '_F95COMD')
+F95PPCommandGenerator = fVLG('F95PPCOM', 'FORTRANPPCOM', '_F95PPCOMD')
+ShF95Generator = fVLG('SHF95', 'SHFORTRAN', 'F95', 'FORTRAN', '_FORTRAND')
+ShF95FlagsGenerator = fVLG('SHF95FLAGS', 'SHFORTRANFLAGS')
+ShF95CommandGenerator = fVLG('SHF95COM', 'SHFORTRANCOM', '_SHF95COMD')
+ShF95PPCommandGenerator = fVLG('SHF95PPCOM', 'SHFORTRANPPCOM', '_SHF95PPCOMD')
+
+del fVLG
+
+#
+F95Action = SCons.Action.Action('$_F95COMG ')
+F95PPAction = SCons.Action.Action('$_F95PPCOMG ')
+ShF95Action = SCons.Action.Action('$_SHF95COMG ')
+ShF95PPAction = SCons.Action.Action('$_SHF95PPCOMG ')
+
+def add_to_env(env):
+ """Add Builders and construction variables for f95 to an Environment."""
+ env.AppendUnique(FORTRANSUFFIXES = F95Suffixes + F95PPSuffixes)
+
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ for suffix in F95Suffixes:
+ static_obj.add_action(suffix, F95Action)
+ shared_obj.add_action(suffix, ShF95Action)
+ static_obj.add_emitter(suffix, fortran.FortranEmitter)
+ shared_obj.add_emitter(suffix, fortran.ShFortranEmitter)
+
+ for suffix in F95PPSuffixes:
+ static_obj.add_action(suffix, F95PPAction)
+ shared_obj.add_action(suffix, ShF95PPAction)
+ static_obj.add_emitter(suffix, fortran.FortranEmitter)
+ shared_obj.add_emitter(suffix, fortran.ShFortranEmitter)
+
+ env['_F95G'] = F95Generator
+ env['_F95FLAGSG'] = F95FlagsGenerator
+ env['_F95COMG'] = F95CommandGenerator
+ env['_F95PPCOMG'] = F95PPCommandGenerator
+
+ env['_SHF95G'] = ShF95Generator
+ env['_SHF95FLAGSG'] = ShF95FlagsGenerator
+ env['_SHF95COMG'] = ShF95CommandGenerator
+ env['_SHF95PPCOMG'] = ShF95PPCommandGenerator
+
+ env['_F95INCFLAGS'] = '$( ${_concat(INCPREFIX, F95PATH, INCSUFFIX, __env__, RDirs)} $)'
+
+ env['_F95COMD'] = '$_F95G $_F95FLAGSG $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+ env['_F95PPCOMD'] = '$_F95G $_F95FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+ env['_SHF95COMD'] = '$_SHF95G $_SHF95FLAGSG $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+ env['_SHF95PPCOMD'] = '$_SHF95G $_SHF95FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+
+def generate(env):
+ fortran.add_to_env(env)
+ add_to_env(env)
+
+ env['_FORTRAND'] = env.Detect(compilers) or 'f95'
+
+def exists(env):
+ return env.Detect(compilers)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/fortran.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/fortran.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/fortran.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,176 @@
+"""SCons.Tool.fortran
+
+Tool-specific initialization for a generic Posix f77/f90 Fortran compiler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/fortran.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import re
+import string
+
+import SCons.Action
+import SCons.Defaults
+import SCons.Scanner.Fortran
+import SCons.Tool
+import SCons.Util
+
+compilers = ['f95', 'f90', 'f77']
+
+#
+# Not yet sure how to deal with fortran pre-processor functions.
+# Different compilers do this differently in modern fortran. Some still
+# rely on the c pre-processor, some (like cvf, ivf) have their own
+# pre-processor technology and use intermediary suffixes (.i90)
+#
+FortranSuffixes = [".f", ".for", ".ftn", ]
+FortranPPSuffixes = ['.fpp', '.FPP']
+upper_case = [".F", ".FOR", ".FTN"]
+if SCons.Util.case_sensitive_suffixes('.f', '.F'):
+ FortranPPSuffixes.extend(upper_case)
+else:
+ FortranSuffixes.extend(upper_case)
+
+#
+FortranScan = SCons.Scanner.Fortran.FortranScan("FORTRANPATH")
+
+for suffix in FortranSuffixes + FortranPPSuffixes:
+ SCons.Defaults.ObjSourceScan.add_scanner(suffix, FortranScan)
+
+#
+def _fortranEmitter(target, source, env):
+ node = source[0].rfile()
+ if not node.exists() and not node.is_derived():
+ print "Could not locate " + str(node.name)
+ return ([], [])
+ mod_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)"""
+ cre = re.compile(mod_regex,re.M)
+ # Retrieve all USE'd module names
+ modules = cre.findall(node.get_contents())
+ # Remove unique items from the list
+ modules = SCons.Util.unique(modules)
+ # Convert module name to a .mod filename
+ suffix = env.subst('$FORTRANMODSUFFIX')
+ modules = map(lambda x, s=suffix: string.lower(x) + s, modules)
+ for m in modules:
+ target.append(env.fs.File(m))
+ return (target, source)
+
+def FortranEmitter(target, source, env):
+ target, source = _fortranEmitter(target, source, env)
+ return SCons.Defaults.StaticObjectEmitter(target, source, env)
+
+def ShFortranEmitter(target, source, env):
+ target, source = _fortranEmitter(target, source, env)
+ return SCons.Defaults.SharedObjectEmitter(target, source, env)
+
+class VariableListGenerator:
+ def __init__(self, *variablelist):
+ self.variablelist = variablelist
+ def __call__(self, env, target, source, for_signature):
+ for v in self.variablelist:
+ try: return env[v]
+ except KeyError: pass
+ return ''
+
+#
+FortranGenerator = VariableListGenerator('FORTRAN', 'F77', '_FORTRAND')
+FortranFlagsGenerator = VariableListGenerator('FORTRANFLAGS', 'F77FLAGS')
+FortranCommandGenerator = VariableListGenerator('FORTRANCOM', 'F77COM', '_FORTRANCOMD')
+FortranPPCommandGenerator = VariableListGenerator('FORTRANPPCOM', 'F77PPCOM', '_FORTRANPPCOMD')
+ShFortranGenerator = VariableListGenerator('SHFORTRAN', 'SHF77', 'FORTRAN', 'F77', '_FORTRAND')
+ShFortranFlagsGenerator = VariableListGenerator('SHFORTRANFLAGS', 'SHF77FLAGS')
+ShFortranCommandGenerator = VariableListGenerator('SHFORTRANCOM', 'SHF77COM', '_SHFORTRANCOMD')
+ShFortranPPCommandGenerator = VariableListGenerator('SHFORTRANPPCOM', 'SHF77PPCOM', '_SHFORTRANPPCOMD')
+
+#
+FortranAction = SCons.Action.Action('$_FORTRANCOMG ')
+FortranPPAction = SCons.Action.Action('$_FORTRANPPCOMG ')
+ShFortranAction = SCons.Action.Action('$_SHFORTRANCOMG ')
+ShFortranPPAction = SCons.Action.Action('$_SHFORTRANPPCOMG ')
+
+def add_to_env(env):
+ """Add Builders and construction variables for Fortran to an Environment."""
+
+ env['_FORTRANG'] = FortranGenerator
+ env['_FORTRANFLAGSG'] = FortranFlagsGenerator
+ env['_FORTRANCOMG'] = FortranCommandGenerator
+ env['_FORTRANPPCOMG'] = FortranPPCommandGenerator
+
+ env['_SHFORTRANG'] = ShFortranGenerator
+ env['_SHFORTRANFLAGSG'] = ShFortranFlagsGenerator
+ env['_SHFORTRANCOMG'] = ShFortranCommandGenerator
+ env['_SHFORTRANPPCOMG'] = ShFortranPPCommandGenerator
+
+ env['_FORTRANINCFLAGS'] = '$( ${_concat(INCPREFIX, FORTRANPATH, INCSUFFIX, __env__, RDirs)} $)'
+
+ env['FORTRANMODPREFIX'] = '' # like $LIBPREFIX
+ env['FORTRANMODSUFFIX'] = '.mod' # like $LIBSUFFIX
+
+ env['FORTRANMODDIR'] = '' # where the compiler should place .mod files
+ env['FORTRANMODDIRPREFIX'] = '' # some prefix to $FORTRANMODDIR - similar to $INCPREFIX
+ env['FORTRANMODDIRSUFFIX'] = '' # some suffix to $FORTRANMODDIR - similar to $INCSUFFIX
+ env['_FORTRANMODFLAG'] = '$( ${_concat(FORTRANMODDIRPREFIX, FORTRANMODDIR, FORTRANMODDIRSUFFIX, __env__)} $)'
+
+ env.AppendUnique(FORTRANSUFFIXES = FortranSuffixes + FortranPPSuffixes)
+
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ for suffix in FortranSuffixes:
+ static_obj.add_action(suffix, FortranAction)
+ shared_obj.add_action(suffix, ShFortranAction)
+ static_obj.add_emitter(suffix, FortranEmitter)
+ shared_obj.add_emitter(suffix, ShFortranEmitter)
+
+ for suffix in FortranPPSuffixes:
+ static_obj.add_action(suffix, FortranPPAction)
+ shared_obj.add_action(suffix, ShFortranPPAction)
+ static_obj.add_emitter(suffix, FortranEmitter)
+ shared_obj.add_emitter(suffix, ShFortranEmitter)
+
+ env['_FORTRANCOMD'] = '$_FORTRANG $_FORTRANFLAGSG $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+ env['_FORTRANPPCOMD'] = '$_FORTRANG $_FORTRANFLAGSG $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+ env['_SHFORTRANCOMD'] = '$_SHFORTRANG $_SHFORTRANFLAGSG $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+ env['_SHFORTRANPPCOMD'] = '$_SHFORTRANG $_SHFORTRANFLAGSG $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+
+def generate(env):
+ import f77
+ import f90
+ import f95
+ f77.add_to_env(env)
+ f90.add_to_env(env)
+ f95.add_to_env(env)
+
+ add_to_env(env)
+
+ env['_FORTRAND'] = env.Detect(compilers) or 'f77'
+
+def exists(env):
+ return env.Detect(compilers)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/g++.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/g++.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/g++.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,87 @@
+"""SCons.Tool.g++
+
+Tool-specific initialization for g++.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/g++.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+import re
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+cplusplus = __import__('c++', globals(), locals(), [])
+
+compilers = ['g++']
+
+def generate(env):
+ """Add Builders and construction variables for g++ to an Environment."""
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ cplusplus.generate(env)
+
+ env['CXX'] = env.Detect(compilers)
+
+ # platform specific settings
+ if env['PLATFORM'] == 'cygwin':
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
+ elif env['PLATFORM'] == 'aix':
+ # Original line from Christian Engel added -DPIC:
+ #env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -DPIC -mminimal-toc')
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -mminimal-toc')
+ env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
+ env['SHOBJSUFFIX'] = '$OBJSUFFIX'
+ elif env['PLATFORM'] == 'hpux':
+ # Original line from Christian Engel added -DPIC:
+ #env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -fPIC -DPIC')
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -fPIC')
+ env['SHOBJSUFFIX'] = '.pic.o'
+ elif env['PLATFORM'] == 'sunos':
+ # Original line from Christian Engel added -DPIC:
+ #env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -fPIC -DPIC')
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -fPIC')
+ env['SHOBJSUFFIX'] = '.pic.o'
+ else:
+ # Original line from Christian Engel added -DPIC:
+ #env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -fPIC -DPIC')
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -fPIC')
+ # determine compiler version
+ if env['CXX']:
+ line = os.popen(env['CXX'] + ' --version').readline()
+ match = re.search(r'[0-9]+(\.[0-9]+)+', line)
+ if match:
+ env['CXXVERSION'] = match.group(0)
+
+
+def exists(env):
+ return env.Detect(compilers)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/g77.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/g77.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/g77.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,47 @@
+"""engine.SCons.Tool.g77
+
+Tool-specific initialization for g77.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/g77.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import f77
+
+compilers = ['g77', 'f77']
+
+def generate(env):
+ """Add Builders and construction variables for g77 to an Environment."""
+ f77.generate(env)
+
+ env['_FORTRAND'] = env.Detect(compilers) or 'g77'
+
+def exists(env):
+ return env.Detect(compilers)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/gas.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/gas.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/gas.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,47 @@
+"""SCons.Tool.gas
+
+Tool-specific initialization for as, the Gnu assembler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/gas.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import as
+
+assemblers = ['as', 'gas']
+
+def generate(env):
+ """Add Builders and construction variables for as to an Environment."""
+ as.generate(env)
+
+ env['AS'] = env.Detect(assemblers) or 'as'
+
+def exists(env):
+ return env.Detect(assemblers)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/gcc.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/gcc.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/gcc.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,53 @@
+"""SCons.Tool.gcc
+
+Tool-specific initialization for gcc.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/gcc.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Util
+
+import cc
+
+compilers = ['gcc', 'cc']
+
+def generate(env):
+ """Add Builders and construction variables for gcc to an Environment."""
+ cc.generate(env)
+
+ env['CC'] = env.Detect(compilers) or 'gcc'
+ if env['PLATFORM'] == 'cygwin':
+ env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
+ else:
+ env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS -fPIC')
+
+def exists(env):
+ return env.Detect(compilers)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/gnulink.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/gnulink.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/gnulink.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,59 @@
+"""SCons.Tool.gnulink
+
+Tool-specific initialization for the gnu linker.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/gnulink.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Util
+
+import link
+
+linkers = ['g++', 'gcc']
+
+def generate(env):
+ """Add Builders and construction variables for gnulink to an Environment."""
+ link.generate(env)
+
+ if env['PLATFORM'] == 'hpux':
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared -fPIC')
+ elif env['PLATFORM'] == 'darwin':
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -dynamiclib')
+
+ # __RPATH is set to $_RPATH in the platform specification if that
+ # platform supports it.
+ env.Append(LINKFLAGS=['$__RPATH'])
+ env['RPATHPREFIX'] = '-Wl,--rpath='
+ env['RPATHSUFFIX'] = ''
+ env['_RPATH'] = '${_concat(RPATHPREFIX, RPATH, RPATHSUFFIX, __env__)}'
+
+def exists(env):
+ return env.Detect(linkers)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/gs.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/gs.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/gs.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,70 @@
+"""SCons.Tool.gs
+
+Tool-specific initialization for Ghostscript.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/gs.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Platform
+import SCons.Util
+
+# Ghostscript goes by different names on different platforms...
+platform = SCons.Platform.platform_default()
+
+if platform == 'os2':
+ gs = 'gsos2'
+elif platform == 'win32':
+ gs = 'gswin32c'
+else:
+ gs = 'gs'
+
+def generate(env):
+ """Add Builders and construction variables for Ghostscript to an
+ Environment."""
+ try:
+ bld = env['BUILDERS']['PDF']
+ except KeyError:
+ bld = SCons.Defaults.PDF()
+ env['BUILDERS']['PDF'] = bld
+
+ bld.add_action('.ps', '$GSCOM')
+
+ env['GS'] = gs
+ env['GSFLAGS'] = SCons.Util.CLVar('-dNOPAUSE -dBATCH -sDEVICE=pdfwrite')
+ env['GSCOM'] = '$GS $GSFLAGS -sOutputFile=$TARGET $SOURCES'
+
+
+def exists(env):
+ if env.has_key('PS2PDF'):
+ return env.Detect(env['PS2PDF'])
+ else:
+ return env.Detect(gs) or SCons.Util.WhereIs(gs)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/hpc++.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/hpc++.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/hpc++.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,76 @@
+"""SCons.Tool.hpc++
+
+Tool-specific initialization for c++ on HP/UX.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/hpc++.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+import string
+
+import SCons.Util
+
+cplusplus = __import__('c++', globals(), locals(), [])
+
+acc = None
+
+# search for the acc compiler and linker front end
+
+try:
+ dirs = os.listdir('/opt')
+except OSError:
+ dirs = []
+
+for dir in dirs:
+ cc = '/opt/' + dir + '/bin/aCC'
+ if os.path.exists(cc):
+ acc = cc
+ break
+
+
+def generate(env):
+ """Add Builders and construction variables for g++ to an Environment."""
+ cplusplus.generate(env)
+
+ if acc:
+ env['CXX'] = acc or 'aCC'
+ # determine version of aCC
+ line = os.popen(acc + ' -V 2>&1').readline().rstrip()
+ if string.find(line, 'aCC: HP ANSI C++') == 0:
+ env['CXXVERSION'] = string.split(line)[-1]
+
+ if env['PLATFORM'] == 'cygwin':
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
+ else:
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS +Z')
+
+def exists(env):
+ return acc
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/hpcc.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/hpcc.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/hpcc.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,44 @@
+"""SCons.Tool.hpcc
+
+Tool-specific initialization for HP aCC and cc.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/hpcc.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import cc
+
+def generate(env):
+ """Add Builders and construction variables for aCC & cc to an Environment."""
+ cc.generate(env)
+
+ env['CXX'] = 'aCC'
+
+def exists(env):
+ return env.Detect('aCC')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/hplink.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/hplink.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/hplink.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,69 @@
+"""SCons.Tool.hplink
+
+Tool-specific initialization for the HP linker.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/hplink.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+import os.path
+
+import SCons.Util
+
+import link
+
+ccLinker = None
+
+# search for the acc compiler and linker front end
+
+try:
+ dirs = os.listdir('/opt')
+except OSError:
+ dirs = []
+
+for dir in dirs:
+ linker = '/opt/' + dir + '/bin/aCC'
+ if os.path.exists(linker):
+ ccLinker = linker
+ break
+
+def generate(env):
+ """
+ Add Builders and construction variables for Visual Age linker to
+ an Environment.
+ """
+ link.generate(env)
+
+ env['LINKFLAGS'] = SCons.Util.CLVar('-Wl,+s -Wl,+vnocompatwarnings')
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -b')
+ env['SHLIBSUFFIX'] = '.sl'
+
+def exists(env):
+ return ccLinker
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/icc.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/icc.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/icc.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,53 @@
+"""engine.SCons.Tool.icc
+
+Tool-specific initialization for the OS/2 icc compiler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/icc.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import cc
+
+def generate(env):
+ """Add Builders and construction variables for the OS/2 to an Environment."""
+ cc.generate(env)
+
+ env['CC'] = 'icc'
+ env['CCCOM'] = '$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo$TARGET'
+ env['CXXCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo$TARGET'
+ env['CPPDEFPREFIX'] = '/D'
+ env['CPPDEFSUFFIX'] = ''
+ env['INCPREFIX'] = '/I'
+ env['INCSUFFIX'] = ''
+ env['CFILESUFFIX'] = '.c'
+ env['CXXFILESUFFIX'] = '.cc'
+
+def exists(env):
+ return env.Detect('icc')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/icl.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/icl.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/icl.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,138 @@
+"""engine.SCons.Tool.icl
+
+Tool-specific initialization for the Intel C/C++ compiler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/icl.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+
+import SCons.Tool.msvc
+import SCons.Util
+import SCons.Warnings
+
+# Find Intel compiler:
+# Could enumerate subkeys here to be more flexible.
+def get_intel_compiler_top(version):
+ """
+ Return the main path to the top-level dir of the Intel compiler,
+ using the given version or latest if 0.
+ The compiler will be in <top>/Bin/icl.exe,
+ the include dir is <top>/Include, etc.
+ """
+
+ if version == 0:
+ version = "7.0" # XXX: should scan for latest
+
+ if not SCons.Util.can_read_reg:
+ raise SCons.Errors.InternalError, "No Windows registry module was found"
+
+ K = ('Software\\Intel\\' +
+ 'Intel(R) C/C++ Compiler for 32-bit apps, Version ' + version)
+ # Note: v5 had slightly different key:
+ # HKCU\Software\Intel\Intel C/C++ Compiler for 32-bit apps, Version 5.0
+ # Note no (R).
+ try:
+ k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_CURRENT_USER, K)
+ except SCons.Util.RegError:
+ return None
+
+ try:
+ # On my machine, this returns:
+ # c:\Program Files\Intel\Compiler70
+ top = SCons.Util.RegQueryValueEx(k, "Directory")[0]
+ except SCons.Util.RegError:
+ raise SCons.Errors.InternalError, "%s was not found in the registry."%K
+
+ if os.path.exists(os.path.join(top, "ia32")):
+ top = os.path.join(top, "ia32")
+
+ if not os.path.exists(os.path.join(top, "Bin", "icl.exe")):
+ raise SCons.Errors.InternalError, "Can't find Intel compiler in %s"%top
+
+ return top
+
+
+def generate(env):
+ """Add Builders and construction variables for icl to an Environment."""
+ SCons.Tool.msvc.generate(env)
+
+ try:
+ icltop = get_intel_compiler_top(0)
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ icltop = None
+
+ if icltop:
+ env.PrependENVPath('INCLUDE', os.path.join(icltop, 'Include'))
+ env.PrependENVPath('LIB', os.path.join(icltop, 'Lib'))
+ env.PrependENVPath('PATH', os.path.join(icltop, 'Bin'))
+
+ env['CC'] = 'icl'
+ env['CXX'] = 'icl'
+ env['LINK'] = 'xilink'
+
+ # Look for license file dir.
+ envlicdir = os.environ.get("INTEL_LICENSE_FILE", '')
+ K = ('SOFTWARE\Intel\Licenses')
+ try:
+ k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, K)
+ reglicdir = SCons.Util.RegQueryValueEx(k, "w_cpp")[0]
+ except (AttributeError, SCons.Util.RegError):
+ reglicdir = ""
+ defaultlicdir = r'C:\Program Files\Common Files\Intel\Licenses'
+
+ licdir = None
+ for ld in [envlicdir, reglicdir]:
+ if ld and os.path.exists(ld):
+ licdir = ld
+ break
+ if not licdir:
+ licdir = defaultlicdir
+ if not os.path.exists(licdir):
+ class ICLLicenseDirWarning(SCons.Warnings.Warning):
+ pass
+ SCons.Warnings.enableWarningClass(ICLLicenseDirWarning)
+ SCons.Warnings.warn(ICLLicenseDirWarning,
+ "Intel license dir was not found."
+ " Tried using the INTEL_LICENSE_FILE environment variable (%s), the registry (%s) and the default path (%s)."
+ " Using the default path as a last resort."
+ % (envlicdir, reglicdir, defaultlicdir))
+ env['ENV']['INTEL_LICENSE_FILE'] = licdir
+
+def exists(env):
+ try:
+ top = get_intel_compiler_top(0)
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ top = None
+
+ if not top:
+ return env.Detect('icl')
+ return top is not None
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/ifl.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/ifl.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/ifl.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,53 @@
+"""SCons.Tool.ifl
+
+Tool-specific initialization for the Intel Fortran compiler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/ifl.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+
+import fortran
+
+def generate(env):
+ """Add Builders and construction variables for ifl to an Environment."""
+ SCons.Defaults.ObjSourceScan.add_scanner('.i90', fortran.FortranScan)
+ fortran.FortranSuffixes.extend(['.i90'])
+ fortran.generate(env)
+
+ env['FORTRAN'] = 'ifl'
+ env['FORTRANCOM'] = '$FORTRAN $FORTRANFLAGS $_FORTRANINCFLAGS /c $SOURCES /Fo$TARGET'
+ env['FORTRANPPCOM'] = '$FORTRAN $FORTRANFLAGS $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS /c $SOURCES /Fo$TARGET'
+ env['SHFORTRANCOM'] = '$SHFORTRAN $SHFORTRANFLAGS $_FORTRANINCFLAGS /c $SOURCES /Fo$TARGET'
+ env['SHFORTRANPPCOM'] = '$SHFORTRAN $SHFORTRANFLAGS $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS /c $SOURCES /Fo$TARGET'
+
+def exists(env):
+ return env.Detect('ifl')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/ifort.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/ifort.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/ifort.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,62 @@
+"""SCons.Tool.ifort
+
+Tool-specific initialization for newer versions of the Intel Fortran Compiler
+for Linux.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/ifort.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+
+import fortran
+
+def generate(env):
+ """Add Builders and construction variables for ifort to an Environment."""
+ # ifort supports Fortran 90 and Fortran 95
+ # Additionally, ifort recognizes more file extensions.
+ SCons.Defaults.ObjSourceScan.add_scanner('.i', fortran.FortranScan)
+ SCons.Defaults.ObjSourceScan.add_scanner('.i90', fortran.FortranScan)
+ fortran.FortranSuffixes.extend(['.i', '.i90'])
+ fortran.generate(env)
+
+ env['_FORTRAND'] = 'ifort'
+
+ # If files are compiled into objects, the Intel Fortran Compiler must use
+ # ld to link shared libraries.
+ env['SHLINK'] = 'ld'
+
+ # Additionally, no symbols can be defined in an archive file; to use
+ # Intel Fortran to create shared libraries, all external symbols must
+ # be in shared libraries.
+ env['SHLINKFLAGS'] = '-shared -no_archive'
+
+def exists(env):
+ return env.Detect('ifort')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/ilink.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/ilink.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/ilink.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,53 @@
+"""SCons.Tool.ilink
+
+Tool-specific initialization for the OS/2 ilink linker.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/ilink.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+def generate(env):
+ """Add Builders and construction variables for ilink to an Environment."""
+ SCons.Tool.createProgBuilder(env)
+
+ env['LINK'] = 'ilink'
+ env['LINKFLAGS'] = SCons.Util.CLVar('')
+ env['LINKCOM'] = '$LINK $LINKFLAGS /O:$TARGET $SOURCES $( $_LIBDIRFLAGS $) $_LIBFLAGS'
+ env['LIBDIRPREFIX']='/LIBPATH:'
+ env['LIBDIRSUFFIX']=''
+ env['LIBLINKPREFIX']=''
+ env['LIBLINKSUFFIX']='$LIBSUFFIX'
+
+def exists(env):
+ return env.Detect('ilink')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/ilink32.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/ilink32.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/ilink32.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,52 @@
+"""SCons.Tool.ilink32
+
+XXX
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/ilink32.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Tool
+import SCons.Tool.bcc32
+import SCons.Util
+
+def generate(env):
+ """Add Builders and construction variables for ilink to an
+ Environment."""
+ SCons.Tool.createProgBuilder(env)
+
+ env['LINK'] = '$CC'
+ env['LINKFLAGS'] = SCons.Util.CLVar('')
+ env['LINKCOM'] = '$LINK -q $LINKFLAGS $SOURCES $LIBS'
+ env['LIBDIRPREFIX']=''
+ env['LIBDIRSUFFIX']=''
+ env['LIBLINKPREFIX']=''
+ env['LIBLINKSUFFIX']='$LIBSUFFIX'
+
+def exists(env):
+ # Uses bcc32 to do linking as it generally knows where the standard
+ # LIBS are and set up the linking correctly
+ return SCons.Tool.bcc32.findIt('bcc32', env)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/jar.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/jar.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/jar.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,102 @@
+"""SCons.Tool.jar
+
+Tool-specific initialization for jar.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/jar.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Builder
+import SCons.Util
+
+def jarSources(target, source, env, for_signature):
+ """Only include sources that are not a manifest file."""
+ ret = []
+ for src in source:
+ contents = src.get_contents()
+ if contents[:16] != "Manifest-Version":
+ if env.has_key('JARCHDIR'):
+ # If we are changing the dir with -C, then sources should
+ # be relative to that directory.
+ ret.append(src.get_path(src.fs.Dir(env['JARCHDIR'])))
+ else:
+ ret.append(src)
+ return ret
+
+def jarManifest(target, source, env, for_signature):
+ """Look in sources for a manifest file, if any."""
+ for src in source:
+ contents = src.get_contents()
+ if contents[:16] == "Manifest-Version":
+ return src
+ return ''
+
+def jarFlags(target, source, env, for_signature):
+ """If we have a manifest, make sure that the 'm'
+ flag is specified."""
+ jarflags = env.subst('$JARFLAGS')
+ for src in source:
+ contents = src.get_contents()
+ if contents[:16] == "Manifest-Version":
+ if not 'm' in jarflags:
+ return jarflags + 'm'
+ break
+ return jarflags
+
+def jarChdir(target, source, env, for_signature):
+ """If we have an Environment variable by the name
+ of JARCHDIR, then supply the command line option
+ '-C <dir>' to Jar."""
+ if env.has_key('JARCHDIR'):
+ return [ '-C', '$JARCHDIR' ]
+ return []
+
+JarBuilder = SCons.Builder.Builder(action = '$JARCOM',
+ source_factory = SCons.Node.FS.default_fs.Entry,
+ suffix = '$JARSUFFIX')
+
+def generate(env):
+ """Add Builders and construction variables for jar to an Environment."""
+ try:
+ env['BUILDERS']['Jar']
+ except KeyError:
+ env['BUILDERS']['Jar'] = JarBuilder
+
+ env['JAR'] = 'jar'
+ env['JARFLAGS'] = SCons.Util.CLVar('cf')
+ env['_JARFLAGS'] = jarFlags
+ env['_JARMANIFEST'] = jarManifest
+ env['_JARSOURCES'] = jarSources
+ env['_JARCHDIR'] = jarChdir
+ env['JARCOM'] = '$JAR $_JARFLAGS $TARGET $_JARMANIFEST $_JARCHDIR $_JARSOURCES'
+ env['JARSUFFIX'] = '.jar'
+
+def exists(env):
+ return env.Detect('jar')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/javac.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/javac.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/javac.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,110 @@
+"""SCons.Tool.javac
+
+Tool-specific initialization for javac.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/javac.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+import os.path
+import string
+
+import SCons.Builder
+from SCons.Node.FS import _my_normcase
+from SCons.Tool.JavaCommon import parse_java_file
+import SCons.Util
+
+def classname(path):
+ """Turn a string (path name) into a Java class name."""
+ return string.replace(os.path.normpath(path), os.sep, '.')
+
+def emit_java_classes(target, source, env):
+ """Create and return lists of source java files
+ and their corresponding target class files.
+ """
+ java_suffix = env.get('JAVASUFFIX', '.java')
+ class_suffix = env.get('JAVACLASSSUFFIX', '.class')
+
+ slist = []
+ js = _my_normcase(java_suffix)
+ for sdir in source:
+ def visit(arg, dirname, names, js=js, dirnode=sdir.rdir()):
+ java_files = filter(lambda n, js=js:
+ _my_normcase(n[-len(js):]) == js,
+ names)
+ mydir = dirnode.Dir(dirname)
+ java_paths = map(lambda f, d=mydir: d.File(f), java_files)
+ arg.extend(java_paths)
+ os.path.walk(sdir.rdir().get_abspath(), visit, slist)
+
+ tlist = []
+ for f in slist:
+ pkg_dir, classes = parse_java_file(f.get_abspath())
+ if pkg_dir:
+ for c in classes:
+ t = target[0].Dir(pkg_dir).File(c+class_suffix)
+ t.attributes.java_classdir = target[0]
+ t.attributes.java_classname = classname(pkg_dir + os.sep + c)
+ tlist.append(t)
+ elif classes:
+ for c in classes:
+ t = target[0].File(c+class_suffix)
+ t.attributes.java_classdir = target[0]
+ t.attributes.java_classname = classname(c)
+ tlist.append(t)
+ else:
+ # This is an odd end case: no package and no classes.
+ # Just do our best based on the source file name.
+ base = str(f)[:-len(java_suffix)]
+ t = target[0].File(base + class_suffix)
+ t.attributes.java_classdir = target[0]
+ t.attributes.java_classname = classname(base)
+ tlist.append(t)
+
+ return tlist, slist
+
+JavaBuilder = SCons.Builder.Builder(action = '$JAVACCOM',
+ emitter = emit_java_classes,
+ target_factory = SCons.Node.FS.default_fs.Dir,
+ source_factory = SCons.Node.FS.default_fs.Dir)
+
+def generate(env):
+ """Add Builders and construction variables for javac to an Environment."""
+ env['BUILDERS']['Java'] = JavaBuilder
+
+ env['JAVAC'] = 'javac'
+ env['JAVACFLAGS'] = SCons.Util.CLVar('')
+ env['JAVACCOM'] = '$JAVAC $JAVACFLAGS -d ${TARGET.attributes.java_classdir} -sourcepath ${SOURCE.dir.rdir()} $SOURCES'
+ env['JAVACLASSSUFFIX'] = '.class'
+ env['JAVASUFFIX'] = '.java'
+
+def exists(env):
+ return env.Detect('javac')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/javah.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/javah.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/javah.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,125 @@
+"""SCons.Tool.javah
+
+Tool-specific initialization for javah.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/javah.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+import string
+
+import SCons.Builder
+import SCons.Node.FS
+import SCons.Tool.javac
+import SCons.Util
+
+def emit_java_headers(target, source, env):
+ """Create and return lists of Java stub header files that will
+ be created from a set of class files.
+ """
+ class_suffix = env.get('JAVACLASSSUFFIX', '.class')
+ classdir = env.get('JAVACLASSDIR')
+
+ if not classdir:
+ try:
+ s = source[0]
+ except IndexError:
+ classdir = '.'
+ else:
+ try:
+ classdir = s.attributes.java_classdir
+ except AttributeError:
+ classdir = '.'
+ classdir = SCons.Node.FS.default_fs.Dir(classdir).rdir()
+ if str(classdir) == '.':
+ c_ = None
+ else:
+ c_ = str(classdir) + os.sep
+
+ slist = []
+ for src in source:
+ try:
+ classname = src.attributes.java_classname
+ except AttributeError:
+ classname = str(src)
+ if c_ and classname[:len(c_)] == c_:
+ classname = classname[len(c_):]
+ if class_suffix and classname[-len(class_suffix):] == class_suffix:
+ classname = classname[:-len(class_suffix)]
+ classname = SCons.Tool.javac.classname(classname)
+ s = src.rfile()
+ s.attributes.java_classdir = classdir
+ s.attributes.java_classname = classname
+ slist.append(s)
+
+ if target[0].__class__ is SCons.Node.FS.File:
+ tlist = target
+ else:
+ if not isinstance(target[0], SCons.Node.FS.Dir):
+ target[0].__class__ = SCons.Node.FS.Dir
+ target[0]._morph()
+ tlist = []
+ for s in source:
+ fname = string.replace(s.attributes.java_classname, '.', '_') + '.h'
+ t = target[0].File(fname)
+ t.attributes.java_lookupdir = target[0]
+ tlist.append(t)
+
+ return tlist, source
+
+def JavaHOutFlagGenerator(target, source, env, for_signature):
+ try:
+ t = target[0]
+ except (AttributeError, TypeError):
+ t = target
+ try:
+ return '-d ' + str(t.attributes.java_lookupdir)
+ except AttributeError:
+ return '-o ' + str(t)
+
+JavaHBuilder = SCons.Builder.Builder(action = '$JAVAHCOM',
+ emitter = emit_java_headers,
+ src_suffix = '$JAVACLASSSUFFIX',
+ target_factory = SCons.Node.FS.default_fs.Entry,
+ source_factory = SCons.Node.FS.default_fs.File)
+
+def generate(env):
+ """Add Builders and construction variables for javah to an Environment."""
+ env['BUILDERS']['JavaH'] = JavaHBuilder
+
+ env['_JAVAHOUTFLAG'] = JavaHOutFlagGenerator
+ env['JAVAH'] = 'javah'
+ env['JAVAHFLAGS'] = SCons.Util.CLVar('')
+ env['JAVAHCOM'] = '$JAVAH $JAVAHFLAGS $_JAVAHOUTFLAG -classpath ${SOURCE.attributes.java_classdir} ${SOURCES.attributes.java_classname}'
+ env['JAVACLASSSUFFIX'] = '.class'
+
+def exists(env):
+ return env.Detect('javah')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/latex.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/latex.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/latex.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,59 @@
+"""SCons.Tool.latex
+
+Tool-specific initialization for LaTeX.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/latex.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Action
+import SCons.Defaults
+import SCons.Util
+
+LaTeXAction = SCons.Action.Action('$LATEXCOM')
+
+def generate(env):
+ """Add Builders and construction variables for LaTeX to an Environment."""
+
+ try:
+ bld = env['BUILDERS']['DVI']
+ except KeyError:
+ bld = SCons.Defaults.DVI()
+ env['BUILDERS']['DVI'] = bld
+
+ bld.add_action('.ltx', LaTeXAction)
+ bld.add_action('.latex', LaTeXAction)
+
+ env['LATEX'] = 'latex'
+ env['LATEXFLAGS'] = SCons.Util.CLVar('')
+ env['LATEXCOM'] = '$LATEX $LATEXFLAGS $SOURCES'
+
+def exists(env):
+ return env.Detect('latex')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/lex.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/lex.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/lex.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,52 @@
+"""SCons.Tool.lex
+
+Tool-specific initialization for lex.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/lex.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+def generate(env):
+ """Add Builders and construction variables for lex to an Environment."""
+ c_file, cxx_file = SCons.Tool.createCFileBuilders(env)
+
+ c_file.add_action('.l', SCons.Defaults.LexAction)
+ cxx_file.add_action('.ll', SCons.Defaults.LexAction)
+
+ env['LEX'] = env.Detect('flex') or 'lex'
+ env['LEXFLAGS'] = SCons.Util.CLVar('')
+ env['LEXCOM'] = '$LEX $LEXFLAGS -t $SOURCES > $TARGET'
+
+def exists(env):
+ return env.Detect(['flex', 'lex'])
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/link.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/link.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/link.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,77 @@
+"""SCons.Tool.link
+
+Tool-specific initialization for the generic Posix linker.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/link.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+cplusplus = __import__('c++', globals(), locals(), [])
+
+def smart_link(source, target, env, for_signature):
+ if cplusplus.iscplusplus(source):
+ return '$CXX'
+ return '$CC'
+
+def generate(env):
+ """Add Builders and construction variables for gnulink to an Environment."""
+ SCons.Tool.createSharedLibBuilder(env)
+ SCons.Tool.createProgBuilder(env)
+
+ env['SHLINK'] = '$LINK'
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
+ env['SHLINKCOM'] = '$SHLINK $SHLINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
+ # don't set up the emitter, cause AppendUnique will generate a list
+ # starting with None :-(
+ #env['SHLIBEMITTER']= None
+ env['SMARTLINK'] = smart_link
+ env['LINK'] = "$SMARTLINK"
+ env['LINKFLAGS'] = SCons.Util.CLVar('')
+ env['LINKCOM'] = '$LINK $LINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
+ env['LIBDIRPREFIX']='-L'
+ env['LIBDIRSUFFIX']=''
+ env['_LIBFLAGS']='${_stripixes(LIBLINKPREFIX, LIBS, LIBLINKSUFFIX, LIBPREFIX, LIBSUFFIX, __env__)}'
+ env['LIBLINKPREFIX']='-l'
+ env['LIBLINKSUFFIX']=''
+
+ if env['PLATFORM'] == 'hpux':
+ env['SHLIBSUFFIX'] = '.sl'
+ elif env['PLATFORM'] == 'aix':
+ env['SHLIBSUFFIX'] = '.a'
+
+
+def exists(env):
+ # This module isn't really a Tool on its own, it's common logic for
+ # other linkers.
+ return None
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/linkloc.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/linkloc.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/linkloc.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,104 @@
+"""SCons.Tool.linkloc
+
+Tool specification for the LinkLoc linker for the Phar Lap ETS embedded
+operating system.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/linkloc.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+import re
+
+import SCons.Action
+import SCons.Defaults
+import SCons.Errors
+import SCons.Tool
+import SCons.Util
+
+from SCons.Tool.msvc import get_msvc_paths
+from SCons.Tool.PharLapCommon import addPharLapPaths
+
+_re_linker_command = re.compile(r'(\s)@\s*([^\s]+)')
+
+def repl_linker_command(m):
+ # Replaces any linker command file directives (e.g. "@foo.lnk") with
+ # the actual contents of the file.
+ try:
+ f=open(m.group(2), "r")
+ return m.group(1) + f.read()
+ except IOError:
+ # the linker should return an error if it can't
+ # find the linker command file so we will remain quiet.
+ # However, we will replace the @ with a # so we will not continue
+ # to find it with recursive substitution
+ return m.group(1) + '#' + m.group(2)
+
+class LinklocGenerator:
+ def __init__(self, cmdline):
+ self.cmdline = cmdline
+
+ def __call__(self, env, target, source, for_signature):
+ if for_signature:
+ # Expand the contents of any linker command files recursively
+ subs = 1
+ strsub = env.subst(self.cmdline)
+ while subs:
+ strsub, subs = _re_linker_command.subn(repl_linker_command, strsub)
+ return strsub
+ else:
+ return "${TEMPFILE('" + self.cmdline + "')}"
+
+def generate(env):
+ """Add Builders and construction variables for ar to an Environment."""
+ SCons.Tool.createSharedLibBuilder(env)
+ SCons.Tool.createProgBuilder(env)
+
+ env['SUBST_CMD_FILE'] = LinklocGenerator
+ env['SHLINK'] = '$LINK'
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS')
+ env['SHLINKCOM'] = '${SUBST_CMD_FILE("$SHLINK $SHLINKFLAGS $( $_LIBDIRFLAGS $) $_LIBFLAGS -dll $TARGET $SOURCES")}'
+ env['SHLIBEMITTER']= None
+ env['LINK'] = "linkloc"
+ env['LINKFLAGS'] = SCons.Util.CLVar('')
+ env['LINKCOM'] = '${SUBST_CMD_FILE("$LINK $LINKFLAGS $( $_LIBDIRFLAGS $) $_LIBFLAGS -exe $TARGET $SOURCES")}'
+ env['LIBDIRPREFIX']='-libpath '
+ env['LIBDIRSUFFIX']=''
+ env['LIBLINKPREFIX']='-lib '
+ env['LIBLINKSUFFIX']='$LIBSUFFIX'
+
+ include_path, lib_path, exe_path = get_msvc_paths()
+ env['ENV']['LIB'] = lib_path
+ env['ENV']['PATH'] = exe_path
+
+ addPharLapPaths(env)
+
+def exists(env):
+ return env.Detect('linkloc')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/m4.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/m4.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/m4.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,55 @@
+"""SCons.Tool.m4
+
+Tool-specific initialization for m4.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/m4.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Builder
+import SCons.Util
+
+def generate(env):
+ """Add Builders and construction variables for m4 to an Environment."""
+ bld = SCons.Builder.Builder(action = '$M4COM', src_suffix = '.m4')
+
+ env['BUILDERS']['M4'] = bld
+
+ # .m4 files might include other files, and it would be pretty hard
+ # to write a scanner for it, so let's just cd to the dir of the m4
+ # file and run from there.
+ # The src_suffix setup is like so: file.c.m4 -> file.c,
+ # file.cpp.m4 -> file.cpp etc.
+ env['M4'] = 'm4'
+ env['M4FLAGS'] = SCons.Util.CLVar('-E')
+ env['M4COM'] = 'cd ${SOURCE.rsrcdir} && $M4 $M4FLAGS < ${SOURCE.file} > ${TARGET.abspath}'
+
+def exists(env):
+ return env.Detect('m4')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/masm.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/masm.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/masm.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,70 @@
+"""SCons.Tool.masm
+
+Tool-specific initialization for the Microsoft Assembler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/masm.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+ASSuffixes = ['.s', '.asm', '.ASM']
+ASPPSuffixes = ['.spp', '.SPP']
+if SCons.Util.case_sensitive_suffixes('.s', '.S'):
+ ASPPSuffixes.extend(['.S'])
+else:
+ ASSuffixes.extend(['.S'])
+
+def generate(env):
+ """Add Builders and construction variables for masm to an Environment."""
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ for suffix in ASSuffixes:
+ static_obj.add_action(suffix, SCons.Defaults.ASAction)
+ shared_obj.add_action(suffix, SCons.Defaults.ASAction)
+ static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter)
+ shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter)
+
+ for suffix in ASPPSuffixes:
+ static_obj.add_action(suffix, SCons.Defaults.ASPPAction)
+ shared_obj.add_action(suffix, SCons.Defaults.ASPPAction)
+ static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter)
+ shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter)
+
+ env['AS'] = 'ml'
+ env['ASFLAGS'] = SCons.Util.CLVar('/nologo')
+ env['ASCOM'] = '$AS $ASFLAGS /c /Fo$TARGET $SOURCES'
+ env['ASPPCOM'] = '$CC $ASFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c /Fo$TARGET $SOURCES'
+ env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
+
+def exists(env):
+ return env.Detect('ml')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/midl.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/midl.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/midl.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,77 @@
+"""SCons.Tool.midl
+
+Tool-specific initialization for midl (Microsoft IDL compiler).
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/midl.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Scanner.IDL
+import SCons.Util
+import SCons.Tool.msvs
+
+def midl_emitter(target, source, env):
+ """Produces a list of outputs from the MIDL compiler"""
+ base, ext = SCons.Util.splitext(str(target[0]))
+ tlb = target[0]
+ incl = base + '.h'
+ interface = base + '_i.c'
+ proxy = base + '_p.c'
+ dlldata = base + '_data.c'
+
+ t = [tlb, incl, interface, proxy, dlldata]
+
+ return (t,source)
+
+idl_scanner = SCons.Scanner.IDL.IDLScan()
+
+midl_builder = SCons.Builder.Builder(action='$MIDLCOM',
+ src_suffix = '.idl',
+ suffix='.tlb',
+ emitter = midl_emitter,
+ scanner = idl_scanner)
+
+def generate(env):
+ """Add Builders and construction variables for midl to an Environment."""
+
+ env['MIDL'] = 'MIDL.EXE'
+ env['MIDLFLAGS'] = SCons.Util.CLVar('/nologo')
+ env['MIDLCOM'] = '$MIDL $MIDLFLAGS /tlb ${TARGETS[0]} /h ${TARGETS[1]} /iid ${TARGETS[2]} /proxy ${TARGETS[3]} /dlldata ${TARGETS[4]} $SOURCE 2> NUL'
+ env['BUILDERS']['TypeLibrary'] = midl_builder
+
+def exists(env):
+ if SCons.Tool.msvs.is_msvs_installed():
+ # there's at least one version of MSVS installed, which comes with midl:
+ return 1
+ else:
+ return env.Detect('midl')
+
+
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/mingw.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/mingw.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/mingw.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,150 @@
+"""SCons.Tool.gcc
+
+Tool-specific initialization for MinGW (http://www.mingw.org/)
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/mingw.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+import os.path
+import string
+
+import SCons.Tool
+import SCons.Util
+
+# This is what we search for to find mingw:
+key_program = 'mingw32-gcc'
+
+def find(env):
+ # First search in the SCons path and then the OS path:
+ return env.WhereIs(key_program) or SCons.Util.WhereIs(key_program)
+
+def shlib_generator(target, source, env, for_signature):
+ cmd = SCons.Util.CLVar(['$SHLINK', '$SHLINKFLAGS'])
+
+ dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+ if dll: cmd.extend(['-o', dll])
+
+ cmd.extend(['$SOURCES', '$_LIBDIRFLAGS', '$_LIBFLAGS'])
+
+ implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX')
+ if implib: cmd.append('-Wl,--out-implib,'+implib.get_string(for_signature))
+
+ def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
+ if def_target: cmd.append('-Wl,--output-def,'+def_target.get_string(for_signature))
+
+ return [cmd]
+
+def shlib_emitter(target, source, env):
+ dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+ no_import_lib = env.get('no_import_lib', 0)
+
+ if not dll:
+ raise SCons.Errors.UserError, "A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")
+
+ if not no_import_lib and \
+ not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'):
+
+ # Append an import library to the list of targets.
+ target.append(env.ReplaceIxes(dll,
+ 'SHLIBPREFIX', 'SHLIBSUFFIX',
+ 'LIBPREFIX', 'LIBSUFFIX'))
+
+ # Append a def file target if there isn't already a def file target
+ # or a def file source. There is no option to disable def file
+ # target emitting, because I can't figure out why someone would ever
+ # want to turn it off.
+ def_source = env.FindIxes(source, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
+ def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
+ if not def_source and not def_target:
+ target.append(env.ReplaceIxes(dll,
+ 'SHLIBPREFIX', 'SHLIBSUFFIX',
+ 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX'))
+
+ return (target, source)
+
+
+shlib_action = SCons.Action.CommandGenerator(shlib_generator)
+
+res_builder = SCons.Builder.Builder(action='$RCCOM', suffix='.o',
+ source_scanner=SCons.Defaults.ObjSourceScan)
+SCons.Defaults.ObjSourceScan.add_scanner('.rc', SCons.Defaults.CScan)
+
+def generate(env):
+ mingw = find(env)
+ if mingw:
+ dir = os.path.dirname(mingw)
+
+ # The mingw bin directory must be added to the path:
+ path = env['ENV'].get('PATH', [])
+ if not path:
+ path = []
+ if SCons.Util.is_String(path):
+ path = string.split(path, os.pathsep)
+
+ env['ENV']['PATH'] = string.join([dir] + path, os.pathsep)
+
+
+ # Most of mingw is the same as gcc and friends...
+ gnu_tools = ['gcc', 'g++', 'gnulink', 'ar', 'gas']
+ for tool in gnu_tools:
+ SCons.Tool.Tool(tool)(env)
+
+ #... but a few things differ:
+ env['CC'] = 'gcc'
+ env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
+ env['CXX'] = 'g++'
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
+ env['SHLINKCOM'] = shlib_action
+ env.Append(SHLIBEMITTER = [shlib_emitter])
+ env['LINK'] = 'g++'
+ env['AS'] = 'as'
+ env['WIN32DEFPREFIX'] = ''
+ env['WIN32DEFSUFFIX'] = '.def'
+ env['SHOBJSUFFIX'] = '.o'
+ env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
+
+ env['RC'] = 'windres'
+ env['RCFLAGS'] = SCons.Util.CLVar('')
+ env['RCINCFLAGS'] = '$( ${_concat(RCINCPREFIX, CPPPATH, RCINCSUFFIX, __env__, RDirs)} $)'
+ env['RCINCPREFIX'] = '--include-dir '
+ env['RCINCSUFFIX'] = ''
+ env['RCCOM'] = '$RC $RCINCFLAGS $RCFLAGS -i $SOURCE -o $TARGET'
+ env['BUILDERS']['RES'] = res_builder
+
+ # Some setting from the platform also have to be overridden:
+ env['OBJSUFFIX'] = '.o'
+ env['LIBPREFIX'] = 'lib'
+ env['LIBSUFFIX'] = '.a'
+
+def exists(env):
+ return find(env)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/mslib.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/mslib.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/mslib.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,76 @@
+"""SCons.Tool.mslib
+
+Tool-specific initialization for lib (MicroSoft library archiver).
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/mslib.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Tool.msvs
+import SCons.Tool.msvc
+import SCons.Util
+
+def generate(env):
+ """Add Builders and construction variables for lib to an Environment."""
+ SCons.Tool.createStaticLibBuilder(env)
+
+ try:
+ version = SCons.Tool.msvs.get_default_visualstudio_version(env)
+
+ if env.has_key('MSVS_IGNORE_IDE_PATHS') and env['MSVS_IGNORE_IDE_PATHS']:
+ include_path, lib_path, exe_path = SCons.Tool.msvc.get_msvc_default_paths(version)
+ else:
+ include_path, lib_path, exe_path = SCons.Tool.msvc.get_msvc_paths(version)
+
+ # since other tools can set this, we just make sure that the
+ # relevant stuff from MSVS is in there somewhere.
+ env.PrependENVPath('PATH', exe_path)
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ pass
+
+ env['AR'] = 'lib'
+ env['ARFLAGS'] = SCons.Util.CLVar('/nologo')
+ env['ARCOM'] = "${TEMPFILE('$AR $ARFLAGS /OUT:$TARGET $SOURCES')}"
+ env['LIBPREFIX'] = ''
+ env['LIBSUFFIX'] = '.lib'
+
+def exists(env):
+ try:
+ v = SCons.Tool.msvs.get_visualstudio_versions()
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ pass
+
+ if not v:
+ return env.Detect('lib')
+ else:
+ # there's at least one version of MSVS installed.
+ return 1
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/mslink.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/mslink.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/mslink.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,186 @@
+"""SCons.Tool.mslink
+
+Tool-specific initialization for the Microsoft linker.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/mslink.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+
+import SCons.Action
+import SCons.Defaults
+import SCons.Errors
+import SCons.Platform.win32
+import SCons.Tool
+import SCons.Tool.msvc
+import SCons.Tool.msvs
+import SCons.Util
+
+def pdbGenerator(env, target, source, for_signature):
+ if target and env.has_key('PDB') and env['PDB']:
+ return ['/PDB:%s'%target[0].File(env['PDB']).get_string(for_signature),
+ '/DEBUG']
+ return None
+
+def win32ShlinkTargets(target, source, env, for_signature):
+ listCmd = []
+ dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+ if dll: listCmd.append("/out:%s"%dll.get_string(for_signature))
+
+ implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX')
+ if implib: listCmd.append("/implib:%s"%implib.get_string(for_signature))
+
+ return listCmd
+
+def win32ShlinkSources(target, source, env, for_signature):
+ listCmd = []
+
+ deffile = env.FindIxes(source, "WIN32DEFPREFIX", "WIN32DEFSUFFIX")
+ for src in source:
+ if src == deffile:
+ # Treat this source as a .def file.
+ listCmd.append("/def:%s" % src.get_string(for_signature))
+ else:
+ # Just treat it as a generic source file.
+ listCmd.append(src)
+ return listCmd
+
+def win32LibEmitter(target, source, env):
+ SCons.Tool.msvc.validate_vars(env)
+
+ dll = env.FindIxes(target, "SHLIBPREFIX", "SHLIBSUFFIX")
+ no_import_lib = env.get('no_import_lib', 0)
+
+ if not dll:
+ raise SCons.Errors.UserError, "A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")
+
+ if env.get("WIN32_INSERT_DEF", 0) and \
+ not env.FindIxes(source, "WIN32DEFPREFIX", "WIN32DEFSUFFIX"):
+
+ # append a def file to the list of sources
+ source.append(env.ReplaceIxes(dll,
+ "SHLIBPREFIX", "SHLIBSUFFIX",
+ "WIN32DEFPREFIX", "WIN32DEFSUFFIX"))
+
+ if env.has_key('PDB') and env['PDB']:
+ target.append(env['PDB'])
+
+ if not no_import_lib and \
+ not env.FindIxes(target, "LIBPREFIX", "LIBSUFFIX"):
+ # Append an import library to the list of targets.
+ target.append(env.ReplaceIxes(dll,
+ "SHLIBPREFIX", "SHLIBSUFFIX",
+ "LIBPREFIX", "LIBSUFFIX"))
+ # and .exp file is created if there are exports from a DLL
+ target.append(env.ReplaceIxes(dll,
+ "SHLIBPREFIX", "SHLIBSUFFIX",
+ "WIN32EXPPREFIX", "WIN32EXPSUFFIX"))
+
+ return (target, source)
+
+def prog_emitter(target, source, env):
+ SCons.Tool.msvc.validate_vars(env)
+
+ if env.has_key('PDB') and env['PDB']:
+ target.append(env['PDB'])
+
+ return (target,source)
+
+def RegServerFunc(target, source, env):
+ if env.has_key('register') and env['register']:
+ ret = regServerAction([target[0]], [source[0]], env)
+ if ret:
+ raise SCons.Errors.UserError, "Unable to register %s" % target[0]
+ else:
+ print "Registered %s sucessfully" % target[0]
+ return ret
+ return 0
+
+regServerAction = SCons.Action.Action("$REGSVRCOM")
+regServerCheck = SCons.Action.Action(RegServerFunc, None)
+shlibLinkAction = SCons.Action.Action('${TEMPFILE("$SHLINK $SHLINKFLAGS $_SHLINK_TARGETS $( $_LIBDIRFLAGS $) $_LIBFLAGS $_PDB $_SHLINK_SOURCES")}')
+compositeLinkAction = shlibLinkAction + regServerCheck
+
+def generate(env):
+ """Add Builders and construction variables for ar to an Environment."""
+ SCons.Tool.createSharedLibBuilder(env)
+ SCons.Tool.createProgBuilder(env)
+
+ env['SHLINK'] = '$LINK'
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS /dll')
+ env['_SHLINK_TARGETS'] = win32ShlinkTargets
+ env['_SHLINK_SOURCES'] = win32ShlinkSources
+ env['SHLINKCOM'] = compositeLinkAction
+ env.Append(SHLIBEMITTER = [win32LibEmitter])
+ env['LINK'] = 'link'
+ env['LINKFLAGS'] = SCons.Util.CLVar('/nologo')
+ env['_PDB'] = pdbGenerator
+ env['LINKCOM'] = '${TEMPFILE("$LINK $LINKFLAGS /OUT:$TARGET.win32 $( $_LIBDIRFLAGS $) $_LIBFLAGS $_PDB $SOURCES.win32")}'
+ env.Append(PROGEMITTER = [prog_emitter])
+ env['LIBDIRPREFIX']='/LIBPATH:'
+ env['LIBDIRSUFFIX']=''
+ env['LIBLINKPREFIX']=''
+ env['LIBLINKSUFFIX']='$LIBSUFFIX'
+
+ env['WIN32DEFPREFIX'] = ''
+ env['WIN32DEFSUFFIX'] = '.def'
+ env['WIN32_INSERT_DEF'] = 0
+
+ env['WIN32EXPPREFIX'] = ''
+ env['WIN32EXPSUFFIX'] = '.exp'
+
+ env['REGSVRACTION'] = regServerCheck
+ env['REGSVR'] = os.path.join(SCons.Platform.win32.get_system_root(),'System32','regsvr32')
+ env['REGSVRFLAGS'] = '/s '
+ env['REGSVRCOM'] = '$REGSVR $REGSVRFLAGS ${TARGET.win32}'
+
+ try:
+ version = SCons.Tool.msvs.get_default_visualstudio_version(env)
+
+ if env.has_key('MSVS_IGNORE_IDE_PATHS') and env['MSVS_IGNORE_IDE_PATHS']:
+ include_path, lib_path, exe_path = SCons.Tool.msvc.get_msvc_default_paths(version)
+ else:
+ include_path, lib_path, exe_path = SCons.Tool.msvc.get_msvc_paths(version)
+
+ # since other tools can set these, we just make sure that the
+ # relevant stuff from MSVS is in there somewhere.
+ env.PrependENVPath('INCLUDE', include_path)
+ env.PrependENVPath('LIB', lib_path)
+ env.PrependENVPath('PATH', exe_path)
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ pass
+
+def exists(env):
+ if SCons.Tool.msvs.is_msvs_installed():
+ # there's at least one version of MSVS installed.
+ return 1
+ else:
+ return env.Detect('link')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/msvc.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/msvc.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/msvc.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,487 @@
+"""engine.SCons.Tool.msvc
+
+Tool-specific initialization for Microsoft Visual C/C++.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/branch.96/baseline/src/engine/SCons/Tool/msvc.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+import re
+import string
+
+import SCons.Action
+import SCons.Builder
+import SCons.Errors
+import SCons.Platform.win32
+import SCons.Tool
+import SCons.Tool.msvs
+import SCons.Util
+import SCons.Warnings
+
+CSuffixes = ['.c', '.C']
+CXXSuffixes = ['.cc', '.cpp', '.cxx', '.c++', '.C++']
+
+def _parse_msvc7_overrides(version):
+ """ Parse any overridden defaults for MSVS directory locations in MSVS .NET. """
+
+ # First, we get the shell folder for this user:
+ if not SCons.Util.can_read_reg:
+ raise SCons.Errors.InternalError, "No Windows registry module was found"
+
+ comps = ""
+ try:
+ (comps, t) = SCons.Util.RegGetValue(SCons.Util.HKEY_CURRENT_USER,
+ r'Software\Microsoft\Windows\CurrentVersion' +\
+ r'\Explorer\Shell Folders\Local AppData')
+ except SCons.Util.RegError:
+ raise SCons.Errors.InternalError, "The Local AppData directory was not found in the registry."
+
+ comps = comps + '\\Microsoft\\VisualStudio\\' + version + '\\VCComponents.dat'
+ dirs = {}
+
+ if os.path.exists(comps):
+ # now we parse the directories from this file, if it exists.
+ # We only look for entries after: [VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories],
+ # since this file could contain a number of things...
+ f = open(comps,'r')
+ line = f.readline()
+ found = 0
+ while line:
+ line.strip()
+ if line.find(r'[VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories]') >= 0:
+ found = 1
+ elif line == '' or line[:1] == '[':
+ found = 0
+ elif found == 1:
+ kv = line.split('=', 1)
+ if len(kv) == 2:
+ (key, val) = kv
+ key = key.replace(' Dirs','')
+ dirs[key.upper()] = val
+ line = f.readline()
+ f.close()
+ else:
+ # since the file didn't exist, we have only the defaults in
+ # the registry to work with.
+ try:
+ K = 'SOFTWARE\\Microsoft\\VisualStudio\\' + version
+ K = K + r'\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories'
+ k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,K)
+ i = 0
+ while 1:
+ try:
+ (key,val,t) = SCons.Util.RegEnumValue(k,i)
+ key = key.replace(' Dirs','')
+ dirs[key.upper()] = val
+ i = i + 1
+ except SCons.Util.RegError:
+ break
+ except SCons.Util.RegError:
+ # if we got here, then we didn't find the registry entries:
+ raise SCons.Errors.InternalError, "Unable to find MSVC paths in the registry."
+ return dirs
+
+def _get_msvc7_path(path, version, platform):
+ """
+ Get Visual Studio directories from version 7 (MSVS .NET)
+ (it has a different registry structure than versions before it)
+ """
+ # first, look for a customization of the default values in the
+ # registry: These are sometimes stored in the Local Settings area
+ # for Visual Studio, in a file, so we have to parse it.
+ dirs = _parse_msvc7_overrides(version)
+
+ if dirs.has_key(path):
+ p = dirs[path]
+ else:
+ raise SCons.Errors.InternalError, "Unable to retrieve the %s path from MS VC++."%path
+
+ # collect some useful information for later expansions...
+ paths = SCons.Tool.msvs.get_msvs_install_dirs(version)
+
+ # expand the directory path variables that we support. If there
+ # is a variable we don't support, then replace that entry with
+ # "---Unknown Location VSInstallDir---" or something similar, to clue
+ # people in that we didn't find something, and so env expansion doesn't
+ # do weird things with the $(xxx)'s
+ s = re.compile('\$\(([a-zA-Z0-9_]+?)\)')
+
+ def repl(match, paths=paths):
+ key = string.upper(match.group(1))
+ if paths.has_key(key):
+ return paths[key]
+ else:
+ return '---Unknown Location %s---' % match.group()
+
+ rv = []
+ for entry in p.split(os.pathsep):
+ entry = s.sub(repl,entry)
+ rv.append(entry)
+
+ return string.join(rv,os.pathsep)
+
+def get_msvc_path (path, version, platform='x86'):
+ """
+ Get a list of visualstudio directories (include, lib or path). Return
+ a string delimited by ';'. An exception will be raised if unable to
+ access the registry or appropriate registry keys not found.
+ """
+
+ if not SCons.Util.can_read_reg:
+ raise SCons.Errors.InternalError, "No Windows registry module was found"
+
+ # normalize the case for comparisons (since the registry is case
+ # insensitive)
+ path = string.upper(path)
+
+ if path=='LIB':
+ path= 'LIBRARY'
+
+ if float(version) >= 7.0:
+ return _get_msvc7_path(path, version, platform)
+
+ path = string.upper(path + ' Dirs')
+ K = ('Software\\Microsoft\\Devstudio\\%s\\' +
+ 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \
+ (version,platform)
+ for base in (SCons.Util.HKEY_CURRENT_USER,
+ SCons.Util.HKEY_LOCAL_MACHINE):
+ try:
+ k = SCons.Util.RegOpenKeyEx(base,K)
+ i = 0
+ while 1:
+ try:
+ (p,v,t) = SCons.Util.RegEnumValue(k,i)
+ if string.upper(p) == path:
+ return v
+ i = i + 1
+ except SCons.Util.RegError:
+ break
+ except SCons.Util.RegError:
+ pass
+
+ # if we got here, then we didn't find the registry entries:
+ raise SCons.Errors.InternalError, "The %s path was not found in the registry."%path
+
+def _get_msvc6_default_paths(version, use_mfc_dirs):
+ """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values of those
+ three environment variables that should be set in order to execute
+ the MSVC 6.0 tools properly, if the information wasn't available
+ from the registry."""
+ MVSdir = None
+ paths = {}
+ exe_path = ''
+ lib_path = ''
+ include_path = ''
+ try:
+ paths = SCons.Tool.msvs.get_msvs_install_dirs(version)
+ MVSdir = paths['VSINSTALLDIR']
+ except (SCons.Util.RegError, SCons.Errors.InternalError, KeyError):
+ if os.environ.has_key('MSDEVDIR'):
+ MVSdir = os.path.normpath(os.path.join(os.environ['MSDEVDIR'],'..','..'))
+ else:
+ MVSdir = r'C:\Program Files\Microsoft Visual Studio'
+ if MVSdir:
+ if SCons.Util.can_read_reg and paths.has_key('VCINSTALLDIR'):
+ MVSVCdir = paths['VCINSTALLDIR']
+ else:
+ MVSVCdir = os.path.join(MVSdir,'VC98')
+
+ MVSCommondir = r'%s\Common' % MVSdir
+ if use_mfc_dirs:
+ mfc_include_ = r'%s\ATL\include;%s\MFC\include;' % (MVSVCdir, MVSVCdir)
+ mfc_lib_ = r'%s\MFC\lib;' % MVSVCdir
+ else:
+ mfc_include_ = ''
+ mfc_lib_ = ''
+ include_path = r'%s%s\include' % (mfc_include_, MVSVCdir)
+ lib_path = r'%s%s\lib' % (mfc_lib_, MVSVCdir)
+
+ if os.environ.has_key('OS') and os.environ['OS'] == "Windows_NT":
+ osdir = 'WINNT'
+ else:
+ osdir = 'WIN95'
+
+ exe_path = r'%s\tools\%s;%s\MSDev98\bin;%s\tools;%s\bin' % (MVSCommondir, osdir, MVSCommondir, MVSCommondir, MVSVCdir)
+ return (include_path, lib_path, exe_path)
+
+def _get_msvc7_default_paths(version, use_mfc_dirs):
+ """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values of those
+ three environment variables that should be set in order to execute
+ the MSVC .NET tools properly, if the information wasn't available
+ from the registry."""
+
+ MVSdir = None
+ paths = {}
+ exe_path = ''
+ lib_path = ''
+ include_path = ''
+ try:
+ paths = SCons.Tool.msvs.get_msvs_install_dirs(version)
+ MVSdir = paths['VSINSTALLDIR']
+ except (KeyError, SCons.Util.RegError, SCons.Errors.InternalError):
+ if os.environ.has_key('VSCOMNTOOLS'):
+ MVSdir = os.path.normpath(os.path.join(os.environ['VSCOMNTOOLS'],'..','..'))
+ else:
+ # last resort -- default install location
+ MVSdir = r'C:\Program Files\Microsoft Visual Studio .NET'
+
+ if MVSdir:
+ if SCons.Util.can_read_reg and paths.has_key('VCINSTALLDIR'):
+ MVSVCdir = paths['VCINSTALLDIR']
+ else:
+ MVSVCdir = os.path.join(MVSdir,'Vc7')
+
+ MVSCommondir = r'%s\Common7' % MVSdir
+ if use_mfc_dirs:
+ mfc_include_ = r'%s\atlmfc\include;' % MVSVCdir
+ mfc_lib_ = r'%s\atlmfc\lib;' % MVSVCdir
+ else:
+ mfc_include_ = ''
+ mfc_lib_ = ''
+ include_path = r'%s%s\include;%s\PlatformSDK\include' % (mfc_include_, MVSVCdir, MVSVCdir)
+ lib_path = r'%s%s\lib;%s\PlatformSDK\lib' % (mfc_lib_, MVSVCdir, MVSVCdir)
+ exe_path = r'%s\IDE;%s\bin;%s\Tools;%s\Tools\bin' % (MVSCommondir,MVSVCdir, MVSCommondir, MVSCommondir )
+
+ if SCons.Util.can_read_reg and paths.has_key('FRAMEWORKSDKDIR'):
+ include_path = include_path + r';%s\include'%paths['FRAMEWORKSDKDIR']
+ lib_path = lib_path + r';%s\lib'%paths['FRAMEWORKSDKDIR']
+ exe_path = exe_path + r';%s\bin'%paths['FRAMEWORKSDKDIR']
+
+ if SCons.Util.can_read_reg and paths.has_key('FRAMEWORKDIR') and paths.has_key('FRAMEWORKVERSION'):
+ exe_path = exe_path + r';%s\%s'%(paths['FRAMEWORKDIR'],paths['FRAMEWORKVERSION'])
+
+ return (include_path, lib_path, exe_path)
+
+def get_msvc_paths(version=None, use_mfc_dirs=0):
+ """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values
+ of those three environment variables that should be set
+ in order to execute the MSVC tools properly."""
+ exe_path = ''
+ lib_path = ''
+ include_path = ''
+
+ if not version:
+ versions = SCons.Tool.msvs.get_visualstudio_versions()
+ if versions:
+ version = versions[0] #use highest version by default
+ else:
+ version = '6.0'
+
+ # Some of the configured directories only
+ # appear if the user changes them from the default.
+ # Therefore, we'll see if we can get the path to the MSDev
+ # base installation from the registry and deduce the default
+ # directories.
+ if float(version) >= 7.0:
+ defpaths = _get_msvc7_default_paths(version, use_mfc_dirs)
+ else:
+ defpaths = _get_msvc6_default_paths(version, use_mfc_dirs)
+
+ try:
+ include_path = get_msvc_path("include", version)
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ include_path = defpaths[0]
+
+ try:
+ lib_path = get_msvc_path("lib", version)
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ lib_path = defpaths[1]
+
+ try:
+ exe_path = get_msvc_path("path", version)
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ exe_path = defpaths[2]
+
+ return (include_path, lib_path, exe_path)
+
+def get_msvc_default_paths(version=None, use_mfc_dirs=0):
+ """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values of those
+ three environment variables that should be set in order to execute
+ the MSVC tools properly. This will only return the default
+ locations for the tools, not the values used by MSVS in their
+ directory setup area. This can help avoid problems with different
+ developers having different settings, and should allow the tools
+ to run in most cases."""
+
+ if not version and not SCons.Util.can_read_reg:
+ version = '6.0'
+
+ try:
+ if not version:
+ version = SCons.Tool.msvs.get_visualstudio_versions()[0] #use highest version
+ except KeyboardInterrupt:
+ raise
+ except:
+ pass
+
+ if float(version) >= 7.0:
+ return _get_msvc7_default_paths(version, use_mfc_dirs)
+ else:
+ return _get_msvc6_default_paths(version, use_mfc_dirs)
+
+def validate_vars(env):
+ """Validate the PCH and PCHSTOP construction variables."""
+ if env.has_key('PCH') and env['PCH']:
+ if not env.has_key('PCHSTOP'):
+ raise SCons.Errors.UserError, "The PCHSTOP construction must be defined if PCH is defined."
+ if not SCons.Util.is_String(env['PCHSTOP']):
+ raise SCons.Errors.UserError, "The PCHSTOP construction variable must be a string: %r"%env['PCHSTOP']
+
+def pch_emitter(target, source, env):
+ """Adds the object file target."""
+
+ validate_vars(env)
+
+ pch = None
+ obj = None
+
+ for t in target:
+ if SCons.Util.splitext(str(t))[1] == '.pch':
+ pch = t
+ if SCons.Util.splitext(str(t))[1] == '.obj':
+ obj = t
+
+ if not obj:
+ obj = SCons.Util.splitext(str(pch))[0]+'.obj'
+
+ target = [pch, obj] # pch must be first, and obj second for the PCHCOM to work
+
+ return (target, source)
+
+def object_emitter(target, source, env, parent_emitter):
+ """Sets up the PCH dependencies for an object file."""
+
+ validate_vars(env)
+
+ parent_emitter(target, source, env)
+
+ if env.has_key('PCH') and env['PCH']:
+ env.Depends(target, env['PCH'])
+
+ return (target, source)
+
+def static_object_emitter(target, source, env):
+ return object_emitter(target, source, env,
+ SCons.Defaults.StaticObjectEmitter)
+
+def shared_object_emitter(target, source, env):
+ return object_emitter(target, source, env,
+ SCons.Defaults.SharedObjectEmitter)
+
+pch_builder = SCons.Builder.Builder(action='$PCHCOM', suffix='.pch', emitter=pch_emitter,
+ source_scanner=SCons.Defaults.ObjSourceScan)
+res_builder = SCons.Builder.Builder(action='$RCCOM', suffix='.res',
+ source_scanner=SCons.Defaults.ObjSourceScan)
+SCons.Defaults.ObjSourceScan.add_scanner('.rc', SCons.Defaults.CScan)
+
+def generate(env):
+ """Add Builders and construction variables for MSVC++ to an Environment."""
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ for suffix in CSuffixes:
+ static_obj.add_action(suffix, SCons.Defaults.CAction)
+ shared_obj.add_action(suffix, SCons.Defaults.ShCAction)
+ static_obj.add_emitter(suffix, static_object_emitter)
+ shared_obj.add_emitter(suffix, shared_object_emitter)
+
+ for suffix in CXXSuffixes:
+ static_obj.add_action(suffix, SCons.Defaults.CXXAction)
+ shared_obj.add_action(suffix, SCons.Defaults.ShCXXAction)
+ static_obj.add_emitter(suffix, static_object_emitter)
+ shared_obj.add_emitter(suffix, shared_object_emitter)
+
+ env['CCPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Z7") or ""}'])
+ env['CCPCHFLAGS'] = SCons.Util.CLVar(['${(PCH and "/Yu%s /Fp%s"%(PCHSTOP or "",File(PCH))) or ""}'])
+ env['CCCOMFLAGS'] = '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo$TARGET $CCPCHFLAGS $CCPDBFLAGS'
+ env['CC'] = 'cl'
+ env['CCFLAGS'] = SCons.Util.CLVar('/nologo')
+ env['CCCOM'] = '$CC $CCFLAGS $CCCOMFLAGS'
+ env['SHCC'] = '$CC'
+ env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
+ env['SHCCCOM'] = '$SHCC $SHCCFLAGS $CCCOMFLAGS'
+ env['CXX'] = '$CC'
+ env['CXXFLAGS'] = SCons.Util.CLVar('$CCFLAGS $( /TP $)')
+ env['CXXCOM'] = '$CXX $CXXFLAGS $CCCOMFLAGS'
+ env['SHCXX'] = '$CXX'
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
+ env['SHCXXCOM'] = '$SHCXX $SHCXXFLAGS $CCCOMFLAGS'
+ env['CPPDEFPREFIX'] = '/D'
+ env['CPPDEFSUFFIX'] = ''
+ env['INCPREFIX'] = '/I'
+ env['INCSUFFIX'] = ''
+# env.Append(OBJEMITTER = [static_object_emitter])
+# env.Append(SHOBJEMITTER = [shared_object_emitter])
+ env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
+
+ env['RC'] = 'rc'
+ env['RCFLAGS'] = SCons.Util.CLVar('')
+ env['RCCOM'] = '$RC $_CPPDEFFLAGS $_CPPINCFLAGS $RCFLAGS /fo$TARGET $SOURCES'
+ env['BUILDERS']['RES'] = res_builder
+ env['OBJPREFIX'] = ''
+ env['OBJSUFFIX'] = '.obj'
+ env['SHOBJPREFIX'] = '$OBJPREFIX'
+ env['SHOBJSUFFIX'] = '$OBJSUFFIX'
+
+ try:
+ version = SCons.Tool.msvs.get_default_visualstudio_version(env)
+
+ # By default, add the MFC directories, because this is what
+ # we've been doing for a long time. We may change this.
+ use_mfc_dirs = env.get('MSVS_USE_MFC_DIRS', 1)
+ if env.get('MSVS_IGNORE_IDE_PATHS', 0):
+ _get_paths = get_msvc_default_paths
+ else:
+ _get_paths = get_msvc_paths
+ include_path, lib_path, exe_path = _get_paths(version, use_mfc_dirs)
+
+ # since other tools can set these, we just make sure that the
+ # relevant stuff from MSVS is in there somewhere.
+ env.PrependENVPath('INCLUDE', include_path)
+ env.PrependENVPath('LIB', lib_path)
+ env.PrependENVPath('PATH', exe_path)
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ pass
+
+ env['CFILESUFFIX'] = '.c'
+ env['CXXFILESUFFIX'] = '.cc'
+
+ env['PCHPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Yd") or ""}'])
+ env['PCHCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo${TARGETS[1]} /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS'
+ env['BUILDERS']['PCH'] = pch_builder
+
+def exists(env):
+ if SCons.Tool.msvs.is_msvs_installed():
+ # there's at least one version of MSVS installed.
+ return 1
+ else:
+ return env.Detect('cl')
+
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/msvs.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/msvs.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/msvs.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,1128 @@
+"""SCons.Tool.msvs
+
+Tool-specific initialization for Microsoft Visual Studio project files.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/branch.96/baseline/src/engine/SCons/Tool/msvs.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import base64
+import md5
+import os.path
+import pickle
+import re
+import string
+import sys
+import types
+
+import SCons.Builder
+import SCons.Node.FS
+import SCons.Platform.win32
+import SCons.Script.SConscript
+import SCons.Util
+import SCons.Warnings
+
+##############################################################################
+# Below here are the classes and functions for generation of
+# DSP/DSW/SLN/VCPROJ files.
+##############################################################################
+
+def _hexdigest(s):
+ """Return a string as a string of hex characters.
+ """
+ # NOTE: This routine is a method in the Python 2.0 interface
+ # of the native md5 module, but we want SCons to operate all
+ # the way back to at least Python 1.5.2, which doesn't have it.
+ h = string.hexdigits
+ r = ''
+ for c in s:
+ i = ord(c)
+ r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
+ return r
+
+def _generateGUID(slnfile, name):
+ """This generates a dummy GUID for the sln file to use. It is
+ based on the MD5 signatures of the sln filename plus the name of
+ the project. It basically just needs to be unique, and not
+ change with each invocation."""
+ solution = _hexdigest(md5.new(str(slnfile)+str(name)).digest()).upper()
+ # convert most of the signature to GUID form (discard the rest)
+ solution = "{" + solution[:8] + "-" + solution[8:12] + "-" + solution[12:16] + "-" + solution[16:20] + "-" + solution[20:32] + "}"
+ return solution
+
+# This is how we re-invoke SCons from inside MSVS Project files.
+# The problem is that we might have been invoked as either scons.bat
+# or scons.py. If we were invoked directly as scons.py, then we could
+# use sys.argv[0] to find the SCons "executable," but that doesn't work
+# if we were invoked as scons.bat, which uses "python -c" to execute
+# things and ends up with "-c" as sys.argv[0]. Consequently, we have
+# the MSVS Project file invoke SCons the same way that scons.bat does,
+# which works regardless of how we were invoked.
+exec_script_main = "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-0.96.1'), join(sys.prefix, 'scons-0.96.1'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()"
+exec_script_main_xml = string.replace(exec_script_main, "'", "'")
+
+# The string for the Python executable we tell the Project file to use
+# is either sys.executable or, if an external PYTHON_ROOT environment
+# variable exists, $(PYTHON)ROOT\\python.exe (generalized a little to
+# pluck the actual executable name from sys.executable).
+try:
+ python_root = os.environ['PYTHON_ROOT']
+except KeyError:
+ python_executable = sys.executable
+else:
+ python_executable = os.path.join('$(PYTHON_ROOT)',
+ os.path.split(sys.executable)[1])
+
+class Config:
+ pass
+
+class _DSPGenerator:
+ """ Base class for DSP generators """
+ def __init__(self, dspfile, source, env):
+ if type(dspfile) == types.StringType:
+ self.dspfile = os.path.abspath(dspfile)
+ else:
+ self.dspfile = dspfile.get_abspath()
+
+ try:
+ self.conspath = source[0].attributes.sconstruct.get_abspath()
+ except KeyError:
+ raise SCons.Errors.InternalError, \
+ "Unable to determine where the SConstruct is"
+
+ self.config = Config()
+ if env.has_key('variant'):
+ self.config.variant = env['variant'].capitalize()
+ else:
+ raise SCons.Errors.InternalError, \
+ "You must specify a 'variant' argument (i.e. 'Debug' or " +\
+ "'Release') to create an MSVSProject."
+
+ if env.has_key('buildtarget'):
+ if type(env['buildtarget']) == types.StringType:
+ self.config.buildtarget = os.path.abspath(env['buildtarget'])
+ elif type(env['buildtarget']) == types.ListType:
+ self.config.buildtarget = env['buildtarget'][0].get_abspath()
+ else:
+ self.config.buildtarget = env['buildtarget'].get_abspath()
+ else:
+ raise SCons.Errors.InternalError, \
+ "You must specify a target 'buildtarget' file argument (such as the target" +\
+ " executable) to create an MSVSProject."
+
+ self.config.outdir = os.path.dirname(self.config.buildtarget)
+
+ if type(source[0]) == types.StringType:
+ self.source = os.path.abspath(source[0])
+ else:
+ self.source = source[0].get_abspath()
+
+ self.env = env
+
+ if self.env.has_key('name'):
+ self.name = self.env['name']
+ else:
+ self.name = os.path.basename(SCons.Util.splitext(self.dspfile)[0])
+
+ print "Adding '" + self.name + ' - ' + self.config.variant + "' to Visual Studio Project '" + str(dspfile) + "'"
+
+ sourcenames = [
+ ' Source Files',
+ 'Header Files',
+ 'Local Headers',
+ 'Resource Files',
+ 'Other Files']
+
+ srcargs = [
+ 'srcs',
+ 'incs',
+ 'localincs',
+ 'resources',
+ 'misc']
+
+ self.sources = {}
+ for n in sourcenames:
+ self.sources[n] = []
+
+ self.configs = {}
+
+ if os.path.exists(self.dspfile):
+ self.Parse()
+
+ for t in zip(sourcenames,srcargs):
+ if self.env.has_key(t[1]):
+ if type(self.env[t[1]]) == types.ListType:
+ for i in self.env[t[1]]:
+ if not i in self.sources[t[0]]:
+ self.sources[t[0]].append(i)
+ else:
+ if not self.env[t[1]] in self.sources[t[0]]:
+ self.sources[t[0]].append(self.env[t[1]])
+
+ for n in sourcenames:
+ self.sources[n].sort()
+
+ self.configs[self.config.variant] = self.config
+
+ def Build(self):
+ pass
+
+class _GenerateV6DSP(_DSPGenerator):
+ """Generates a Project file for MSVS 6.0"""
+
+ def PrintHeader(self):
+ name = self.name
+ # pick a default config
+ confkeys = self.configs.keys()
+ confkeys.sort()
+
+ self.file.write('# Microsoft Developer Studio Project File - Name="%s" - Package Owner=<4>\n'
+ '# Microsoft Developer Studio Generated Build File, Format Version 6.00\n'
+ '# ** DO NOT EDIT **\n\n'
+ '# TARGTYPE "Win32 (x86) External Target" 0x0106\n\n'
+ 'CFG=%s - Win32 %s\n'
+ '!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n'
+ '!MESSAGE use the Export Makefile command and run\n'
+ '!MESSAGE \n'
+ '!MESSAGE NMAKE /f "%s.mak".\n'
+ '!MESSAGE \n'
+ '!MESSAGE You can specify a configuration when running NMAKE\n'
+ '!MESSAGE by defining the macro CFG on the command line. For example:\n'
+ '!MESSAGE \n'
+ '!MESSAGE NMAKE /f "%s.mak" CFG="%s - Win32 %s"\n'
+ '!MESSAGE \n'
+ '!MESSAGE Possible choices for configuration are:\n'
+ '!MESSAGE \n' % (name,name,confkeys[0],name,name,name,confkeys[0]))
+
+ for kind in confkeys:
+ self.file.write('!MESSAGE "%s - Win32 %s" (based on "Win32 (x86) External Target")\n' % (name, kind))
+
+ self.file.write('!MESSAGE \n\n')
+
+ def PrintProject(self):
+ name = self.name
+ self.file.write('# Begin Project\n'
+ '# PROP AllowPerConfigDependencies 0\n'
+ '# PROP Scc_ProjName ""\n'
+ '# PROP Scc_LocalPath ""\n\n')
+
+ first = 1
+ confkeys = self.configs.keys()
+ confkeys.sort()
+ for kind in confkeys:
+ outdir = self.configs[kind].outdir
+ buildtarget = self.configs[kind].buildtarget
+ if first == 1:
+ self.file.write('!IF "$(CFG)" == "%s - Win32 %s"\n\n' % (name, kind))
+ first = 0
+ else:
+ self.file.write('\n!ELSEIF "$(CFG)" == "%s - Win32 %s"\n\n' % (name, kind))
+
+ # have to write this twice, once with the BASE settings, and once without
+ for base in ("BASE ",""):
+ self.file.write('# PROP %sUse_MFC 0\n'
+ '# PROP %sUse_Debug_Libraries ' % (base, base))
+ if kind.lower().find('debug') < 0:
+ self.file.write('0\n')
+ else:
+ self.file.write('1\n')
+ self.file.write('# PROP %sOutput_Dir "%s"\n'
+ '# PROP %sIntermediate_Dir "%s"\n' % (base,outdir,base,outdir))
+ (d,c) = os.path.split(str(self.conspath))
+ cmd = '"%s" -c "%s" -C %s -f %s %s' % (python_executable,
+ exec_script_main,
+ d, c, buildtarget)
+ self.file.write('# PROP %sCmd_Line "%s"\n'
+ '# PROP %sRebuild_Opt "-c && %s"\n'
+ '# PROP %sTarget_File "%s"\n'
+ '# PROP %sBsc_Name ""\n'
+ '# PROP %sTarget_Dir ""\n'\
+ %(base,cmd,base,cmd,base,buildtarget,base,base))
+
+ self.file.write('\n!ENDIF\n\n'
+ '# Begin Target\n\n')
+ for kind in confkeys:
+ self.file.write('# Name "%s - Win32 %s"\n' % (name,kind))
+ self.file.write('\n')
+ first = 0
+ for kind in confkeys:
+ if first == 0:
+ self.file.write('!IF "$(CFG)" == "%s - Win32 %s"\n\n' % (name,kind))
+ first = 1
+ else:
+ self.file.write('!ELSEIF "$(CFG)" == "%s - Win32 %s"\n\n' % (name,kind))
+ self.file.write('!ENDIF \n\n')
+ self.PrintSourceFiles()
+ self.file.write('# End Target\n'
+ '# End Project\n')
+
+ # now we pickle some data and add it to the file -- MSDEV will ignore it.
+ pdata = pickle.dumps(self.configs,1)
+ pdata = base64.encodestring(pdata)
+ self.file.write(pdata + '\n')
+ pdata = pickle.dumps(self.sources,1)
+ pdata = base64.encodestring(pdata)
+ self.file.write(pdata + '\n')
+
+ def PrintSourceFiles(self):
+ categories = {' Source Files': 'cpp|c|cxx|l|y|def|odl|idl|hpj|bat',
+ 'Header Files': 'h|hpp|hxx|hm|inl',
+ 'Local Headers': 'h|hpp|hxx|hm|inl',
+ 'Resource Files': 'r|rc|ico|cur|bmp|dlg|rc2|rct|bin|cnt|rtf|gif|jpg|jpeg|jpe',
+ 'Other Files': ''}
+
+ cats = categories.keys()
+ cats.sort()
+ for kind in cats:
+ if not self.sources[kind]:
+ continue # skip empty groups
+
+ self.file.write('# Begin Group "' + kind + '"\n\n')
+ typelist = categories[kind].replace('|',';')
+ self.file.write('# PROP Default_Filter "' + typelist + '"\n')
+
+ for file in self.sources[kind]:
+ file = os.path.normpath(file)
+ self.file.write('# Begin Source File\n\n'
+ 'SOURCE="' + file + '"\n'
+ '# End Source File\n')
+ self.file.write('# End Group\n')
+
+ # add the Conscript file outside of the groups
+ self.file.write('# Begin Source File\n\n'
+ 'SOURCE="' + str(self.source) + '"\n'
+ '# End Source File\n')
+
+ def Parse(self):
+ try:
+ dspfile = open(self.dspfile,'r')
+ except IOError:
+ return # doesn't exist yet, so can't add anything to configs.
+
+ line = dspfile.readline()
+ while line:
+ if line.find("# End Project") > -1:
+ break
+ line = dspfile.readline()
+
+ line = dspfile.readline()
+ datas = line
+ while line and line != '\n':
+ line = dspfile.readline()
+ datas = datas + line
+
+ # OK, we've found our little pickled cache of data.
+ try:
+ datas = base64.decodestring(datas)
+ data = pickle.loads(datas)
+ except KeyboardInterrupt:
+ raise
+ except:
+ return # unable to unpickle any data for some reason
+
+ self.configs.update(data)
+
+ data = None
+ line = dspfile.readline()
+ datas = line
+ while line and line != '\n':
+ line = dspfile.readline()
+ datas = datas + line
+
+ # OK, we've found our little pickled cache of data.
+ # it has a "# " in front of it, so we strip that.
+ try:
+ datas = base64.decodestring(datas)
+ data = pickle.loads(datas)
+ except KeyboardInterrupt:
+ raise
+ except:
+ return # unable to unpickle any data for some reason
+
+ self.sources.update(data)
+
+ def Build(self):
+ try:
+ self.file = open(self.dspfile,'w')
+ except IOError, detail:
+ raise SCons.Errors.InternalError, 'Unable to open "' + self.dspfile + '" for writing:' + str(detail)
+ else:
+ self.PrintHeader()
+ self.PrintProject()
+ self.file.close()
+
+class _GenerateV7DSP(_DSPGenerator):
+ """Generates a Project file for MSVS .NET"""
+
+ def __init__(self, dspfile, source, env):
+ _DSPGenerator.__init__(self, dspfile, source, env)
+ self.version = float(env['MSVS_VERSION'])
+ self.versionstr = '7.00'
+ if self.version >= 7.1:
+ self.versionstr = '7.10'
+
+ def PrintHeader(self):
+ self.file.write('<?xml version="1.0" encoding = "Windows-1252"?>\n'
+ '<VisualStudioProject\n'
+ ' ProjectType="Visual C++"\n'
+ ' Version="%s"\n'
+ ' Name="%s"\n'
+ ' SccProjectName=""\n'
+ ' SccLocalPath=""\n'
+ ' Keyword="MakeFileProj">\n'
+ ' <Platforms>\n'
+ ' <Platform\n'
+ ' Name="Win32"/>\n'
+ ' </Platforms>\n' % (self.versionstr, self.name))
+
+ def PrintProject(self):
+
+
+ self.file.write(' <Configurations>\n')
+
+ confkeys = self.configs.keys()
+ confkeys.sort()
+ for kind in confkeys:
+ outdir = self.configs[kind].outdir
+ buildtarget = self.configs[kind].buildtarget
+
+ (d,c) = os.path.split(str(self.conspath))
+ cmd = '"%s" -c "%s" -C %s -f %s %s' % (python_executable,
+ exec_script_main_xml,
+ d, c, buildtarget)
+
+ cleancmd = '"%s" -c "%s" -C %s -f %s -c %s' % (python_executable,
+ exec_script_main_xml,
+ d, c, buildtarget)
+
+ self.file.write(' <Configuration\n'
+ ' Name="%s|Win32"\n'
+ ' OutputDirectory="%s"\n'
+ ' IntermediateDirectory="%s"\n'
+ ' ConfigurationType="0"\n'
+ ' UseOfMFC="0"\n'
+ ' ATLMinimizesCRunTimeLibraryUsage="FALSE">\n'
+ ' <Tool\n'
+ ' Name="VCNMakeTool"\n'
+ ' BuildCommandLine="%s"\n'
+ ' CleanCommandLine="%s"\n'
+ ' RebuildCommandLine="%s"\n'
+ ' Output="%s"/>\n'
+ ' </Configuration>\n' % (kind.capitalize(),outdir,outdir,\
+ cmd,cleancmd,cmd,buildtarget))
+
+ self.file.write(' </Configurations>\n')
+ if self.version >= 7.1:
+ self.file.write(' <References>\n')
+ self.file.write(' </References>\n')
+
+ self.PrintSourceFiles()
+
+ self.file.write('</VisualStudioProject>\n')
+
+ # now we pickle some data and add it to the file -- MSDEV will ignore it.
+ pdata = pickle.dumps(self.configs,1)
+ pdata = base64.encodestring(pdata)
+ self.file.write('<!-- SCons Data:\n' + pdata + '\n')
+ pdata = pickle.dumps(self.sources,1)
+ pdata = base64.encodestring(pdata)
+ self.file.write(pdata + '-->\n')
+
+ def PrintSourceFiles(self):
+ categories = {' Source Files': 'cpp;c;cxx;l;y;def;odl;idl;hpj;bat',
+ 'Header Files': 'h;hpp;hxx;hm;inl',
+ 'Local Headers': 'h;hpp;hxx;hm;inl',
+ 'Resource Files': 'r;rc;ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe',
+ 'Other Files': ''}
+
+ self.file.write(' <Files>\n')
+
+ cats = categories.keys()
+ cats.sort()
+ for kind in cats:
+ if not self.sources[kind]:
+ continue # skip empty groups
+
+ self.file.write(' <Filter\n'
+ ' Name="%s"\n'
+ ' Filter="%s">\n' % (kind, categories[kind]))
+
+ for file in self.sources[kind]:
+ file = os.path.normpath(file)
+ self.file.write(' <File\n'
+ ' RelativePath="%s">\n'
+ ' </File>\n' % file)
+
+ self.file.write(' </Filter>\n')
+
+ # add the Conscript file outside of the groups
+ self.file.write(' <File\n'
+ ' RelativePath="%s">\n'
+ ' </File>\n'
+ ' </Files>\n'
+ ' <Globals>\n'
+ ' </Globals>\n' % str(self.source))
+
+ def Parse(self):
+ try:
+ dspfile = open(self.dspfile,'r')
+ except IOError:
+ return # doesn't exist yet, so can't add anything to configs.
+
+ line = dspfile.readline()
+ while line:
+ if line.find('<!-- SCons Data:') > -1:
+ break
+ line = dspfile.readline()
+
+ line = dspfile.readline()
+ datas = line
+ while line and line != '\n':
+ line = dspfile.readline()
+ datas = datas + line
+
+ # OK, we've found our little pickled cache of data.
+ try:
+ datas = base64.decodestring(datas)
+ data = pickle.loads(datas)
+ except KeyboardInterrupt:
+ raise
+ except:
+ return # unable to unpickle any data for some reason
+
+ self.configs.update(data)
+
+ data = None
+ line = dspfile.readline()
+ datas = line
+ while line and line != '\n':
+ line = dspfile.readline()
+ datas = datas + line
+
+ # OK, we've found our little pickled cache of data.
+ try:
+ datas = base64.decodestring(datas)
+ data = pickle.loads(datas)
+ except KeyboardInterrupt:
+ raise
+ except:
+ return # unable to unpickle any data for some reason
+
+ self.sources.update(data)
+
+ def Build(self):
+ try:
+ self.file = open(self.dspfile,'w')
+ except IOError, detail:
+ raise SCons.Errors.InternalError, 'Unable to open "' + self.dspfile + '" for writing:' + str(detail)
+ else:
+ self.PrintHeader()
+ self.PrintProject()
+ self.file.close()
+
+class _DSWGenerator:
+ """ Base class for DSW generators """
+ def __init__(self, dswfile, dspfile, source, env):
+ self.dswfile = os.path.normpath(str(dswfile))
+ self.dspfile = os.path.abspath(str(dspfile))
+ self.env = env
+
+ if self.env.has_key('name'):
+ self.name = self.env['name']
+ else:
+ self.name = os.path.basename(SCons.Util.splitext(self.dspfile)[0])
+
+ def Build(self):
+ pass
+
+class _GenerateV7DSW(_DSWGenerator):
+ """Generates a Solution file for MSVS .NET"""
+ def __init__(self, dswfile, dspfile, source, env):
+ _DSWGenerator.__init__(self, dswfile, dspfile, source, env)
+
+ self.version = float(self.env['MSVS_VERSION'])
+ self.versionstr = '7.00'
+ if self.version >= 7.1:
+ self.versionstr = '8.00'
+
+ if env.has_key('slnguid') and env['slnguid']:
+ self.slnguid = env['slnguid']
+ else:
+ self.slnguid = _generateGUID(dswfile, self.name)
+
+ self.config = Config()
+ if env.has_key('variant'):
+ self.config.variant = env['variant'].capitalize()
+ else:
+ raise SCons.Errors.InternalError, \
+ "You must specify a 'variant' argument (i.e. 'Debug' or " +\
+ "'Release') to create an MSVS Solution File."
+
+ self.configs = {}
+
+ if os.path.exists(self.dswfile):
+ self.Parse()
+
+ self.configs[self.config.variant] = self.config
+
+ def Parse(self):
+ try:
+ dswfile = open(self.dswfile,'r')
+ except IOError:
+ return # doesn't exist yet, so can't add anything to configs.
+
+ line = dswfile.readline()
+ while line:
+ if line[:9] == "EndGlobal":
+ break
+ line = dswfile.readline()
+
+ line = dswfile.readline()
+ datas = line
+ while line:
+ line = dswfile.readline()
+ datas = datas + line
+
+ # OK, we've found our little pickled cache of data.
+ try:
+ datas = base64.decodestring(datas)
+ data = pickle.loads(datas)
+ except KeyboardInterrupt:
+ raise
+ except:
+ return # unable to unpickle any data for some reason
+
+ self.configs.update(data)
+
+ def PrintSolution(self):
+ """Writes a solution file"""
+ self.file.write('Microsoft Visual Studio Solution File, Format Version %s\n'
+ # the next line has the GUID for an external makefile project.
+ 'Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "%s", "%s", "%s"\n'
+ % (self.versionstr, self.name, os.path.basename(self.dspfile), self.slnguid))
+ if self.version >= 7.1:
+ self.file.write(' ProjectSection(ProjectDependencies) = postProject\n'
+ ' EndProjectSection\n')
+ self.file.write('EndProject\n'
+ 'Global\n'
+ ' GlobalSection(SolutionConfiguration) = preSolution\n')
+ confkeys = self.configs.keys()
+ confkeys.sort()
+ cnt = 0
+ for name in confkeys:
+ self.file.write(' ConfigName.%d = %s\n' % (cnt, name.capitalize()))
+ cnt = cnt + 1
+ self.file.write(' EndGlobalSection\n')
+ if self.version < 7.1:
+ self.file.write(' GlobalSection(ProjectDependencies) = postSolution\n'
+ ' EndGlobalSection\n')
+ self.file.write(' GlobalSection(ProjectConfiguration) = postSolution\n')
+ for name in confkeys:
+ name = name.capitalize()
+ self.file.write(' %s.%s.ActiveCfg = %s|Win32\n'
+ ' %s.%s.Build.0 = %s|Win32\n' %(self.slnguid,name,name,self.slnguid,name,name))
+ self.file.write(' EndGlobalSection\n'
+ ' GlobalSection(ExtensibilityGlobals) = postSolution\n'
+ ' EndGlobalSection\n'
+ ' GlobalSection(ExtensibilityAddIns) = postSolution\n'
+ ' EndGlobalSection\n'
+ 'EndGlobal\n')
+ pdata = pickle.dumps(self.configs,1)
+ pdata = base64.encodestring(pdata)
+ self.file.write(pdata + '\n')
+
+ def Build(self):
+ try:
+ self.file = open(self.dswfile,'w')
+ except IOError, detail:
+ raise SCons.Errors.InternalError, 'Unable to open "' + self.dswfile + '" for writing:' + str(detail)
+ else:
+ self.PrintSolution()
+ self.file.close()
+
+class _GenerateV6DSW(_DSWGenerator):
+ """Generates a Workspace file for MSVS 6.0"""
+
+ def PrintWorkspace(self):
+ """ writes a DSW file """
+ self.file.write('Microsoft Developer Studio Workspace File, Format Version 6.00\n'
+ '# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n'
+ '\n'
+ '###############################################################################\n'
+ '\n'
+ 'Project: "%s"="%s" - Package Owner=<4>\n'
+ '\n'
+ 'Package=<5>\n'
+ '{{{\n'
+ '}}}\n'
+ '\n'
+ 'Package=<4>\n'
+ '{{{\n'
+ '}}}\n'
+ '\n'
+ '###############################################################################\n'
+ '\n'
+ 'Global:\n'
+ '\n'
+ 'Package=<5>\n'
+ '{{{\n'
+ '}}}\n'
+ '\n'
+ 'Package=<3>\n'
+ '{{{\n'
+ '}}}\n'
+ '\n'
+ '###############################################################################\n'\
+ %(self.name,self.dspfile))
+
+ def Build(self):
+ try:
+ self.file = open(self.dswfile,'w')
+ except IOError, detail:
+ raise SCons.Errors.InternalError, 'Unable to open "' + self.dswfile + '" for writing:' + str(detail)
+ else:
+ self.PrintWorkspace()
+ self.file.close()
+
+
+def GenerateDSP(dspfile, source, env):
+ """Generates a Project file based on the version of MSVS that is being used"""
+
+ if env.has_key('MSVS_VERSION') and float(env['MSVS_VERSION']) >= 7.0:
+ g = _GenerateV7DSP(dspfile, source, env)
+ g.Build()
+ else:
+ g = _GenerateV6DSP(dspfile, source, env)
+ g.Build()
+
+def GenerateDSW(dswfile, dspfile, source, env):
+ """Generates a Solution/Workspace file based on the version of MSVS that is being used"""
+
+ if env.has_key('MSVS_VERSION') and float(env['MSVS_VERSION']) >= 7.0:
+ g = _GenerateV7DSW(dswfile, dspfile, source, env)
+ g.Build()
+ else:
+ g = _GenerateV6DSW(dswfile, dspfile, source, env)
+ g.Build()
+
+
+##############################################################################
+# Above here are the classes and functions for generation of
+# DSP/DSW/SLN/VCPROJ files.
+##############################################################################
+
+def get_default_visualstudio_version(env):
+ """Returns the version set in the env, or the latest version
+ installed, if it can find it, or '6.0' if all else fails. Also
+ updated the environment with what it found."""
+
+ version = '6.0'
+ versions = [version]
+ if not env.has_key('MSVS') or type(env['MSVS']) != types.DictType:
+ env['MSVS'] = {}
+
+ if env.has_key('MSVS_VERSION'):
+ version = env['MSVS_VERSION']
+ versions = [version]
+ else:
+ if SCons.Util.can_read_reg:
+ versions = get_visualstudio_versions()
+ if versions:
+ version = versions[0] #use highest version by default
+
+ env['MSVS_VERSION'] = version
+ env['MSVS']['VERSIONS'] = versions
+ env['MSVS']['VERSION'] = version
+
+ return version
+
+def get_visualstudio_versions():
+ """
+ Get list of visualstudio versions from the Windows registry. Return a
+ list of strings containing version numbers; an exception will be raised
+ if we were unable to access the registry (eg. couldn't import
+ a registry-access module) or the appropriate registry keys weren't
+ found.
+ """
+
+ if not SCons.Util.can_read_reg:
+ return []
+
+ HLM = SCons.Util.HKEY_LOCAL_MACHINE
+ K = r'Software\Microsoft\VisualStudio'
+ L = []
+ try:
+ k = SCons.Util.RegOpenKeyEx(HLM, K)
+ i = 0
+ while 1:
+ try:
+ p = SCons.Util.RegEnumKey(k,i)
+ except SCons.Util.RegError:
+ break
+ i = i + 1
+ if not p[0] in '123456789' or p in L:
+ continue
+ # Only add this version number if there is a valid
+ # registry structure (includes the "Setup" key),
+ # and at least some of the correct directories
+ # exist. Sometimes VS uninstall leaves around
+ # some registry/filesystem turds that we don't
+ # want to trip over. Also, some valid registry
+ # entries are MSDN entries, not MSVS ('7.1',
+ # notably), and we want to skip those too.
+ try:
+ SCons.Util.RegOpenKeyEx(HLM, K + '\\' + p + '\\Setup')
+ except SCons.Util.RegError:
+ continue
+
+ id = []
+ idk = SCons.Util.RegOpenKeyEx(HLM, K + '\\' + p)
+ # This is not always here -- it only exists if the
+ # user installed into a non-standard location (at
+ # least in VS6 it works that way -- VS7 seems to
+ # always write it)
+ try:
+ id = SCons.Util.RegQueryValueEx(idk, 'InstallDir')
+ except SCons.Util.RegError:
+ pass
+
+ # If the InstallDir key doesn't exist,
+ # then we check the default locations.
+ if not id or not id[0]:
+ files_dir = SCons.Platform.win32.get_program_files_dir()
+ if float(p) < 7.0:
+ vs = r'Microsoft Visual Studio\Common\MSDev98'
+ else:
+ vs = r'Microsoft Visual Studio .NET\Common7\IDE'
+ id = [ os.path.join(files_dir, vs) ]
+ if os.path.exists(id[0]):
+ L.append(p)
+ except SCons.Util.RegError:
+ pass
+
+ if not L:
+ return []
+
+ # This is a hack to get around the fact that certain Visual Studio
+ # patches place a "6.1" version in the registry, which does not have
+ # any of the keys we need to find include paths, install directories,
+ # etc. Therefore we ignore it if it is there, since it throws all
+ # other logic off.
+ try:
+ L.remove("6.1")
+ except ValueError:
+ pass
+
+ L.sort()
+ L.reverse()
+
+ return L
+
+def is_msvs_installed():
+ """
+ Check the registry for an installed visual studio.
+ """
+ try:
+ v = SCons.Tool.msvs.get_visualstudio_versions()
+ return v
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ return 0
+
+def get_msvs_install_dirs(version = None):
+ """
+ Get installed locations for various msvc-related products, like the .NET SDK
+ and the Platform SDK.
+ """
+
+ if not SCons.Util.can_read_reg:
+ return {}
+
+ if not version:
+ versions = get_visualstudio_versions()
+ if versions:
+ version = versions[0] #use highest version by default
+ else:
+ return {}
+
+ K = 'Software\\Microsoft\\VisualStudio\\' + version
+
+ # vc++ install dir
+ rv = {}
+ try:
+ if (float(version) < 7.0):
+ (rv['VCINSTALLDIR'], t) = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE,
+ K + r'\Setup\Microsoft Visual C++\ProductDir')
+ else:
+ (rv['VCINSTALLDIR'], t) = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE,
+ K + r'\Setup\VC\ProductDir')
+ except SCons.Util.RegError:
+ pass
+
+ # visual studio install dir
+ if (float(version) < 7.0):
+ try:
+ (rv['VSINSTALLDIR'], t) = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE,
+ K + r'\Setup\Microsoft Visual Studio\ProductDir')
+ except SCons.Util.RegError:
+ pass
+
+ if not rv.has_key('VSINSTALLDIR') or not rv['VSINSTALLDIR']:
+ if rv.has_key('VCINSTALLDIR') and rv['VCINSTALLDIR']:
+ rv['VSINSTALLDIR'] = os.path.dirname(rv['VCINSTALLDIR'])
+ else:
+ rv['VSINSTALLDIR'] = os.path.join(SCons.Platform.win32.get_program_files_dir(),'Microsoft Visual Studio')
+ else:
+ try:
+ (rv['VSINSTALLDIR'], t) = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE,
+ K + r'\Setup\VS\ProductDir')
+ except SCons.Util.RegError:
+ pass
+
+ # .NET framework install dir
+ try:
+ (rv['FRAMEWORKDIR'], t) = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE,
+ r'Software\Microsoft\.NETFramework\InstallRoot')
+ except SCons.Util.RegError:
+ pass
+
+ if rv.has_key('FRAMEWORKDIR'):
+ # try and enumerate the installed versions of the .NET framework.
+ contents = os.listdir(rv['FRAMEWORKDIR'])
+ l = re.compile('v[0-9]+.*')
+ versions = []
+ for entry in contents:
+ if l.match(entry):
+ versions.append(entry)
+
+ def versrt(a,b):
+ # since version numbers aren't really floats...
+ aa = a[1:]
+ bb = b[1:]
+ aal = aa.split('.')
+ bbl = bb.split('.')
+ c = int(bbl[0]) - int(aal[0])
+ if c == 0:
+ c = int(bbl[1]) - int(aal[1])
+ if c == 0:
+ c = int(bbl[2]) - int(aal[2])
+ return c
+
+ versions.sort(versrt)
+
+ rv['FRAMEWORKVERSIONS'] = versions
+ # assume that the highest version is the latest version installed
+ rv['FRAMEWORKVERSION'] = versions[0]
+
+ # .NET framework SDK install dir
+ try:
+ if rv.has_key('FRAMEWORKVERSION') and rv['FRAMEWORKVERSION'][:4] == 'v1.1':
+ key = r'Software\Microsoft\.NETFramework\sdkInstallRootv1.1'
+ else:
+ key = r'Software\Microsoft\.NETFramework\sdkInstallRoot'
+
+ (rv['FRAMEWORKSDKDIR'], t) = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE,key)
+
+ except SCons.Util.RegError:
+ pass
+
+ # MS Platform SDK dir
+ try:
+ (rv['PLATFORMSDKDIR'], t) = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE,
+ r'Software\Microsoft\MicrosoftSDK\Directories\Install Dir')
+ except SCons.Util.RegError:
+ pass
+
+ if rv.has_key('PLATFORMSDKDIR'):
+ # if we have a platform SDK, try and get some info on it.
+ vers = {}
+ try:
+ loc = r'Software\Microsoft\MicrosoftSDK\InstalledSDKs'
+ k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,loc)
+ i = 0
+ while 1:
+ try:
+ key = SCons.Util.RegEnumKey(k,i)
+ sdk = SCons.Util.RegOpenKeyEx(k,key)
+ j = 0
+ name = ''
+ date = ''
+ version = ''
+ while 1:
+ try:
+ (vk,vv,t) = SCons.Util.RegEnumValue(sdk,j)
+ if vk.lower() == 'keyword':
+ name = vv
+ if vk.lower() == 'propagation_date':
+ date = vv
+ if vk.lower() == 'version':
+ version = vv
+ j = j + 1
+ except SCons.Util.RegError:
+ break
+ if name:
+ vers[name] = (date, version)
+ i = i + 1
+ except SCons.Util.RegError:
+ break
+ rv['PLATFORMSDK_MODULES'] = vers
+ except SCons.Util.RegError:
+ pass
+
+ return rv;
+
+def GetMSVSProjectSuffix(target, source, env, for_signature):
+ return env['MSVS']['PROJECTSUFFIX'];
+
+def GetMSVSSolutionSuffix(target, source, env, for_signature):
+ return env['MSVS']['SOLUTIONSUFFIX'];
+
+def GenerateProject(target, source, env):
+ # generate the dsp file, according to the version of MSVS.
+ builddspfile = target[0]
+ builddswfile = target[1]
+ dswfile = builddswfile.srcnode()
+ dspfile = builddspfile.srcnode()
+
+# print "SConscript :",str(source[0])
+# print "DSW file :",dswfile
+# print "DSP file :",dspfile
+# print "Build DSW file:",builddswfile
+# print "Build DSP file:",builddspfile
+
+ # this detects whether or not we're using a BuildDir
+ if os.path.abspath(os.path.normcase(str(dspfile))) != \
+ os.path.abspath(os.path.normcase(str(builddspfile))):
+ try:
+ bdsp = open(str(builddspfile), "w+")
+ except IOError, detail:
+ print 'Unable to open "' + str(dspfile) + '" for writing:',detail,'\n'
+ raise
+
+ bdsp.write("This is just a placeholder file.\nThe real project file is here:\n%s\n" % dspfile.get_abspath())
+
+ try:
+ bdsw = open(str(builddswfile), "w+")
+ except IOError, detail:
+ print 'Unable to open "' + str(dspfile) + '" for writing:',detail,'\n'
+ raise
+
+ bdsw.write("This is just a placeholder file.\nThe real workspace file is here:\n%s\n" % dswfile.get_abspath())
+
+ GenerateDSP(dspfile, source, env)
+ GenerateDSW(dswfile, dspfile, source, env)
+
+def projectEmitter(target, source, env):
+ """Sets up the DSP and DSW dependencies for an SConscript file."""
+
+ if source[0] == target[0]:
+ source = []
+
+ # make sure the suffix is correct for the version of MSVS we're running.
+ (base, suff) = SCons.Util.splitext(str(target[0]))
+ suff = env.subst('$MSVSPROJECTSUFFIX')
+ target[0] = base + suff
+
+ dspfile = SCons.Node.FS.default_fs.File(target[0]).srcnode()
+ dswfile = SCons.Node.FS.default_fs.File(SCons.Util.splitext(str(dspfile))[0] + env.subst('$MSVSSOLUTIONSUFFIX'))
+
+ if not source:
+ source = [SCons.Script.SConscript.stack[-1].sconscript.srcnode()]
+
+ source[0].attributes.sconstruct = SCons.Script.SConscript.stack[0].sconscript
+
+ bdswpath = SCons.Util.splitext(str(target[0]))[0] + env.subst('$MSVSSOLUTIONSUFFIX')
+ bdswfile = SCons.Node.FS.default_fs.File(bdswpath)
+
+ # only make these side effects if they're
+ # not the same file.
+ if os.path.abspath(os.path.normcase(str(dspfile))) != \
+ os.path.abspath(os.path.normcase(str(target[0]))):
+ env.SideEffect(dspfile, target[0])
+ env.Precious(dspfile)
+ # dswfile isn't precious -- it can be blown away and rewritten each time.
+ env.SideEffect(dswfile, target[0])
+
+ return ([target[0],bdswfile], source)
+
+projectGeneratorAction = SCons.Action.Action(GenerateProject, None)
+
+projectBuilder = SCons.Builder.Builder(action = '$MSVSPROJECTCOM',
+ suffix = '$MSVSPROJECTSUFFIX',
+ emitter = projectEmitter)
+
+def generate(env):
+ """Add Builders and construction variables for Microsoft Visual
+ Studio project files to an Environment."""
+ try:
+ env['BUILDERS']['MSVSProject']
+ except KeyError:
+ env['BUILDERS']['MSVSProject'] = projectBuilder
+
+ env['MSVSPROJECTCOM'] = projectGeneratorAction
+
+ try:
+ version = get_default_visualstudio_version(env)
+ # keep a record of some of the MSVS info so the user can use it.
+ dirs = get_msvs_install_dirs(version)
+ env['MSVS'].update(dirs)
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ # we don't care if we can't do this -- if we can't, it's
+ # because we don't have access to the registry, or because the
+ # tools aren't installed. In either case, the user will have to
+ # find them on their own.
+ pass
+
+ if (float(env['MSVS_VERSION']) < 7.0):
+ env['MSVS']['PROJECTSUFFIX'] = '.dsp'
+ env['MSVS']['SOLUTIONSUFFIX'] = '.dsw'
+ else:
+ env['MSVS']['PROJECTSUFFIX'] = '.vcproj'
+ env['MSVS']['SOLUTIONSUFFIX'] = '.sln'
+
+ env['GET_MSVSPROJECTSUFFIX'] = GetMSVSProjectSuffix
+ env['GET_MSVSSOLUTIONSUFFIX'] = GetMSVSSolutionSuffix
+ env['MSVSPROJECTSUFFIX'] = '${GET_MSVSPROJECTSUFFIX}'
+ env['MSVSSOLUTIONSUFFIX'] = '${GET_MSVSSOLUTIONSUFFIX}'
+
+def exists(env):
+ try:
+ v = SCons.Tool.msvs.get_visualstudio_versions()
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ pass
+
+ if not v:
+ if env.has_key('MSVS_VERSION') and float(env['MSVS_VERSION']) >= 7.0:
+ return env.Detect('devenv')
+ else:
+ return env.Detect('msdev')
+ else:
+ # there's at least one version of MSVS installed.
+ return 1
+
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/nasm.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/nasm.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/nasm.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,65 @@
+"""SCons.Tool.nasm
+
+Tool-specific initialization for nasm, the famous Netwide Assembler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/nasm.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+ASSuffixes = ['.s', '.asm', '.ASM']
+ASPPSuffixes = ['.spp', '.SPP']
+if SCons.Util.case_sensitive_suffixes('.s', '.S'):
+ ASPPSuffixes.extend(['.S'])
+else:
+ ASSuffixes.extend(['.S'])
+
+def generate(env):
+ """Add Builders and construction variables for nasm to an Environment."""
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ for suffix in ASSuffixes:
+ static_obj.add_action(suffix, SCons.Defaults.ASAction)
+ static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter)
+
+ for suffix in ASPPSuffixes:
+ static_obj.add_action(suffix, SCons.Defaults.ASPPAction)
+ static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter)
+
+ env['AS'] = 'nasm'
+ env['ASFLAGS'] = SCons.Util.CLVar('')
+ env['ASCOM'] = '$AS $ASFLAGS -o $TARGET $SOURCES'
+ env['ASPPCOM'] = '$CC $ASFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
+
+def exists(env):
+ return env.Detect('nasm')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/pdflatex.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/pdflatex.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/pdflatex.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,58 @@
+"""SCons.Tool.pdflatex
+
+Tool-specific initialization for pdflatex.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/pdflatex.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Action
+import SCons.Defaults
+import SCons.Util
+
+PDFLaTeXAction = SCons.Action.Action('$PDFLATEXCOM')
+
+def generate(env):
+ """Add Builders and construction variables for pdflatex to an Environment."""
+ try:
+ bld = env['BUILDERS']['PDF']
+ except KeyError:
+ bld = SCons.Defaults.PDF()
+ env['BUILDERS']['PDF'] = bld
+
+ bld.add_action('.ltx', PDFLaTeXAction)
+ bld.add_action('.latex', PDFLaTeXAction)
+
+ env['PDFLATEX'] = 'pdflatex'
+ env['PDFLATEXFLAGS'] = SCons.Util.CLVar('')
+ env['PDFLATEXCOM'] = '$PDFLATEX $PDFLATEXFLAGS $SOURCES $TARGET'
+
+def exists(env):
+ return env.Detect('pdflatex')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/pdftex.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/pdftex.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/pdftex.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,54 @@
+"""SCons.Tool.pdftex
+
+Tool-specific initialization for pdftex.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/pdftex.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Util
+
+def generate(env):
+ """Add Builders and construction variables for pdftex to an Environment."""
+ try:
+ bld = env['BUILDERS']['PDF']
+ except KeyError:
+ bld = SCons.Defaults.PDF()
+ env['BUILDERS']['PDF'] = bld
+
+ bld.add_action('.tex', '$PDFTEXCOM')
+
+ env['PDFTEX'] = 'pdftex'
+ env['PDFTEXFLAGS'] = SCons.Util.CLVar('')
+ env['PDFTEXCOM'] = '$PDFTEX $PDFTEXFLAGS $SOURCES $TARGET'
+
+def exists(env):
+ return env.Detect('pdftex')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/qt.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/qt.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/qt.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,309 @@
+
+"""SCons.Tool.qt
+
+Tool-specific initialization for qt.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/qt.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+import re
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+class ToolQtWarning(SCons.Warnings.Warning):
+ pass
+
+class GeneratedMocFileNotIncluded(ToolQtWarning):
+ pass
+
+class QtdirNotFound(ToolQtWarning):
+ pass
+
+SCons.Warnings.enableWarningClass(ToolQtWarning)
+
+header_extensions = [".h", ".hxx", ".hpp", ".hh"]
+if SCons.Util.case_sensitive_suffixes('.h', '.H'):
+ header_extensions.append('.H')
+cplusplus = __import__('c++', globals(), locals(), [])
+cxx_suffixes = cplusplus.CXXSuffixes
+
+def checkMocIncluded(target, source, env):
+ moc = target[0]
+ cpp = source[0]
+ # looks like cpp.includes is cleared before the build stage :-(
+ # not really sure about the path transformations (moc.cwd? cpp.cwd?) :-/
+ path = SCons.Defaults.CScan.path_function(env, moc.cwd)
+ includes = SCons.Defaults.CScan(cpp, env, path)
+ if not moc in includes:
+ SCons.Warnings.warn(
+ GeneratedMocFileNotIncluded,
+ "Generated moc file '%s' is not included by '%s'" %
+ (str(moc), str(cpp)))
+
+def find_file(filename, paths, node_factory):
+ retval = None
+ for dir in paths:
+ node = node_factory(filename, dir)
+ if node.rexists():
+ return node
+ return None
+
+class _Automoc:
+ """
+ Callable class, which works as an emitter for Programs, SharedLibraries and
+ StaticLibraries.
+ """
+
+ def __init__(self, objBuilderName):
+ self.objBuilderName = objBuilderName
+
+ def __call__(self, target, source, env):
+ """
+ Smart autoscan function. Gets the list of objects for the Program
+ or Lib. Adds objects and builders for the special qt files.
+ """
+ try:
+ if int(env.subst('$QT_AUTOSCAN')) == 0:
+ return target, source
+ except ValueError:
+ pass
+ try:
+ debug = int(env.subst('$QT_DEBUG'))
+ except ValueError:
+ debug = 0
+
+ # some shortcuts used in the scanner
+ FS = SCons.Node.FS.default_fs
+ splitext = SCons.Util.splitext
+ objBuilder = getattr(env, self.objBuilderName)
+
+ # some regular expressions:
+ # Q_OBJECT detection
+ q_object_search = re.compile(r'[^A-Za-z0-9]Q_OBJECT[^A-Za-z0-9]')
+ # cxx and c comment 'eater'
+ #comment = re.compile(r'(//.*)|(/\*(([^*])|(\*[^/]))*\*/)')
+ # CW: something must be wrong with the regexp. See also bug #998222
+ # CURRENTLY THERE IS NO TEST CASE FOR THAT
+
+ # The following is kind of hacky to get builders working properly (FIXME)
+ objBuilderEnv = objBuilder.env
+ objBuilder.env = env
+ mocBuilderEnv = env.Moc.env
+ env.Moc.env = env
+
+ # make a deep copy for the result; MocH objects will be appended
+ out_sources = source[:]
+
+ for obj in source:
+ if not obj.has_builder():
+ # binary obj file provided
+ if debug:
+ print "scons: qt: '%s' seems to be a binary. Discarded." % str(obj)
+ continue
+ cpp = obj.sources[0]
+ if not splitext(str(cpp))[1] in cxx_suffixes:
+ if debug:
+ print "scons: qt: '%s' is no cxx file. Discarded." % str(cpp)
+ # c or fortran source
+ continue
+ #cpp_contents = comment.sub('', cpp.get_contents())
+ cpp_contents = cpp.get_contents()
+ h=None
+ for h_ext in header_extensions:
+ # try to find the header file in the corresponding source
+ # directory
+ hname = splitext(cpp.name)[0] + h_ext
+ h = find_file(hname,
+ (cpp.get_dir(),),
+ FS.File)
+ if h:
+ if debug:
+ print "scons: qt: Scanning '%s' (header of '%s')" % (str(h), str(cpp))
+ #h_contents = comment.sub('', h.get_contents())
+ h_contents = h.get_contents()
+ break
+ if not h and debug:
+ print "scons: qt: no header for '%s'." % (str(cpp))
+ if h and q_object_search.search(h_contents):
+ # h file with the Q_OBJECT macro found -> add moc_cpp
+ moc_cpp = env.Moc(h)
+ moc_o = objBuilder(moc_cpp)
+ out_sources.append(moc_o)
+ #moc_cpp.target_scanner = SCons.Defaults.CScan
+ if debug:
+ print "scons: qt: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(h), str(moc_cpp))
+ if cpp and q_object_search.search(cpp_contents):
+ # cpp file with Q_OBJECT macro found -> add moc
+ # (to be included in cpp)
+ moc = env.Moc(cpp)
+ env.Ignore(moc, moc)
+ if debug:
+ print "scons: qt: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(cpp), str(moc))
+ #moc.source_scanner = SCons.Defaults.CScan
+ # restore the original env attributes (FIXME)
+ objBuilder.env = objBuilderEnv
+ env.Moc.env = mocBuilderEnv
+
+ return (target, out_sources)
+
+AutomocShared = _Automoc('SharedObject')
+AutomocStatic = _Automoc('StaticObject')
+
+def _detect(env):
+ """Not really safe, but fast method to detect the QT library"""
+ QTDIR = None
+ if not QTDIR:
+ QTDIR = env.get('QTDIR',None)
+ if not QTDIR:
+ QTDIR = os.environ.get('QTDIR',None)
+ if not QTDIR:
+ moc = env.WhereIs('moc')
+ if moc:
+ QTDIR = os.path.dirname(os.path.dirname(moc))
+ SCons.Warnings.warn(
+ QtdirNotFound,
+ "Could not detect qt, using moc executable as a hint (QTDIR=%s)" % QTDIR)
+ else:
+ QTDIR = None
+ SCons.Warnings.warn(
+ QtdirNotFound,
+ "Could not detect qt, using empty QTDIR")
+ return QTDIR
+
+
+def generate(env):
+ """Add Builders and construction variables for qt to an Environment."""
+ CLVar = SCons.Util.CLVar
+ Action = SCons.Action.Action
+ Builder = SCons.Builder.Builder
+ splitext = SCons.Util.splitext
+
+ # the basics
+ env['QTDIR'] = _detect(env)
+ env['QT_MOC'] = os.path.join('$QTDIR','bin','moc')
+ env['QT_UIC'] = os.path.join('$QTDIR','bin','uic')
+ env['QT_LIB'] = 'qt' # may be set to qt-mt
+
+ # Should the qt tool try to figure out, which sources are to be moc'ed ?
+ env['QT_AUTOSCAN'] = 1
+
+ # Some QT specific flags. I don't expect someone wants to
+ # manipulate those ...
+ env['QT_UICIMPLFLAGS'] = CLVar('')
+ env['QT_UICDECLFLAGS'] = CLVar('')
+ env['QT_MOCFROMHFLAGS'] = CLVar('')
+ env['QT_MOCFROMCXXFLAGS'] = CLVar('-i')
+
+ # suffixes/prefixes for the headers / sources to generate
+ env['QT_UICDECLPREFIX'] = ''
+ env['QT_UICDECLSUFFIX'] = '.h'
+ env['QT_UICIMPLPREFIX'] = 'uic_'
+ env['QT_UICIMPLSUFFIX'] = '$CXXFILESUFFIX'
+ env['QT_MOCHPREFIX'] = 'moc_'
+ env['QT_MOCHSUFFIX'] = '$CXXFILESUFFIX'
+ env['QT_MOCCXXPREFIX'] = ''
+ env['QT_MOCCXXSUFFIX'] = '.moc'
+ env['QT_UISUFFIX'] = '.ui'
+
+ def uicEmitter(target, source, env):
+ adjustixes = SCons.Util.adjustixes
+ bs = SCons.Util.splitext(str(source[0].name))[0]
+ bs = os.path.join(str(target[0].get_dir()),bs)
+ # first target (header) is automatically added by builder
+ if len(target) < 2:
+ # second target is implementation
+ target.append(adjustixes(bs,
+ env.subst('$QT_UICIMPLPREFIX'),
+ env.subst('$QT_UICIMPLSUFFIX')))
+ if len(target) < 3:
+ # third target is moc file
+ target.append(adjustixes(bs,
+ env.subst('$QT_MOCHPREFIX'),
+ env.subst('$QT_MOCHSUFFIX')))
+ return target, source
+
+ # Commands for the qt support ...
+ # command to generate header, implementation and moc-file from a .ui file
+ env['QT_UICCOM'] = [
+ CLVar('$QT_UIC $QT_UICDECLFLAGS -o ${TARGETS[0]} $SOURCE'),
+ CLVar('$QT_UIC $QT_UICIMPLFLAGS -impl ${TARGETS[0].file} '
+ '-o ${TARGETS[1]} $SOURCE'),
+ CLVar('$QT_MOC $QT_MOCFROMHFLAGS -o ${TARGETS[2]} ${TARGETS[0]}')]
+ # command to generate meta object information for a class declarated
+ # in a header
+ env['QT_MOCFROMHCOM'] = (
+ '$QT_MOC $QT_MOCFROMHFLAGS -o ${TARGETS[0]} $SOURCE')
+ # command to generate meta object information for a class declarated
+ # in a cpp file
+ env['QT_MOCFROMCXXCOM'] = [
+ CLVar('$QT_MOC $QT_MOCFROMCXXFLAGS -o ${TARGETS[0]} $SOURCE'),
+ Action(checkMocIncluded,None)]
+ # ... and the corresponding builders
+ uicBld = Builder(action='$QT_UICCOM',
+ emitter=uicEmitter,
+ src_suffix='$QT_UISUFFIX',
+ suffix='$QT_UICDECLSUFFIX',
+ prefix='$QT_UICDECLPREFIX')
+ mocBld = Builder(action={}, prefix={}, suffix={})
+ for h in header_extensions:
+ mocBld.add_action(h, '$QT_MOCFROMHCOM')
+ mocBld.prefix[h] = '$QT_MOCHPREFIX'
+ mocBld.suffix[h] = '$QT_MOCHSUFFIX'
+ for cxx in cxx_suffixes:
+ mocBld.add_action(cxx, '$QT_MOCFROMCXXCOM')
+ mocBld.prefix[cxx] = '$QT_MOCCXXPREFIX'
+ mocBld.suffix[cxx] = '$QT_MOCCXXSUFFIX'
+
+ # register the builders
+ env['BUILDERS']['Uic'] = uicBld
+ env['BUILDERS']['Moc'] = mocBld
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+ static_obj.src_builder.append('Uic')
+ shared_obj.src_builder.append('Uic')
+
+ # We use the emitters of Program / StaticLibrary / SharedLibrary
+ # to scan for moc'able files
+ # We can't refer to the builders directly, we have to fetch them
+ # as Environment attributes because that sets them up to be called
+ # correctly later by our emitter.
+ env.AppendUnique(PROGEMITTER =[AutomocStatic],
+ SHLIBEMITTER=[AutomocShared],
+ LIBEMITTER =[AutomocStatic],
+ # Of course, we need to link against the qt libraries
+ CPPPATH=[os.path.join('$QTDIR', 'include')],
+ LIBPATH=[os.path.join('$QTDIR', 'lib')],
+ LIBS=['$QT_LIB'])
+
+def exists(env):
+ return _detect(env)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/rmic.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/rmic.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/rmic.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,108 @@
+"""SCons.Tool.rmic
+
+Tool-specific initialization for rmic.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/rmic.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+import string
+
+import SCons.Builder
+import SCons.Node.FS
+import SCons.Util
+
+def emit_rmic_classes(target, source, env):
+ """Create and return lists of Java RMI stub and skeleton
+ class files to be created from a set of class files.
+ """
+ class_suffix = env.get('JAVACLASSSUFFIX', '.class')
+ classdir = env.get('JAVACLASSDIR')
+
+ if not classdir:
+ try:
+ s = source[0]
+ except IndexError:
+ classdir = '.'
+ else:
+ try:
+ classdir = s.attributes.java_classdir
+ except AttributeError:
+ classdir = '.'
+ classdir = SCons.Node.FS.default_fs.Dir(classdir).rdir()
+ if str(classdir) == '.':
+ c_ = None
+ else:
+ c_ = str(classdir) + os.sep
+
+ slist = []
+ for src in source:
+ try:
+ classname = src.attributes.java_classname
+ except AttributeError:
+ classname = str(src)
+ if c_ and classname[:len(c_)] == c_:
+ classname = classname[len(c_):]
+ if class_suffix and classname[:-len(class_suffix)] == class_suffix:
+ classname = classname[-len(class_suffix):]
+ s = src.rfile()
+ s.attributes.java_classdir = classdir
+ s.attributes.java_classname = classname
+ slist.append(s)
+
+ tlist = []
+ for s in source:
+ for suff in ['_Skel', '_Stub']:
+ fname = string.replace(s.attributes.java_classname, '.', os.sep) + \
+ suff + class_suffix
+ t = target[0].File(fname)
+ t.attributes.java_lookupdir = target[0]
+ tlist.append(t)
+
+ return tlist, source
+
+RMICBuilder = SCons.Builder.Builder(action = '$RMICCOM',
+ emitter = emit_rmic_classes,
+ src_suffix = '$JAVACLASSSUFFIX',
+ target_factory = SCons.Node.FS.default_fs.Dir,
+ source_factory = SCons.Node.FS.default_fs.File)
+
+def generate(env):
+ """Add Builders and construction variables for rmic to an Environment."""
+ env['BUILDERS']['RMIC'] = RMICBuilder
+
+ env['RMIC'] = 'rmic'
+ env['RMICFLAGS'] = SCons.Util.CLVar('')
+ env['RMICCOM'] = '$RMIC $RMICFLAGS -d ${TARGET.attributes.java_lookupdir} -classpath ${SOURCE.attributes.java_classdir} ${SOURCES.attributes.java_classname}'
+ env['JAVACLASSSUFFIX'] = '.class'
+
+def exists(env):
+ return env.Detect('rmic')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/sgiar.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/sgiar.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/sgiar.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,62 @@
+"""SCons.Tool.sgiar
+
+Tool-specific initialization for SGI ar (library archive). If CC
+exists, static libraries should be built with it, so the prelinker has
+a chance to resolve C++ template instantiations.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/sgiar.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+def generate(env):
+ """Add Builders and construction variables for ar to an Environment."""
+ SCons.Tool.createStaticLibBuilder(env)
+
+ if env.Detect('CC'):
+ env['AR'] = 'CC'
+ env['ARFLAGS'] = SCons.Util.CLVar('-ar')
+ env['ARCOM'] = '$AR $ARFLAGS -o $TARGET $SOURCES'
+ else:
+ env['AR'] = 'ar'
+ env['ARFLAGS'] = SCons.Util.CLVar('r')
+ env['ARCOM'] = '$AR $ARFLAGS $TARGET $SOURCES'
+
+ env['SHLINK'] = '$LINK'
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
+ env['SHLINKCOM'] = '$SHLINK $SHLINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
+ env['LIBPREFIX'] = 'lib'
+ env['LIBSUFFIX'] = '.a'
+
+def exists(env):
+ return env.Detect('CC') or env.Detect('ar')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/sgic++.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/sgic++.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/sgic++.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,52 @@
+"""SCons.Tool.sgic++
+
+Tool-specific initialization for MIPSpro C++ on SGI.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/sgic++.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Util
+
+cplusplus = __import__('c++', globals(), locals(), [])
+
+def generate(env):
+ """Add Builders and construction variables for SGI MIPS C++ to an Environment."""
+
+ cplusplus.generate(env)
+
+ env['CXX'] = 'CC'
+ env['CXXFLAGS'] = SCons.Util.CLVar('$CCFLAGS -LANG:std')
+ env['SHCXX'] = 'CC'
+ env['SHOBJSUFFIX'] = '.o'
+ env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
+
+def exists(env):
+ return env.Detect('CC')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/sgicc.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/sgicc.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/sgicc.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,47 @@
+"""SCons.Tool.sgicc
+
+Tool-specific initialization for MIPSPro cc on SGI.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/sgicc.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import cc
+
+def generate(env):
+ """Add Builders and construction variables for gcc to an Environment."""
+ cc.generate(env)
+
+ env['CXX'] = 'CC'
+ env['SHOBJSUFFIX'] = '.o'
+ env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
+
+def exists(env):
+ return env.Detect('cc')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/sgilink.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/sgilink.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/sgilink.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,57 @@
+"""SCons.Tool.sgilink
+
+Tool-specific initialization for the SGI MIPSPro linker on SGI.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/sgilink.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Util
+
+import link
+
+linkers = ['CC', 'cc']
+
+def generate(env):
+ """Add Builders and construction variables for MIPSPro to an Environment."""
+ link.generate(env)
+
+ env['LINK'] = env.Detect(linkers) or 'cc'
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
+
+ # __RPATH is set to $_RPATH in the platform specification if that
+ # platform supports it.
+ env.Append(LINKFLAGS=['$__RPATH'])
+ env['RPATHPREFIX'] = '-rpath '
+ env['RPATHSUFFIX'] = ''
+ env['_RPATH'] = '${_concat(RPATHPREFIX, RPATH, RPATHSUFFIX, __env__)}'
+
+def exists(env):
+ return env.Detect(linkers)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/sunar.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/sunar.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/sunar.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,61 @@
+"""engine.SCons.Tool.sunar
+
+Tool-specific initialization for Solaris (Forte) ar (library archive). If CC
+exists, static libraries should be built with it, so that template
+instantians can be resolved.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/sunar.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+def generate(env):
+ """Add Builders and construction variables for ar to an Environment."""
+ SCons.Tool.createStaticLibBuilder(env)
+
+ if env.Detect('CC'):
+ env['AR'] = 'CC'
+ env['ARFLAGS'] = SCons.Util.CLVar('-xar')
+ env['ARCOM'] = '$AR $ARFLAGS -o $TARGET $SOURCES'
+ else:
+ env['AR'] = 'ar'
+ env['ARFLAGS'] = SCons.Util.CLVar('r')
+ env['ARCOM'] = '$AR $ARFLAGS $TARGET $SOURCES'
+
+ env['SHLINK'] = '$LINK'
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -G')
+ env['SHLINKCOM'] = '$SHLINK $SHLINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
+ env['LIBPREFIX'] = 'lib'
+ env['LIBSUFFIX'] = '.a'
+
+def exists(env):
+ return env.Detect('CC') or env.Detect('ar')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/sunc++.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/sunc++.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/sunc++.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,77 @@
+"""SCons.Tool.sunc++
+
+Tool-specific initialization for C++ on SunOS / Solaris.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/sunc++.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+
+cplusplus = __import__('c++', globals(), locals(), [])
+
+# use the package installer tool lslpp to figure out where cppc and what
+# version of it is installed
+def get_cppc(env):
+ cppcPath = env.get('CXX', None)
+ cppcVersion = None
+
+ for package in ['SPROcpl']:
+ cmd = "pkginfo -l " + package + " 2>/dev/null | grep '^ *VERSION:'"
+ line = os.popen(cmd).readline()
+ if line:
+ cppcVersion = line.split()[-1]
+ cmd = "pkgchk -l " + package + " | grep '^Pathname:.*/bin/CC$' | grep -v '/SC[0-9]*\.[0-9]*/'"
+ line = os.popen(cmd).readline()
+ cppcPath = os.path.dirname(line.split()[-1])
+ break
+ return (cppcPath, 'CC', 'CC', cppcVersion)
+
+def generate(env):
+ """Add Builders and construction variables for SUN PRO C++ to an Environment."""
+ path, cxx, shcxx, version = get_cppc(env)
+ if path:
+ cxx = os.path.join(path, cxx)
+ shcxx = os.path.join(path, shcxx)
+
+ cplusplus.generate(env)
+
+ env['CXX'] = cxx
+ env['SHCXX'] = shcxx
+ env['CXXVERSION'] = version
+ env['SHOBJSUFFIX'] = '.os'
+
+def exists(env):
+ path, cxx, shcxx, version = get_cppc(env)
+ if path and cxx:
+ cppc = os.path.join(path, cxx)
+ if os.path.exists(cppc):
+ return cppc
+ return None
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/suncc.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/suncc.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/suncc.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,47 @@
+"""SCons.Tool.suncc
+
+Tool-specific initialization for Sun Solaris (Forte) CC and cc.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/suncc.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import cc
+
+def generate(env):
+ """
+ Add Builders and construction variables for Forte C and C++ compilers
+ to an Environment.
+ """
+ cc.generate(env)
+
+ env['CXX'] = 'CC'
+
+def exists(env):
+ return env.Detect('CC')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/sunlink.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/sunlink.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/sunlink.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,64 @@
+"""SCons.Tool.sunlink
+
+Tool-specific initialization for the Sun Solaris (Forte) linker.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/sunlink.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os
+import os.path
+
+import SCons.Util
+
+import link
+
+ccLinker = None
+
+# search for the acc compiler and linker front end
+
+try:
+ dirs = os.listdir('/opt')
+except OSError:
+ dirs = []
+
+for d in dirs:
+ linker = '/opt/' + d + '/bin/CC'
+ if os.path.exists(linker):
+ ccLinker = linker
+ break
+
+def generate(env):
+ """Add Builders and construction variables for Forte to an Environment."""
+ link.generate(env)
+
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -G')
+
+def exists(env):
+ return ccLinker
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/swig.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/swig.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/swig.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,63 @@
+"""SCons.Tool.swig
+
+Tool-specific initialization for swig.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/swig.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+def swigSuffixEmitter(env, source):
+ if '-c++' in SCons.Util.CLVar(env.subst("$SWIGFLAGS")):
+ return '$SWIGCXXFILESUFFIX'
+ else:
+ return '$SWIGCFILESUFFIX'
+
+def generate(env):
+ """Add Builders and construction variables for swig to an Environment."""
+ c_file, cxx_file = SCons.Tool.createCFileBuilders(env)
+
+ c_file.suffix['.i'] = swigSuffixEmitter
+ cxx_file.suffix['.i'] = swigSuffixEmitter
+
+ c_file.add_action('.i', '$SWIGCOM')
+ cxx_file.add_action('.i', '$SWIGCOM')
+
+ env['SWIG'] = 'swig'
+ env['SWIGFLAGS'] = SCons.Util.CLVar('')
+ env['SWIGCFILESUFFIX'] = '_wrap$CFILESUFFIX'
+ env['SWIGCXXFILESUFFIX'] = '_wrap$CXXFILESUFFIX'
+ env['SWIGCOM'] = '$SWIG $SWIGFLAGS -o $TARGET $SOURCES'
+
+def exists(env):
+ return env.Detect(['swig'])
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/tar.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/tar.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/tar.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,62 @@
+"""SCons.Tool.tar
+
+Tool-specific initialization for tar.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/tar.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Builder
+import SCons.Node.FS
+import SCons.Util
+
+tars = ['tar', 'gtar']
+
+TarBuilder = SCons.Builder.Builder(action = '$TARCOM',
+ source_factory = SCons.Node.FS.default_fs.Entry,
+ suffix = '$TARSUFFIX',
+ multi = 1)
+
+
+def generate(env):
+ """Add Builders and construction variables for tar to an Environment."""
+ try:
+ bld = env['BUILDERS']['Tar']
+ except KeyError:
+ bld = TarBuilder
+ env['BUILDERS']['Tar'] = bld
+
+ env['TAR'] = env.Detect(tars) or 'gtar'
+ env['TARFLAGS'] = SCons.Util.CLVar('-c')
+ env['TARCOM'] = '$TAR $TARFLAGS -f $TARGET $SOURCES'
+ env['TARSUFFIX'] = '.tar'
+
+def exists(env):
+ return env.Detect(tars)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/tex.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/tex.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/tex.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,118 @@
+"""SCons.Tool.tex
+
+Tool-specific initialization for TeX.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/tex.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+import re
+import string
+
+import SCons.Action
+import SCons.Defaults
+import SCons.Node
+import SCons.Node.FS
+import SCons.Util
+
+# Define an action to build a generic tex file. This is sufficient for all
+# tex files.
+TeXAction = SCons.Action.CommandAction("$TEXCOM")
+
+# Define an action to build a latex file. This action might be needed more
+# than once if we are dealing with labels and bibtex
+LaTeXAction = SCons.Action.CommandAction("$LATEXCOM")
+
+# Define an action to run BibTeX on a file.
+BibTeXAction = SCons.Action.CommandAction("$BIBTEXCOM")
+
+def LaTeXAuxAction(target = None, source= None, env=None):
+ """A builder for LaTeX files that checks the output in the aux file
+ and decides how many times to use LaTeXAction, and BibTeXAction."""
+ # Get the base name of the target
+ basename, ext = os.path.splitext(str(target[0]))
+ # Run LaTeX once to generate a new aux file.
+ LaTeXAction(target,source,env)
+ # Now if bibtex will need to be run.
+ content = open(basename + ".aux","rb").read()
+ if string.find(content, "bibdata") != -1:
+ bibfile = env.fs.File(basename)
+ BibTeXAction(None,bibfile,env)
+ # Now check if latex needs to be run yet again.
+ for trial in range(3):
+ content = open(basename + ".log","rb").read()
+ if not re.search("^LaTeX Warning:.*Rerun",content,re.MULTILINE):
+ break
+ LaTeXAction(target,source,env)
+ return 0
+
+def TeXLaTeXAction(target = None, source= None, env=None):
+ """A builder for TeX and LaTeX that scans the source file to
+ decide the "flavor" of the source and then executes the appropriate
+ program."""
+ LaTeXFile = None
+ for src in source:
+ content = src.get_contents()
+ if re.search("\\\\document(style|class)",content):
+ LaTeXFile = 1
+ break
+ if LaTeXFile:
+ LaTeXAuxAction(target,source,env)
+ else:
+ TeXAction(target,source,env)
+ return 0
+
+def generate(env):
+ """Add Builders and construction variables for TeX to an Environment."""
+ try:
+ bld = env['BUILDERS']['DVI']
+ except KeyError:
+ bld = SCons.Defaults.DVI()
+ env['BUILDERS']['DVI'] = bld
+
+ bld.add_action('.tex', TeXLaTeXAction)
+
+ env['TEX'] = 'tex'
+ env['TEXFLAGS'] = SCons.Util.CLVar('')
+ env['TEXCOM'] = '$TEX $TEXFLAGS $SOURCES'
+
+ # Duplicate from latex.py. If latex.py goes away, then this is still OK.
+ env['LATEX'] = 'latex'
+ env['LATEXFLAGS'] = SCons.Util.CLVar('')
+ env['LATEXCOM'] = '$LATEX $LATEXFLAGS $SOURCES'
+
+ env['BIBTEX'] = 'bibtex'
+ env['BIBTEXFLAGS'] = SCons.Util.CLVar('')
+ env['BIBTEXCOM'] = '$BIBTEX $BIBTEXFLAGS $SOURCES'
+
+
+def exists(env):
+ return env.Detect('tex')
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/tlib.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/tlib.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/tlib.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,47 @@
+"""SCons.Tool.tlib
+
+XXX
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/tlib.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Tool
+import SCons.Tool.bcc32
+import SCons.Util
+
+def generate(env):
+ SCons.Tool.bcc32.findIt('tlib', env)
+ """Add Builders and construction variables for ar to an Environment."""
+ SCons.Tool.createStaticLibBuilder(env)
+ env['AR'] = 'tlib'
+ env['ARFLAGS'] = SCons.Util.CLVar('')
+ env['ARCOM'] = '$AR $TARGET $ARFLAGS /a $SOURCES'
+ env['LIBPREFIX'] = ''
+ env['LIBSUFFIX'] = '.lib'
+
+def exists(env):
+ return SCons.Tool.bcc32.findIt('tlib', env)
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/yacc.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/yacc.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/yacc.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,73 @@
+"""SCons.Tool.yacc
+
+Tool-specific initialization for yacc.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/yacc.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+def _yaccEmitter(target, source, env, ysuf, hsuf):
+ # If -d is specified on the command line, yacc will emit a .h
+ # or .hpp file as well as a .c or .cpp file, depending on whether
+ # the input file is a .y or .yy, respectively.
+ if len(source) and '-d' in SCons.Util.CLVar(env.subst("$YACCFLAGS")):
+ base, ext = os.path.splitext(SCons.Util.to_String(source[0]))
+ if ext == ysuf:
+ base, ext = os.path.splitext(SCons.Util.to_String(target[0]))
+ target.append(base + hsuf)
+ return (target, source)
+
+def yEmitter(target, source, env):
+ return _yaccEmitter(target, source, env, '.y', '.h')
+
+def yyEmitter(target, source, env):
+ return _yaccEmitter(target, source, env, '.yy', '.hpp')
+
+def generate(env):
+ """Add Builders and construction variables for yacc to an Environment."""
+ c_file, cxx_file = SCons.Tool.createCFileBuilders(env)
+
+ c_file.add_action('.y', SCons.Defaults.YaccAction)
+ cxx_file.add_action('.yy', SCons.Defaults.YaccAction)
+ c_file.add_emitter('.y', yEmitter)
+ cxx_file.add_emitter('.yy', yyEmitter)
+
+ env['YACC'] = env.Detect('bison') or 'yacc'
+ env['YACCFLAGS'] = SCons.Util.CLVar('')
+ env['YACCCOM'] = '$YACC $YACCFLAGS -o $TARGET $SOURCES'
+
+def exists(env):
+ return env.Detect(['bison', 'yacc'])
Added: development/support/scons/scons-local-0.96.1/SCons/Tool/zip.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Tool/zip.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Tool/zip.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,92 @@
+"""SCons.Tool.zip
+
+Tool-specific initialization for zip.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Tool/zip.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import os.path
+
+import SCons.Builder
+import SCons.Node.FS
+import SCons.Util
+
+try:
+ import zipfile
+ internal_zip = 1
+except ImportError:
+ internal_zip = 0
+
+if internal_zip:
+ zipcompression = zipfile.ZIP_DEFLATED
+ def zip(target, source, env):
+ def visit(arg, dirname, names):
+ for name in names:
+ path = os.path.join(dirname, name)
+ if os.path.isfile(path):
+ arg.write(path)
+ compression = env.get('ZIPCOMPRESSION', 0)
+ zf = zipfile.ZipFile(str(target[0]), 'w', compression)
+ for s in source:
+ if os.path.isdir(str(s)):
+ os.path.walk(str(s), visit, zf)
+ else:
+ zf.write(str(s))
+ zf.close()
+else:
+ zipcompression = 0
+ zip = "$ZIP $ZIPFLAGS ${TARGET.abspath} $SOURCES"
+
+
+zipAction = SCons.Action.Action(zip, varlist=['ZIPCOMPRESSION'])
+
+ZipBuilder = SCons.Builder.Builder(action = '$ZIPCOM',
+ source_factory = SCons.Node.FS.default_fs.Entry,
+ suffix = '$ZIPSUFFIX',
+ multi = 1)
+
+
+def generate(env):
+ """Add Builders and construction variables for zip to an Environment."""
+ try:
+ bld = env['BUILDERS']['Zip']
+ except KeyError:
+ bld = ZipBuilder
+ env['BUILDERS']['Zip'] = bld
+
+ env['ZIP'] = 'zip'
+ env['ZIPFLAGS'] = SCons.Util.CLVar('')
+ env['ZIPCOM'] = zipAction
+ env['ZIPCOMPRESSION'] = zipcompression
+ env['ZIPSUFFIX'] = '.zip'
+
+def exists(env):
+ return internal_zip or env.Detect('zip')
Added: development/support/scons/scons-local-0.96.1/SCons/Util.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Util.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Util.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,1448 @@
+"""SCons.Util
+
+Various utility functions go here.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/branch.96/baseline/src/engine/SCons/Util.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+
+import copy
+import os
+import os.path
+import re
+import stat
+import string
+import sys
+import types
+import UserDict
+import UserList
+
+import SCons.Errors
+
+try:
+ from UserString import UserString
+except ImportError:
+ # "Borrowed" from the Python 2.2 UserString module
+ # and modified slightly for use with SCons.
+ class UserString:
+ def __init__(self, seq):
+ if is_String(seq):
+ self.data = seq
+ elif isinstance(seq, UserString):
+ self.data = seq.data[:]
+ else:
+ self.data = str(seq)
+ def __str__(self): return str(self.data)
+ def __repr__(self): return repr(self.data)
+ def __int__(self): return int(self.data)
+ def __long__(self): return long(self.data)
+ def __float__(self): return float(self.data)
+ def __complex__(self): return complex(self.data)
+ def __hash__(self): return hash(self.data)
+
+ def __cmp__(self, string):
+ if isinstance(string, UserString):
+ return cmp(self.data, string.data)
+ else:
+ return cmp(self.data, string)
+ def __contains__(self, char):
+ return char in self.data
+
+ def __len__(self): return len(self.data)
+ def __getitem__(self, index): return self.__class__(self.data[index])
+ def __getslice__(self, start, end):
+ start = max(start, 0); end = max(end, 0)
+ return self.__class__(self.data[start:end])
+
+ def __add__(self, other):
+ if isinstance(other, UserString):
+ return self.__class__(self.data + other.data)
+ elif is_String(other):
+ return self.__class__(self.data + other)
+ else:
+ return self.__class__(self.data + str(other))
+ def __radd__(self, other):
+ if is_String(other):
+ return self.__class__(other + self.data)
+ else:
+ return self.__class__(str(other) + self.data)
+ def __mul__(self, n):
+ return self.__class__(self.data*n)
+ __rmul__ = __mul__
+
+_altsep = os.altsep
+if _altsep is None and sys.platform == 'win32':
+ # My ActivePython 2.0.1 doesn't set os.altsep! What gives?
+ _altsep = '/'
+if _altsep:
+ def rightmost_separator(path, sep, _altsep=_altsep):
+ rfind = string.rfind
+ return max(rfind(path, sep), rfind(path, _altsep))
+else:
+ rightmost_separator = string.rfind
+
+# First two from the Python Cookbook, just for completeness.
+# (Yeah, yeah, YAGNI...)
+def containsAny(str, set):
+ """Check whether sequence str contains ANY of the items in set."""
+ for c in set:
+ if c in str: return 1
+ return 0
+
+def containsAll(str, set):
+ """Check whether sequence str contains ALL of the items in set."""
+ for c in set:
+ if c not in str: return 0
+ return 1
+
+def containsOnly(str, set):
+ """Check whether sequence str contains ONLY items in set."""
+ for c in str:
+ if c not in set: return 0
+ return 1
+
+def splitext(path):
+ "Same as os.path.splitext() but faster."
+ sep = rightmost_separator(path, os.sep)
+ dot = string.rfind(path, '.')
+ # An ext is only real if it has at least one non-digit char
+ if dot > sep and not containsOnly(path[dot:], "0123456789."):
+ return path[:dot],path[dot:]
+ else:
+ return path,""
+
+def updrive(path):
+ """
+ Make the drive letter (if any) upper case.
+ This is useful because Windows is inconsitent on the case
+ of the drive letter, which can cause inconsistencies when
+ calculating command signatures.
+ """
+ drive, rest = os.path.splitdrive(path)
+ if drive:
+ path = string.upper(drive) + rest
+ return path
+
+#
+# Generic convert-to-string functions that abstract away whether or
+# not the Python we're executing has Unicode support. The wrapper
+# to_String_for_signature() will use a for_signature() method if the
+# specified object has one.
+#
+if hasattr(types, 'UnicodeType'):
+ def to_String(s):
+ if isinstance(s, UserString):
+ t = type(s.data)
+ else:
+ t = type(s)
+ if t is types.UnicodeType:
+ return unicode(s)
+ else:
+ return str(s)
+else:
+ to_String = str
+
+def to_String_for_signature(obj):
+ try:
+ f = obj.for_signature
+ except:
+ return to_String(obj)
+ else:
+ return f()
+
+# Indexed by the SUBST_* constants below.
+_strconv = [to_String, to_String, to_String_for_signature]
+
+class Literal:
+ """A wrapper for a string. If you use this object wrapped
+ around a string, then it will be interpreted as literal.
+ When passed to the command interpreter, all special
+ characters will be escaped."""
+ def __init__(self, lstr):
+ self.lstr = lstr
+
+ def __str__(self):
+ return self.lstr
+
+ def escape(self, escape_func):
+ return escape_func(self.lstr)
+
+ def for_signature(self):
+ return self.lstr
+
+ def is_literal(self):
+ return 1
+
+class SpecialAttrWrapper:
+ """This is a wrapper for what we call a 'Node special attribute.'
+ This is any of the attributes of a Node that we can reference from
+ Environment variable substitution, such as $TARGET.abspath or
+ $SOURCES[1].filebase. We implement the same methods as Literal
+ so we can handle special characters, plus a for_signature method,
+ such that we can return some canonical string during signature
+ calculation to avoid unnecessary rebuilds."""
+
+ def __init__(self, lstr, for_signature=None):
+ """The for_signature parameter, if supplied, will be the
+ canonical string we return from for_signature(). Else
+ we will simply return lstr."""
+ self.lstr = lstr
+ if for_signature:
+ self.forsig = for_signature
+ else:
+ self.forsig = lstr
+
+ def __str__(self):
+ return self.lstr
+
+ def escape(self, escape_func):
+ return escape_func(self.lstr)
+
+ def for_signature(self):
+ return self.forsig
+
+ def is_literal(self):
+ return 1
+
+class CallableComposite(UserList.UserList):
+ """A simple composite callable class that, when called, will invoke all
+ of its contained callables with the same arguments."""
+ def __call__(self, *args, **kwargs):
+ retvals = map(lambda x, args=args, kwargs=kwargs: apply(x,
+ args,
+ kwargs),
+ self.data)
+ if self.data and (len(self.data) == len(filter(callable, retvals))):
+ return self.__class__(retvals)
+ return NodeList(retvals)
+
+class NodeList(UserList.UserList):
+ """This class is almost exactly like a regular list of Nodes
+ (actually it can hold any object), with one important difference.
+ If you try to get an attribute from this list, it will return that
+ attribute from every item in the list. For example:
+
+ >>> someList = NodeList([ ' foo ', ' bar ' ])
+ >>> someList.strip()
+ [ 'foo', 'bar' ]
+ """
+ def __nonzero__(self):
+ return len(self.data) != 0
+
+ def __str__(self):
+ return string.join(map(str, self.data))
+
+ def __getattr__(self, name):
+ if not self.data:
+ # If there is nothing in the list, then we have no attributes to
+ # pass through, so raise AttributeError for everything.
+ raise AttributeError, "NodeList has no attribute: %s" % name
+
+ # Return a list of the attribute, gotten from every element
+ # in the list
+ attrList = map(lambda x, n=name: getattr(x, n), self.data)
+
+ # Special case. If the attribute is callable, we do not want
+ # to return a list of callables. Rather, we want to return a
+ # single callable that, when called, will invoke the function on
+ # all elements of this list.
+ if self.data and (len(self.data) == len(filter(callable, attrList))):
+ return CallableComposite(attrList)
+ return self.__class__(attrList)
+
+_valid_var = re.compile(r'[_a-zA-Z]\w*$')
+_get_env_var = re.compile(r'^\$([_a-zA-Z]\w*|{[_a-zA-Z]\w*})$')
+
+def is_valid_construction_var(varstr):
+ """Return if the specified string is a legitimate construction
+ variable.
+ """
+ return _valid_var.match(varstr)
+
+def get_environment_var(varstr):
+ """Given a string, first determine if it looks like a reference
+ to a single environment variable, like "$FOO" or "${FOO}".
+ If so, return that variable with no decorations ("FOO").
+ If not, return None."""
+ mo=_get_env_var.match(to_String(varstr))
+ if mo:
+ var = mo.group(1)
+ if var[0] == '{':
+ return var[1:-1]
+ else:
+ return var
+ else:
+ return None
+
+def quote_spaces(arg):
+ """Generic function for putting double quotes around any string that
+ has white space in it."""
+ if ' ' in arg or '\t' in arg:
+ return '"%s"' % arg
+ else:
+ return str(arg)
+
+class CmdStringHolder(UserString):
+ """This is a special class used to hold strings generated by
+ scons_subst() and scons_subst_list(). It defines a special method
+ escape(). When passed a function with an escape algorithm for a
+ particular platform, it will return the contained string with the
+ proper escape sequences inserted.
+
+ This should really be a subclass of UserString, but that module
+ doesn't exist in Python 1.5.2."""
+ def __init__(self, cmd, literal=None):
+ UserString.__init__(self, cmd)
+ self.literal = literal
+
+ def is_literal(self):
+ return self.literal
+
+ def escape(self, escape_func, quote_func=quote_spaces):
+ """Escape the string with the supplied function. The
+ function is expected to take an arbitrary string, then
+ return it with all special characters escaped and ready
+ for passing to the command interpreter.
+
+ After calling this function, the next call to str() will
+ return the escaped string.
+ """
+
+ if self.is_literal():
+ return escape_func(self.data)
+ elif ' ' in self.data or '\t' in self.data:
+ return quote_func(self.data)
+ else:
+ return self.data
+
+class DisplayEngine:
+ def __init__(self):
+ self.__call__ = self.print_it
+
+ def print_it(self, text):
+ sys.stdout.write(text + '\n')
+
+ def dont_print(self, text):
+ pass
+
+ def set_mode(self, mode):
+ if mode:
+ self.__call__ = self.print_it
+ else:
+ self.__call__ = self.dont_print
+
+def escape_list(list, escape_func):
+ """Escape a list of arguments by running the specified escape_func
+ on every object in the list that has an escape() method."""
+ def escape(obj, escape_func=escape_func):
+ try:
+ e = obj.escape
+ except AttributeError:
+ return obj
+ else:
+ return e(escape_func)
+ return map(escape, list)
+
+class NLWrapper:
+ """A wrapper class that delays turning a list of sources or targets
+ into a NodeList until it's needed. The specified function supplied
+ when the object is initialized is responsible for turning raw nodes
+ into proxies that implement the special attributes like .abspath,
+ .source, etc. This way, we avoid creating those proxies just
+ "in case" someone is going to use $TARGET or the like, and only
+ go through the trouble if we really have to.
+
+ In practice, this might be a wash performance-wise, but it's a little
+ cleaner conceptually...
+ """
+
+ def __init__(self, list, func):
+ self.list = list
+ self.func = func
+ def _create_nodelist(self):
+ try:
+ return self.nodelist
+ except AttributeError:
+ list = self.list
+ if list is None:
+ list = []
+ elif not is_List(list):
+ list = [list]
+ # The map(self.func) call is what actually turns
+ # a list into appropriate proxies.
+ self.nodelist = NodeList(map(self.func, list))
+ return self.nodelist
+
+class Targets_or_Sources(UserList.UserList):
+ """A class that implements $TARGETS or $SOURCES expansions by in turn
+ wrapping a NLWrapper. This class handles the different methods used
+ to access the list, calling the NLWrapper to create proxies on demand.
+
+ Note that we subclass UserList.UserList purely so that the is_List()
+ function will identify an object of this class as a list during
+ variable expansion. We're not really using any UserList.UserList
+ methods in practice.
+ """
+ def __init__(self, nl):
+ self.nl = nl
+ def __getattr__(self, attr):
+ nl = self.nl._create_nodelist()
+ return getattr(nl, attr)
+ def __getitem__(self, i):
+ nl = self.nl._create_nodelist()
+ return nl[i]
+ def __getslice__(self, i, j):
+ nl = self.nl._create_nodelist()
+ i = max(i, 0); j = max(j, 0)
+ return nl[i:j]
+ def __str__(self):
+ nl = self.nl._create_nodelist()
+ return str(nl)
+ def __repr__(self):
+ nl = self.nl._create_nodelist()
+ return repr(nl)
+
+class Target_or_Source:
+ """A class that implements $TARGET or $SOURCE expansions by in turn
+ wrapping a NLWrapper. This class handles the different methods used
+ to access an individual proxy Node, calling the NLWrapper to create
+ a proxy on demand.
+ """
+ def __init__(self, nl):
+ self.nl = nl
+ def __getattr__(self, attr):
+ nl = self.nl._create_nodelist()
+ try:
+ nl0 = nl[0]
+ except IndexError:
+ # If there is nothing in the list, then we have no attributes to
+ # pass through, so raise AttributeError for everything.
+ raise AttributeError, "NodeList has no attribute: %s" % attr
+ return getattr(nl0, attr)
+ def __str__(self):
+ nl = self.nl._create_nodelist()
+ try:
+ nl0 = nl[0]
+ except IndexError:
+ return ''
+ return str(nl0)
+ def __repr__(self):
+ nl = self.nl._create_nodelist()
+ try:
+ nl0 = nl[0]
+ except IndexError:
+ return ''
+ return repr(nl0)
+
+def subst_dict(target, source):
+ """Create a dictionary for substitution of special
+ construction variables.
+
+ This translates the following special arguments:
+
+ target - the target (object or array of objects),
+ used to generate the TARGET and TARGETS
+ construction variables
+
+ source - the source (object or array of objects),
+ used to generate the SOURCES and SOURCE
+ construction variables
+ """
+ dict = {}
+
+ if target:
+ tnl = NLWrapper(target, lambda x: x.get_subst_proxy())
+ dict['TARGETS'] = Targets_or_Sources(tnl)
+ dict['TARGET'] = Target_or_Source(tnl)
+
+ if source:
+ snl = NLWrapper(source, lambda x: x.rfile().get_subst_proxy())
+ dict['SOURCES'] = Targets_or_Sources(snl)
+ dict['SOURCE'] = Target_or_Source(snl)
+
+ return dict
+
+# Constants for the "mode" parameter to scons_subst_list() and
+# scons_subst(). SUBST_RAW gives the raw command line. SUBST_CMD
+# gives a command line suitable for passing to a shell. SUBST_SIG
+# gives a command line appropriate for calculating the signature
+# of a command line...if this changes, we should rebuild.
+SUBST_CMD = 0
+SUBST_RAW = 1
+SUBST_SIG = 2
+
+_rm = re.compile(r'\$[()]')
+_remove = re.compile(r'\$\(([^\$]|\$[^\(])*?\$\)')
+
+# Indexed by the SUBST_* constants above.
+_regex_remove = [ _rm, None, _remove ]
+
+# This regular expression splits a string into the following types of
+# arguments for use by the scons_subst() and scons_subst_list() functions:
+#
+# "$$"
+# "$("
+# "$)"
+# "$variable" [must begin with alphabetic or underscore]
+# "${any stuff}"
+# " " [white space]
+# "non-white-space" [without any dollar signs]
+# "$" [single dollar sign]
+#
+_separate_args = re.compile(r'(\$[\$\(\)]|\$[_a-zA-Z][\.\w]*|\${[^}]*}|\s+|[^\s\$]+|\$)')
+
+# This regular expression is used to replace strings of multiple white
+# space characters in the string result from the scons_subst() function.
+_space_sep = re.compile(r'[\t ]+(?![^{]*})')
+
+def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=None, conv=None, gvars=None):
+ """Expand a string containing construction variable substitutions.
+
+ This is the work-horse function for substitutions in file names
+ and the like. The companion scons_subst_list() function (below)
+ handles separating command lines into lists of arguments, so see
+ that function if that's what you're looking for.
+ """
+ class StringSubber:
+ """A class to construct the results of a scons_subst() call.
+
+ This binds a specific construction environment, mode, target and
+ source with two methods (substitute() and expand()) that handle
+ the expansion.
+ """
+ def __init__(self, env, mode, target, source, conv, gvars):
+ self.env = env
+ self.mode = mode
+ self.target = target
+ self.source = source
+ self.conv = conv
+ self.gvars = gvars
+
+ def expand(self, s, lvars):
+ """Expand a single "token" as necessary, returning an
+ appropriate string containing the expansion.
+
+ This handles expanding different types of things (strings,
+ lists, callables) appropriately. It calls the wrapper
+ substitute() method to re-expand things as necessary, so that
+ the results of expansions of side-by-side strings still get
+ re-evaluated separately, not smushed together.
+ """
+ if is_String(s):
+ try:
+ s0, s1 = s[:2]
+ except (IndexError, ValueError):
+ return s
+ if s0 == '$':
+ if s1 == '$':
+ return '$'
+ elif s1 in '()':
+ return s
+ else:
+ key = s[1:]
+ if key[0] == '{':
+ key = key[1:-1]
+ try:
+ s = eval(key, self.gvars, lvars)
+ except (IndexError, NameError, TypeError):
+ return ''
+ except SyntaxError,e:
+ if self.target:
+ raise SCons.Errors.BuildError, (self.target[0], "Syntax error `%s' trying to evaluate `%s'" % (e,s))
+ else:
+ raise SCons.Errors.UserError, "Syntax error `%s' trying to evaluate `%s'" % (e,s)
+ else:
+ # Before re-expanding the result, handle
+ # recursive expansion by copying the local
+ # variable dictionary and overwriting a null
+ # string for the value of the variable name
+ # we just expanded.
+ lv = lvars.copy()
+ var = string.split(key, '.')[0]
+ lv[var] = ''
+ return self.substitute(s, lv)
+ else:
+ return s
+ elif is_List(s):
+ r = []
+ for l in s:
+ r.append(self.conv(self.substitute(l, lvars)))
+ return string.join(r)
+ elif callable(s):
+ s = s(target=self.target,
+ source=self.source,
+ env=self.env,
+ for_signature=(self.mode != SUBST_CMD))
+ return self.substitute(s, lvars)
+ elif s is None:
+ return ''
+ else:
+ return s
+
+ def substitute(self, args, lvars):
+ """Substitute expansions in an argument or list of arguments.
+
+ This serves as a wrapper for splitting up a string into
+ separate tokens.
+ """
+ if is_String(args) and not isinstance(args, CmdStringHolder):
+ args = _separate_args.findall(args)
+ result = []
+ for a in args:
+ result.append(self.conv(self.expand(a, lvars)))
+ try:
+ result = string.join(result, '')
+ except TypeError:
+ pass
+ return result
+ else:
+ return self.expand(args, lvars)
+
+ if dict is None:
+ dict = subst_dict(target, source)
+ if conv is None:
+ conv = _strconv[mode]
+ if gvars is None:
+ gvars = env.Dictionary()
+
+ ss = StringSubber(env, mode, target, source, conv, gvars)
+ result = ss.substitute(strSubst, dict)
+
+ if is_String(result):
+ # Remove $(-$) pairs and any stuff in between,
+ # if that's appropriate.
+ remove = _regex_remove[mode]
+ if remove:
+ result = remove.sub('', result)
+ if mode != SUBST_RAW:
+ # Compress strings of white space characters into
+ # a single space.
+ result = string.strip(_space_sep.sub(' ', result))
+
+ return result
+
+def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=None, conv=None, gvars=None):
+ """Substitute construction variables in a string (or list or other
+ object) and separate the arguments into a command list.
+
+ The companion scons_subst() function (above) handles basic
+ substitutions within strings, so see that function instead
+ if that's what you're looking for.
+ """
+ class ListSubber(UserList.UserList):
+ """A class to construct the results of a scons_subst_list() call.
+
+ Like StringSubber, this class binds a specific construction
+ environment, mode, target and source with two methods
+ (substitute() and expand()) that handle the expansion.
+
+ In addition, however, this class is used to track the state of
+ the result(s) we're gathering so we can do the appropriate thing
+ whenever we have to append another word to the result--start a new
+ line, start a new word, append to the current word, etc. We do
+ this by setting the "append" attribute to the right method so
+ that our wrapper methods only need ever call ListSubber.append(),
+ and the rest of the object takes care of doing the right thing
+ internally.
+ """
+ def __init__(self, env, mode, target, source, conv, gvars):
+ UserList.UserList.__init__(self, [])
+ self.env = env
+ self.mode = mode
+ self.target = target
+ self.source = source
+ self.conv = conv
+ self.gvars = gvars
+
+ if self.mode == SUBST_RAW:
+ self.add_strip = lambda x, s=self: s.append(x)
+ else:
+ self.add_strip = lambda x, s=self: None
+ self.in_strip = None
+ self.next_line()
+
+ def expand(self, s, lvars, within_list):
+ """Expand a single "token" as necessary, appending the
+ expansion to the current result.
+
+ This handles expanding different types of things (strings,
+ lists, callables) appropriately. It calls the wrapper
+ substitute() method to re-expand things as necessary, so that
+ the results of expansions of side-by-side strings still get
+ re-evaluated separately, not smushed together.
+ """
+
+ if is_String(s):
+ try:
+ s0, s1 = s[:2]
+ except (IndexError, ValueError):
+ self.append(s)
+ return
+ if s0 == '$':
+ if s1 == '$':
+ self.append('$')
+ elif s1 == '(':
+ self.open_strip('$(')
+ elif s1 == ')':
+ self.close_strip('$)')
+ else:
+ key = s[1:]
+ if key[0] == '{':
+ key = key[1:-1]
+ try:
+ s = eval(key, self.gvars, lvars)
+ except (IndexError, NameError, TypeError):
+ return
+ except SyntaxError,e:
+ if self.target:
+ raise SCons.Errors.BuildError, (self.target[0], "Syntax error `%s' trying to evaluate `%s'" % (e,s))
+ else:
+ raise SCons.Errors.UserError, "Syntax error `%s' trying to evaluate `%s'" % (e,s)
+ else:
+ # Before re-expanding the result, handle
+ # recursive expansion by copying the local
+ # variable dictionary and overwriting a null
+ # string for the value of the variable name
+ # we just expanded.
+ lv = lvars.copy()
+ var = string.split(key, '.')[0]
+ lv[var] = ''
+ self.substitute(s, lv, 0)
+ self.this_word()
+ else:
+ self.append(s)
+ elif is_List(s):
+ for a in s:
+ self.substitute(a, lvars, 1)
+ self.next_word()
+ elif callable(s):
+ s = s(target=self.target,
+ source=self.source,
+ env=self.env,
+ for_signature=(self.mode != SUBST_CMD))
+ self.substitute(s, lvars, within_list)
+ elif s is None:
+ self.this_word()
+ else:
+ self.append(s)
+
+ def substitute(self, args, lvars, within_list):
+ """Substitute expansions in an argument or list of arguments.
+
+ This serves as a wrapper for splitting up a string into
+ separate tokens.
+ """
+
+ if is_String(args) and not isinstance(args, CmdStringHolder):
+ args = _separate_args.findall(args)
+ for a in args:
+ if a[0] in ' \t\n\r\f\v':
+ if '\n' in a:
+ self.next_line()
+ elif within_list:
+ self.append(a)
+ else:
+ self.next_word()
+ else:
+ self.expand(a, lvars, within_list)
+ else:
+ self.expand(args, lvars, within_list)
+
+ def next_line(self):
+ """Arrange for the next word to start a new line. This
+ is like starting a new word, except that we have to append
+ another line to the result."""
+ UserList.UserList.append(self, [])
+ self.next_word()
+
+ def this_word(self):
+ """Arrange for the next word to append to the end of the
+ current last word in the result."""
+ self.append = self.add_to_current_word
+
+ def next_word(self):
+ """Arrange for the next word to start a new word."""
+ self.append = self.add_new_word
+
+ def add_to_current_word(self, x):
+ """Append the string x to the end of the current last word
+ in the result. If that is not possible, then just add
+ it as a new word. Make sure the entire concatenated string
+ inherits the object attributes of x (in particular, the
+ escape function) by wrapping it as CmdStringHolder."""
+
+ if not self.in_strip or self.mode != SUBST_SIG:
+ try:
+ current_word = self[-1][-1]
+ except IndexError:
+ self.add_new_word(x)
+ else:
+ # All right, this is a hack and it should probably
+ # be refactored out of existence in the future.
+ # The issue is that we want to smoosh words together
+ # and make one file name that gets escaped if
+ # we're expanding something like foo$EXTENSION,
+ # but we don't want to smoosh them together if
+ # it's something like >$TARGET, because then we'll
+ # treat the '>' like it's part of the file name.
+ # So for now, just hard-code looking for the special
+ # command-line redirection characters...
+ try:
+ last_char = str(current_word)[-1]
+ except IndexError:
+ last_char = '\0'
+ if last_char in '<>|':
+ self.add_new_word(x)
+ else:
+ y = current_word + x
+ literal1 = self.literal(self[-1][-1])
+ literal2 = self.literal(x)
+ y = self.conv(y)
+ if is_String(y):
+ y = CmdStringHolder(y, literal1 or literal2)
+ self[-1][-1] = y
+
+ def add_new_word(self, x):
+ if not self.in_strip or self.mode != SUBST_SIG:
+ literal = self.literal(x)
+ x = self.conv(x)
+ if is_String(x):
+ x = CmdStringHolder(x, literal)
+ self[-1].append(x)
+ self.append = self.add_to_current_word
+
+ def literal(self, x):
+ try:
+ l = x.is_literal
+ except AttributeError:
+ return None
+ else:
+ return l()
+
+ def open_strip(self, x):
+ """Handle the "open strip" $( token."""
+ self.add_strip(x)
+ self.in_strip = 1
+
+ def close_strip(self, x):
+ """Handle the "close strip" $) token."""
+ self.add_strip(x)
+ self.in_strip = None
+
+ if dict is None:
+ dict = subst_dict(target, source)
+ if conv is None:
+ conv = _strconv[mode]
+ if gvars is None:
+ gvars = env.Dictionary()
+
+ ls = ListSubber(env, mode, target, source, conv, gvars)
+ ls.substitute(strSubst, dict, 0)
+
+ return ls.data
+
+def scons_subst_once(strSubst, env, key):
+ """Perform single (non-recursive) substitution of a single
+ construction variable keyword.
+
+ This is used when setting a variable when copying or overriding values
+ in an Environment. We want to capture (expand) the old value before
+ we override it, so people can do things like:
+
+ env2 = env.Copy(CCFLAGS = '$CCFLAGS -g')
+
+ We do this with some straightforward, brute-force code here...
+ """
+ matchlist = ['$' + key, '${' + key + '}']
+ if is_List(strSubst):
+ result = []
+ for arg in strSubst:
+ if is_String(arg):
+ if arg in matchlist:
+ arg = env[key]
+ if is_List(arg):
+ result.extend(arg)
+ else:
+ result.append(arg)
+ else:
+ r = []
+ for a in _separate_args.findall(arg):
+ if a in matchlist:
+ a = env[key]
+ if is_List(a):
+ r.append(string.join(map(str, a)))
+ else:
+ r.append(str(a))
+ result.append(string.join(r, ''))
+ else:
+ result.append(arg)
+ return result
+ elif is_String(strSubst):
+ result = []
+ for a in _separate_args.findall(strSubst):
+ if a in matchlist:
+ a = env[key]
+ if is_List(a):
+ result.append(string.join(map(str, a)))
+ else:
+ result.append(str(a))
+ return string.join(result, '')
+ else:
+ return strSubst
+
+def render_tree(root, child_func, prune=0, margin=[0], visited={}):
+ """
+ Render a tree of nodes into an ASCII tree view.
+ root - the root node of the tree
+ child_func - the function called to get the children of a node
+ prune - don't visit the same node twice
+ margin - the format of the left margin to use for children of root.
+ 1 results in a pipe, and 0 results in no pipe.
+ visited - a dictionary of visited nodes in the current branch if not prune,
+ or in the whole tree if prune.
+ """
+
+ if visited.has_key(root):
+ return ""
+
+ children = child_func(root)
+ retval = ""
+ for pipe in margin[:-1]:
+ if pipe:
+ retval = retval + "| "
+ else:
+ retval = retval + " "
+
+ retval = retval + "+-" + str(root) + "\n"
+ if not prune:
+ visited = copy.copy(visited)
+ visited[root] = 1
+
+ for i in range(len(children)):
+ margin.append(i<len(children)-1)
+ retval = retval + render_tree(children[i], child_func, prune, margin, visited
+)
+ margin.pop()
+
+ return retval
+
+def is_Dict(e):
+ return type(e) is types.DictType or isinstance(e, UserDict.UserDict)
+
+def is_List(e):
+ return type(e) is types.ListType or isinstance(e, UserList.UserList)
+
+if hasattr(types, 'UnicodeType'):
+ def is_String(e):
+ return type(e) is types.StringType \
+ or type(e) is types.UnicodeType \
+ or isinstance(e, UserString)
+else:
+ def is_String(e):
+ return type(e) is types.StringType or isinstance(e, UserString)
+
+def is_Scalar(e):
+ return is_String(e) or not is_List(e)
+
+def flatten(sequence, scalarp=is_Scalar, result=None):
+ if result is None:
+ result = []
+ for item in sequence:
+ if scalarp(item):
+ result.append(item)
+ else:
+ flatten(item, scalarp, result)
+ return result
+
+class Proxy:
+ """A simple generic Proxy class, forwarding all calls to
+ subject. So, for the benefit of the python newbie, what does
+ this really mean? Well, it means that you can take an object, let's
+ call it 'objA', and wrap it in this Proxy class, with a statement
+ like this
+
+ proxyObj = Proxy(objA),
+
+ Then, if in the future, you do something like this
+
+ x = proxyObj.var1,
+
+ since Proxy does not have a 'var1' attribute (but presumably objA does),
+ the request actually is equivalent to saying
+
+ x = objA.var1
+
+ Inherit from this class to create a Proxy."""
+
+ def __init__(self, subject):
+ """Wrap an object as a Proxy object"""
+ self.__subject = subject
+
+ def __getattr__(self, name):
+ """Retrieve an attribute from the wrapped object. If the named
+ attribute doesn't exist, AttributeError is raised"""
+ return getattr(self.__subject, name)
+
+ def get(self):
+ """Retrieve the entire wrapped object"""
+ return self.__subject
+
+# attempt to load the windows registry module:
+can_read_reg = 0
+try:
+ import _winreg
+
+ can_read_reg = 1
+ hkey_mod = _winreg
+
+ RegOpenKeyEx = _winreg.OpenKeyEx
+ RegEnumKey = _winreg.EnumKey
+ RegEnumValue = _winreg.EnumValue
+ RegQueryValueEx = _winreg.QueryValueEx
+ RegError = _winreg.error
+
+except ImportError:
+ try:
+ import win32api
+ import win32con
+ can_read_reg = 1
+ hkey_mod = win32con
+
+ RegOpenKeyEx = win32api.RegOpenKeyEx
+ RegEnumKey = win32api.RegEnumKey
+ RegEnumValue = win32api.RegEnumValue
+ RegQueryValueEx = win32api.RegQueryValueEx
+ RegError = win32api.error
+
+ except ImportError:
+ class _NoError(Exception):
+ pass
+ RegError = _NoError
+
+if can_read_reg:
+ HKEY_CLASSES_ROOT = hkey_mod.HKEY_CLASSES_ROOT
+ HKEY_LOCAL_MACHINE = hkey_mod.HKEY_LOCAL_MACHINE
+ HKEY_CURRENT_USER = hkey_mod.HKEY_CURRENT_USER
+ HKEY_USERS = hkey_mod.HKEY_USERS
+
+ def RegGetValue(root, key):
+ """This utility function returns a value in the registry
+ without having to open the key first. Only available on
+ Windows platforms with a version of Python that can read the
+ registry. Returns the same thing as
+ SCons.Util.RegQueryValueEx, except you just specify the entire
+ path to the value, and don't have to bother opening the key
+ first. So:
+
+ Instead of:
+ k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,
+ r'SOFTWARE\Microsoft\Windows\CurrentVersion')
+ out = SCons.Util.RegQueryValueEx(k,
+ 'ProgramFilesDir')
+
+ You can write:
+ out = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE,
+ r'SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir')
+ """
+ # I would use os.path.split here, but it's not a filesystem
+ # path...
+ p = key.rfind('\\') + 1
+ keyp = key[:p]
+ val = key[p:]
+ k = SCons.Util.RegOpenKeyEx(root, keyp)
+ return SCons.Util.RegQueryValueEx(k,val)
+
+if sys.platform == 'win32':
+
+ def WhereIs(file, path=None, pathext=None, reject=[]):
+ if path is None:
+ try:
+ path = os.environ['PATH']
+ except KeyError:
+ return None
+ if is_String(path):
+ path = string.split(path, os.pathsep)
+ if pathext is None:
+ try:
+ pathext = os.environ['PATHEXT']
+ except KeyError:
+ pathext = '.COM;.EXE;.BAT;.CMD'
+ if is_String(pathext):
+ pathext = string.split(pathext, os.pathsep)
+ for ext in pathext:
+ if string.lower(ext) == string.lower(file[-len(ext):]):
+ pathext = ['']
+ break
+ if not is_List(reject):
+ reject = [reject]
+ for dir in path:
+ f = os.path.join(dir, file)
+ for ext in pathext:
+ fext = f + ext
+ if os.path.isfile(fext):
+ try:
+ reject.index(fext)
+ except ValueError:
+ return os.path.normpath(fext)
+ continue
+ return None
+
+elif os.name == 'os2':
+
+ def WhereIs(file, path=None, pathext=None, reject=[]):
+ if path is None:
+ try:
+ path = os.environ['PATH']
+ except KeyError:
+ return None
+ if is_String(path):
+ path = string.split(path, os.pathsep)
+ if pathext is None:
+ pathext = ['.exe', '.cmd']
+ for ext in pathext:
+ if string.lower(ext) == string.lower(file[-len(ext):]):
+ pathext = ['']
+ break
+ if not is_List(reject):
+ reject = [reject]
+ for dir in path:
+ f = os.path.join(dir, file)
+ for ext in pathext:
+ fext = f + ext
+ if os.path.isfile(fext):
+ try:
+ reject.index(fext)
+ except ValueError:
+ return os.path.normpath(fext)
+ continue
+ return None
+
+else:
+
+ def WhereIs(file, path=None, pathext=None, reject=[]):
+ if path is None:
+ try:
+ path = os.environ['PATH']
+ except KeyError:
+ return None
+ if is_String(path):
+ path = string.split(path, os.pathsep)
+ if not is_List(reject):
+ reject = [reject]
+ for d in path:
+ f = os.path.join(d, file)
+ if os.path.isfile(f):
+ try:
+ st = os.stat(f)
+ except OSError:
+ continue
+ if stat.S_IMODE(st[stat.ST_MODE]) & 0111:
+ try:
+ reject.index(f)
+ except ValueError:
+ return os.path.normpath(f)
+ continue
+ return None
+
+def PrependPath(oldpath, newpath, sep = os.pathsep):
+ """This prepends newpath elements to the given oldpath. Will only
+ add any particular path once (leaving the first one it encounters
+ and ignoring the rest, to preserve path order), and will
+ os.path.normpath and os.path.normcase all paths to help assure
+ this. This can also handle the case where the given old path
+ variable is a list instead of a string, in which case a list will
+ be returned instead of a string.
+
+ Example:
+ Old Path: "/foo/bar:/foo"
+ New Path: "/biz/boom:/foo"
+ Result: "/biz/boom:/foo:/foo/bar"
+ """
+
+ orig = oldpath
+ is_list = 1
+ paths = orig
+ if not is_List(orig):
+ paths = string.split(paths, sep)
+ is_list = 0
+
+ if is_List(newpath):
+ newpaths = newpath
+ else:
+ newpaths = string.split(newpath, sep)
+
+ newpaths = newpaths + paths # prepend new paths
+
+ normpaths = []
+ paths = []
+ # now we add them only if they are unique
+ for path in newpaths:
+ normpath = os.path.normpath(os.path.normcase(path))
+ if path and not normpath in normpaths:
+ paths.append(path)
+ normpaths.append(normpath)
+
+ if is_list:
+ return paths
+ else:
+ return string.join(paths, sep)
+
+def AppendPath(oldpath, newpath, sep = os.pathsep):
+ """This appends new path elements to the given old path. Will
+ only add any particular path once (leaving the last one it
+ encounters and ignoring the rest, to preserve path order), and
+ will os.path.normpath and os.path.normcase all paths to help
+ assure this. This can also handle the case where the given old
+ path variable is a list instead of a string, in which case a list
+ will be returned instead of a string.
+
+ Example:
+ Old Path: "/foo/bar:/foo"
+ New Path: "/biz/boom:/foo"
+ Result: "/foo/bar:/biz/boom:/foo"
+ """
+
+ orig = oldpath
+ is_list = 1
+ paths = orig
+ if not is_List(orig):
+ paths = string.split(paths, sep)
+ is_list = 0
+
+ if is_List(newpath):
+ newpaths = newpath
+ else:
+ newpaths = string.split(newpath, sep)
+
+ newpaths = paths + newpaths # append new paths
+ newpaths.reverse()
+
+ normpaths = []
+ paths = []
+ # now we add them only of they are unique
+ for path in newpaths:
+ normpath = os.path.normpath(os.path.normcase(path))
+ if path and not normpath in normpaths:
+ paths.append(path)
+ normpaths.append(normpath)
+
+ paths.reverse()
+
+ if is_list:
+ return paths
+ else:
+ return string.join(paths, sep)
+
+
+def dir_index(directory):
+ files = []
+ for f in os.listdir(directory):
+ fullname = os.path.join(directory, f)
+ files.append(fullname)
+
+ # os.listdir() isn't guaranteed to return files in any specific order,
+ # but some of the test code expects sorted output.
+ files.sort()
+ return files
+
+def fs_delete(path, remove=1):
+ try:
+ if os.path.exists(path):
+ if os.path.isfile(path):
+ if remove: os.unlink(path)
+ display("Removed " + path)
+ elif os.path.isdir(path) and not os.path.islink(path):
+ # delete everything in the dir
+ for p in dir_index(path):
+ if os.path.isfile(p):
+ if remove: os.unlink(p)
+ display("Removed " + p)
+ else:
+ fs_delete(p, remove)
+ # then delete dir itself
+ if remove: os.rmdir(path)
+ display("Removed directory " + path)
+ except OSError, e:
+ print "scons: Could not remove '%s':" % str(path), e.strerror
+
+if sys.platform == 'cygwin':
+ def get_native_path(path):
+ """Transforms an absolute path into a native path for the system. In
+ Cygwin, this converts from a Cygwin path to a Win32 one."""
+ return string.replace(os.popen('cygpath -w ' + path).read(), '\n', '')
+else:
+ def get_native_path(path):
+ """Transforms an absolute path into a native path for the system.
+ Non-Cygwin version, just leave the path alone."""
+ return path
+
+display = DisplayEngine()
+
+def Split(arg):
+ if is_List(arg):
+ return arg
+ elif is_String(arg):
+ return string.split(arg)
+ else:
+ return [arg]
+
+class CLVar(UserList.UserList):
+ """A class for command-line construction variables.
+
+ This is a list that uses Split() to split an initial string along
+ white-space arguments, and similarly to split any strings that get
+ added. This allows us to Do the Right Thing with Append() and
+ Prepend() (as well as straight Python foo = env['VAR'] + 'arg1
+ arg2') regardless of whether a user adds a list or a string to a
+ command-line construction variable.
+ """
+ def __init__(self, seq = []):
+ UserList.UserList.__init__(self, Split(seq))
+ def __coerce__(self, other):
+ return (self, CLVar(other))
+ def __str__(self):
+ return string.join(self.data)
+
+class Selector(UserDict.UserDict):
+ """A callable dictionary that maps file suffixes to dictionary
+ values."""
+ def __call__(self, env, source):
+ ext = splitext(str(source[0]))[1]
+ try:
+ return self[ext]
+ except KeyError:
+ # Try to perform Environment substitution on the keys of
+ # emitter_dict before giving up.
+ s_dict = {}
+ for (k,v) in self.items():
+ if not k is None:
+ s_k = env.subst(k)
+ if s_dict.has_key(s_k):
+ # We only raise an error when variables point
+ # to the same suffix. If one suffix is literal
+ # and a variable suffix contains this literal,
+ # the literal wins and we don't raise an error.
+ raise KeyError, (s_dict[s_k][0], k, s_k)
+ s_dict[s_k] = (k,v)
+ try:
+ return s_dict[ext][1]
+ except KeyError:
+ try:
+ return self[None]
+ except KeyError:
+ return None
+
+
+if sys.platform == 'cygwin':
+ # On Cygwin, os.path.normcase() lies, so just report back the
+ # fact that the underlying Win32 OS is case-insensitive.
+ def case_sensitive_suffixes(s1, s2):
+ return 0
+else:
+ def case_sensitive_suffixes(s1, s2):
+ return (os.path.normcase(s1) != os.path.normcase(s2))
+
+def adjustixes(fname, pre, suf):
+ if pre:
+ path, fn = os.path.split(os.path.normpath(fname))
+ if fn[:len(pre)] != pre:
+ fname = os.path.join(path, pre + fn)
+ # Only append a suffix if the file does not have one.
+ if suf and not splitext(fname)[1] and fname[-len(suf):] != suf:
+ fname = fname + suf
+ return fname
+
+
+def unique(s):
+ """Return a list of the elements in s, but without duplicates.
+
+ For example, unique([1,2,3,1,2,3]) is some permutation of [1,2,3],
+ unique("abcabc") some permutation of ["a", "b", "c"], and
+ unique(([1, 2], [2, 3], [1, 2])) some permutation of
+ [[2, 3], [1, 2]].
+
+ For best speed, all sequence elements should be hashable. Then
+ unique() will usually work in linear time.
+
+ If not possible, the sequence elements should enjoy a total
+ ordering, and if list(s).sort() doesn't raise TypeError it's
+ assumed that they do enjoy a total ordering. Then unique() will
+ usually work in O(N*log2(N)) time.
+
+ If that's not possible either, the sequence elements must support
+ equality-testing. Then unique() will usually work in quadratic
+ time.
+ """
+
+ n = len(s)
+ if n == 0:
+ return []
+
+ # Try using a dict first, as that's the fastest and will usually
+ # work. If it doesn't work, it will usually fail quickly, so it
+ # usually doesn't cost much to *try* it. It requires that all the
+ # sequence elements be hashable, and support equality comparison.
+ u = {}
+ try:
+ for x in s:
+ u[x] = 1
+ except TypeError:
+ del u # move on to the next method
+ else:
+ return u.keys()
+
+ # We can't hash all the elements. Second fastest is to sort,
+ # which brings the equal elements together; then duplicates are
+ # easy to weed out in a single pass.
+ # NOTE: Python's list.sort() was designed to be efficient in the
+ # presence of many duplicate elements. This isn't true of all
+ # sort functions in all languages or libraries, so this approach
+ # is more effective in Python than it may be elsewhere.
+ try:
+ t = list(s)
+ t.sort()
+ except TypeError:
+ del t # move on to the next method
+ else:
+ assert n > 0
+ last = t[0]
+ lasti = i = 1
+ while i < n:
+ if t[i] != last:
+ t[lasti] = last = t[i]
+ lasti = lasti + 1
+ i = i + 1
+ return t[:lasti]
+
+ # Brute force is all that's left.
+ u = []
+ for x in s:
+ if x not in u:
+ u.append(x)
+ return u
+
+
Added: development/support/scons/scons-local-0.96.1/SCons/Warnings.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/Warnings.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/Warnings.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,103 @@
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+"""SCons.Warnings
+
+This file implements the warnings framework for SCons.
+
+"""
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/Warnings.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+import SCons.Errors
+
+class Warning(SCons.Errors.UserError):
+ pass
+
+
+
+class CacheWriteErrorWarning(Warning):
+ pass
+
+class CorruptSConsignWarning(Warning):
+ pass
+
+class DependencyWarning(Warning):
+ pass
+
+class DeprecatedWarning(Warning):
+ pass
+
+class DuplicateEnvironmentWarning(Warning):
+ pass
+
+class MissingSConscriptWarning(Warning):
+ pass
+
+class NoParallelSupportWarning(Warning):
+ pass
+
+class ReservedVariableWarning(Warning):
+ pass
+
+class MisleadingKeywordsWarning(Warning):
+ pass
+
+_warningAsException = 0
+
+# The below is a list of 2-tuples. The first element is a class object.
+# The second element is true if that class is enabled, false if it is disabled.
+_enabled = []
+
+_warningOut = None
+
+def suppressWarningClass(clazz):
+ """Suppresses all warnings that are of type clazz or
+ derived from clazz."""
+ _enabled.insert(0, (clazz, 0))
+
+def enableWarningClass(clazz):
+ """Suppresses all warnings that are of type clazz or
+ derived from clazz."""
+ _enabled.insert(0, (clazz, 1))
+
+def warningAsException(flag=1):
+ """Turn warnings into exceptions. Returns the old value of the flag."""
+ global _warningAsException
+ old = _warningAsException
+ _warningAsException = flag
+ return old
+
+def warn(clazz, *args):
+ global _enabled, _warningAsException, _warningOut
+
+ warning = clazz(args)
+ for clazz, flag in _enabled:
+ if isinstance(warning, clazz):
+ if flag:
+ if _warningAsException:
+ raise warning
+
+ if _warningOut:
+ _warningOut(warning)
+ break
Added: development/support/scons/scons-local-0.96.1/SCons/__init__.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/__init__.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/__init__.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,40 @@
+"""SCons
+
+The main package for the SCons software construction utility.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/__init__.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+__version__ = "0.96.1"
+
+__build__ = "D001"
+
+__buildsys__ = "casablanca"
+
+__date__ = "2004/08/23 09:55:29"
+
+__developer__ = "knight"
Added: development/support/scons/scons-local-0.96.1/SCons/dblite.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/dblite.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/dblite.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,182 @@
+# dblite.py module contributed by Ralf W. Grosse-Kunstleve.
+# Extended for Unicode by Steven Knight.
+
+import cPickle
+import time
+import shutil
+import os
+import types
+import __builtin__
+
+_open = __builtin__.open # avoid name clash
+
+keep_all_files = 00000
+ignore_corrupt_dbfiles = 0
+
+if hasattr(types, 'UnicodeType'):
+ def is_string(s):
+ t = type(s)
+ return t is types.StringType or t is types.UnicodeType
+else:
+ def is_string(s):
+ return type(s) is types.StringType
+
+try:
+ unicode('a')
+except NameError:
+ def unicode(s): return s
+
+class dblite:
+
+ def __init__(self, file_base_name, flag, mode):
+ assert flag in (None, "r", "w", "c", "n")
+ if (flag is None): flag = "r"
+ if file_base_name[-7:] != '.dblite':
+ file_base_name = file_base_name + '.dblite'
+ self._file_name = file_base_name
+ self._flag = flag
+ self._mode = mode
+ self._dict = {}
+ self._needs_sync = 00000
+ if (self._flag == "n"):
+ _open(self._file_name, "wb", self._mode)
+ else:
+ try:
+ f = _open(self._file_name, "rb")
+ except IOError, e:
+ if (self._flag != "c"):
+ raise e
+ _open(self._file_name, "wb", self._mode)
+ else:
+ p = f.read()
+ if (len(p) > 0):
+ try:
+ self._dict = cPickle.loads(p)
+ except:
+ if (ignore_corrupt_dbfiles == 0): raise
+ if (ignore_corrupt_dbfiles == 1):
+ print "Warning: Discarding corrupt database:", self._file_name
+
+ def __del__(self):
+ if (self._needs_sync):
+ self.sync()
+
+ def sync(self):
+ self._check_writable()
+ f = _open(self._file_name, "wb", self._mode)
+ cPickle.dump(self._dict, f, 1)
+ f.close()
+ self._needs_sync = 00000
+ if (keep_all_files):
+ shutil.copyfile(
+ self._file_name,
+ self._file_name + "_" + str(int(time.time())))
+
+ def _check_writable(self):
+ if (self._flag == "r"):
+ raise IOError("Read-only database: %s" % self._file_name)
+
+ def __getitem__(self, key):
+ return self._dict[key]
+
+ def __setitem__(self, key, value):
+ self._check_writable()
+ if (not is_string(key)):
+ raise TypeError, "key `%s' must be a string but is %s" % (key, type(key))
+ if (not is_string(value)):
+ raise TypeError, "value `%s' must be a string but is %s" % (value, type(value))
+ self._dict[key] = value
+ self._needs_sync = 0001
+
+ def keys(self):
+ return self._dict.keys()
+
+ def has_key(self, key):
+ return key in self._dict
+
+ def __contains__(self, key):
+ return key in self._dict
+
+ def iterkeys(self):
+ return self._dict.iterkeys()
+
+ __iter__ = iterkeys
+
+ def __len__(self):
+ return len(self._dict)
+
+def open(file, flag=None, mode=0666):
+ return dblite(file, flag, mode)
+
+def _exercise():
+ db = open("tmp", "n")
+ assert len(db) == 0
+ db["foo"] = "bar"
+ assert db["foo"] == "bar"
+ db[unicode("ufoo")] = unicode("ubar")
+ assert db[unicode("ufoo")] == unicode("ubar")
+ db.sync()
+ db = open("tmp", "c")
+ assert len(db) == 2, len(db)
+ assert db["foo"] == "bar"
+ db["bar"] = "foo"
+ assert db["bar"] == "foo"
+ db[unicode("ubar")] = unicode("ufoo")
+ assert db[unicode("ubar")] == unicode("ufoo")
+ db.sync()
+ db = open("tmp", "r")
+ assert len(db) == 4, len(db)
+ assert db["foo"] == "bar"
+ assert db["bar"] == "foo"
+ assert db[unicode("ufoo")] == unicode("ubar")
+ assert db[unicode("ubar")] == unicode("ufoo")
+ try:
+ db.sync()
+ except IOError, e:
+ assert str(e) == "Read-only database: tmp.dblite"
+ else:
+ raise RuntimeError, "IOError expected."
+ db = open("tmp", "w")
+ assert len(db) == 4
+ db["ping"] = "pong"
+ db.sync()
+ try:
+ db[(1,2)] = "tuple"
+ except TypeError, e:
+ assert str(e) == "key `(1, 2)' must be a string but is <type 'tuple'>", str(e)
+ else:
+ raise RuntimeError, "TypeError exception expected"
+ try:
+ db["list"] = [1,2]
+ except TypeError, e:
+ assert str(e) == "value `[1, 2]' must be a string but is <type 'list'>", str(e)
+ else:
+ raise RuntimeError, "TypeError exception expected"
+ db = open("tmp", "r")
+ assert len(db) == 5
+ db = open("tmp", "n")
+ assert len(db) == 0
+ _open("tmp.dblite", "w")
+ db = open("tmp", "r")
+ _open("tmp.dblite", "w").write("x")
+ try:
+ db = open("tmp", "r")
+ except cPickle.UnpicklingError:
+ pass
+ else:
+ raise RuntimeError, "cPickle exception expected."
+ global ignore_corrupt_dbfiles
+ ignore_corrupt_dbfiles = 2
+ db = open("tmp", "r")
+ assert len(db) == 0
+ os.unlink("tmp.dblite")
+ try:
+ db = open("tmp", "w")
+ except IOError, e:
+ assert str(e) == "[Errno 2] No such file or directory: 'tmp.dblite'", str(e)
+ else:
+ raise RuntimeError, "IOError expected."
+ print "OK"
+
+if (__name__ == "__main__"):
+ _exercise()
Added: development/support/scons/scons-local-0.96.1/SCons/exitfuncs.py
===================================================================
--- development/support/scons/scons-local-0.96.1/SCons/exitfuncs.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons-local-0.96.1/SCons/exitfuncs.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -0,0 +1,71 @@
+"""SCons.exitfuncs
+
+Register functions which are executed when SCons exits for any reason.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "/home/scons/scons/branch.0/baseline/src/engine/SCons/exitfuncs.py 0.96.1.D001 2004/08/23 09:55:29 knight"
+
+
+
+_exithandlers = []
+def _run_exitfuncs():
+ """run any registered exit functions
+
+ _exithandlers is traversed in reverse order so functions are executed
+ last in, first out.
+ """
+
+ while _exithandlers:
+ func, targs, kargs = _exithandlers.pop()
+ apply(func, targs, kargs)
+
+def register(func, *targs, **kargs):
+ """register a function to be executed upon normal program termination
+
+ func - function to be called at exit
+ targs - optional arguments to pass to func
+ kargs - optional keyword arguments to pass to func
+ """
+ _exithandlers.append((func, targs, kargs))
+
+import sys
+
+try:
+ x = sys.exitfunc
+
+ # if x isn't our own exit func executive, assume it's another
+ # registered exit function - append it to our list...
+ if x != _run_exitfuncs:
+ register(x)
+
+except AttributeError:
+ pass
+
+# make our exit function get run by python when it exits:
+sys.exitfunc = _run_exitfuncs
+
+del sys
Modified: development/support/scons/scons.py
===================================================================
--- development/support/scons/scons.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/scons.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -24,15 +24,15 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "/home/scons/scons/branch.0/branch.96/baseline/src/script/scons.py 0.96.92.D002 2006/04/11 07:39:43 knight"
+__revision__ = "/home/scons/scons/branch.0/baseline/src/script/scons.py 0.96.1.D001 2004/08/23 09:55:29 knight"
-__version__ = "0.96.92"
+__version__ = "0.96.1"
-__build__ = "D002"
+__build__ = "D001"
-__buildsys__ = "roxbury"
+__buildsys__ = "casablanca"
-__date__ = "2006/04/11 07:39:43"
+__date__ = "2004/08/23 09:55:29"
__developer__ = "knight"
@@ -129,23 +129,6 @@
prefs))
prefs = temp
- # Add the parent directory of the current python's library to the
- # preferences. On SuSE-91/AMD64, for example, this is /usr/lib64,
- # not /usr/lib.
- try:
- libpath = os.__file__
- except AttributeError:
- pass
- else:
- while libpath:
- libpath, tail = os.path.split(libpath)
- if tail[:6] == "python":
- break
- if libpath:
- # Python library is in /usr/libfoo/python*;
- # check /usr/libfoo/scons*.
- prefs.append(libpath)
-
# Look first for 'scons-__version__' in all of our preference libs,
# then for 'scons'.
libs.extend(map(lambda x: os.path.join(x, scons_version), prefs))
Modified: development/support/scons/sconsign.py
===================================================================
--- development/support/scons/sconsign.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/scons/sconsign.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -24,15 +24,15 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "/home/scons/scons/branch.0/branch.96/baseline/src/script/sconsign.py 0.96.92.D002 2006/04/11 07:39:43 knight"
+__revision__ = "/home/scons/scons/branch.0/baseline/src/script/sconsign.py 0.96.1.D001 2004/08/23 09:55:29 knight"
-__version__ = "0.96.92"
+__version__ = "0.96.1"
-__build__ = "D002"
+__build__ = "D001"
-__buildsys__ = "roxbury"
+__buildsys__ = "casablanca"
-__date__ = "2006/04/11 07:39:43"
+__date__ = "2004/08/23 09:55:29"
__developer__ = "knight"
@@ -130,23 +130,6 @@
prefs))
prefs = temp
- # Add the parent directory of the current python's library to the
- # preferences. On SuSE-91/AMD64, for example, this is /usr/lib64,
- # not /usr/lib.
- try:
- libpath = os.__file__
- except AttributeError:
- pass
- else:
- while libpath:
- libpath, tail = os.path.split(libpath)
- if tail[:6] == "python":
- break
- if libpath:
- # Python library is in /usr/libfoo/python*;
- # check /usr/libfoo/scons*.
- prefs.append(libpath)
-
# Look first for 'scons-__version__' in all of our preference libs,
# then for 'scons'.
libs.extend(map(lambda x: os.path.join(x, scons_version), prefs))
@@ -201,7 +184,6 @@
Print_Flags = Flagger()
Verbose = 0
Readable = 0
-Raw = 0
def default_mapper(entry, name):
try:
@@ -242,44 +224,23 @@
'implicit' : 'bkids',
}
-def field(name, entry, verbose=Verbose):
- if not Print_Flags[name]:
- return None
- fieldname = map_name.get(name, name)
- mapper = map_field.get(fieldname, default_mapper)
- val = mapper(entry, name)
- if verbose:
- val = name + ": " + val
- return val
+def printfield(name, entry):
+ def field(name, verbose=Verbose, entry=entry):
+ if not Print_Flags[name]:
+ return None
+ fieldname = map_name.get(name, name)
+ mapper = map_field.get(fieldname, default_mapper)
+ val = mapper(entry, name)
+ if verbose:
+ val = name + ": " + val
+ return val
-def nodeinfo_raw(name, ninfo, prefix=""):
- # This does essentially what the pprint module does,
- # except that it sorts the keys for deterministic output.
- d = ninfo.__dict__
- keys = d.keys()
- keys.sort()
- l = []
- for k in keys:
- l.append('%s: %s' % (repr(k), repr(d[k])))
- return name + ': {' + string.join(l, ', ') + '}'
+ fieldlist = ["timestamp", "bsig", "csig"]
+ outlist = [name+":"] + filter(None, map(field, fieldlist))
+ sep = Verbose and "\n " or " "
+ print string.join(outlist, sep)
-def nodeinfo_string(name, ninfo, prefix=""):
- fieldlist = ["bsig", "csig", "timestamp", "size"]
- f = lambda x, ni=ninfo, v=Verbose: field(x, ni, v)
- outlist = [name+":"] + filter(None, map(f, fieldlist))
- if Verbose:
- sep = "\n " + prefix
- else:
- sep = " "
- return string.join(outlist, sep)
-
-def printfield(name, entry, prefix=""):
- if Raw:
- print nodeinfo_raw(name, entry.ninfo, prefix)
- else:
- print nodeinfo_string(name, entry.ninfo, prefix)
-
- outlist = field("implicit", entry, 0)
+ outlist = field("implicit", 0)
if outlist:
if Verbose:
print " implicit:"
@@ -295,10 +256,8 @@
else:
printfield(name, entry)
else:
- names = entries.keys()
- names.sort()
- for name in names:
- printfield(name, entries[name])
+ for name, e in entries.items():
+ printfield(name, e)
class Do_SConsignDB:
def __init__(self, dbm_name, dbm):
@@ -386,17 +345,14 @@
-h, --help Print this message and exit.
-i, --implicit Print implicit dependency information.
-r, --readable Print timestamps in human-readable form.
- --raw Print raw Python object representations.
- -s, --size Print file sizes.
-t, --timestamp Print timestamp information.
-v, --verbose Verbose, describe each field.
"""
-opts, args = getopt.getopt(sys.argv[1:], "bcd:e:f:hirstv",
+opts, args = getopt.getopt(sys.argv[1:], "bcd:e:f:hirtv",
['bsig', 'csig', 'dir=', 'entry=',
'format=', 'help', 'implicit',
- 'raw', 'readable',
- 'size', 'timestamp', 'verbose'])
+ 'readable', 'timestamp', 'verbose'])
for o, a in opts:
@@ -427,12 +383,8 @@
sys.exit(0)
elif o in ('-i', '--implicit'):
Print_Flags['implicit'] = 1
- elif o in ('--raw',):
- Raw = 1
elif o in ('-r', '--readable'):
Readable = 1
- elif o in ('-s', '--size'):
- Print_Flags['size'] = 1
elif o in ('-t', '--timestamp'):
Print_Flags['timestamp'] = 1
elif o in ('-v', '--verbose'):
Modified: development/support/utils/AvidaUtils/CmdLineOpts.py
===================================================================
--- development/support/utils/AvidaUtils/CmdLineOpts.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/utils/AvidaUtils/CmdLineOpts.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -235,19 +235,19 @@
#)
#env.Append(PYSTE_DEBUG = '$pysteDebug')
- def customOptionsPathValidator(key, val, env):
- if val not in ['None', 'none']:
- if not os.path.exists(val):
- print """
-... Creating "%s" since it doesn't exist.
-""" % env.subst('$default_custom_options_filename')
- shutil.copyfile(
- os.path.join(
- env.subst('$AvidaUtils_path'),
- env.subst('$default_custom_options_filename')
- ),
- val
- )
+# def customOptionsPathValidator(key, val, env):
+# if val not in ['None', 'none']:
+# if not os.path.exists(val):
+# print """
+#... Creating "%s" since it doesn't exist.
+#""" % env.subst('$default_custom_options_filename')
+# shutil.copyfile(
+# os.path.join(
+# env.subst('$AvidaUtils_path'),
+# env.subst('$default_custom_options_filename')
+# ),
+# val
+# )
opts.AddOptions(
SCons.Options.PathOption(
@@ -256,7 +256,7 @@
- This file will be created if it doesn't exist.
""",
'$default_custom_options_filename',
- customOptionsPathValidator
+ #customOptionsPathValidator
),
)
opts.Update(env)
Modified: development/support/utils/AvidaUtils/PlatformTool.py
===================================================================
--- development/support/utils/AvidaUtils/PlatformTool.py 2006-10-12 00:27:41 UTC (rev 1039)
+++ development/support/utils/AvidaUtils/PlatformTool.py 2006-10-12 19:23:38 UTC (rev 1040)
@@ -22,7 +22,7 @@
"""
Default compiler options for posix platforms, assuming they use gcc.
"""
- env.SetDefault(
+ env.Replace(
PLATFORM_CPPPATH = CLVar('/usr/include /usr/local/include /opt/local/include' '$CPPPATH'),
PLATFORM_LIBPATH = CLVar('/usr/lib /usr/local/lib /opt/local/lib' '$LIBPATH'),
#_PLATFORM_DEBUG_BUILD_FLAGS = "-g $COMPILER_WARNING_FLAGS -pedantic -DDEBUG",
@@ -44,7 +44,7 @@
env['ENV']['MACOSX_DEPLOYMENT_TARGET'] = '10.4'
env['ENV']['GCCXML_COMPILER'] = 'c++-3.3'
- env.SetDefault(
+ env.Replace(
COMPILER_WARNING_FLAGS = "-Wall -Wno-long-double -Wno-long-long",
plat_default_enableMemTracking = 0,
plat_default_enablePyPkg = 0,
@@ -334,7 +334,7 @@
# - No
# - Yes (/u)
- env.SetDefault(
+ env.Replace(
_PLATFORM_DEBUG_BUILD_FLAGS = '/D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /EHsc /RTCs /MDd /GS /GR /W3 /nologo /c /Zi /TP /Zm1000',
_PLATFORM_RELEASE_DEBUG_BUILD_FLAGS = '/D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /O1 /EHsc /MD /W3 /nologo /c /Zi /TP /Zm1000',
@@ -346,7 +346,7 @@
# header file with a null pthread implementation.
env.Append(CPPPATH = ['#/source/platform/win32-pthread'])
- env.SetDefault(
+ env.Replace(
plat_default_enableMemTracking = 0,
plat_default_enablePyPkg = 0,
plat_default_enableSerialization = 0,
@@ -376,7 +376,7 @@
"""
# PLATFORM_TOOL_ERR is used to report messages back to the rest of the build
# system. You can use them as error messages to the user.
- env.SetDefault(
+ env.Replace(
PLATFORM_TOOL_ERR = '',
)
if env.Dictionary().has_key('PLATFORM'):
More information about the Avida-cvs
mailing list