root/branches/Carsten_PtrWork/SConstruct

Revision 922, 38.2 kB (checked in by vossg, 1 year ago)

fixed: vtk compile problems

  • 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["freetype"] = sca_opts.StandardPackageOption(
486     "freetype", "Location of freetype2 library", library = "freetype",
487     header = "freetype/config/ftheader.h", required = False)
488
489 if "win32" != platform:
490    optional_libs_options["freetype"].incDir = '/usr/include/freetype2'
491
492 optional_libs_options["fontconfig"] = sca_opts.StandardPackageOption(
493     "fontconfig", "Location of fontconfig library", library = "fontconfig",
494     header = "fontconfig/fontconfig.h", required = False)
495
496 optional_libs_options["zlib"] = sca_opts.StandardPackageOption(
497     "zlib", "Location of the zlib compression library", library = zlib_libname,
498     header = "zlib.h", required = False)
499
500 optional_libs_options["NVPerfSDK"] = sca_opts.StandardPackageOption(
501     "NVPerfSDK", "Location of the NVPerfSDK library", library = "NVPerfSDK",
502     header = "NVPerfSDK.h", required = False)
503
504 optional_libs_options["collada"] = OpenSG.ColladaOption.ColladaOption(
505     "collada", "Location of the collada dom library", library =
506     ["collada_dae",
507      "collada_LIBXMLPlugin",
508      "collada_STLDatabase",
509      "collada_dom",
510      "collada_stdErrPlugin",
511      "collada_dae"],
512     header = "dae/daeIntegrationObject.h", required = False)
513
514 optional_libs_options["xml2"] = sca_opts.StandardPackageOption(
515     "xml2", "Location of the xml2 library", library = "xml2",
516     required = False)
517
518 vtk_libs = ['vtkRendering',
519             'vtkIO',
520             'vtkGraphics',
521             'vtkImaging',
522             'vtkFiltering',
523             'vtkCommon',
524             'vtkftgl',
525             'vtkDICOMParser',
526             'vtksys',
527             'verdict',
528             'vtkNetCDF',
529             'vtkmetaio']
530
531 #if "win32" != platform:
532 #    vtk_libs.append('vtkMPEG2Encode')
533
534 optional_libs_options['vtk'] = sca_opts.VTK.VTK(
535    "vtk",
536    "Location of the vtk libraries",
537    required = False,
538    libList = vtk_libs)
539
540 # Feature options - select library/interface features
541 feature_options = {}
542 feature_options["gif"] = sca_opts.BoolOption(
543     "enable_gif", "Enable GIF support", True)
544
545 feature_options["fcptr_mode"] = sca_opts.EnumOption(
546     "fcptr_mode", "Select the mode for field container pointers",
547     "MT_CPTR", ["SINGLE_THREAD", "MT_CPTR"])
548
549 feature_options["disable_deprecated"] = sca_opts.BoolOption(
550     "disable_deprecated", "Disable deprecated interfaces and code", False)
551
552 feature_options["disable_glut_glsubdir"] = sca_opts.BoolOption(
553     "disable_glut_glsubdir", "Do not use GL subdir when including glut.h", False)
554
555 feature_options["enable_osg1_compat"] = sca_opts.BoolOption(
556     "enable_osg1_compat", "Enable OpenSG 1.x compatibility", False)
557
558 feature_options["enable_deprecated_props"] = sca_opts.BoolOption(
559     "enable_deprecated_props", "Enable deprecated property types.", False)
560
561 feature_options["enable_new_osb_io"] = sca_opts.BoolOption(
562     "enable_new_osb_io", "Enable the new OSB IO facilities.", False)
563
564 feature_options["enable_scanparse_regen"] = sca_opts.BoolOption(
565     "enable_scanparse_regen", "Enable regenerating the scanner/parser files using flex and bison", False);
566
567 feature_options["enable_testcontainer"] = sca_opts.BoolOption(
568     "enable_testcontainer", "Enable container used for testing (from Source/Test)", False)
569
570 feature_options["docs_mode"] = sca_opts.EnumOption(
571     "docs_mode", "Select the mode for documentation generation",
572     "NONE", ["NONE", "STANDALONE", "TRAC", "DEVELOPER"])
573
574 feature_options["enable_valgrind_checks"] = sca_opts.BoolOption(
575     "enable_valgrind_checks", "Enable valgrind check code embedded in OpenSG.", False)
576
577 feature_options["enable_memory_debugging"] = sca_opts.BoolOption(
578     "enable_memory_debugging", "Enable memory debugging checks in OpenSG.", False)
579
580 if "win32" == platform:
581     feature_options["enable_win_localstorage"] = sca_opts.BoolOption(
582         "enable_win_localstorage", "Enable use of local storage instead of __declspec to "+
583         "get thread local storage on windows", True)
584
585 if "win32" != platform:
586     feature_options["enable_elf_localstorage"] = sca_opts.BoolOption(
587         "enable_elf_localstorage", "Enable use of elf thread local storage with pthreads",
588         ("linux" == platform))
589
590 # Misc options
591 misc_options = {}
592 #misc_options["icc_compat"] = sca_opts.SimpleOption(
593 #    "icc_gnu_compat", "icc_gnu_compat", "<GCC Version> Make the binaries built " +
594 #                      "with icc compatible with the given verion of gcc. (unsupported)",
595 #                      "", None, None, None)
596
597 # Options to specify additional library/header search paths and librarys to
598 # link agains.
599 extra_libs_options = {}
600 extra_libs_options["incdir"] = SimpleAppendOption('add_incdir', 'CPPPATH', 'Additional include dir')
601 extra_libs_options["libdir"] = SimpleAppendOption('add_libdir', 'LIBPATH', 'Additional library dir')
602 extra_libs_options["lib"]    = SimpleAppendOption('add_lib',    'LIBS',    'Additional library')
603
604 # Group all image format options together.
605 image_format_options = {}
606 image_format_options["jpeg"] = optional_libs_options["jpeg"]
607 image_format_options["tiff"] = optional_libs_options["tiff"]
608 image_format_options["png"]  = optional_libs_options["png"]
609 image_format_options["gif"]  = feature_options["gif"]
610
611 #
612 # 2) Register options
613 #    This should not require any changes unless a new option group is added.
614
615 for opt in extra_libs_options.itervalues():
616     if opt not in image_format_options.itervalues():
617         opts.AddOption(opt)
618
619 opts.AddOption(sca_opts.SeparatorOption("\nBuild/Install settings"))
620 for opt in build_options.itervalues():
621     if opt not in image_format_options.itervalues():
622         opts.AddOption(opt)
623
624 opts.AddOption(sca_opts.SeparatorOption("\nPackage settings (required libs)"))
625 for opt in required_libs_options.itervalues():
626     if opt not in image_format_options.itervalues():
627         opts.AddOption(opt)
628
629 opts.AddOption(sca_opts.SeparatorOption("\nPackage settings (optional libs)"))
630 for opt in optional_libs_options.itervalues():
631     if opt not in image_format_options.itervalues():
632         opts.AddOption(opt)
633
634 for opt in image_format_options.itervalues():
635     opts.AddOption(opt)
636
637
638 opts.AddOption(sca_opts.SeparatorOption("\nAdvanced options"))
639 for opt in feature_options.itervalues():
640     if opt not in image_format_options.itervalues():
641         opts.AddOption(opt)
642
643 for opt in misc_options.itervalues():
644     if opt not in image_format_options.itervalues():
645         opts.AddOption(opt)
646
647 # Add environment builder options
648 base_bldr.addOptions(opts)
649
650 # Add variant building options
651 variant_helper.addOptions(opts)
652
653 #
654 # 3) Process options
655
656 try:
657    opts.Process(common_env)
658 except Exception, ex:
659    if not SConsAddons.Util.hasHelpFlag():
660       print "Option error: ", str(ex)
661       traceback.print_exc()
662       sys.exit(1)
663
664 #
665 # 4) Generate help message
666
667 help_text = \
668 """--- OpenSG Build system ---
669 %s
670 Targets:
671    install - Install OpenSG
672       ex: 'scons install prefix=$HOME/software' to install in your account
673    Type 'scons' to just build it
674
675 """ % (opts.GenerateHelpText(common_env),)
676
677 Help(help_text)
678
679 # --------------------------------------------------------------------------- #
680 # ---------------------------- MAIN BUILD STEPS ----------------------------- #
681 # --------------------------------------------------------------------------- #
682
683 # If we are running the build
684 if not SConsAddons.Util.hasHelpFlag():
685    try:                                   # Try to save the options if possible
686       if not ARGUMENTS.has_key("options_file"):
687          opts.Save(option_filename, common_env)
688    except LookupError, le:
689       pass
690    
691    if common_env.has_key("MSVS"):
692       import pprint
693       print "Found MSVS. using version: ", common_env["MSVS"]["VERSION"]
694       pprint.pprint(common_env["MSVS"])
695
696    # Update settings
697    if common_env.has_key("MSVS"):
698       buildDir += "." + common_env["MSVS"]["VERSION"]
699    if common_env["build_suffix"] != "":
700       buildDir += "." + common_env["build_suffix"]
701      
702    # .fcd processing
703    if common_env["enable_fcd2code"]:
704       registerfcd2codeBuilder(common_env)
705      
706       fcd_files = []
707       for root, dirs, files in os.walk(pj(os.getcwd(),'Source')):
708          fcd_files += [pj(root,f) for f in files if f.endswith(".fcd")]
709      
710       for f in fcd_files:
711          fcd_targets = common_env.fcd2code(source=f)
712          NoClean(fcd_targets)
713    
714    # .fbd processing
715    if common_env["enable_fbd2code"]:
716       registerfbd2codeBuilder(common_env)
717      
718       fbd_files = []
719       for root, dirs, files in os.walk(pj(os.getcwd(),'Source')):
720          fbd_files += [pj(root,f) for f in files if f.endswith(".fbd")]
721      
722       for f in fbd_files:
723          fbd_targets = common_env.fbd2code(source=f)
724          NoClean(fbd_targets)
725
726    # Distcc enable
727    if common_env["enable_distcc"] and WhereIs("distcc"):
728       common_env.Prepend(CXX = "distcc ", CC = "distcc ")
729
730
731    # Trigger recursive scanning of library directorties
732    if not verbose_build:
733       print "Scanning libraries: ",
734    biScanner = BuildInfoScanner("Source", opts, common_env,
735                                 [".svn", "ES", "EGL"], verbose_build)
736    lib_map   = biScanner.scan()
737    if not verbose_build:
738       print "  found %s libraries" % len(lib_map)
739    
740    # Add lexer to the build
741    addScanParseSkel(common_env)     
742      
743    # -- Common builder settings
744    variant_helper.readOptions(common_env)
745    base_bldr.readOptions(common_env)
746    #base_bldr.enableWarnings()
747    base_bldr.enableWarnings(EnvironmentBuilder.MINIMAL)
748    
749    # Apply any common package options
750    # Update environment for boost options
751    required_libs_options["boost"].apply(common_env)
752      
753    # If defaulting to instlinks prefix:
754    #  - Us