root/branches/Carsten_PtrWork2/SConstruct

Revision 1002, 38.3 kB (checked in by vossg, 10 months ago)

fixed: missing x option

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 #!python
2 #
3 # SCons build script for OpenSG
4 import os, string, sys, re, glob, copy, types, traceback, pprint, tempfile, shutil
5 pj = os.path.join
6
7 # If we have wingide, try loading the debugging extenstions
8 try:
9    import wing.wingdbstub
10    print "Loaded wingdb stub for debugging..."
11 except:
12    pass
13
14 # Extend paths for scons-addons and scons-build if needed
15 # - this allows a development version of scons-addons to be
16 #   in the standard python path and used instead.
17 try:
18    import SConsAddons.Util
19    print "Using SConsAddons from: ", os.path.dirname(SConsAddons.Util.__file__)
20 except:
21    sys.path.insert(0,pj('Tools','scons-addons','src'))
22    print "Using SConsAddons from: Tools/scons-addons/src"
23
24 sys.path.insert(0,pj('Tools','scons-build'))
25
26 print "-------------------------------------------------"
27 print "WARNING: The build is currently in development.  "
28 print "            - It needs the svn version of scons-addons"
29 print "WARNING:"
30
31 import SCons.Environment
32 import SCons
33 import SConsAddons.Util as sca_util
34 import SConsAddons.Options as sca_opts
35 import SConsAddons.Variants as sca_variants
36 import SConsAddons.Builders
37 import SConsAddons.Options.Boost
38 import SConsAddons.Options.VTK
39 from SConsAddons.EnvironmentBuilder import EnvironmentBuilder
40 from LibraryUtils import *
41 from sets import Set
42 from socket import gethostname
43
44 import OpenSG.AddOnHacks
45 import OpenSG.ColladaOption
46
47 from BuildInfoScanner import BuildInfoScanner
48 from RevisionTagWriter import RevisionTagWriter
49
50 # If we have pysvn, load it
51 try:
52    import pysvn
53    have_pysvn = True
54 except:
55    have_pysvn = False
56
57 # Aliases
58 GetPlatform = sca_util.GetPlatform
59 Export('GetPlatform')
60 verbose_build = False
61
62 # Build TODO
63 # - Support selection of WS/ES
64 # - Support selection of compiler to build with
65 # - QT support
66 # - Contrib libraries
67 # - Library specific defines (if needed)
68 # - Build on windows
69 # - Project files for windows
70
71 # ---------------------------------------------------------------------------- #
72 # ------------------------------ HELPER METHODS ------------------------------ #
73 # ---------------------------------------------------------------------------- #
74
75 # ---------------- #
76 # --- BUILDERS --- #
77 # ---------------- #
78
79 # fcd2code builder
80 # - Custom builder for fcd2code
81 def registerfcd2codeBuilder(env, required=True):
82    print "Setting up fcd2code builder...",
83    
84    fcd2code_cmd = pj("Tools", "fcd2code","fcd2code")
85    fcd2code_cmd = os.path.abspath(fcd2code_cmd)
86    if not os.path.isfile(fcd2code_cmd):
87       print " Warning: fcd2code not found at: ", fcd2code_cmd
88       if required:
89          sys.exit(1)
90       return
91    
92    template_files = glob.glob(pj("Tools",
93                                  "fcd2code",
94                                  "*TemplateFieldContainer*Base*.txt"))
95
96    template_files.append(glob.glob(pj("Tools",
97                                       "fcd2code",
98                                       "*TemplateFieldContainer*Field*.txt")))
99
100    template_files.append(glob.glob(pj("Tools",
101                                       "fcd2code",
102                                       "*.py")))
103
104
105    
106    def prop_emitter(target,source,env, template_files=template_files):
107       """ Returns a list of files including all output forms and
108           The input templates as sources.
109       """
110       assert str(source[0]).endswith(".fcd")
111       assert len(source) == 1
112
113       base_name = os.path.splitext(str(source[0]))[0]
114
115       # Targets are all the files that we build
116       target = []
117       for ext in ["Base.cpp","Base.h","Base.inl","Fields.h"]:
118          target.append(base_name+ext)
119      
120       # Sources are the fcd file and all the template files
121       source.extend(template_files)
122
123       return (target, source)
124    
125    
126    fcd2code_builder = Builder(action = " ".join([sys.executable, fcd2code_cmd]) + ' -c -b -d $SOURCE -p ${TARGET.dir}',
127                               src_suffix = '.fcd',
128                               suffix = 'unused.h',
129                               emitter = prop_emitter)
130    env.Append(BUILDERS = {'fcd2code' : fcd2code_builder})
131    print "[OK]"
132
133
134 # fbd2code builder
135 # - Custom builder for fbd2code
136 def registerfbd2codeBuilder(env, required=True):
137    print "Setting up fbd2code builder...",
138    
139    fbd2code_cmd = pj("Tools", "fcd2code","fcd2code")
140    fbd2code_cmd = os.path.abspath(fbd2code_cmd)
141    if not os.path.isfile(fbd2code_cmd):
142       print " Warning: fcd2code not found at: ", fbd2code_cmd
143       if required:
144          sys.exit(1)
145       return
146    
147    template_files = glob.glob(pj("Tools",
148                                  "fcd2code",
149                                  "*TemplateFieldBundle*Base*.txt"))
150
151    template_files.append(glob.glob(pj("Tools",
152                                       "fcd2code",
153                                       "*TemplateFieldBundle*Field*.txt")))
154
155    template_files.append(glob.glob(pj("Tools",
156                                       "fcd2code",
157                                       "*Template*.py")))
158    
159    def prop_emitter(target,source,env, template_files=template_files):
160       """ Returns a list of files including all output forms and
161           The input templates as sources.
162       """
163       assert str(source[0]).endswith(".fbd")
164       assert len(source) == 1
165
166       base_name = os.path.splitext(str(source[0]))[0]
167
168       # Targets are all the files that we build
169       target = []
170       for ext in ["Base.cpp","Base.h","Base.inl","Fields.h"]:
171          target.append(base_name+ext)
172      
173       # Sources are the fbd file and all the template files
174       source.extend(template_files)
175
176       return (target, source)
177    
178    
179    fbd2code_builder = Builder(action = " ".join([sys.executable,
180                               fbd2code_cmd]) + ' -c -b -B -d $SOURCE -p ${TARGET.dir}',
181                               src_suffix = '.fbd',
182                               suffix = 'unused.h',
183                               emitter = prop_emitter)
184    env.Append(BUILDERS = {'fbd2code' : fbd2code_builder})
185    print "[OK]"
186
187
188 def addScanParseSkel(common_env):
189    """ This is an ugly hack to add the lex/yacc support into the build.  It is ugly because of a couple of things.
190       - We use some very custom flags
191       - We need to post process the scanner to include a different file then normal.
192       - We are forcing this to be done in the source tree in a subdir without actually going there.
193       - Dependency management seems to be a little messed up right now in the code or scons.
194       - BUGS: Scons does not seem to recognize that the files we are building here are source
195               files for the libraries.  This makes it so we have to run the build twice if the files change.
196               Scons cannot recognize whether the existing files are current or not, if they come out of
197                svn. This can result in spurious regens, which break the code if the wrong versions of
198                flex/bison are present.
199    """
200    # Hack to handle the generation of the parser from .y
201    # This pretty hacky to allow using a version of the file from the repository if yacc is not installed
202    # 1. Call bison: OSGScanParseSkelParser.yy -> OSGScanParseSkelParser.hpp .cpp .output (we don't need the last one)
203    if "yacc" in common_env["TOOLS"]:
204       if common_env["enable_scanparse_regen"]:
205          parser_env = common_env.Copy()
206          parser_env.Append(YACCFLAGS = ["-d","-v","-pOSGScanParseSkel_","-bOSGScanParseSkel_"])
207          source_file = "Source/System/FileIO/ScanParseSkel/OSGScanParseSkelParser.yy"
208          target_file = "Source/System/FileIO/ScanParseSkel/OSGScanParseSkelParser.cpp"
209          yfiles = parser_env.CXXFile(target=target_file,source=source_file)
210          NoClean(yfiles)
211          #print "yfiles: ", yfiles
212
213          # Make sure the parser files have been found for OSGFileIO
214          y_cpp_file = str(yfiles[0]).replace("Source/","",1)
215          y_hpp_file = str(yfiles[1]).replace("Source/","",1)
216          #if not y_cpp_file in lib_map["OSGSystem"].source_files:
217          #   lib_map["OSGSystem"].source_files.append(y_cpp_file)
218          #if not y_hpp_file in lib_map["OSGSystem"].header_files:
219          #   lib_map["OSGSystem"].header_files.append(y_hpp_file)
220          #print " yy source: %s \n header: %s"%(lib_map["OSGSystem"].source_files, lib_map["OSGSystem"].header_files)
221       else:
222          print "WARNING: enable_scanparse_regen disabled. If you change .yy files they will not be rebuilt."
223          common_env["TOOLS"].remove('yacc')
224    else:
225       print "WARNING: bison not available.  If you change .yy files they cannot be rebuilt."
226    
227    # Hack to handle the generation of the scanner from .lpp
228    # This pretty hacky to allow using a version of the file from the repository if lex is not installed
229    # 2. Call flex: OSGScanParseSkelScanner.lpp -> OSGScanParseSkelScanner.cpp (this one needs to be filtered to change the include)
230    if "lex" in common_env["TOOLS"]:
231       def filter_header(target, source, env):
232          """ Custom filter to change the include file for the flexlexer.h"""
233          fname = str(target[0])
234          contents = open(fname).readlines()
235          for i in range(len(contents)):
236             if contents[i] == "#include <FlexLexer.h>\n":
237                contents[i] = "#include \"%s\"\n" % os.path.split(OSG_flexlexer_h)[1]
238                break
239          open(fname,'w').writelines(contents)
240          #print "filter_header: Created ", fname
241
242       if common_env["enable_scanparse_regen"]:
243          lexer_env = common_env.Copy()
244          lexer_env.Append(LEXFLAGS = ["-+","-POSGScanParseSkel_"])
245
246          lexer_dir       = pj('Source','System','FileIO','ScanParseSkel')
247          sys_flexlexer_h = "/usr/include/FlexLexer.h"
248          OSG_flexlexer_h = pj(lexer_dir,"OSGScanParseSkelScanner_FlexLexer.h")
249          source_file     = pj(lexer_dir,"OSGScanParseSkelScanner.ll")
250          target_file     = pj(lexer_dir,"OSGScanParseSkelScanner.cpp")
251
252          # Replace lex builder with new action that calls flex and then filters
253          std_lex_action = Action("$LEXCOM", "$LEXCOMSTR")
254          filter_action = Action(filter_header, lambda t,s,e: "Filtering header: %s %s"%(str(t),str(s)))
255          cxx_file_builder = lexer_env['BUILDERS']['CXXFile']
256          cxx_file_builder.add_action('.ll', Action([std_lex_action, filter_action]))
257          lfiles = lexer_env.CXXFile(target=target_file,source=source_file)
258          NoClean(lfiles)
259          #print "lfiles: ", lfiles
260
261          # If available, copy the system FlexLexer.h file to local source dir
262          if os.path.exists(sys_flexlexer_h):
263             flexlex_cp = lexer_env.Command(OSG_flexlexer_h, sys_flexlexer_h,[Copy('$TARGET','$SOURCE'),])
264             Depends(lfiles, flexlex_cp)
265
266          #Depends(lfiles, "Source/System/FileIO/ScanParseSkel/OSGScanParseSkelParser.hpp") # the scanner includes the token header from the parser...
267          if vars().has_key('yfiles'):
268             Depends(lfiles, yfiles)
269
270          # Strip off "Source/" since this will be in the build dir
271          scanner_src = target_file.replace("Source/","",1)
272          #if not scanner_src in lib_map["OSGSystem"].source_files:
273          #   lib_map["OSGSystem"].source_files.append(scanner_src)
274          #print "FileIO source files: ", lib_map["OSGSystem"].source_files
275       else:
276          print "WARNING: enable_scanparse_regen disabled. If you change .ll files they will not be rebuilt."
277          common_env["TOOLS"].remove('lex')
278    else:
279       print "WARNING: flex not available.  If you change .ll files they cannot be rebuilt."
280
281 # -------------------- #
282 # --- OPTION TYPES --- #
283 # -------------------- #
284
285 class SimpleAppendOption(sca_opts.SimpleOption):
286    """
287    Variant of the simple option wrapper that appends a value to the environment instead
288    of replacing it.
289    """
290    def __init__(self, name, key, help):
291       """
292       Create an option
293       name - the name of the commandline option
294       key - the name of the key in the environment to append to
295       help - Help text about the option object
296       """
297       sca_opts.SimpleOption.__init__(self, name, name, help + " (Use ':' to separate multiple)", \
298                                      None, None, None, None)
299       self.key = key
300
301    """
302    We want these options to be applied before all others, to have them have effect on e.g.
303    StandardPackageOption tests, so override completeProcess instead of apply.
304    """
305    def completeProcess(self, env):
306       if self.value:
307          for i in self.value.split(os.pathsep):
308             exec("env.Append(%s = [i])" % self.key)
309
310 # ---------------------------------------------------------------------------- #
311 # ----------------------------- Main build setup ----------------------------- #
312 # ---------------------------------------------------------------------------- #
313
314 EnsureSConsVersion(0,96,92)
315 SourceSignatures('MD5')
316 #SourceSignatures('timestamp')
317 opensg_version_string = file("VERSION").readline().strip()
318
319 print "Building OpenSG ", opensg_version_string
320
321 OpenSG.AddOnHacks.apply()
322
323 # Allow user to pass an options file on the command line, with the
324 # option_file=myOptFile syntax
325
326 platform = sca_util.GetPlatform()
327 unspecified_prefix = "use-instlinks"
328
329
330 # Create base environment to use for option processing
331 if GetPlatform() == "win32":
332    # XXX: Temp hack to get msvs version setting
333    if ARGUMENTS.has_key("MSVS_VERSION"):
334       common_env = Environment(MSVS_VERSION=ARGUMENTS["MSVS_VERSION"],
335                                 tools = ['default', 'doxygen'],
336                                 toolpath = '.')
337    else:
338       common_env = Environment(tools = ['default', 'doxygen'], toolpath = '.')
339 else:
340    if ARGUMENTS.has_key("icc"):
341       use_cxxlib_icc = False
342
343       if ARGUMENTS.has_key("cxxlib-icc"):
344          use_cxxlib_icc = True
345
346       common_env = Environment(ENV = os.environ,
347                                tools=['gnulink', 'intelicc', 'intelicpc', 'doxygen'],
348                                cxxlib_icc=use_cxxlib_icc,
349                                toolpath = ['.', 'Tools/scons-build/OpenSG/Tools'])
350    else:
351       common_env = Environment(ENV = os.environ,
352                                toolpath = '.',
353                                tools = ['default', 'doxygen'])
354
355 SConsignFile('.sconsign.'+GetPlatform()+common_env.subst('$CXX'))
356 buildDir = "build." + platform + '.' + common_env.subst('$CXX')
357
358 option_filename = "option.cache." + platform + '.' + common_env.subst('$CXX')
359
360 if ARGUMENTS.has_key("options_file"):
361    opt_file = ARGUMENTS["options_file"]
362    if os.path.exists(opt_file):
363       print "Reading options from: %s" % str(opt_file)
364       option_filename = opt_file
365    else:
366       print "Options file '%s' not found.. will continue with default '%s'" % \
367       (opt_file, option_filename)
368
369
370 # Setup the directories used for sconf processing
371 common_env["CONFIGUREDIR"] = '.sconf_temp_'+platform+'_'+common_env.subst('$CXX')
372 common_env["CONFIGURELOG"] = 'sconf.log_'+platform+'_'+common_env.subst('$CXX')
373 if common_env.has_key("MSVS"):
374    common_env["CONFIGUREDIR"] += "." + common_env["MSVS"]["VERSION"]
375    common_env["CONFIGURELOG"] += "." + common_env["MSVS"]["VERSION"]
376
377 SConsAddons.Builders.registerDefineBuilder(common_env)
378 SConsAddons.Builders.registerSubstBuilder(common_env)
379
380 # Create variant helper and builder
381 variant_helper = sca_variants.VariantsHelper(variantKeys=["type", "arch"])
382 base_bldr = EnvironmentBuilder()
383
384 # ----------------- #
385 # --- CONFIGURE --- #
386 # ----------------- #
387
388 # There is nothing to do ATM - sca_opts.StandardPackageOption can handle
389 # everything so far.
390
391 # --------------- #
392 # --- OPTIONS --- #
393 # --------------- #
394
395 # Options are stored in one of these groups:
396 # - required_libs_options:  Libraries needed to build OpenSG
397 # - optional_libs_options:  Libraries needed for/providing additional functionality
398 # - build_options:          Options to select build/install directories and
399 #                           special build steps.
400 # - feature_options:        Options to enable/disable or tweak certain features
401 #                           of OpenSG.
402 # - misc_options:           Options that do not fit anywhere else.
403 # - extra_libs_options:     Should not be changed - it's only to allow building
404 #                           with additional libraries that are not integrated into
405 #                           the build
406 #
407 # There is special handling for image formats, because some are directly
408 # supported and others require external libs, they may end up in different
409 # option groups, but in the help message they should show up together - see below.
410
411 #
412 # 1) Setup options
413 #    Create Option objects and store them in their group.
414
415 opts = sca_opts.Options(files = [option_filename, 'options.custom'],
416                                    args= ARGUMENTS)
417
418 # Handle library name differences between platforms
419 if "win32" == platform:
420     glut_libname = "glut32"
421     tiff_libname = "tif32"
422     zlib_libname = "zlib"
423     jpeg_libname = "libjpeg"
424     png_libname = "libpng"
425 else:
426     glut_libname = "glut"
427     tiff_libname = "tiff"
428     zlib_libname = "z"
429     jpeg_libname = "jpeg"
430     png_libname = "png"
431
432
433 # Build options - source and destination directories etc.
434 build_options = {}
435 build_options["install_prefix"] = sca_opts.SimpleOption(
436     "prefix", "prefix", "Installation prefix", unspecified_prefix, None, None, None)
437 build_options["build_suffix"] = sca_opts.SimpleOption(
438     "build_suffix", "build_suffix",
439     "Suffix to append to build directory.  Useful for compiling multiple variations on the same platform",
440     "", None, None, None)
441 build_options["enable_fcd2code"] = sca_opts.BoolOption(
442     "enable_fcd2code", "Enable code generation pass (from .fcd files) during build", False)
443 build_options["enable_fbd2code"] = sca_opts.BoolOption(
444     "enable_fbd2code", "Enable code generation pass (from .fbd files) during build", False)
445 build_options["enable_distcc"] = sca_opts.BoolOption(
446     "enable_distcc", "Enable use of distcc during build. (distcc must be in your path)", False)
447 build_options["enable_unittests"] = sca_opts.BoolOption(
448     "enable_unittests", "Enable building and running of the unit tests after build", True)
449 build_options["enable_revision_tags"] = sca_opts.BoolOption(
450     "enable_revision_tags", "Enable updating of OSG*Def.cpp files with current svn revision numbers", False)
451 build_options["enable_gv_beta"] = sca_opts.BoolOption(
452     "enable_gv_beta", "Enable gv testing stuff", False)
453
454 # Options for required external libraries
455 required_libs_options = {}
456 if "win32" == platform:
457
458     toolset = "auto"
459
460     if common_env.has_key("MSVS"):
461        toolset = 'vc' + common_env["MSVS"]["VERSION"].replace('.', '')
462
463     required_libs_options["boost"] = sca_opts.Boost.Boost(
464         "boost", "1.31.0", libs = ["filesystem"], required = True,
465         useVersion = True, allowLibNameFallbacks=True, toolset = toolset);
466 else:
467     required_libs_options["boost"] = sca_opts.Boost.Boost(
468         "boost", "1.31.0", libs = ["filesystem"], required = True, useVersion = True, allowLibNameFallbacks=True);
469
470 # Options for optional external libraries
471 optional_libs_options = {}
472 optional_libs_options["jpeg"] = sca_opts.StandardPackageOption(
473     "jpeg", "Location of the JPEG library", library = jpeg_libname, required = False)
474
475 optional_libs_options["tiff"] = sca_opts.StandardPackageOption(
476     "tiff", "Location of the TIFF library", library = tiff_libname, required = False)
477
478 optional_libs_options["png"] = sca_opts.StandardPackageOption(
479     "png", "Location of the PNG library", library = png_libname, required = False)
480
481 optional_libs_options["glut"] = sca_opts.StandardPackageOption(
482     "glut", "Location of the GLUT library", library = glut_libname,
483     header = "GL/glut.h", required = False)
484
485 optional_libs_options["X"] = sca_opts.StandardPackageOption(
486     "X", "Location of the X library", library = 'X11',
487     required = False)
488
489 optional_libs_options["freetype"] = sca_opts.StandardPackageOption(
490     "freetype", "Location of freetype2 library", library = "freetype",
491     header = "freetype/config/ftheader.h", required = False)
492
493 if "win32" != platform:
494    optional_libs_options["freetype"].incDir = '/usr/include/freetype2'
495
496 optional_libs_options["fontconfig"] = sca_opts.StandardPackageOption(
497     "fontconfig", "Location of fontconfig library", library = "fontconfig",
498     header = "fontconfig/fontconfig.h", required = False)
499
500 optional_libs_options["zlib"] = sca_opts.StandardPackageOption(
501     "zlib", "Location of the zlib compression library", library = zlib_libname,
502     header = "zlib.h", required = False)
503
504 optional_libs_options["NVPerfSDK"] = sca_opts.StandardPackageOption(
505     "NVPerfSDK", "Location of the NVPerfSDK library", library = "NVPerfSDK",
506     header = "NVPerfSDK.h", required = False)
507
508 optional_libs_options["collada"] = OpenSG.ColladaOption.ColladaOption(
509     "collada", "Location of the collada dom library", library =
510     ["collada_dae",
511      "collada_LIBXMLPlugin",
512      "collada_STLDatabase",
513      "collada_dom",
514      "collada_stdErrPlugin",
515      "collada_dae"],
516     header = "dae/daeIntegrationObject.h", required = False)
517
518 optional_libs_options["xml2"] = sca_opts.StandardPackageOption(
519     "xml2", "Location of the xml2 library", library = "xml2",
520     required = False)
521
522 vtk_libs = ['vtkRendering',
523             'vtkIO',
524             'vtkGraphics',
525             'vtkImaging',
526             'vtkFiltering',
527             'vtkCommon',
528             'vtkftgl',
529             'vtkDICOMParser',
530             'vtksys',
531             'verdict',
532             'vtkNetCDF',
533             'vtkmetaio']
534
535 #if "win32" != platform:
536 #    vtk_libs.append('vtkMPEG2Encode')
537
538 optional_libs_options['vtk'] = sca_opts.VTK.VTK(
539    "vtk",
540    "Location of the vtk libraries",
541    required = False,
542    libList = vtk_libs)
543
544 # Feature options - select library/interface features
545 feature_options = {}
546 feature_options["gif"] = sca_opts.BoolOption(
547     "enable_gif", "Enable GIF support", True)
548
549 feature_options["fcptr_mode"] = sca_opts.EnumOption(
550     "fcptr_mode", "Select the mode for field container pointers",
551     "MT_CPTR", ["SINGLE_THREAD", "MT_CPTR"])
552
553 feature_options["disable_deprecated"] = sca_opts.BoolOption(
554     "disable_deprecated", "Disable deprecated interfaces and code", False)
555
556 feature_options["disable_glut_glsubdir"] = sca_opts.BoolOption(
557     "disable_glut_glsubdir", "Do not use GL subdir when including glut.h", False)
558
559 feature_options["enable_osg1_compat"] = sca_opts.BoolOption(
560     "enable_osg1_compat", "Enable OpenSG 1.x compatibility", False)
561
562 feature_options["enable_deprecated_props"] = sca_opts.BoolOption(
563     "enable_deprecated_props", "Enable deprecated property types.", False)
564
565 feature_options["enable_new_osb_io"] = sca_opts.BoolOption(
566     "enable_new_osb_io", "Enable the new OSB IO facilities.", False)
567
568 feature_options["enable_scanparse_regen"] = sca_opts.BoolOption(
569     "enable_scanparse_regen", "Enable regenerating the scanner/parser files using flex and bison", False);
570
571 feature_options["enable_testcontainer"] = sca_opts.BoolOption(
572     "enable_testcontainer", "Enable container used for testing (from Source/Test)", False)
573
574 feature_options["docs_mode"] = sca_opts.EnumOption(
575     "docs_mode", "Select the mode for documentation generation",
576     "NONE", ["NONE", "STANDALONE", "TRAC", "DEVELOPER"])
577
578 feature_options["enable_valgrind_checks"] = sca_opts.BoolOption(
579     "enable_valgrind_checks", "Enable valgrind check code embedded in OpenSG.", False)
580
581 feature_options["enable_memory_debugging"] = sca_opts.BoolOption(
582     "enable_memory_debugging", "Enable memory debugging checks in OpenSG.", False)
583
584 if "win32" == platform:
585     feature_options["enable_win_localstorage"] = sca_opts.BoolOption(
586         "enable_win_localstorage", "Enable use of local storage instead of __declspec to "+
587         "get thread local storage on windows", True)
588
589 if "win32" != platform:
590     feature_options["enable_elf_localstorage"] = sca_opts.BoolOption(
591         "enable_elf_localstorage", "Enable use of elf thread local storage with pthreads",
592         ("linux" == platform))
593
594 # Misc options
595 misc_options = {}
596 #misc_options["icc_compat"] = sca_opts.SimpleOption(
597 #    "icc_gnu_compat", "icc_gnu_compat", "<GCC Version> Make the binaries built " +
598 #                      "with icc compatible with the given verion of gcc. (unsupported)",
599 #                      "", None, None, None)
600
601 # Options to specify additional library/header search paths and librarys to
602 # link agains.
603 extra_libs_options = {}
604 extra_libs_options["incdir"] = SimpleAppendOption('add_incdir', 'CPPPATH', 'Additional include dir')
605 extra_libs_options["libdir"] = SimpleAppendOption('add_libdir', 'LIBPATH', 'Additional library dir')
606 extra_libs_options["lib"]    = SimpleAppendOption('add_lib',    'LIBS',    'Additional library')
607
608 # Group all image format options together.
609 image_format_options = {}
610 image_format_options["jpeg"] = optional_libs_options["jpeg"]
611 image_format_options["tiff"] = optional_libs_options["tiff"]
612 image_format_options["png"]  = optional_libs_options["png"]
613 image_format_options["gif"]  = feature_options["gif"]
614
615 #
616 # 2) Register options
617 #    This should not require any changes unless a new option group is added.
618
619 for opt in extra_libs_options.itervalues():
620     if opt not in image_format_options.itervalues():
621         opts.AddOption(opt)
622
623 opts.AddOption(sca_opts.SeparatorOption("\nBuild/Install settings"))
624 for opt in build_options.itervalues():
625     if opt not in image_format_options.itervalues():
626         opts.AddOption(opt)
627
628 opts.AddOption(sca_opts.SeparatorOption("\nPackage settings (required libs)"))
629 for opt in required_libs_options.itervalues():
630     if opt not in image_format_options.itervalues():
631         opts.AddOption(opt)
632
633 opts.AddOption(sca_opts.SeparatorOption("\nPackage settings (optional libs)"))
634 for opt in optional_libs_options.itervalues():
635     if opt not in image_format_options.itervalues():
636         opts.AddOption(opt)
637
638 for opt in image_format_options.itervalues():
639     opts.AddOption(opt)
640
641
642 opts.AddOption(sca_opts.SeparatorOption("\nAdvanced options"))
643 for opt in feature_options.itervalues():
644     if opt not in image_format_options.itervalues():
645         opts.AddOption(opt)
646
647 for opt in misc_options.itervalues():
648     if opt not in image_format_options.itervalues():
649         opts.AddOption(opt)
650
651 # Add environment builder options
652 base_bldr.addOptions(opts)
653
654 # Add variant building options
655 variant_helper.addOptions(opts)
656
657 #
658 # 3) Process options
659
660 try:
661    opts.Process(common_env)
662 except Exception, ex:
663    if not SConsAddons.Util.hasHelpFlag():
664       print "Option error: ", str(ex)
665       traceback.print_exc()
666       sys.exit(1)
667
668 #
669 # 4) Generate help message
670
671 help_text = \
672 """--- OpenSG Build system ---
673 %s
674 Targets:
675    install - Install OpenSG
676       ex: 'scons install prefix=$HOME/software' to install in your account
677    Type 'scons' to just build it
678
679 """ % (opts.GenerateHelpText(common_env),)
680
681 Help(help_text)
682
683 # --------------------------------------------------------------------------- #
684 # ---------------------------- MAIN BUILD STEPS ----------------------------- #
685 # --------------------------------------------------------------------------- #
686
687 # If we are running the build
688 if not SConsAddons.Util.hasHelpFlag():
689    try:                                   # Try to save the options if possible
690       if not ARGUMENTS.has_key("options_file"):
691          opts.Save(option_filename, common_env)
692    except LookupError, le:
693       pass
694    
695    if common_env.has_key("MSVS"):
696       import pprint
697       print "Found MSVS. using version: ", common_env["MSVS"]["VERSION"]
698       pprint.pprint(common_env["MSVS"])
699
700    # Update settings
701    if common_env.has_key("MSVS"):
702       buildDir += "." + common_env["MSVS"]["VERSION"]
703    if common_env["build_suffix"] != "":
704       buildDir += "." + common_env["build_suffix"]
705      
706    # .fcd processing
707    if common_env["enable_fcd2code"]:
708       registerfcd2codeBuilder(common_env)
709      
710       fcd_files = []
711       for root, dirs, files in os.walk(pj(os.getcwd(),'Source')):
712          fcd_files += [pj(root,f) for f in files if f.endswith(".fcd")]
713      
714       for f in fcd_files:
715          fcd_targets = common_env.fcd2code(source=f)
716          NoClean(fcd_targets)
717    
718    # .fbd processing
719    if common_env["enable_fbd2code"]:
720       registerfbd2codeBuilder(common_env)
721      
722       fbd_files = []
723       for root, dirs, files in os.walk(pj(os.getcwd(),'Source')):
724          fbd_files += [pj(root,f) for f in files if f.endswith(".fbd")]
725      
726       for f in fbd_files:
727          fbd_targets = common_env.fbd2code(source=f)
728          NoClean(fbd_targets)
729
730    # Distcc enable
731    if common_env["enable_distcc"] and WhereIs("distcc"):
732       common_env.Prepend(CXX = "distcc ", CC = "distcc ")
733
734
735    # Trigger recursive scanning of library directorties
736    if not verbose_build:
737       print "Scanning libraries: ",
738    biScanner = BuildInfoScanner("Source", opts, common_env,
739                                 [".svn", "ES", "EGL"], verbose_build)
740    lib_map   = biScanner.scan()
741    if not verbose_build:
742       print "  found %s libraries" % len(lib_map)
743    
744    # Add lexer to the build
745    addScanParseSkel(common_env)     
746      
747    # -- Common builder settings
748    variant_helper.readOptions(common_env)
749    base_bldr.readOptions(common_env)
750    #base_bldr.enableWarnings()
751    base_bldr.enableWarnings(EnvironmentBuilder.MINIMAL)
752    
753    # Apply any common package options
754    # Update environment for boost options
755    required_libs_options["boost"</