-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSConstruct
88 lines (73 loc) · 2.5 KB
/
SConstruct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#
# Copyright 2010-2014 Fabric Software Inc. All rights reserved.
#
import os, sys, platform
if not platform.system().lower().startswith('win'):
raise Exception("This extension only builds for Windows.")
thirdpartyDirs = {
'FABRIC_DIR': "Should point to Fabric Engine's installation folder.",
'BOOST_INCLUDE_DIR': "Should point to Boost include folder.",
'BOOST_LIBRARY_DIR': "Should point to Boost library folder."
}
# help debug print
if GetOption('help'):
print ''
print 'Fabric Engine extension build script.'
print '-----------------------------------'
print 'Required environment variables: '
for thirdpartyDir in thirdpartyDirs:
print thirdpartyDir + ': ' + thirdpartyDirs[thirdpartyDir]
print ''
Exit()
# helper functions
def which(program):
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if platform.system() == 'Windows':
exe_file += ".exe"
if is_exe(exe_file):
return exe_file
return None
#determine the suffix for the extension
extSuffix = platform.system()+'-x86_64.dll'
Export('extSuffix')
# try to find kl2edk and kl
kl2edk = which('kl2edk')
if kl2edk is None:
raise Exception('kl2edk could not be found on the PATH.')
kl = which('kl')
if kl is None:
raise Exception('kl could not be found on the PATH.')
Export('kl2edk', 'kl')
# setup the environment and define some methods
def RunKL2EDK(
env,
targets,
sources
):
targetFolder = os.path.split(targets[0].path)[0]
cmdLine = [[kl2edk] + [sources[0].srcnode().path]]
cmdLine[0] += ['-o', targetFolder]
result = env.Command(
targets,
sources,
cmdLine
)
return result
# for windows for now use Visual Studio 2010.
# if you upgrade this you will also have to provide
# boost libs for the corresponding VS version
env = Environment(ENV = os.environ, MSVC_VERSION='10.0')
env.AddMethod(RunKL2EDK)
# find the third party libs
for thirdpartyDir in thirdpartyDirs:
if not os.environ.has_key(thirdpartyDir):
raise Exception(thirdpartyDir+' env variable not defined. '+thirdpartyDirs[thirdpartyDir])
env.Append(CPPPATH = [os.path.join(os.environ['FABRIC_DIR'], 'include')])
env.Append(CPPPATH = [os.environ['BOOST_INCLUDE_DIR']])
env.Append(LIBPATH = [os.environ['BOOST_LIBRARY_DIR']])
alias = SConscript('src/SConscript', variant_dir = 'build', exports = {'parentEnv': env, 'STAGE_DIR': env.Dir('stage')}, duplicate=0)
env.Default(alias)