| 1 |
|
|---|
| 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 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
lib_env = common_lib_env.Copy() |
|---|
| 24 |
full_lib_name = lib_name + shared_lib_suffix |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 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 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 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 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 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 |
|
|---|
| 53 |
if default_combo_type == combo["type"] and (GetPlatform() != "win32"): |
|---|
| 54 |
lib_env.Install(inst_paths["lib"], shared_lib_inst) |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
if variant_pass == 0: |
|---|
| 58 |
lib_env.Install(pj(inst_paths["include"],"OpenSG"), library.header_files) |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
config_info = ConfigInfoAdapter([lib_name] + library.osg_test_libs, |
|---|
| 63 |
lib_map, |
|---|
| 64 |
osg_lib_suffix=shared_lib_suffix) |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 79 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 106 |
if not verbose_build: |
|---|
| 107 |
print "" |
|---|