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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
# Copyright (c) 2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import fnmatch
import os
import re
import shutil
import subprocess
import utils
import SCons.Node
Import('env')
env = env.Clone()
if env['OS'] in ['win32', 'wince']:
env.Append(DATE = 'echo %DATE%.%TIME%')
else:
env.Append(DATE = 'date')
def GetInputs(var): return utils.GetInputs(var, env)
def Shell(cmd):
"""Execute a shell command and return the output."""
cmd[0] = env.Entry(cmd[0]).abspath
cmd = env.subst(cmd)
return subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE).communicate()[0]
if env['OS'] == 'win32':
def GGUIDGen(value):
"""Generate a GGUID for the given value."""
return Shell(['$GGUIDGEN', '$NAMESPACE_GUID', value + '-$VERSION'])
env.Replace(
GGUIDGEN = '#/$OPEN_DIR/tools/gguidgen.exe',
NAMESPACE_GUID = '36F65206-5D4E-4752-9D52-27708E10DA79',
# MSI version numbers must have the form <major>.<minor>.<build>. To meet this,
# we combine our build and patch version numbers like so:
# MSI_VERSION = <major>.<minor>.<BUILD * 100 + PATCH>.
# Note: This assumes that the BUILD and PATCH variables adhere to the range
# requirements in version.mk. See comments in version.mk for more details.
MSI_BUILD = eval(env.subst('$BUILD * 100 + $PATCH')),
MSI_VERSION = '${MAJOR}.${MINOR}.${MSI_BUILD}',
)
# Building wxiobjs with candle
env.Replace(
CANDLEDEFPREFIX = '-d',
CANDLEDEFSUFFIX = '',
_CANDLEDEFFLAGS = ('${_defines(CANDLEDEFPREFIX, CANDLEDEFINES, '
'CANDLEDEFSUFFIX, __env__)}'),
CANDLECOM = 'candle.exe -out $TARGET $SOURCE ${_CANDLEDEFFLAGS}',
)
env.Append(
# Note: Since light.exe is run from $OPEN_DIR, candle.exe must generate
# output with paths relative to that dir.
SCONS_DIR = '..', # the scons dir relative to OPEN_DIR
# You can change the names of ProductId vars, but NEVER change their values!
CANDLEDEFINES = [
('OurWin32ProductId',
GGUIDGen('OUR_PRODUCT_ID')),
('OurComponentGUID_FFComponentsDirFiles',
GGUIDGen('OUR_COMPONENT_GUID_FF_COMPONENTS_DIR_FILES')),
('OurComponentGUID_FFContentDirFiles',
GGUIDGen('OUR_COMPONENT_GUID_FF_CONTENT_DIR_FILES')),
('OurComponentGUID_FFDirFiles',
GGUIDGen('OUR_COMPONENT_GUID_FF_DIR_FILES')),
('OurComponentGUID_FFLibDirFiles',
GGUIDGen('OUR_COMPONENT_GUID_FF_LIB_DIR_FILES')),
('OurComponentGUID_FFRegistry',
GGUIDGen('OUR_COMPONENT_GUID_FF_REGISTRY')),
('OurComponentGUID_IEFiles',
GGUIDGen('OUR_COMPONENT_GUID_IE_FILES')),
('OurComponentGUID_IERegistry',
GGUIDGen('OUR_COMPONENT_GUID_IE_REGISTRY')),
('OurComponentGUID_SharedFiles',
GGUIDGen('OUR_COMPONENT_GUID_SHARED_FILES')),
('OurComponentGUID_SharedVersionedFiles',
GGUIDGen('OUR_COMPONENT_GUID_SHARED_VERSIONED_FILES')),
('OurComponentGUID_SharedRegistry',
GGUIDGen('OUR_COMPONENT_GUID_SHARED_REGISTRY')),
('OurNpapiProductId',
GGUIDGen('OUR_2ND_PRODUCT_ID')),
('OurComponentGUID_NpapiFiles',
GGUIDGen('OUR_COMPONENT_GUID_NPAPI_FILES')),
('OurComponentGUID_NpapiRegistry',
GGUIDGen('OUR_COMPONENT_GUID_NPAPI_REGISTRY')),
('OurMsiVersion', '$MSI_VERSION'),
('OurCommonPath', '$COMMON_OUTDIR'),
('OurIEPath', '$IE_OUTDIR'),
('OurIpcTestPath', '$COMMON_OUTDIR'),
('OurFFPath', '$INSTALLER_OUTDIR/$INSTALLER_BASENAME'),
('OurNpapiPath', '$NPAPI_OUTDIR'),
]
)
wix_langs = [re.sub('-', '_', lang) for lang in env['I18N_LANGS']]
env.Append(
CANDLEDEFINES =
[('OurComponentGUID_FFLang' + lang + 'DirFiles',
GGUIDGen('OUR_COMPONENT_GUID_FF_' + lang + '_DIR_FILES'))
for lang in wix_langs],
)
def SafeMkdir(dir):
"""Like the builtin Mkdir, but doesn't fail if the dir exists."""
def Func(target, source, env):
dir_subst = env.subst(dir, target=target)
if not os.path.exists(dir_subst):
os.makedirs(dir_subst)
return 0
return Action(Func, 'SafeMkdir("' + dir + '")')
def RecursiveDelete(pattern):
"""Recursively deletes directories matching a pattern."""
def Func(target, source, env):
# strip off '.dir' suffix
target_dir = env.subst('${TARGET.base}', target=target)
for root, dirs, files in os.walk(target_dir):
if fnmatch.fnmatch(os.path.normpath(root), pattern):
print 'Deleting', root
shutil.rmtree(root)
return 0
return Action(Func, 'RecursiveDelete("' + pattern + '")')
def ToUnixPath(path):
"""Converts windows-style \ to unix-style /."""
return re.sub(r'\\', r'/', path)
def DirBuilder(env, dirtarget, dirsrcs):
"""Builder that makes a directory tree by copying source files to
corresponding locations inside 'dirtarget'. 'dirsrcs' specifies the list of
mappings from source file/directory to the target location. It's formatted
like:
(<target file or dir>, <list of source files>)
Note: source files that come from an output directory must be explicitly
specified relative to the toplevel dir '#'.
Note: as shorthand, if the target ends with a '/', then the sources will
be placed into that dir. Otherwise, source is renamed into the target.
"""
srcs = []
actions = [Delete('${TARGET.base}')]
for target, sources in dirsrcs:
target_is_dir = target.endswith('/')
if target_is_dir:
actions.append(SafeMkdir('${TARGET.base}/' + target))
else:
actions.append(SafeMkdir('${TARGET.base}/' + os.path.dirname(target)))
for source in env.Flatten(sources):
source = env.subst(source, conv=lambda x:x)
srcs.append(source)
# Special-case for Nodes and Node lists: use their absolute paths for
# the Copy() action, otherwise it will be relative to our variant dir
# (not what Copy expects).
if isinstance(source, list): source = source[0]
if isinstance(source, SCons.Node.Node): source = source.abspath
# HACK: Compensate for the workaround below. We want the .dir file
# to be the dependency to the Command() builder, but we want to copy
# the actual directory - so strip the extension here.
if source.endswith('.dir'):
source = source[:-4]
if target_is_dir:
actions.append(
Copy('${TARGET.base}/' + target + os.path.basename(source),
source))
else:
actions.append(Copy('${TARGET.base}/' + target, source))
# Remove any .svn directories that were copied.
actions.append(RecursiveDelete('*/.svn'))
# HACK: Workaround for bug in scons where directories aren't checked for
# dependency changes. Instead, we make a temp file the target, and ensure
# that that file changes everytime we execute these actions.
# See http://scons.tigris.org/issues/show_bug.cgi?id=2261
actions += ['$DATE > ${TARGET}']
return env.Command(env.subst(dirtarget) + '.dir', srcs, actions)
env.AddMethod(DirBuilder)
def FirefoxInstaller():
dirsrcs = [
('/', ['$FF3_OUTDIR/genfiles/install.rdf',
'$FF3_OUTDIR/genfiles/chrome.manifest']),
('lib/', ['$OPEN_DIR/base/firefox/static_files/lib/updater.js']),
('chrome/chromeFiles/content/',
GetInputs('$FF3_RESOURCES $COMMON_RESOURCES')),
('chrome/chromeFiles/locale', ['$FF3_OUTDIR/genfiles/i18n']),
('components/',
['$FF3_MODULE_TYPELIB',
'$OPEN_DIR/base/firefox/static_files/components/bootstrap.js']),
('components/${SHLIBPREFIX}gears${SHLIBSUFFIX}', ['$FF2_MODULE']),
('components/${SHLIBPREFIX}gears_ff2${SHLIBSUFFIX}', ['$FF3_MODULE']),
]
if env['USING_CCTESTS']:
dirsrcs += [
('components/', ['$IPC_TEST_EXE']),
]
if env['OS'] != 'win32':
# TODO(playmobil): Inspector should be located in extensions dir on win32.
dirsrcs += [
('resources/inspector', [env.Dir('#/$OPEN_DIR/inspector')]),
('resources/inspector/common/', ['$OPEN_DIR/sdk/gears_init.js',
'$OPEN_DIR/sdk/samples/sample.js']),
]
if env['MODE'] == 'dbg' and env['OS'] in ['win32', 'wince']:
dirsrcs += [
('components/gears_ff2.pdb', ['$FF2_MODULE_PDB']),
('components/gears.pdb', ['$FF3_MODULE_PDB']),
]
if env['OS'] == 'osx':
dirsrcs += [
('resources/', ['$OSX_LAUNCHURL_EXE']),
]
dir = env.DirBuilder('$INSTALLER_OUTDIR/$INSTALLER_BASENAME', dirsrcs)
actions = [
# Mark files writeable to allow .xpi rebuilds
'chmod -R 777 ${SOURCE.base}',
'(cd ${SOURCE.base} && zip -r ../${TARGET.file} .)'
]
return env.Command('$FF_XPI', dir, actions)
firefox_installer = FirefoxInstaller()
def Win32Installer():
wxiobj = env.Command(
'$COMMON_GENFILES_DIR/win32_msi.wxiobj',
'$COMMON_GENFILES_DIR/win32_msi.wxs',
'$CANDLECOM')
# TODO(mpcomplete): remove this if/when the notifier goes away. This
# creates fake targets to satisfy the installer build.
notifier = env.Command(
[
'$COMMON_OUTDIR/notifier.exe',
'$COMMON_OUTDIR/notifier.dll',
'$COMMON_OUTDIR/notifier_test.exe'
], [],
'touch $TARGETS')
# light.exe must be run from $OPEN_DIR
msi = env.Command(
'$WIN32_INSTALLER_MSI',
[wxiobj, notifier, firefox_installer, '$IE_MODULE', '$NPAPI_MODULE'],
'cd $OPEN_DIR && light.exe -out ${TARGET.abspath} ${SOURCES[0].abspath}')
return msi
win32_installer = Win32Installer()
def WinCEInstaller():
env['ToUnixPath'] = ToUnixPath
inf_outdir = ToUnixPath(env.subst('$IE_OUTDIR'))
inf = env.Command(
'$COMMON_GENFILES_DIR/wince_cab_fixed.inf',
'$COMMON_GENFILES_DIR/wince_cab.inf',
'sed -e "s#bin-....wince-arm.ie.#' + inf_outdir + '#g" $SOURCE > $TARGET')
cab = env.Command(
'$WINCE_INSTALLER_CAB',
[inf, '$IE_MODULE', '$IE_WINCE_SETUP_DLL'],
['cabwiz ${ToUnixPath(str(SOURCE))} /compress'
' /err ${SOURCES[0].base}.log',
Copy('$TARGET', '${SOURCE.base}.CAB')])
return cab
wince_installer = WinCEInstaller()
def SafariPluginBundle():
"""This is the actual gears plugin bundle for Safari."""
dirsrcs = [
('Contents/', ['$SF_OUTDIR/genfiles/Info.plist']),
('Contents/Resources/English.lproj/InfoPlist.strings',
['$OPEN_DIR/tools/osx/English.lproj/InfoPlist.strings']),
('Contents/Resources/', env.Glob('#/$OPEN_DIR/ui/safari/*.nib')),
('Contents/Resources/', ['$CRASH_SENDER_EXE']),
('Contents/Resources/', ['$OSX_CRASH_INSPECTOR_EXE']),
('Contents/Resources/', ['$OSX_LAUNCHURL_EXE']),
('Contents/MacOS/', ['$SF_MODULE']),
]
if env['USING_CCTESTS']:
dirsrcs += [
('Contents/Resources/', ['$IPC_TEST_EXE']),
]
return env.DirBuilder('$SF_PLUGIN_BUNDLE', dirsrcs)
safari_plugin_bundle = SafariPluginBundle()
def SafariPluginProxyBundle():
"""This is a proxy plugin which simply loads gears into Safari and keeps
it in memory. It exists so that gears doesn't unload when Safari wants us
to, since that causes crashes."""
dirsrcs = [
('Contents/', ['$SF_OUTDIR/genfiles/Info.plist']),
('Contents/MacOS/${SHLIBPREFIX}gears${SHLIBSUFFIX}', ['$SF_PROXY_DLL']),
('Contents/Resources/', [safari_plugin_bundle]),
('Contents/Resources/', ['$OPEN_DIR/tools/osx/uninstall.command']),
]
return env.DirBuilder('$SF_PLUGIN_PROXY_BUNDLE', dirsrcs)
safari_plugin_proxy_bundle = SafariPluginProxyBundle()
def SafariInstallerPluginBundle():
dirsrcs = [
('Contents/Info.plist',
['$OPEN_DIR/base/safari/advanced_stats_sheet.plist']),
('Contents/MacOS/', ['$SF_INSTALLER_PLUGIN_EXE']),
('Contents/Resources/AdvancedStatsSheet.nib',
[env.Dir('#/$OPEN_DIR/base/safari/advanced_stats_sheet.nib')]),
]
return env.DirBuilder('$SF_INSTALLER_PLUGIN_BUNDLE', dirsrcs)
safari_installer_plugin_bundle = SafariInstallerPluginBundle()
def SafariInputManagerBundle():
info = env.Command('$SF_OUTDIR/genfiles/Enabler-Info.plist',
'$OPEN_DIR/tools/osx/Enabler-Info.plist',
'cat $SOURCE |'
'sed \'s/$${EXECUTABLE_NAME}/GearsEnabler/\' |'
'sed \'s/$${PRODUCT_NAME}/GearsEnabler/\' > $TARGET')
dirsrcs = [
('Contents/Info.plist', [info]),
('Contents/MacOS/', ['$SF_INPUTMANAGER_EXE']),
('Contents/Resources/English.lproj/',
['$OPEN_DIR/tools/osx/English.lproj/InfoPlist.strings']),
]
return env.DirBuilder('$SF_INPUTMANAGER_BUNDLE', dirsrcs)
safari_input_manager_bundle = SafariInputManagerBundle()
def SafariInstallerPackage():
pkg = env.Iceberg(env.Dir('${SF_INSTALLER_PKG}'),
[
'$SF_OUTDIR/genfiles/installer.packproj',
safari_plugin_proxy_bundle,
safari_input_manager_bundle,
])
return pkg
safari_installer_package = SafariInstallerPackage()
installers = []
if 'FF3' in env['VALID_BROWSERS']:
installers += firefox_installer
if 'SF' in env['VALID_BROWSERS']:
installers += [
safari_input_manager_bundle,
safari_plugin_bundle,
safari_plugin_proxy_bundle,
safari_installer_plugin_bundle,
safari_installer_package,
safari_input_manager_bundle,
]
if env['OS'] == 'win32':
installers += win32_installer
if env['OS'] == 'wince':
installers += wince_installer
env.Alias('gears-installers', installers)
|