| 1 |
|
|---|
| 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 |
|
|---|
| 17 |
|
|---|
| 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 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
lib_env = common_lib_env.Copy() |
|---|
| 32 |
full_lib_name = lib_name + shared_lib_suffix |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 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 |
|
|---|
| 42 |
lib_env.Append(CPPPATH=config_info.getIncPath(), |
|---|
| 43 |
CXXFLAGS=config_info.getCXXFlags(), |
|---|
| 44 |
LIBPATH=[inst_paths["lib_inst_combo"]] + config_info.getLibPath(), |
|---|
| 45 |
LIBS=dep_libs, |
|---|
| 46 |
FRAMEWORKPATH=config_info.getFrameworkPath(), |
|---|
| 47 |
FRAMEWORKS=config_info.getFrameworks()) |
|---|
| 48 |
|
|---|
| 49 |
lib_env.Append(CPPPATH=['External']) |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
if combo["type"] in ["debugrt","debug"]: |
|---|
| 54 |
lib_env.Append(CPPDEFINES=["OSG_DEBUG",]) |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
compile_define = "OSG_COMPILE%sLIB"%lib_name[3:].upper() |
|---|
| 60 |
lib_env.Append(CPPDEFINES=[compile_define]) |
|---|
| 61 |
|
|---|
| 62 |
if GetPlatform() == "win32": |
|---|
| 63 |
|
|---|
| 64 |
lib_env.Append(LIBS = ["MSVCPRT$DEBUG_CHAR", "MSVCRT$DEBUG_CHAR"]) |
|---|
| 65 |
|
|---|
| 66 |
lib_env.Append(CPPDEFINES=['_WIN32_WINNT=0x0400', |
|---|
| 67 |
'WINVER=0x0400']); |
|---|
| 68 |
|
|---|
| 69 |
if "debugrt" == combo["type"]: |
|---|
| 70 |
lib_env["DEBUG_CHAR"]='D' |
|---|
| 71 |
else: |
|---|
| 72 |
lib_env["DEBUG_CHAR"]='' |
|---|
| 73 |
|
|---|
| 74 |
shared_lib = lib_env.SharedLibrary(full_lib_name, library.source_files) |
|---|
| 75 |
|
|---|
| 76 |
if GetPlatform() == "win32": |
|---|
| 77 |
lib_env.AddPostAction(shared_lib, 'mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;2') |
|---|
| 78 |
|
|---|
| 79 |
shared_lib_inst = lib_env.Install(inst_paths['lib_inst_combo'], shared_lib) |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
if default_combo_type == combo["type"] and (GetPlatform() != "win32"): |
|---|
| 83 |
lib_env.Install(inst_paths["lib"], shared_lib_inst) |
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
if variant_pass == 0: |
|---|
| 87 |
lib_env.Install(pj(inst_paths["include"],"OpenSG"), library.header_files) |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
have_test_deps = True |
|---|
| 93 |
for n in library.osg_test_libs: |
|---|
| 94 |
if not lib_map.has_key(n): |
|---|
| 95 |
have_test_deps = False |
|---|
| 96 |
print " missing test dep library:", n |
|---|
| 97 |
|
|---|
| 98 |
if have_test_deps: |
|---|
| 99 |
|
|---|
| 100 |
config_info = ConfigInfoAdapter([lib_name] + library.osg_test_libs, |
|---|
| 101 |
lib_map, |
|---|
| 102 |
osg_lib_suffix=shared_lib_suffix) |
|---|
| 103 |
test_env = build_env.Copy() |
|---|
| 104 |
test_env.Append(CPPPATH=library.test_cpppath + config_info.getIncPath(), |
|---|
| 105 |
CXXFLAGS=config_info.getCXXFlags(), |
|---|
| 106 |
LIBPATH=library.test_libpath + [inst_paths["lib_inst_combo"]] + config_info.getLibPath(), |
|---|
| 107 |
LIBS=config_info.getLibs() + library.other_test_libs, |
|---|
| 108 |
FRAMEWORKPATH=config_info.getFrameworkPath(), |
|---|
| 109 |
FRAMEWORKS=config_info.getFrameworks()) |
|---|
| 110 |
|
|---|
| 111 |
test_env.Append(CPPPATH=['External']) |
|---|
| 112 |
|
|---|
| 113 |
if GetPlatform() == "win32": |
|---|
| 114 |
|
|---|
| 115 |
test_env.Append(LIBS = ["MSVCPRT$DEBUG_CHAR", "MSVCRT$DEBUG_CHAR"]) |
|---|
| 116 |
test_env.Append(CPPDEFINES=['_WIN32_WINNT=0x0400', |
|---|
| 117 |
'WINVER=0x0400']); |
|---|
| 118 |
|
|---|
| 119 |
if "debugrt" == combo["type"]: |
|---|
| 120 |
test_env["DEBUG_CHAR"]='D' |
|---|
| 121 |
else: |
|---|
| 122 |
test_env["DEBUG_CHAR"]='' |
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
for s in library.test_files: |
|---|
| 126 |
test_env.Program(target= pj("..","test",os.path.splitext(os.path.basename(s))[0]), |
|---|
| 127 |
source=s) |
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
if build_env["enable_unittests"] and (len(library.unittest_files) > 0): |
|---|
| 132 |
unittest_env = test_env.Copy() |
|---|
| 133 |
unittest_env.Append(CPPPATH=unittest_inc, |
|---|
| 134 |
LIBPATH=unittest_libpath, |
|---|
| 135 |
LIBS=unittest_lib) |
|---|
| 136 |
|
|---|
| 137 |
if GetPlatform() == "win32": |
|---|
| 138 |
|
|---|
| 139 |
unittest_env.Append(LIBS = ["MSVCPRT$DEBUG_CHAR", "MSVCRT$DEBUG_CHAR"]) |
|---|
| 140 |
unittest_env.Append(CPPDEFINES=['_WIN32_WINNT=0x0400', |
|---|
| 141 |
'WINVER=0x0400']); |
|---|
| 142 |
|
|---|
| 143 |
if "debugrt" == combo["type"]: |
|---|
| 144 |
unittest_env["DEBUG_CHAR"]='D' |
|---|
| 145 |
unittest_env["UTDBGDIR"]='dbg' |
|---|
| 146 |
else: |
|---|
| 147 |
unittest_env["DEBUG_CHAR"]='' |
|---|
| 148 |
unittest_env["UTDBGDIR"]='opt' |
|---|
| 149 |
|
|---|
| 150 |
unittest_env.Append(CPPPATH=['External']) |
|---|
| 151 |
|
|---|
| 152 |
runner_obj = unittest_env.Object(target=pj("..","unittest","run"+lib_name), source=unittest_runner) |
|---|
| 153 |
runner = unittest_env.Program(pj("..","unittest","run"+lib_name), |
|---|
| 154 |
library.unittest_files + [str(runner_obj[0])]) |
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
def runTest(target, source, env): |
|---|
| 158 |
path = "" |
|---|
| 159 |
for i in env["LIBPATH"]: |
|---|
| 160 |
path += i + os.pathsep |
|---|
| 161 |
path = path[:-1] |
|---|
| 162 |
|
|---|
| 163 |
ev = os.environ |
|---|
| 164 |
if GetPlatform() == "win32": |
|---|
| 165 |
key = "PATH" |
|---|
| 166 |
elif GetPlatform() == "darwin": |
|---|
| 167 |
key = "DYLD_LIBRARY_PATH" |
|---|
| 168 |
else: |
|---|
| 169 |
key = "LD_LIBRARY_PATH" |
|---|
| 170 |
|
|---|
| 171 |
if ev.has_key(key): |
|---|
| 172 |
ev[key] = path + os.pathsep + ev[key] |
|---|
| 173 |
else: |
|---|
| 174 |
ev[key] = path |
|---|
| 175 |
|
|---|
| 176 |
print "TEST SUITE: [%s]"%(target[0],) |
|---|
| 177 |
prog = str(target[0]) |
|---|
| 178 |
exit_code = os.spawnle(os.P_WAIT, prog, prog, ev) |
|---|
| 179 |
|
|---|
| 180 |
if exit_code != 0: |
|---|
| 181 |
Exit(exit_code) |
|---|
| 182 |
|
|---|
| 183 |
AddPostAction(runner, runTest) |
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
if not verbose_build: |
|---|
| 188 |
print "" |
|---|