forked from appcelerator-archive/titanium_desktop
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SConscript.dist
100 lines (79 loc) · 3.45 KB
/
SConscript.dist
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
89
90
91
92
93
94
95
96
97
98
99
Import('build')
import os.path as path
import effess
import os
import zipfile
import sys
from glob import glob
# Network installable zip files for distribution. We must
# encase this in a builder because the files necessary for zipping
# don't exist when this file is processed.
excludes = ['.pdb', '.exp', '.ilk', '.db', '.gitignore','.psd', '.xib'
'.cpp', '.obj', '.pyc', 'SConscript', '.xib']
sdk_dir = path.join(build.dir, 'sdk')
def build_dist_zips(target, source, env):
f = path.join(build.dist_dir, 'runtime-%s.zip' % build.version)
if not(path.isdir(build.dist_dir)):
os.makedirs(build.dist_dir)
print "Packing %s" % f
effess.make_zip(build.runtime_build_dir, f, exclude=excludes)
for m in build.modules:
f = path.join(build.dist_dir, 'module-%s-%s.zip' % (m.name, m.version))
print "Packing %s" % f
effess.make_zip(m.dir, f, exclude=excludes)
def build_sdk(target, source, env):
sdkZipPath = path.join(build.dist_dir, 'sdk-%s.zip' % build.version)
print "Packing %s " % sdkZipPath
sdkZip = zipfile.ZipFile(sdkZipPath, 'w', zipfile.ZIP_DEFLATED)
def buildRuntimeZip(file):
relativePath = file.replace(build.runtime_build_dir, '')
zipPath = '/'.join(['runtime', build.os, build.version, relativePath])
effess.add_to_zip(sdkZip, file, zipPath)
effess.walk_dir(build.runtime_build_dir, buildRuntimeZip, exclude=excludes, dirs=True)
def buildModuleZip(file, module):
relativePath = file.replace(m.dir, '')
zipPath = '/'.join(['modules', build.os, module.name, build.version, relativePath])
effess.add_to_zip(sdkZip, file, zipPath)
for m in build.modules:
effess.walk_dir(m.dir, lambda f: buildModuleZip(f, m), exclude=excludes, dirs=True)
def sdkPath(*args):
return '/'.join(['sdk', build.os, build.version] + list(args))
def bundleSupport(supportDir,recurse=False):
for root, dirs, files in os.walk(supportDir):
if recurse or root == supportDir:
for file in files:
relativeFile = os.path.join(root[len(supportDir)+1:], file)
absoluteFile = os.path.join(root, file)
fileExt = os.path.splitext(relativeFile)[1]
exclude = fileExt in excludes or file == fileExt
if not exclude and path.isfile(absoluteFile):
zipPath = '/'.join(relativeFile.split(os.sep))
sdkZip.write(absoluteFile, sdkPath(zipPath))
bundleSupport(sdk_dir, recurse=True)
sdkZip.close()
build.env.Append(BUILDERS = {'BuildSDK' : Builder(action=build_sdk)})
build.env.Append(BUILDERS = {'BuildDistZips' : Builder(action=build_dist_zips)})
zips = build.env.BuildDistZips('#dummy-dist-zips', [])
build.mark_dist_target(zips)
AlwaysBuild(zips)
sdk_target = build.env.BuildSDK('build-sdk', [])
build.env.Depends(sdk_target, zips)
build.mark_dist_target(sdk_target)
AlwaysBuild(sdk_target)
# Copy the SDK files to the SDK build directory.
if not(path.exists(sdk_dir)):
os.makedirs(sdk_dir)
effess.lightweight_copy_tree(path.join(build.titanium_sdk_dir, build.os),
sdk_dir, exclude=excludes)
effess.copy_to_dir(glob(path.join(build.titanium_sdk_dir, "*.py")),
sdk_dir, exclude=excludes)
effess.copy_to_dir(glob(path.join(build.kroll_source_dir, 'tools', "effess.py")),
sdk_dir, exclude=excludes)
if build.is_osx():
os.system('ibtool --errors --warnings --notices ' + \
'--output-format human-readable-text --compile %s %s' % \
(path.join(sdk_dir, 'MainMenu.nib'),
path.join(build.titanium_sdk_dir, 'osx', 'MainMenu.xib')))
if build.is_win32():
effess.copy_to_dir(build.tp('microsoft', 'Microsoft_VC80_CRT_x86.msm'),
path.join(sdk_dir, 'installer'))