forked from tidev/titanium-sdk
/
SConstruct
81 lines (65 loc) · 2.08 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
#!/usr/bin/env python
#
# Top level scons script
#
import os, shutil, platform, os.path as path, sys
import package
import SCons.Variables
import SCons.Environment
from SCons.Script import *
# read version from the build folder
# this is used by other python scripts too
cwd = os.path.abspath(os.path.dirname(sys._getframe(0).f_code.co_filename))
sys.path.append(path.join(cwd,"build"))
import titanium_version
version = titanium_version.version
# allow it to be overriden on command line or in env
if os.environ.has_key('PRODUCT_VERSION'):
version = os.environ['PRODUCT_VERSION']
elif ARGUMENTS.get('PRODUCT_VERSION', 0):
version = ARGUMENTS.get('PRODUCT_VERSION')
# we clean at the top-level but do incremental at the specific folder level
if os.path.exists('iphone/build'):
shutil.rmtree('iphone/build')
if os.path.exists('android/titanium/bin'):
shutil.rmtree('android/titanium/bin')
#
# this is messy, but i don't care, scons makes it too
# hard to include python after an external SConscript
#
build_dirs = []
if not ARGUMENTS.get('iphone',0):
build_dirs.append('android/titanium')
if platform.system() == "Darwin" and not ARGUMENTS.get('android',0):
build_dirs.append('iphone')
flags = ''
# TEMP until android is merged
build_type = 'full'
build_dirs = ['iphone', 'android']
if ARGUMENTS.get('iphone',0):
build_type='iphone'
build_dirs=['iphone']
if ARGUMENTS.get('android',0):
build_type='android'
build_dirs=['android']
if ARGUMENTS.get('COMPILER_FLAGS', 0):
flags = ARGUMENTS.get('COMPILER_FLAGS')
for dir in build_dirs:
d = os.getcwd()
os.chdir(dir)
try:
#output = 0
output = os.system("scons PRODUCT_VERSION=%s COMPILER_FLAGS='%s' BUILD_TYPE='%s'" % (version,flags,build_type))
if output!=0:
sys.stderr.write("BUILD FAILED!!!!\n")
# beep, please
if platform.system() == "Darwin":
os.system("say 'OH NO...the build failed!!!'")
os.system("printf \"\a\"")
os.system("printf \"\a\"")
os.system("printf \"\a\"")
sys.exit(output)
finally:
os.chdir(d)
print "Packaging MobileSDK (%s)..." % version
package.Packager().build(os.path.abspath('dist'),version)