3 Builders and other things for the local site. Here's where we'll
4 duplicate the functionality of autoconf until we move it into the
5 installation procedure or use something like qmconf.
7 The code that reads the registry to find MSVC components was borrowed
8 from distutils.msvccompiler.
13 # Copyright (c) 2001, 2002 Steven Knight
15 # Permission is hereby granted, free of charge, to any person obtaining
16 # a copy of this software and associated documentation files (the
17 # "Software"), to deal in the Software without restriction, including
18 # without limitation the rights to use, copy, modify, merge, publish,
19 # distribute, sublicense, and/or sell copies of the Software, and to
20 # permit persons to whom the Software is furnished to do so, subject to
21 # the following conditions:
23 # The above copyright notice and this permission notice shall be included
24 # in all copies or substantial portions of the Software.
26 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
27 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
28 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
47 import SCons.Node.Alias
49 import SCons.Scanner.C
50 import SCons.Scanner.Fortran
51 import SCons.Scanner.Prog
53 def alias_builder(env, target, source):
56 Alias = SCons.Builder.Builder(action = alias_builder,
57 target_factory = SCons.Node.Alias.default_ans.Alias,
58 source_factory = SCons.Node.FS.default_fs.Entry,
61 CScan = SCons.Scanner.C.CScan()
63 FortranScan = SCons.Scanner.Fortran.FortranScan()
65 def yaccEmitter(target, source, env, **kw):
66 # Yacc can be configured to emit a .h file as well
67 # as a .c file, if -d is specified on the command line.
69 os.path.splitext(SCons.Util.to_String(source[0]))[1] in \
71 '-d' in string.split(env.subst("$YACCFLAGS")):
72 target.append(os.path.splitext(SCons.Util.to_String(target[0]))[0] + \
74 return (target, source)
77 """Common function to generate a C file Builder."""
78 return SCons.Builder.Builder(action = {},
79 emitter = yaccEmitter,
80 suffix = '$CFILESUFFIX')
83 """Common function to generate a C++ file Builder."""
84 return SCons.Builder.Builder(action = {},
85 emitter = yaccEmitter,
86 suffix = '$CXXFILESUFFIX')
88 class SharedFlagChecker:
89 """This is a callable class that is used as
90 a build action for all objects, libraries, and programs.
91 Its job is to run before the "real" action that builds the
92 file, to make sure we aren't trying to link shared objects
93 into a static library/program, or static objects into a
96 def __init__(self, shared, set_target_flag):
98 self.set_target_flag = set_target_flag
100 def __call__(self, source, target, env, **kw):
101 if kw.has_key('shared'):
102 raise SCons.Errors.UserError, "The shared= parameter to Library() or Object() no longer works.\nUse SharedObject() or SharedLibrary() instead."
103 if self.set_target_flag:
105 tgt.attributes.shared = self.shared
108 if hasattr(src.attributes, 'shared'):
109 if self.shared and not src.attributes.shared:
110 raise SCons.Errors.UserError, "Source file: %s is static and is not compatible with shared target: %s" % (src, target[0])
111 elif not self.shared and src.attributes.shared:
112 raise SCons.Errors.UserError, "Source file: %s is shared and is not compatible with static target: %s" % (src, target[0])
114 SharedCheck = SCons.Action.Action(SharedFlagChecker(1, 0))
115 StaticCheck = SCons.Action.Action(SharedFlagChecker(0, 0))
116 SharedCheckSet = SCons.Action.Action(SharedFlagChecker(1, 1))
117 StaticCheckSet = SCons.Action.Action(SharedFlagChecker(0, 1))
119 CAction = SCons.Action.Action([ StaticCheckSet, "$CCCOM" ])
120 ShCAction = SCons.Action.Action([ SharedCheckSet, "$SHCCCOM" ])
121 CXXAction = SCons.Action.Action([ StaticCheckSet, "$CXXCOM" ])
122 ShCXXAction = SCons.Action.Action([ SharedCheckSet, "$SHCXXCOM" ])
124 F77Action = SCons.Action.Action([ StaticCheckSet, "$F77COM" ])
125 ShF77Action = SCons.Action.Action([ SharedCheckSet, "$SHF77COM" ])
126 F77PPAction = SCons.Action.Action([ StaticCheckSet, "$F77PPCOM" ])
127 ShF77PPAction = SCons.Action.Action([ SharedCheckSet, "$SHF77PPCOM" ])
129 ASAction = SCons.Action.Action([ StaticCheckSet, "$ASCOM" ])
130 ASPPAction = SCons.Action.Action([ StaticCheckSet, "$ASPPCOM" ])
134 """A function for generating the static object Builder."""
135 return SCons.Builder.Builder(action = {},
136 emitter="$OBJEMITTER",
137 prefix = '$OBJPREFIX',
138 suffix = '$OBJSUFFIX',
139 src_builder = ['CFile', 'CXXFile'])
142 """A function for generating the shared object Builder."""
143 return SCons.Builder.Builder(action = {},
144 prefix = '$SHOBJPREFIX',
145 suffix = '$SHOBJSUFFIX',
146 emitter="$OBJEMITTER",
147 src_builder = ['CFile', 'CXXFile'])
149 ProgScan = SCons.Scanner.Prog.ProgScan()
151 StaticLibrary = SCons.Builder.Builder(action=[ StaticCheck, "$ARCOM" ],
152 prefix = '$LIBPREFIX',
153 suffix = '$LIBSUFFIX',
154 src_suffix = '$OBJSUFFIX',
155 src_builder = 'Object')
157 SharedLibrary = SCons.Builder.Builder(action=[ SharedCheck, "$SHLINKCOM" ],
158 emitter="$SHLIBEMITTER",
159 prefix = '$SHLIBPREFIX',
160 suffix = '$SHLIBSUFFIX',
162 src_suffix = '$SHOBJSUFFIX',
163 src_builder = 'SharedObject')
166 """Common function to generate a DVI file Builder."""
167 return SCons.Builder.Builder(action = {},
168 # The suffix is not configurable via a
169 # construction variable like $DVISUFFIX
170 # because the output file name is
171 # hard-coded within TeX.
175 """A function for generating the PDF Builder."""
176 return SCons.Builder.Builder(action = { },
177 prefix = '$PDFPREFIX',
178 suffix = '$PDFSUFFIX')
180 Program = SCons.Builder.Builder(action=[ StaticCheck, '$LINKCOM' ],
181 emitter='$PROGEMITTER',
182 prefix='$PROGPREFIX',
183 suffix='$PROGSUFFIX',
184 src_suffix='$OBJSUFFIX',
185 src_builder='Object',
188 ConstructionEnvironment = {
189 'BUILDERS' : { 'SharedLibrary' : SharedLibrary,
190 'Library' : StaticLibrary,
191 'StaticLibrary' : StaticLibrary,
193 'Program' : Program },
194 'SCANNERS' : [CScan, FortranScan],
196 'PDFSUFFIX' : '.pdf',