root/branches/Dirk_RenderTraversalWork/SConstruct

Revision 367, 26.4 kB (checked in by dirk, 2 years ago)

Typo in PNG option fixed

Line 
1 #!python
2 #
3 # SCons build script for OpenSG
4 #
5
6 # If we have wingide, try loading the debugging extenstions
7 try:
8    import wing.wingdbstub
9    print "Loaded wingdb stub for debugging..."
10 except:
11    pass
12
13 import os, string, sys, re, glob, copy, types, traceback, pprint, tempfile, shutil
14 pj = os.path.join
15
16 print "-------------------------------------------------"
17 print "WARNING: The build is currently in development.  "
18 print "            - It needs the svn version of scons-addons"
19 print "WARNING:"
20
21 sys.path.insert(0,pj('Tools','scons-addons','src'))
22 sys.path.insert(0,pj('Tools','scons-build'))
23
24 import SCons.Environment
25 import SCons
26 import SConsAddons.Util as sca_util
27 import SConsAddons.Options as sca_opts
28 import SConsAddons.Variants as sca_variants
29 import SConsAddons.Builders
30 import SConsAddons.Options.Boost
31 from SConsAddons.EnvironmentBuilder import EnvironmentBuilder
32 from LibraryUtils import *
33 from sets import Set
34
35 # Aliases
36 GetPlatform = sca_util.GetPlatform
37 Export('GetPlatform')
38 pj = os.path.join
39 verbose_build = False
40
41 # Build TODO
42 # - Support selection of WS/ES
43 # - Support selection of compiler to build with
44 # - QT support
45 # - Contrib libraries
46 # - Library specific defines (if needed)
47 # - Build on windows
48 # - Project files for windows
49
50 # ------ HELPER METHODS -------- #
51
52 # ------------------ BUILDERS ------------------- #
53 # fcdProcess builder
54 # - Custom builder for fcdProcess
55 def registerFcdProcessBuilder(env, required=True):
56    print "Setting up fcdProcess builder...",
57    
58    fcdProcess_cmd = pj("Tools", "fcdProcess","fcdProcess.pl")
59    fcdProcess_cmd = os.path.abspath(fcdProcess_cmd)
60    if not os.path.isfile(fcdProcess_cmd):
61       print " Warning: fcdProcess not found at: ", fcdProcess_cmd     
62       if required:
63          sys.exit(1)
64       return
65    
66    template_files = glob.glob(pj("Tools","fcdProcess","*Template*"))   
67    
68      
69    def prop_emitter(target,source,env, template_files=template_files):
70       """ Returns a list of files including all output forms and
71           The input templates as sources.
72       """
73       assert str(source[0]).endswith(".fcd")
74       assert len(source) == 1
75
76       base_name = os.path.splitext(str(source[0]))[0]
77
78       # Targets are all the files that we build
79       target = []
80       for ext in ["Base.cpp","Base.h","Base.inl","Fields.h"]:
81          target.append(base_name+ext)
82      
83       # Sources are the fcd file and all the template files
84       source.extend(template_files)
85
86       return (target, source)
87    
88    
89    fcdprocess_builder = Builder(action = fcdProcess_cmd + ' -c -b -d $SOURCE -p ${TARGET.dir}',
90                               src_suffix = '.fcd',
91                               suffix = 'unused.h',
92                               emitter = prop_emitter)
93    env.Append(BUILDERS = {'FcdProcess' : fcdprocess_builder});
94    print "[OK]"
95
96
97 def addScanParseSkel(common_env):
98    """ This is an ugly hack to add the lex/yacc support into the build.  It is ugly because of a couple of things.
99       - We use some very custom flags
100       - We need to post process the scanner to include a different file then normal.
101       - We are forcing this to be done in the source tree in a subdir without actually going there.
102       - Dependency management seems to be a little messed up right now in the code or scons.
103       - BUGS: Scons does not seem to recognize that the files we are building here are source
104               files for the libraries.  This makes it so we have to run the build twice if the files change.
105    """
106    # Hack to handle the generation of the parser from .y
107    # This pretty hacky to allow using a version of the file from the repository if yacc is not installed
108    # 1. Call bison: OSGScanParseSkelParser.yy -> OSGScanParseSkelParser.hpp .cpp .output (we don't need the last one)
109    if "yacc" in common_env["TOOLS"]:
110       parser_env = common_env.Copy()
111       parser_env.Append(YACCFLAGS = ["-d","-v","-pOSGScanParseSkel_","-bOSGScanParseSkel_"])
112       source_file = "Source/System/FileIO/ScanParseSkel/OSGScanParseSkelParser.yy"
113       target_file = "Source/System/FileIO/ScanParseSkel/OSGScanParseSkelParser.cpp"
114       yfiles = parser_env.CXXFile(target=target_file,source=source_file)   
115       NoClean(yfiles)
116       #print "yfiles: ", yfiles
117
118       # Make sure the parser files have been found for OSGFileIO
119       y_cpp_file = str(yfiles[0]).replace("Source/","",1)
120       y_hpp_file = str(yfiles[1]).replace("Source/","",1)
121       #if not y_cpp_file in lib_map["OSGSystem"].source_files:
122       #   lib_map["OSGSystem"].source_files.append(y_cpp_file)
123       #if not y_hpp_file in lib_map["OSGSystem"].header_files:
124       #   lib_map["OSGSystem"].header_files.append(y_hpp_file)
125       #print " yy source: %s \n header: %s"%(lib_map["OSGSystem"].source_files, lib_map["OSGSystem"].header_files)
126    else:
127       print "WARNING: bison not available.  If you change .yy files they will not be built."
128    
129    # Hack to handle the generation of the scanner from .lpp
130    # This pretty hacky to allow using a version of the file from the repository if lex is not installed
131    # 2. Call flex: OSGScanParseSkelScanner.lpp -> OSGScanParseSkelScanner.cpp (this one needs to be filtered to change the include)
132    if "lex" in common_env["TOOLS"]:
133       def filter_header(target, source, env):
134          """ Custom filter to change the include file for the flexlexer.h"""
135          fname = str(target[0])
136          contents = open(fname).readlines()
137          for i in range(len(contents)):
138             if contents[i] == "#include <FlexLexer.h>\n":
139                contents[i] = "#include \"%s\"\n" % os.path.split(OSG_flexlexer_h)[1]
140                break
141          open(fname,'w').writelines(contents)
142          #print "filter_header: Created ", fname     
143
144       lexer_env = common_env.Copy()
145       lexer_env.Append(LEXFLAGS = ["-+","-POSGScanParseSkel_"])
146
147       lexer_dir       = pj('Source','System','FileIO','ScanParseSkel')
148       sys_flexlexer_h = "/usr/include/FlexLexer.h"
149       OSG_flexlexer_h = pj(lexer_dir,"OSGScanParseSkelScanner_FlexLexer.h")
150       source_file     = pj(lexer_dir,"OSGScanParseSkelScanner.ll")
151       target_file     = pj(lexer_dir,"OSGScanParseSkelScanner.cpp")
152
153       # Replace lex builder with new action that calls flex and then filters
154       std_lex_action = Action("$LEXCOM", "$LEXCOMSTR")     
155       filter_action = Action(filter_header, lambda t,s,e: "Filtering header: %s %s"%(str(t),str(s)))
156       cxx_file_builder = lexer_env['BUILDERS']['CXXFile']
157       cxx_file_builder.add_action('.ll', Action([std_lex_action, filter_action]))           
158       lfiles = lexer_env.CXXFile(target=target_file,source=source_file)
159       NoClean(lfiles)
160       #print "lfiles: ", lfiles
161       
162       # If available, copy the system FlexLexer.h file to local source dir
163       if os.path.exists(sys_flexlexer_h):     
164          flexlex_cp = lexer_env.Command(OSG_flexlexer_h, sys_flexlexer_h,[Copy('$TARGET','$SOURCE'),])
165          Depends(lfiles, flexlex_cp)
166
167       #Depends(lfiles, "Source/System/FileIO/ScanParseSkel/OSGScanParseSkelParser.hpp") # the scanner includes the token header from the parser...
168       if vars().has_key('yfiles'):
169          Depends(lfiles, yfiles)     
170      
171       # Strip off "Source/" since this will be in the build dir
172       scanner_src = target_file.replace("Source/","",1)
173       #if not scanner_src in lib_map["OSGSystem"].source_files:
174       #   lib_map["OSGSystem"].source_files.append(scanner_src)
175       #print "FileIO source files: ", lib_map["OSGSystem"].source_files         
176    else:
177       print "WARNING: flex not available.  If you change .ll files they will not be built." 
178    
179 #------------------------------------------------------------------------------
180 # Main build setup
181 #------------------------------------------------------------------------------
182 EnsureSConsVersion(0,96,92)
183 SourceSignatures('MD5')
184 #SourceSignatures('timestamp')
185 SConsignFile('.sconsign.'+GetPlatform())
186 opensg_version_string = file("VERSION").readline().strip()
187
188 # Figure out what version of CppDom we're using
189 print "Building OpenSG ", opensg_version_string
190
191 platform = sca_util.GetPlatform()
192 unspecified_prefix = "use-instlinks"
193 buildDir = "build." + platform     
194 option_filename = "option.cache." + platform
195
196 # Create base environment to use for option processing
197 if GetPlatform() == "win32":
198    common_env = Environment()
199 else:
200    common_env = Environment(ENV = os.environ)
201 # Setup the directories used for sconf processing
202 common_env["CONFIGUREDIR"] = '.sconf_temp_'+platform
203 common_env["CONFIGURELOG"] = 'sconf.log_'+platform
204 SConsAddons.Builders.registerDefineBuilder(common_env)
205 SConsAddons.Builders.registerSubstBuilder(common_env)
206
207 # Create variant helper and builder
208 variant_helper = sca_variants.VariantsHelper(variantKeys=["type","arch"])
209 base_bldr = EnvironmentBuilder()
210
211 # --------------- #
212 # --- OPTIONS --- #
213 # --------------- #
214 # Find all build.info files that may have options
215 #build_info_files = []
216 #for root, dirs, files in os.walk(pj(os.getcwd(),'Source')):
217 #   build_info_files += [pj(root,f) for f in files if f == "build.info"]
218 #
219 #print "Build info files found: ", build_info_files
220
221 opts = sca_opts.Options(files = [option_filename, 'options.custom'],
222                                    args= ARGUMENTS)
223
224 # Create option objects
225 boost_options = sca_opts.Boost.Boost("boost","1.31.0",required=True)
226
227 glut_libname = "glut"
228 tiff_libname = "tiff"
229 if "win32" == platform:
230    glut_libname = "glut32"
231    tiff_libname = "tif32"
232    
233 jpeg_option = sca_opts.StandardPackageOption("jpeg","Jpeg library location",
234                                              library="jpeg", required=False)
235 tiff_option = sca_opts.StandardPackageOption("tiff","Tiff library location",
236                                              library=tiff_libname, required=False)
237 png_option = sca_opts.StandardPackageOption("png","PNG library location",
238                                              library="png", required=False)
239 glut_option = sca_opts.StandardPackageOption("glut","GLUT library location",
240                                              library=glut_libname, header="GL/glut.h", required=False)
241 zlib_option = sca_opts.StandardPackageOption("zlib","zlib library location",
242                                              library="z", header="zlib.h", required=False)                                             
243 nvperfsdk_option = sca_opts.StandardPackageOption("NVPerfSDK", "NVPerfSDK library location", header="NVPerfSDK.h",
244                                              library="NVPerfSDK", required=False)
245
246 format_options = [jpeg_option,tiff_option,png_option,zlib_option,nvperfsdk_option]
247 # Setup options
248 opts.AddOption(sca_opts.SeparatorOption("\nStandard settings"))
249 opts.Add('prefix', 'Installation prefix', unspecified_prefix)
250 opts.AddOption(sca_opts.SeparatorOption("\nPackage Options"))
251 opts.AddOption( boost_options )
252 opts.AddOption( glut_option )
253 opts.AddOption(sca_opts.SeparatorOption("\nFormat Options"))
254 for o in format_options:
255    opts.AddOption(o)
256 opts.AddOption(sca_opts.BoolOption("enable_gif","Enable GIF support.",True))   
257 # Custom options
258 opts.AddOption(sca_opts.SeparatorOption("\nAdvanced Options"))
259 opts.AddOption(sca_opts.EnumOption("fcptr_mode","Set the pointer mode to use for field containers",
260                                    "MT_FCPTR",["SINGLE_THREAD","MT_CPTR","MT_FCPTR"]))
261 opts.AddOption(sca_opts.BoolOption("disable_deprecated","Disable deprecated code.",False))
262 opts.AddOption(sca_opts.BoolOption("disable_glut_glsubdir","Do not use GL subdir while including glut.h",False))
263 opts.AddOption(sca_opts.BoolOption("osg_1_compat","Enable opensg 1.x compatibility.",False))
264 opts.AddOption(sca_opts.BoolOption("osg_deprecated_props","Enable deprecated property types.",False))
265 opts.Add("build_suffix", "Suffix to append to build directory.  Useful for compiling multiple variations on same platform.", "")                                   
266 opts.AddOption(sca_opts.BoolOption("enable_fcdprocess","If true, enable support for fcdProcess in the build.",False))
267 opts.AddOption(sca_opts.BoolOption("enable_unittests","If true, enable unit tests in the build.",True))
268 opts.Add("icc_gnu_compat","<GCC Version> to make the icc resultbinary compatible to the given gcc version. (unsupported)")
269 if "win32" == platform:
270    opts.AddOption(sca_opts.BoolOption("win_localstorage", "Use local storage instead of __declspec to get thread local storage on windows",
271                                       True))
272 if "win32" != platform:
273    opts.AddOption(sca_opts.BoolOption("pthread_elf_tls", "Enable elf thread local storage with pthreads.",
274                                       ("linux"==platform)))
275                                      
276                                    
277 base_bldr.addOptions(opts)             # Add environment builder options
278 variant_helper.addOptions(opts)        # Add variant building options
279
280 try:
281    opts.Process(common_env)               # Process the options
282 except Exception, ex:
283    if not SConsAddons.Util.hasHelpFlag():
284       print "Option error: ", str(ex)
285       traceback.print_exc()
286       sys.exit(1)
287
288 help_text = """--- OpenSG Build system ---
289 %s
290 Targets:
291    install - Install OpenSG
292       ex: 'scons install prefix=$HOME/software' to install in your account
293    Type 'scons' to just build it
294  
295 """%(opts.GenerateHelpText(common_env),)
296
297 #help_text = opts.GenerateHelpText(common_env) + help_text
298 Help(help_text)
299
300
301 # --- MAIN BUILD STEPS ---- #
302 # If we are running the build
303 if not SConsAddons.Util.hasHelpFlag():
304    try:                                   # Try to save the options if possible
305       opts.Save(option_filename, common_env)
306    except LookupError, le:
307       pass
308    
309    # Update settings
310    if common_env["build_suffix"] != "":
311       buildDir = buildDir + "." + common_env["build_suffix"]
312      
313    # .fcd processing
314    if common_env["enable_fcdprocess"]:     
315       registerFcdProcessBuilder(common_env)
316      
317       fcd_files = []
318       for root, dirs, files in os.walk(pj(os.getcwd(),'Source')):
319          fcd_files += [pj(root,f) for f in files if f.endswith(".fcd")]
320      
321       for f in fcd_files:
322          fcd_targets = common_env.FcdProcess(source=f)
323          NoClean(fcd_targets)
324
325    
326    # --- Collect all Source and Header files --- #         
327   
328    # --- Find and process all the build.info files ---- #
329    # - Find them
330    # This is a little more complex then I would like. The complexity
331    # comes from the fact that we are recursing in the directories
332    # and that any file found overrides the current settings.
333    # Basic idea is:
334    #   - Keep track of a library stack that we are adding
335    #   - Recurse into each subdirectory of source
336    #   - Keep all file names relative to the Source directory (so they work in builddir)
337    #
338    # ----- BUILD.INFO FILES ------- #
339    # When evaluating build.info files:
340    #   input vars:
341    #      option_pass: If true, we are just trying to get options
342    #      opts: If not none, this is an options object that can have options added
343    #      platform: The current platform string ("win32", "linux", )
344    #      compiler: The current compiler being used ("g++","cl", )
345    #   output vars:
346    #      library: Name of the library to add code to
347    #      stop_traversal: If set tru, do not traverse into this directory
348    #      - Dependencies
349    #         osg_dep_libs: Name of OpenSG libraries that we depend upon (need for link)
350    #         libs: Name of non-OpenSG libraries we depend upon
351    #         cpppath: Additional cpp paths that we should set for building
352    #         libpath: Additional library paths that we should set
353    #      - Tests
354    #         osg_test_libs: OpenSG libraries that we need when building tests
355    #         other_test_libs: Other libraries we need when building tests
356    #         test_cpppath: Additional cpppaths for building tests
357    #         test_libpath: Additional lib paths we need for building tests
358    #
359    lib_map = {}    # Map from name to library we are using   
360    dir_ignores = [".svn", "ES","EGL"]   
361
362    def scan_libs(base_dir, cur_dir, name_stack):
363       """ Scan library directory.
364           base_dir: Directory to keep all paths relative to
365           cur_dir: Directory to examine.
366           name_stack: Current stack of library names
367       """
368       global lib_map
369       #print "dir: ", cur_dir
370       full_dir = pj(base_dir, cur_dir)
371       dir_contents = [pj(cur_dir,f) for f in os.listdir(full_dir)]
372       files = [f for f in dir_contents if os.path.isfile(pj(base_dir,f))]
373       dirs  = [d for d in dir_contents if os.path.isdir(pj(base_dir,d))]
374       have_build_info = os.path.exists(pj(full_dir,"build.info"))
375       cur_lib = None          # The current library we are adding to
376
377       lib_attrib_names = ["osg_dep_libs","libs","cpppath","libpath",
378                           "osg_test_libs","other_test_libs","test_cpppath", "test_libpath"]
379       # If we have a build info file
380       # - Setup namespace and evaluate it
381       # - Create on demand
382       # - Fill with anything from the file
383       if have_build_info:     
384          bi_filename = pj(full_dir,"build.info")
385          if verbose_build:
386             print "   Evaluating: ", bi_filename         
387          else:
388             sys.stdout.write(".")
389          
390          # Custom options
391          ns = {"option_pass":False,
392                "opts":opts,
393                "library":None,
394                "platform":platform,
395                "compiler":common_env["CXX"],
396                "stop_traversal":False
397          }
398          # Options for the lib package
399          for n in lib_attrib_names:
400             ns[n] = []
401            
402          execfile(bi_filename, ns)
403          if ns["stop_traversal"]:          # Don't traverse any further
404             if verbose_build:
405                print "   Pruning traversal."
406             return
407          if not ns.has_key("library"):
408             print "Error: Must specify 'library' value in build.info file:", bi_filename
409             sys.exit(1)         
410          lib_name = ns["library"]
411          if not lib_map.has_key(lib_name):
412             lib_map[lib_name] = LibraryInfo(name=lib_name)
413             if verbose_build:
414                print "Created new LibraryInfo: ", lib_name
415          name_stack.append(lib_name)
416          cur_lib = lib_map[lib_name]
417    
418          if verbose_build:
419             print "lib name: ", lib_name
420          
421          # Add all the lib options from the evaluation
422          # - Only add on the unique ones
423          for n in lib_attrib_names:
424             attrib_list = getattr(cur_lib,n)
425             attrib_list.extend([x for x in ns[n] if x not in attrib_list])
426      
427       # Collect source files from all directories and put them into the active library object         
428       test_files =   [f for f in files if os.path.basename(f).startswith("test") and f.endswith(".cpp")]
429       unittest_files =   [f for f in files if os.path.basename(f).endswith("Test.cpp") and\
430                                               os.path.basename(f).startswith("OSG")]
431       source_files = [f for f in files if (os.path.splitext(f)[1] in [".cpp",".cc"]) and\
432                                           (os.path.basename(f).startswith("OSG") and\
433                                            f not in test_files and f not in unittest_files)]
434       header_files = [f for f in files if os.path.splitext(f)[1] in [".h",".inl",".ins",".hpp"] and\
435                                          (os.path.basename(f).startswith("OSG"))]     
436      
437       #print "Adding to lib:[%s]  source: [%s]"%(name_stack[-1],source_files)
438       if len(test_files) or len(source_files) or len(header_files):
439          if len(name_stack) == 0:
440             print "Error: Attempted to add source with no library build.info specifed.  In dir: %s"%pj(base_dir,cur_dir)
441             sys.exit(1)
442          lib_name = name_stack[-1]
443          lib_map[lib_name].source_files     += source_files
444          lib_map[lib_name].header_files     += header_files
445          lib_map[lib_name].test_files       += test_files
446          lib_map[lib_name].unittest_files   += unittest_files
447      
448       # Recurse into subdirectories
449       for d in dirs:
450          if not os.path.basename(d) in dir_ignores:
451             scan_libs(base_dir, d, copy.copy(name_stack))
452    
453    # Trigger recursive scanning of library directorties
454    if not verbose_build:
455       print "Scanning libraries: ",
456    scan_libs(pj(os.getcwd(),"Source"), '', [])
457    if not verbose_build:
458       print "  found %s libraries"%len(lib_map)
459    
460    # Add lexer to the build
461    addScanParseSkel(common_env)
462
463    # -- Common builder settings
464    variant_helper.readOptions(common_env)
465    base_bldr.readOptions(common_env)
466    #base_bldr.enableWarnings()
467    base_bldr.enableWarnings(EnvironmentBuilder.MINIMAL)
468  
469    # Apply any common package options
470    # Update environment for boost options
471    boost_options.apply(common_env)   
472      
473    # If defaulting to instlinks prefix:
474    #  - Use symlinks
475    #  - Manually set the used prefix to the instlinks of the build dir
476    if common_env['prefix'] == unspecified_prefix:
477       if hasattr(os,'symlink'):
478          common_env['INSTALL'] = SConsAddons.Util.symlinkInstallFunc
479       common_env['prefix'] = pj( Dir('.').get_abspath(), buildDir, 'instlinks')
480    
481    # --- Setup installation paths --- #
482    paths = {}
483    paths['base']      = os.path.abspath(common_env['prefix'])
484    paths['lib']       = pj(paths['base'], 'lib')
485    paths['include']   = pj(paths['base'], 'include')   
486    paths['bin']       = pj(paths['base'], 'bin')   
487    print "Using prefix: ", paths['base']         
488    common_env.Append(CPPPATH = [paths['include'],pj(paths['include'],"OpenSG")])
489      
490    # ---- Generate OSGConfigured.h --- #
491    definemap = {"OSG_DISABLE_DEPRECATED": (common_env["disable_deprecated"],
492                                            "Disable interface that will go away in the future"),               
493                 "OSG_NO_GLUT_GLSUBDIR":(common_env["disable_glut_glsubdir"],"Don't use GL subdir for glut"),
494                 "OSG_MT_FIELDCONTAINERPTR":("MT_FCPTR" == common_env["fcptr_mode"]),
495                 "OSG_MT_CPTR_ASPECT":("MT_CPTR" == common_env["fcptr_mode"]),
496                 "OSG_1_COMPAT":common_env["osg_1_compat"],
497                 "OSG_DEPRECATED_PROPS":common_env["osg_deprecated_props"],
498                
499                 "OSG_WITH_JPG":jpeg_option.isAvailable(),
500                 "OSG_WITH_TIF":tiff_option.isAvailable(),
501                 "OSG_WITH_PNG":png_option.isAvailable(),
502                 "OSG_WITH_GLUT":glut_option.isAvailable(),
503                 "OSG_WITH_GIF":common_env["enable_gif"],
504                 "OSG_WITH_ZLIB":zlib_option.isAvailable(),
505                 "OSG_WITH_NVPERFSDK":nvperfsdk_option.isAvailable()
506                }
507    if "win32" == platform:   # Win32 specific defines
508       definemap.update( {"OSG_WIN32_ASPECT_USE_LOCALSTORAGE": common_env["win_localstorage"],} )
509    else:
510       definemap.update( {"OSG_PTHREAD_ELF_TLS":(common_env["pthread_elf_tls"],"Use elf tls with pthreads."),} )
511    
512    common_env.DefineBuilder(pj(paths["include"],"OpenSG","OSGConfigured.h"),Value(definemap),
513                             definemap=definemap)
514    
515    # Unit Testing framework
516    # - Build the framework
517    if common_env["enable_unittests"]:     
518       # common_env.Append(CXXFLAGS = "-H") # Use this for pch script generation
519       # Until they have the SConstruct in their svn, let's just copy it over
520       SConscript(pj("Tools", "unittest-cpp.SConstruct"))   
521    
522       # set the needed vars
523       unittest_inc = pj(os.getcwd(),"Tools","unittest-cpp","UnitTest++","src");
524       unittest_libpath = pj(os.getcwd(),"Tools","unittest-cpp","UnitTest++");
525       unittest_lib = "UnitTest++";
526       unittest_runner = pj(os.getcwd(),"Tools","UnitTestRunner.cpp");
527       Export('unittest_inc', 'unittest_lib', 'unittest_libpath', 'unittest_runner')
528    
529      
530    # ---- FOR EACH VARIANT ----- #   
531    # This is the core of the build.
532    if verbose_build:
533       print "types: ",    variant_helper.variants["type"]
534       print "libtypes: ", variant_helper.variants["libtype"]
535       print "archs: ",    variant_helper.variants["arch"]   
536      
537    # We tread the first variant type special (auto link from libs here)
538    default_combo_type = variant_helper.variants["type"][0][0]
539    
540    for combo in variant_helper.iterate(locals(), base_bldr, common_env):           
541       #baseEnv = env_bldr.applyToEnvironment(common_env.Copy(), variant=combo,options=opts)     
542       print "   Processing combo: ", ", ".join(['%s:%s'%(i[0],i[1]) for i in combo.iteritems()])
543
544       inst_paths = copy.copy(paths)
545       if "x64" == combo["arch"]:
546          inst_paths['lib'] = inst_paths['lib'] + '64'                 
547       inst_paths["lib_inst_combo"] = inst_paths["lib"]
548       if GetPlatform() != "win32":
549          if "debug" == combo["type"]:
550             inst_paths["lib_inst_combo"] = pj(inst_paths["lib_inst_combo"],"debug")     
551          else:
552             inst_paths["lib_inst_combo"] = pj(inst_paths["lib_inst_combo"],"opt")     
553      
554       Export('build_env','inst_paths','opts', 'variant_pass','combo',
555              'lib_map','boost_options',
556              'shared_lib_suffix','static_lib_suffix',
557              'default_combo_type','verbose_build',)
558      
559       # Process subdirectories
560       sub_dirs = ['Source']   
561       full_build_dir = pj(buildDir,combo_dir)
562       for d in sub_dirs:
563          SConscript(pj(d,'SConscript'), build_dir=pj(full_build_dir, d), duplicate=0)
564          
565       # Build -config file based on first set installed
566       if 0 == variant_pass:
567          # - Create string using pprint.pformat that can build libmap (see osg-config.in for read)
568          lib_map_build_list = []
569          for (name,lib) in lib_map.iteritems():
570             lib_map_build_list.append(lib.dump())
571            
572             # Add an alias just for this lib and its unittests
573             Alias(name[3:], [ pj(full_build_dir, "Source", "lib" + name + common_env["SHLIBSUFFIX"]), \
574                               pj(full_build_dir, "unittest", "run" + name)\
575                             ])
576
577          lib_map_str = pprint.pformat(lib_map_build_list)
578
579          submap = {'@LIB_MAP_STR@':lib_map_str,
580                    '@PREFIX@':common_env["prefix"],
581                    '@LIBPATH@':inst_paths["lib"],
582                    '@INCPATH@':inst_paths["include"],
583                    '@VERSION@':opensg_version_string,
584                    '@LIBRARY_UTIL_SRC@':file(pj('Tools','scons-build','LibraryUtils.py')).read()}
585          # Install two scripts so we have one with osg2 in the name to let users be sure they get the right version             
586          for n in ["osg-config","osg2-config"]:
587             osg_config = common_env.SubstBuilder(pj(paths['bin'],n),
588                                     'osg-config.in', submap=submap)   
589             common_env.AddPostAction(osg_config, Chmod('$TARGET', 0755))
590             common_env.Depends(osg_config, Value(lib_map_str))
591
592    
593    common_env.Alias('install', paths['base'])   
594    
595    # Close up with aliases and defaults   
596    Default('.')
597
Note: See TracBrowser for help on using the browser.