root/branches/Carsten_PtrWork2/Source/SConscript

Revision 999, 6.4 kB (checked in by vossg, 1 year ago)

fixed: pushed google to where it can be found from different dirs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 #!python
2 import os, os.path
3 pj = os.path.join
4 from LibraryUtils import *
5 import SCons
6
7 Import('*')
8
9 import SCons
10
11 common_lib_env = build_env.Copy()
12
13 if verbose_build:
14    print "Setting up build for libraries: ",
15
16 # On windows we do not want to remove all default libraries from the list of libraries
17 # it searches when resolving external references.
18 if GetPlatform() == "win32":
19    common_lib_env.Append(LINKFLAGS = SCons.Util.CLVar('/nodefaultlib'))
20
21 for (lib_name, library) in lib_map.iteritems():
22    if verbose_build:
23       print "Library: ", lib_name, "  tests:", library.test_files, "  unittests:", library.unittest_files
24    else:
25       print "%s"%lib_name,
26    
27    # ---- Setup and Build library --- #
28    # - Setup environment for build: library deps, custom options
29    # - Set builder for the library
30    # - Install headers if in first pass
31    lib_env = common_lib_env.Copy()
32    full_lib_name = lib_name + shared_lib_suffix
33
34    # Use ConfigInfo to find build flags for building with/against this library and it's dependencies
35    # - We have to pull our library name off the list (slight hack)   
36    default_lib_settings = LibraryInfo()
37    config_info = ConfigInfoAdapter(lib_name, lib_map, default_lib_settings,
38                                    osg_lib_suffix=shared_lib_suffix)
39
40    dep_libs = [l for l in config_info.getLibs() if l != full_lib_name]
41    lib_env.Append(CPPPATH=config_info.getIncPath(),
42                   LIBPATH=[inst_paths["lib_inst_combo"]] + config_info.getLibPath(),
43                   LIBS=dep_libs,
44                   FRAMEWORKPATH=config_info.getFrameworkPath(),
45                   FRAMEWORKS=config_info.getFrameworks())
46
47    lib_env.Append(CPPPATH=['External'])
48 #   lib_env.Append(LINKFLAGS=['-Wl,--no-undefined'])
49
50    # Define OSG_DEBUG if needed
51    if combo["type"] in ["debug","hybrid"]:
52       lib_env.Append(CPPDEFINES=["OSG_DEBUG",])
53
54    # XXX: Apply custom options
55    #
56    # Add the define needed for declspec to know what library we are building
57    compile_define = "OSG_COMPILE%sLIB"%lib_name[3:].upper()
58    lib_env.Append(CPPDEFINES=[compile_define])
59
60    if GetPlatform() == "win32":
61
62       lib_env.Append(LIBS = ["MSVCPRT$DEBUG_CHAR", "MSVCRT$DEBUG_CHAR"])
63
64       if "debug" == combo["type"] or "hybrid" == combo["type"]:
65          lib_env["DEBUG_CHAR"]='D'
66       else:
67          lib_env["DEBUG_CHAR"]=''
68
69    shared_lib = lib_env.SharedLibrary(full_lib_name, library.source_files)
70    shared_lib_inst = lib_env.Install(inst_paths['lib_inst_combo'], shared_lib)
71      
72    # If default combo type, then make links from lib dir
73    if default_combo_type == combo["type"] and (GetPlatform() != "win32"):
74       lib_env.Install(inst_paths["lib"], shared_lib_inst)     
75    
76    # Install headers (but only do it once during variant_pass 0 )
77    if variant_pass == 0:     
78       lib_env.Install(pj(inst_paths["include"],"OpenSG"), library.header_files)
79    
80    # ---- Build Tests ---- #   
81    # Verify we have all the deps for the tests
82    #   todo: How do we verify the "other test libs"
83    have_test_deps = True
84    for n in library.osg_test_libs:
85       if not lib_map.has_key(n):
86          have_test_deps = False
87          print "   missing test dep library:", n
88    
89    if have_test_deps:
90       # Use ConfigInfo to find build flags for building applications against this library
91       config_info = ConfigInfoAdapter([lib_name] + library.osg_test_libs,
92                                        lib_map,
93                                       osg_lib_suffix=shared_lib_suffix)   
94       test_env = build_env.Copy()
95       test_env.Append(CPPPATH=library.test_cpppath + config_info.getIncPath(),
96                       LIBPATH=library.test_libpath + [inst_paths["lib_inst_combo"]] + config_info.getLibPath(),
97                       LIBS=config_info.getLibs() + library.other_test_libs,
98                       FRAMEWORKPATH=config_info.getFrameworkPath(),
99                       FRAMEWORKS=config_info.getFrameworks())
100
101       test_env.Append(CPPPATH=['External'])
102
103       if GetPlatform() == "win32":
104
105         test_env.Append(LIBS = ["MSVCPRT$DEBUG_CHAR", "MSVCRT$DEBUG_CHAR"])
106
107         if "debug" == combo["type"] or "hybrid" == combo["type"]:
108             test_env["DEBUG_CHAR"]='D'
109         else:
110             test_env["DEBUG_CHAR"]=''
111    
112       # - Build them all in the local 'test' subdir
113       for s in library.test_files:
114          test_env.Program(target= pj("..","test",os.path.splitext(os.path.basename(s))[0]),
115                           source=s)
116    
117       # ---- Build Unit Tests ---- #   
118       # - Build them all in the unittest directory
119       if build_env["enable_unittests"] and (len(library.unittest_files) > 0):         
120          unittest_env = test_env.Copy()
121          unittest_env.Append(CPPPATH=unittest_inc,
122                              LIBPATH=unittest_libpath,
123                              LIBS=unittest_lib)
124
125          if GetPlatform() == "win32":
126
127             unittest_env.Append(LIBS = ["MSVCPRT$DEBUG_CHAR", "MSVCRT$DEBUG_CHAR"])
128
129             if "debug" == combo["type"] or "hybrid" == combo["type"]:
130                 unittest_env["DEBUG_CHAR"]='D'
131                 unittest_env["UTDBGDIR"]='dbg'
132             else:
133                 unittest_env["DEBUG_CHAR"]=''
134                 unittest_env["UTDBGDIR"]='opt'
135
136          unittest_env.Append(CPPPATH=['External'])
137
138          runner_obj = unittest_env.Object(target=pj("..","unittest","run"+lib_name), source=unittest_runner)
139          runner = unittest_env.Program(pj("..","unittest","run"+lib_name),
140                                        library.unittest_files + [str(runner_obj[0])])
141
142          # Run the Test once the program is built
143          def runTest(target, source, env):
144             path = ""
145             for i in env["LIBPATH"]:
146                 path += i + os.pathsep
147             path = path[:-1]
148            
149             ev = os.environ
150             if GetPlatform() == "win32":
151                 key = "PATH"
152             elif GetPlatform() == "darwin":
153                 key = "DYLD_LIBRARY_PATH"
154             else:
155                 key = "LD_LIBRARY_PATH"
156                
157             if ev.has_key(key):
158                 ev[key] = path + os.pathsep + ev[key]
159             else:
160                 ev[key] = path
161            
162             print "TEST SUITE: [%s]"%(target[0],)
163             prog = str(target[0])
164             exit_code = os.spawnle(os.P_WAIT, prog, prog, ev)
165            
166             if exit_code != 0:
167                 Exit(exit_code)
168
169          AddPostAction(runner, runTest)
170
171      
172    # Done   
173 if not verbose_build:
174    print ""
Note: See TracBrowser for help on using the browser.