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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
# 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.
# Notes:
# This assumes you have a working gears checkout from p4 in the current dir.
# Steps for this:
# > echo %USER%-chromegears > p4config
# > set P4CONFIG=p4config
# > g4 client -p //depot/googleclient/gears/p4_depot_paths
# > g4 sync
#
# This is a work-in-progress conversion of the current Gears set of Makefiles.
# A lot of the stuff doesn't translate to SCons-land well, and I'm not sure
# how faithful we want to be to the original.
#
# Questions:
# Should we flatten the output directory into
# Hammer/gears/platform/browser/*.obj like Gears does now? If so, how?
# Notes to self:
# - os.path.abspath('.') (the CWD) is variant_dir if it exists, else it's the
# toplevel_dir (which contains the SConstruct).
# - env.Entry('.') is the entry representing the variant_dir.
# - env.Entry('#') is the entry representing the toplevel_dir.
# - str(entry) gives the path relative to variant_dir, or abspath if the entry
# is outside the variant_dir.
# - entry.path gives the path relative to toplevel_dir.
# - entry.abspath gives the absolute path.
import os
Import('env')
env = env.Clone(
OPEN_DIR = "googleclient/gears/opensource/gears",
THIRD_PARTY_DIR = "googleclient/gears/opensource/third_party",
GENFILES_DIR = "genfiles",
PRIVATE_THIRD_PARTY_DIR = "googleclient/third_party",
)
# Argument switches
# TODO: how do we detect linux vs osx?
os_guess = env['PLATFORM']
if os_guess == 'posix':
os_guess = 'linux'
elif os_guess == 'darwin':
os_guess = 'osx'
# Map of OS -> valid browser targets for that OS.
os_browsers_map = {
'win32': ['IE', 'FF2', 'FF3', 'NPAPI'],
'wince': ['IE'],
'linux': ['FF2', 'FF3'],
'osx': ['SF'],
'android': ['NPAPI'],
}
vars = Variables(None, ARGUMENTS)
vars.AddVariables(
EnumVariable('OS',
'Which OS is the target', os_guess, os_browsers_map.keys()),
EnumVariable('MODE',
'Type of binary to generate', 'dbg', ['dbg', 'opt']),
BoolVariable('OFFICIAL_BUILD',
'Create a binary suitable for public release', 0)
)
vars.Update(env)
env['VALID_BROWSERS'] = os_browsers_map[env['OS']]
# Add BROWSER last, since its valid inputs depend on $OS.
vars.Add(
EnumVariable('BROWSER',
'Which browser we want to build the plugin for. "all" builds all '
'browsers for this OS.',
'all', env['VALID_BROWSERS'] + ['all']))
vars.Update(env)
env.Replace(
USING_CCTESTS = (env['MODE'] == 'dbg' or not env['OFFICIAL_BUILD'])
)
# Version
env.Replace(
MAJOR = '0',
MINOR = '4',
BUILD = '22',
PATCH = '0',
VERSION = '${MAJOR}.${MINOR}.${BUILD}.${PATCH}',
FRIENDLY_NAME = 'Google Gears',
SHORT_NAME = 'gears',
)
# Platform
env.Replace(ARCH = 'i386')
# Output dirs
env.Replace(
BASE_OUTDIR = env.subst('$MODE').lower(),
COMMON_OUTDIR = '$BASE_OUTDIR/common',
IE_OUTDIR = '$BASE_OUTDIR/ie',
FF2_OUTDIR = '$BASE_OUTDIR/ff2',
FF3_OUTDIR = '$BASE_OUTDIR/ff3',
NPAPI_OUTDIR = '$BASE_OUTDIR/npapi',
SF_OUTDIR = '$BASE_OUTDIR/sf',
)
# Add GNU tools to the PATH.
env.PrependENVPath('PATH',
env.Dir('#/$PRIVATE_THIRD_PARTY_DIR/gnu/files').abspath)
env.PrependENVPath('PATH',
env.Dir('#/$PRIVATE_THIRD_PARTY_DIR/python_24').abspath)
env.Tool('m4')
# C++ build flags.
# Clear out the inherited defines from Chrome's build. I want to match Gears'
# current build as closely as possible until we switch everyone to SCons, then
# gradually integrate.
env.Replace(
CPPPATH = [
'$OPEN_DIR',
'$OPEN_DIR/..',
'$THIRD_PARTY_DIR',
'$THIRD_PARTY_DIR/breakpad/src',
'$THIRD_PARTY_DIR/googleurl',
'$THIRD_PARTY_DIR/npapi',
'$THIRD_PARTY_DIR/zlib',
'$THIRD_PARTY_DIR/v8/bindings_local',
'.',
],
LIBPATH = [
'$LIBS_DIR',
],
CCFLAGS = [],
CPPDEFINES = [],
LIBS = [],
LINKFLAGS = [],
)
if env['MODE'] == 'dbg':
env.Append(
CPPDEFINES = [
'DEBUG=1',
'_DEBUG=1',
],
M4FLAGS = '-DDEBUG=1',
)
else:
env.Append(
CPPDEFINES = 'NDEBUG=1',
M4FLAGS = '-DNDEBUG=1',
)
if env['USING_CCTESTS']:
env.Append(
CPPDEFINES = 'USING_CCTESTS=1',
M4FLAGS = '-DUSING_CCTESTS=1',
)
if env['OFFICIAL_BUILD']:
env.Append(
CPPDEFINES = 'OFFICIAL_BUILD=1',
M4FLAGS = '-DOFFICIAL_BUILD=1',
)
# TODO: if USING_PNG
env.Append(CPPDEFINES = 'PNG_USER_CONFIG')
# TODO: if USING_ZLIB
env.Append(
CPPDEFINES = [
'NO_GZIP',
'NO_GZCOMPRESS',
]
)
# Platform-specific flags follow.
if env['OS'] == 'win32':
env.Append(
CPPDEFINES = [
'STRICT',
'_UNICODE',
'UNICODE',
'_USRDLL',
'WIN32',
'_WINDLL',
'_CRT_SECURE_NO_DEPRECATE',
'NOMINMAX',
# We require APPVER=5.0 for things like HWND_MESSAGE.
# When APPVER=5.0, win32.mak in the Platform SDK sets:
# C defines: WINVER=0x0500
# _WIN32_WINNT=0x0500
# _WIN32_IE=0x0500
# _RICHEDIT_VER=0x0010
# RC defines: WINVER=0x0500
# MIDL flags: /target NT50
# Note: _WIN32_WINDOWS was replaced by _WIN32_WINNT for post-Win95 builds.
# Note: XP_WIN is only used by Firefox headers
'_WINDOWS',
'WINVER=0x0500',
'_WIN32_WINNT=0x0500',
'_WIN32_IE=0x0500',
'_RICHEDIT_VER=0x0010',
'_MERGE_PROXYSTUB',
'BREAKPAD_AVOID_STREAMS',
'XP_WIN',
# In VC8, the way to disable exceptions is to remove all /EH* flags, and to
# define _HAS_EXCEPTIONS=0 (for C++ headers) and _ATL_NO_EXCEPTIONS (for ATL).
'_HAS_EXCEPTIONS=0',
'_ATL_NO_EXCEPTIONS',
# Do not export UTF functions.
'U_STATIC_IMPLEMENTATION',
],
LINKFLAGS = [
'/NOLOGO',
'/DEBUG',
'/RELEASE',
# win32-specific
'/MACHINE:X86',
'/NODEFAULTLIB:msvcrt',
# Flags for security hardening (only available for win32, not wince).
'/DYNAMICBASE',
'/SAFESEH',
# We only use /SUBSYSTEM on DLLs. For EXEs we omit the flag, and
# the presence of main() or WinMain() determines the subsystem.
'/SUBSYSTEM:WINDOWS',
# Set the preferred base address. This value was chosen because (a) it's near
# the top of the valid address range, and (b) it doesn't conflict with other
# DLLs loaded by Chrome in either the browser or plugin process.
'/BASE:0x65000000',
],
CPPFLAGS = [
'/nologo',
'/Zi', # TODO: Chrome defines /Z7, no idea what these are.
'/Zc:wchar_t-',
'/c',
'/W3',
'/WX',
'/GR-',
],
CXXFLAGS = [
'/TP',
'/J',
],
CPPPATH = [
# TODO: switch over to Chrome's SDK.
# Note: these must come after $THIRD_PARTY_DIR/npapi because we want our own
# npapi.h to take precedence.
'$PRIVATE_THIRD_PARTY_DIR/atlmfc_vc80/files/include',
'$PRIVATE_THIRD_PARTY_DIR/platformsdk_vc80/files/include',
'$PRIVATE_THIRD_PARTY_DIR/vc_80/files/include',
],
LIBPATH = [
'$PRIVATE_THIRD_PARTY_DIR/atlmfc_vc80/files/lib',
'$PRIVATE_THIRD_PARTY_DIR/platformsdk_vc80/files/lib',
'$PRIVATE_THIRD_PARTY_DIR/vc_80/files/vc/lib',
],
)
if env['MODE'] == 'dbg':
env.Append(
CPPFLAGS = [
'/MTd',
],
)
else: # MODE=opt
env.Append(
CPPFLAGS = [
'/MT',
'/O2',
],
LINKFLAGS = [
'/INCREMENTAL:NO',
'/OPT:REF',
'/OPT:ICF',
],
)
elif env['OS'] == 'linux':
env.Append(
CPPDEFINES = [
'LINUX',
],
CPPPATH = [
'$THIRD_PARTY_DIR/gtk/include/gtk-2.0',
'$THIRD_PARTY_DIR/gtk/include/atk-1.0',
'$THIRD_PARTY_DIR/gtk/include/glib-2.0',
'$THIRD_PARTY_DIR/gtk/include/pango-1.0',
'$THIRD_PARTY_DIR/gtk/include/cairo',
'$THIRD_PARTY_DIR/gtk/lib/gtk-2.0/include',
'$THIRD_PARTY_DIR/gtk/lib/glib-2.0/include',
],
CCFLAGS = [
'-fPIC',
'-fmessage-length=0',
'-Wall',
'-Werror',
# NS_LITERAL_STRING does not work properly without this compiler option
'-fshort-wchar',
# Additions to compile on hardy
'-Wno-unused-variable',
'-Wno-missing-braces',
'-Wno-address',
'-m32',
],
CXXFLAGS = [
'-fno-exceptions',
'-fno-rtti',
'-Wno-non-virtual-dtor',
'-Wno-ctor-dtor-privacy',
'-funsigned-char',
'-Wno-char-subscripts',
],
LINKFLAGS = [
'-fPIC',
'-Bsymbolic',
'-pthread',
# TODO: Following are DLLFLAGS. Figure something out for non-lib targets.
'-shared',
'-Wl,--version-script',
'-Wl,$OPEN_DIR/tools/xpcom-ld-script',
# for PortAudio: need pthread and math
'-lpthread',
'-lm',
# Additions to compile on hardy
'-m32',
],
)
if env['MODE'] == 'dbg':
env.Append(
CPPFLAGS = [
'-g',
'-O0',
],
)
else: # MODE=opt
env.Append(
CPPFLAGS = [
'-O2',
],
)
# Load all the components
sconscripts = [
'SConscript.googleurl',
'SConscript.libgd',
'SConscript.libjpeg',
'SConscript.libpng',
'SConscript.portaudio',
'SConscript.sqlite',
'SConscript.zlib',
]
for each in sconscripts:
env.SConscript(each,
exports=['env'],
variant_dir='$COMMON_OUTDIR',
duplicate=0)
browsers = [env['BROWSER']]
if browsers[0] == 'all':
browsers = env['VALID_BROWSERS']
print 'Building:', browsers
for each in browsers:
env.Replace(
BROWSER = each,
BROWSER_OUTDIR = env.subst('$MODE/' + each).lower(),
)
env.SConscript('SConscript.dll',
exports=['env'],
variant_dir='$BROWSER_OUTDIR',
duplicate=0)
env.SConscript('SConscript.installers',
exports=['env'],
variant_dir='$BASE_OUTDIR',
duplicate=0)
|