root/branches/Dirk_RenderTraversalWork/Source/SConscript

Revision 333, 4.5 kB (checked in by dirk, 2 years ago)

path order

  • Property svn:keywords set to Id
Line 
1 #!python
2 import os, os.path
3 pj = os.path.join
4 from LibraryUtils import *
5
6 Import('*')
7
8 common_lib_env = build_env.Copy()
9
10 if verbose_build:
11    print "Setting up build for libraries: ",
12    
13 for (lib_name, library) in lib_map.iteritems():
14    if verbose_build:
15       print "Library: ", lib_name, "  tests:", library.test_files, "  unittests:", library.unittest_files
16    else:
17       print "%s"%lib_name,
18    
19    # ---- Setup and Build library --- #
20    # - Setup environment for build: library deps, custom options
21    # - Set builder for the library
22    # - Install headers if in first pass
23    lib_env = common_lib_env.Copy()
24    full_lib_name = lib_name + shared_lib_suffix
25
26    # Use ConfigInfo to find build flags for building with/against this library and it's dependencies
27    # - We have to pull our library name off the list (slight hack)   
28    default_lib_settings = LibraryInfo()
29    try:
30       config_info = ConfigInfoAdapter(lib_name, lib_map, default_lib_settings,
31                                     osg_lib_suffix=shared_lib_suffix)
32    ##   config_info = ConfigInfoAdapter(lib_name, lib_map, default_lib_settings,
33    ##                                 osg_lib_suffix=shared_lib_suffix, opts=opts)
34    #except Exception, e:
35    except EOFError, e:
36       print "Caught %s trying to configure deps for %s!" % (str(e), lib_name)
37       break
38    dep_libs = [l for l in config_info.getLibs() if l != full_lib_name]
39    lib_env.Append(CPPPATH=config_info.getIncPath(),
40                   LIBPATH=[inst_paths["lib_inst_combo"]] + config_info.getLibPath(),
41                   LIBS=dep_libs)
42
43    # XXX: Apply custom options
44    #
45    # Add the define needed for declspec to know what library we are building
46    compile_define = "OSG_COMPILE%sLIB"%lib_name[3:].upper()
47    lib_env.Append(CPPDEFINES=[compile_define])
48    
49    shared_lib = lib_env.SharedLibrary(full_lib_name, library.source_files)
50    shared_lib_inst = lib_env.Install(inst_paths['lib_inst_combo'], shared_lib)
51      
52    # If default combo type, then make links from lib dir
53    if default_combo_type == combo["type"] and (GetPlatform() != "win32"):
54       lib_env.Install(inst_paths["lib"], shared_lib_inst)     
55    
56    # Install headers (but only do it once during variant_pass 0 )
57    if variant_pass == 0:     
58       lib_env.Install(pj(inst_paths["include"],"OpenSG"), library.header_files)
59    
60    # ---- Build Tests ---- #   
61    # Use ConfigInfo to find build flags for building applications against this library
62    config_info = ConfigInfoAdapter([lib_name] + library.osg_test_libs,
63                                     lib_map,
64                                     osg_lib_suffix=shared_lib_suffix)   
65    ##config_info = ConfigInfoAdapter([lib_name] + library.osg_test_libs,
66    ##                                 lib_map,
67    ##                                 osg_lib_suffix=shared_lib_suffix, opts=opts)   
68    test_env = build_env.Copy()
69    test_env.Append(CPPPATH=library.test_cpppath + config_info.getIncPath(),
70                    LIBPATH=library.test_libpath + [inst_paths["lib_inst_combo"]] + config_info.getLibPath(),
71                    LIBS=config_info.getLibs() + library.other_test_libs)
72
73    # - Build them all in the local 'test' subdir
74    for s in library.test_files:
75       test_env.Program(target= pj("..","test",os.path.splitext(os.path.basename(s))[0]),
76                        source=s)
77
78    # ---- Build Unit Tests ---- #   
79    # - Build them all in the unittest directory
80    if build_env["enable_unittests"] and (len(library.unittest_files) > 0):         
81       unittest_env = test_env.Copy()
82       unittest_env.Append(CPPPATH=unittest_inc,
83                           LIBPATH=unittest_libpath,
84                           LIBS=unittest_lib)
85       runner_obj = unittest_env.Object(target=pj("..","unittest","run"+lib_name), source=unittest_runner)
86       runner = unittest_env.Program(pj("..","unittest","run"+lib_name),
87                                     library.unittest_files + [str(runner_obj[0])])
88
89       # Run the Test once the program is built
90       def runTest(target, source, env):
91          print "Running ", os.path.basename(str(target[0]))
92          env = os.environ
93          if os.name == 'nt':
94             env['PATH'] = inst_paths['lib_inst_combo'] + os.pathsep + env['PATH']
95          else:
96             if 'LD_LIBRARY_PATH' in env:
97                 env['LD_LIBRARY_PATH'] = inst_paths['lib_inst_combo'] + os.pathsep + env['LD_LIBRARY_PATH']
98             else:
99                 env['LD_LIBRARY_PATH']  = inst_paths['lib_inst_combo']
100          os.spawnle(os.P_WAIT, str(target[0]), env)
101
102       AddPostAction(runner, runTest)
103
104      
105    # Done   
106 if not verbose_build:
107    print ""
Note: See TracBrowser for help on using the browser.