| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
import sys |
|---|
| 8 |
import os |
|---|
| 9 |
pj = os.path.join |
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
import SCons.Environment |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
try: |
|---|
| 19 |
import SConsAddons.Util |
|---|
| 20 |
print "Using SConsAddons from: ", os.path.dirname(SConsAddons.Util.__file__) |
|---|
| 21 |
except: |
|---|
| 22 |
sys.path.insert(0,pj('../Tools','scons-addons','src')) |
|---|
| 23 |
print "Using SConsAddons from: ../Tools/scons-addons/src" |
|---|
| 24 |
|
|---|
| 25 |
import SConsAddons.Options as sca_opts |
|---|
| 26 |
import SConsAddons.Options.OpenSG2 |
|---|
| 27 |
import SConsAddons.Options.Boost |
|---|
| 28 |
from SConsAddons.EnvironmentBuilder import EnvironmentBuilder |
|---|
| 29 |
import SConsAddons.Util as sca_util |
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
EnsureSConsVersion(0,96) |
|---|
| 33 |
SetOption('max_drift',30) |
|---|
| 34 |
SetOption('implicit_cache',1) |
|---|
| 35 |
SConsignFile('.sconsign.'+sca_util.GetPlatform()) |
|---|
| 36 |
|
|---|
| 37 |
GetPlatform = sca_util.GetPlatform |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
if GetPlatform() == "win32": |
|---|
| 44 |
opt_env = Environment() |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
else: |
|---|
| 48 |
opt_env = Environment(ENV = os.environ) |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
default_types = ['optimized', 'debug'] |
|---|
| 52 |
if GetPlatform() == 'win32': |
|---|
| 53 |
default_types.append("hybrid") |
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
options_cache_filename = 'options.cache' |
|---|
| 59 |
opts = sca_opts.Options(files = [options_cache_filename, 'options.custom'], args=ARGUMENTS) |
|---|
| 60 |
|
|---|
| 61 |
opts.AddOption(sca_opts.SeparatorOption("\nBuild Variants")) |
|---|
| 62 |
opts.Add(sca_opts.EnumOption('type','Types of run-times to build.(comma separated list)', |
|---|
| 63 |
default_types[0], default_types)) |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
opensg2_options = SConsAddons.Options.OpenSG2.OpenSG2("opensg", "2.0", required=True) |
|---|
| 67 |
opensg2_options.verbose = True |
|---|
| 68 |
boost_options = sca_opts.Boost.Boost("boost", "1.31.0", libs = [], |
|---|
| 69 |
required = True , useVersion = True, useDebug=True, autoLink=True) |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
opts.AddOption(sca_opts.SeparatorOption("\nPackage Options")) |
|---|
| 73 |
opts.AddOption(opensg2_options) |
|---|
| 74 |
opts.AddOption(boost_options) |
|---|
| 75 |
|
|---|
| 76 |
help_text = """---- Tutorials Build ---- |
|---|
| 77 |
|
|---|
| 78 |
%s |
|---|
| 79 |
|
|---|
| 80 |
This file will be loaded each time. Note: Options are cached in the file: %s |
|---|
| 81 |
""" %(opts.GenerateHelpText(opt_env),options_cache_filename) |
|---|
| 82 |
Help(help_text) |
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
if not sca_util.hasHelpFlag(): |
|---|
| 88 |
opts.Process(opt_env) |
|---|
| 89 |
opts.Save(options_cache_filename, opt_env) |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
if 1: |
|---|
| 93 |
print "---- OpenSG settings ----" |
|---|
| 94 |
opensg2_options.dumpSettings() |
|---|
| 95 |
print "---- Boost settings ----" |
|---|
| 96 |
boost_options.dumpSettings() |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
combo = {'type':opt_env['type'], 'archs':'32'} |
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
env_bldr = EnvironmentBuilder() |
|---|
| 103 |
env_bldr.enableWarnings(EnvironmentBuilder.MINIMAL) |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
if combo["type"] == "debug": |
|---|
| 107 |
env_bldr.enableDebug() |
|---|
| 108 |
env_bldr.setMsvcRuntime(EnvironmentBuilder.MSVC_MT_DBG_DLL_RT) |
|---|
| 109 |
elif combo["type"] == "optimized": |
|---|
| 110 |
env_bldr.enableOpt(EnvironmentBuilder.STANDARD) |
|---|
| 111 |
env_bldr.setMsvcRuntime(EnvironmentBuilder.MSVC_MT_DLL_RT) |
|---|
| 112 |
elif combo["type"] == "hybrid": |
|---|
| 113 |
env_bldr.enableDebug() |
|---|
| 114 |
env_bldr.setMsvcRuntime(EnvironmentBuilder.MSVC_MT_DLL_RT) |
|---|
| 115 |
|
|---|
| 116 |
base_env = env_bldr.applyToEnvironment(opt_env.Copy(), variant=combo) |
|---|
| 117 |
|
|---|
| 118 |
if GetPlatform() == "win32": |
|---|
| 119 |
base_env.Append(CPPDEFINES = ['BOOST_ALL_DYN_LINK',]) |
|---|
| 120 |
base_env.Append(CPPFLAGS = ["/wd4996",]) |
|---|
| 121 |
|
|---|
| 122 |
if combo["type"] == "hybrid": |
|---|
| 123 |
base_env.Append(CPPDEFINES = ['_USE_RELEASE_RUNTIME',]) |
|---|
| 124 |
base_env.Append(LINKFLAGS = ['/NODEFAULTLIB:msvcprtd',]) |
|---|
| 125 |
base_env.Append(LINKFLAGS = ['/NODEFAULTLIB:msvcrtd',]) |
|---|
| 126 |
base_env.Append(LIBS = ['msvcprt',]) |
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
runtime_suffix = "" |
|---|
| 131 |
if combo["type"] == "debug": |
|---|
| 132 |
runtime_suffix = "_d" |
|---|
| 133 |
elif combo["type"] == "hybrid": |
|---|
| 134 |
runtime_suffix = "_h" |
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
libs=['State', 'System', 'Window', 'FileIO', 'Text', 'WIN32', 'GLUT', |
|---|
| 138 |
'Group', 'Util', 'ImageFileIO', 'Base', 'RenderTraversal', |
|---|
| 139 |
'Drawable', 'Cluster' ] |
|---|
| 140 |
opensg2_options.apply(base_env, libs=libs) |
|---|
| 141 |
boost_options.apply(base_env, useDebug=('debug' == combo['type'])) |
|---|
| 142 |
|
|---|
| 143 |
build_app = True |
|---|
| 144 |
|
|---|
| 145 |
if not opensg2_options.isAvailable(): |
|---|
| 146 |
print "OpenSG not available: Skipping viewer." |
|---|
| 147 |
build_app = False |
|---|
| 148 |
if not boost_options.isAvailable(): |
|---|
| 149 |
print "Boost not available: Skipping viewer." |
|---|
| 150 |
build_app = False |
|---|
| 151 |
|
|---|
| 152 |
if build_app: |
|---|
| 153 |
|
|---|
| 154 |
files = os.listdir('.') |
|---|
| 155 |
tutorials = [f for f in files if f.endswith('.cpp')] |
|---|
| 156 |
|
|---|
| 157 |
for file in tutorials: |
|---|
| 158 |
name = file.split('.')[0] |
|---|
| 159 |
local_env = base_env.Copy() |
|---|
| 160 |
mylibs = local_env['LIBS'] |
|---|
| 161 |
for l in open(file).readlines(): |
|---|
| 162 |
if l.startswith("// Libs:"): |
|---|
| 163 |
mylibs += ["OSG"+m for m in l[8:].split()] |
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
loader = local_env.Program(name+runtime_suffix, file, LIBS = mylibs) |
|---|
| 167 |
|
|---|
| 168 |
Default(".") |
|---|