root/branches/Carsten_PtrWork/Source/SConscript

Revision 921, 6.2 kB (checked in by vossg, 1 year ago)

fixed : debug defines

  • 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    # Define OSG_DEBUG if needed
48    if combo["type"] in ["debug","hybrid"]:
49       lib_env.Append(CPPDEFINES=["OSG_DEBUG",])
50
51    # XXX: Apply custom options
52    #
53    # Add the define needed for declspec to know what library we are building
54    compile_define = "OSG_COMPILE%sLIB"%lib_name[3:].upper()
55    lib_env.Append(CPPDEFINES=[compile_define])
56
57    if GetPlatform() == "win32":
58
59       lib_env.Append(LIBS = ["MSVCPRT$DEBUG_CHAR", "MSVCRT$DEBUG_CHAR"])
60
61       if "debug" == combo["type"] or "hybrid" == combo["type"]:
62          lib_env["DEBUG_CHAR"]='D'
63       else:
64          lib_env["DEBUG_CHAR"]=''
65
66    shared_lib = lib_env.SharedLibrary(full_lib_name, library.source_files)
67    shared_lib_inst = lib_env.Install(inst_paths['lib_inst_combo'], shared_lib)
68      
69    # If default combo type, then make links from lib dir
70    if default_combo_type == combo["type"] and (GetPlatform() != "win32"):
71       lib_env.Install(inst_paths["lib"], shared_lib_inst)     
72    
73    # Install headers (but only do it once during variant_pass 0 )
74    if variant_pass == 0:     
75       lib_env.Install(pj(inst_paths["include"],"OpenSG"), library.header_files)
76    
77    # ---- Build Tests ---- #   
78    # Verify we have all the deps for the tests
79    #   todo: How do we verify the "other test libs"
80    have_test_deps = True
81    for n in library.osg_test_libs:
82       if not lib_map.has_key(n):
83          have_test_deps = False
84          print "   missing test dep library:", n
85    
86    if have_test_deps:
87       # Use ConfigInfo to find build flags for building applications against this library
88       config_info = ConfigInfoAdapter([lib_name] + library.osg_test_libs,
89                                        lib_map,
90                                       osg_lib_suffix=shared_lib_suffix)   
91       test_env = build_env.Copy()
92       test_env.Append(CPPPATH=library.test_cpppath + config_info.getIncPath(),
93                       LIBPATH=library.test_libpath + [inst_paths["lib_inst_combo"]] + config_info.getLibPath(),
94                       LIBS=config_info.getLibs() + library.other_test_libs,
95                       FRAMEWORKPATH=config_info.getFrameworkPath(),
96                       FRAMEWORKS=config_info.getFrameworks())
97
98       if GetPlatform() == "win32":
99
100         test_env.Append(LIBS = ["MSVCPRT$DEBUG_CHAR", "MSVCRT$DEBUG_CHAR"])
101
102         if "debug" == combo["type"] or "hybrid" == combo["type"]:
103             test_env["DEBUG_CHAR"]='D'
104         else:
105             test_env["DEBUG_CHAR"]=''
106    
107       # - Build them all in the local 'test' subdir
108       for s in library.test_files:
109          test_env.Program(target= pj("..","test",os.path.splitext(os.path.basename(s))[0]),
110                           source=s)
111    
112       # ---- Build Unit Tests ---- #   
113       # - Build them all in the unittest directory
114       if build_env["enable_unittests"] and (len(library.unittest_files) > 0):         
115          unittest_env = test_env.Copy()
116          unittest_env.Append(CPPPATH=unittest_inc,
117                              LIBPATH=unittest_libpath,
118                              LIBS=unittest_lib)
119
120          if GetPlatform() == "win32":
121
122             unittest_env.Append(LIBS = ["MSVCPRT$DEBUG_CHAR", "MSVCRT$DEBUG_CHAR"])
123
124             if "debug" == combo["type"] or "hybrid" == combo["type"]:
125                 unittest_env["DEBUG_CHAR"]='D'
126                 unittest_env["UTDBGDIR"]='dbg'
127             else:
128                 unittest_env["DEBUG_CHAR"]=''
129                 unittest_env["UTDBGDIR"]='opt'
130
131          runner_obj = unittest_env.Object(target=pj("..","unittest","run"+lib_name), source=unittest_runner)
132          runner = unittest_env.Program(pj("..","unittest","run"+lib_name),
133                                        library.unittest_files + [str(runner_obj[0])])
134
135          # Run the Test once the program is built
136          def runTest(target, source, env):
137             path = ""
138             for i in env["LIBPATH"]:
139                 path += i + os.pathsep
140             path = path[:-1]
141            
142             ev = os.environ
143             if GetPlatform() == "win32":
144                 key = "PATH"
145             elif GetPlatform() == "darwin":
146                 key = "DYLD_LIBRARY_PATH"
147             else:
148                 key = "LD_LIBRARY_PATH"
149                
150             if ev.has_key(key):
151                 ev[key] = path + os.pathsep + ev[key]
152             else:
153                 ev[key] = path
154            
155             print "TEST SUITE: [%s]"%(target[0],)
156             prog = str(target[0])
157             exit_code = os.spawnle(os.P_WAIT, prog, prog, ev)
158            
159             if exit_code != 0:
160                 Exit(exit_code)
161
162          AddPostAction(runner, runTest)
163
164      
165    # Done   
166 if not verbose_build:
167    print ""
Note: See TracBrowser for help on using the browser.