blob: 0811393262f20e8a2580fe6219173f6e15eface6 [file] [log] [blame]
[email protected]186f5602008-09-16 18:24:301# Copyright (c) 2008 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
[email protected]172914a2008-09-25 17:09:265# Notes:
6# This assumes you have a working gears checkout from p4 in the current dir.
7# Steps for this:
8# > echo %USER%-chromegears > p4config
[email protected]b0faad62008-10-21 23:59:039# or on linux/osx:
10# > echo $USER-chromegears > p4config
[email protected]172914a2008-09-25 17:09:2611# > set P4CONFIG=p4config
12# > g4 client -p //depot/googleclient/gears/p4_depot_paths
13# > g4 sync
14#
15# This is a work-in-progress conversion of the current Gears set of Makefiles.
16# A lot of the stuff doesn't translate to SCons-land well, and I'm not sure
17# how faithful we want to be to the original.
18#
19# Questions:
20# Should we flatten the output directory into
21# Hammer/gears/platform/browser/*.obj like Gears does now? If so, how?
22
[email protected]c1a3747e2008-10-08 00:05:2623# Notes to self:
24# - os.path.abspath('.') (the CWD) is variant_dir if it exists, else it's the
25# toplevel_dir (which contains the SConstruct).
26# - env.Entry('.') is the entry representing the variant_dir.
27# - env.Entry('#') is the entry representing the toplevel_dir.
28# - str(entry) gives the path relative to variant_dir, or abspath if the entry
29# is outside the variant_dir.
30# - entry.path gives the path relative to toplevel_dir.
31# - entry.abspath gives the absolute path.
32
[email protected]172914a2008-09-25 17:09:2633import os
34
[email protected]186f5602008-09-16 18:24:3035Import('env')
36
37env = env.Clone(
[email protected]b92ed9d22008-10-23 19:40:0838 OPEN_DIR = "gears",
39 THIRD_PARTY_DIR = "third_party",
40 PRIVATE_THIRD_PARTY_DIR = "third_party_internal",
[email protected]17ee3a072008-11-06 22:45:5041 SYMBIAN_DIR = "symbian_internal",
[email protected]186f5602008-09-16 18:24:3042)
43
[email protected]dff2b53ed2008-10-08 22:59:5344if not os.path.exists(env.Dir('#/$OPEN_DIR').abspath):
45 print 'Skipping Gears build: no perforce tree checked out.'
46 Return()
47
[email protected]186f5602008-09-16 18:24:3048# Argument switches
[email protected]777c7bf2008-09-30 20:01:2449
50# TODO: how do we detect linux vs osx?
51os_guess = env['PLATFORM']
52if os_guess == 'posix':
53 os_guess = 'linux'
54elif os_guess == 'darwin':
55 os_guess = 'osx'
56
[email protected]c1a3747e2008-10-08 00:05:2657# Map of OS -> valid browser targets for that OS.
58os_browsers_map = {
59 'win32': ['IE', 'FF2', 'FF3', 'NPAPI'],
60 'wince': ['IE'],
61 'linux': ['FF2', 'FF3'],
[email protected]b0faad62008-10-21 23:59:0362 'osx': ['SF', 'FF2', 'FF3'],
[email protected]c1a3747e2008-10-08 00:05:2663 'android': ['NPAPI'],
[email protected]17ee3a072008-11-06 22:45:5064 'symbian': ['NPAPI'],
[email protected]c1a3747e2008-10-08 00:05:2665}
66
[email protected]186f5602008-09-16 18:24:3067vars = Variables(None, ARGUMENTS)
68vars.AddVariables(
[email protected]c1a3747e2008-10-08 00:05:2669 EnumVariable('OS',
70 'Which OS is the target', os_guess, os_browsers_map.keys()),
71 EnumVariable('MODE',
72 'Type of binary to generate', 'dbg', ['dbg', 'opt']),
73 BoolVariable('OFFICIAL_BUILD',
74 'Create a binary suitable for public release', 0)
[email protected]186f5602008-09-16 18:24:3075)
76vars.Update(env)
77
[email protected]c1a3747e2008-10-08 00:05:2678env['VALID_BROWSERS'] = os_browsers_map[env['OS']]
79
80# Add BROWSER last, since its valid inputs depend on $OS.
81vars.Add(
82 EnumVariable('BROWSER',
83 'Which browser we want to build the plugin for. "all" builds all '
84 'browsers for this OS.',
85 'all', env['VALID_BROWSERS'] + ['all']))
86vars.Update(env)
87
[email protected]777c7bf2008-09-30 20:01:2488env.Replace(
[email protected]186f5602008-09-16 18:24:3089 USING_CCTESTS = (env['MODE'] == 'dbg' or not env['OFFICIAL_BUILD'])
90)
91
92# Version
[email protected]777c7bf2008-09-30 20:01:2493env.Replace(
[email protected]186f5602008-09-16 18:24:3094 MAJOR = '0',
95 MINOR = '4',
[email protected]b9e30c22008-10-15 21:25:0696 BUILD = '24',
[email protected]186f5602008-09-16 18:24:3097 PATCH = '0',
98 VERSION = '${MAJOR}.${MINOR}.${BUILD}.${PATCH}',
99
[email protected]172914a2008-09-25 17:09:26100 FRIENDLY_NAME = 'Google Gears',
[email protected]186f5602008-09-16 18:24:30101 SHORT_NAME = 'gears',
102)
103
104# Platform
[email protected]b0faad62008-10-21 23:59:03105# TODO: Symbian builds will override this value.
[email protected]25ab0c62008-10-14 00:28:34106# For other platforms we set just one value.
107if env['OS'] in ['wince', 'android']:
108 env.Replace(ARCH = 'arm')
109elif env['OS'] == 'osx':
110 # On OSX we build a fat binary.
111 env.Replace(ARCH = 'i386+ppc')
112else:
113 env.Replace(ARCH = 'i386')
[email protected]186f5602008-09-16 18:24:30114
[email protected]c1a3747e2008-10-08 00:05:26115# Output dirs
116env.Replace(
[email protected]25ab0c62008-10-14 00:28:34117 BASE_OUTDIR = '$GEARS_DIR/$OS-$ARCH-$MODE',
[email protected]c1a3747e2008-10-08 00:05:26118 COMMON_OUTDIR = '$BASE_OUTDIR/common',
[email protected]6b3531282008-10-10 00:01:37119 BROWSER_OUTDIR = '$BASE_OUTDIR/${BROWSER.lower()}',
[email protected]c1a3747e2008-10-08 00:05:26120 IE_OUTDIR = '$BASE_OUTDIR/ie',
121 FF2_OUTDIR = '$BASE_OUTDIR/ff2',
122 FF3_OUTDIR = '$BASE_OUTDIR/ff3',
123 NPAPI_OUTDIR = '$BASE_OUTDIR/npapi',
124 SF_OUTDIR = '$BASE_OUTDIR/sf',
[email protected]6b3531282008-10-10 00:01:37125
126 GENFILES_DIR = "$BROWSER_OUTDIR/genfiles",
127 COMMON_GENFILES_DIR = "$COMMON_OUTDIR/genfiles",
[email protected]c1a3747e2008-10-08 00:05:26128)
129
[email protected]b0faad62008-10-21 23:59:03130# Library flags
131env.Replace(
132 MOZJS_INCLUDE_PATHS = [
133 '$MOZJS_DIR',
134 '$THIRD_PARTY_DIR/spidermonkey/nspr/pr/include',
135 '$THIRD_PARTY_DIR/spidermonkey/nspr/pr/include/private',
136 '$THIRD_PARTY_DIR/spidermonkey/nspr/pr/include/obsolete',
137 '$OSX_SDK_ROOT/Developer/Headers/FlatCarbon/',
138 ],
139 MOZJS_DIR = '$THIRD_PARTY_DIR/spidermonkey',
140)
141
[email protected]5514903c2008-10-08 21:24:55142# Add our tools to the PATH.
[email protected]4509f39a2008-10-29 18:35:46143if env['OS'] in ['win32', 'wince']:
144 if os.path.exists(env.Dir('#/$PRIVATE_THIRD_PARTY_DIR').abspath):
145 # Clear out our environment so we don't accidentally use the system's
146 # libs.
[email protected]bfb2cf72008-10-21 20:42:29147 env['ENV']['PATH'] = ''
148 env['ENV']['LIB'] = ''
149 env['ENV']['INCLUDE'] = ''
[email protected]25ab0c62008-10-14 00:28:34150
[email protected]4509f39a2008-10-29 18:35:46151 paths = []
152
[email protected]bfb2cf72008-10-21 20:42:29153 # Keep system32 for 'xcopy'.
154 paths += [env.subst('${ENV["SYSTEMROOT"]}/system32')]
155 if env['OS'] == 'win32':
156 env.Append(
157 VC80 = env.Dir('#/$PRIVATE_THIRD_PARTY_DIR/vc_80/files').abspath)
158 paths += [
159 env.subst('$VC80/common7/ide'),
160 env.subst('$VC80/vc/bin'),
161 env.subst('$VC80/common7/tools'),
162 env.subst('$VC80/common7/tools/bin'),
163 env.subst('$VC80/team_tools/performance_tools'),
164 ]
165 else: # wince
166 env.Append(
167 VC80 = env.Dir('#/$PRIVATE_THIRD_PARTY_DIR/vc_80ce/files').abspath)
168 paths += [
169 env.subst('$VC80/bin/x86_arm'),
170 env.subst('$VC80/common7/ide'),
171 env.subst('$VC80/common7/tools'),
172 env.subst('$VC80/common7/tools/bin'),
173 env.subst('$VC80/vc/bin'),
174 env.subst('$VC80/smartdevices/sdktools'),
175 ]
[email protected]25ab0c62008-10-14 00:28:34176
[email protected]4509f39a2008-10-29 18:35:46177 paths += [
178 env.Dir('#/$PRIVATE_THIRD_PARTY_DIR/wix/v3_0_2925/files').abspath]
[email protected]25ab0c62008-10-14 00:28:34179
[email protected]4509f39a2008-10-29 18:35:46180 paths += [env.Dir('#/$PRIVATE_THIRD_PARTY_DIR/gnu/files').abspath]
181 paths += [env.Dir('#/$PRIVATE_THIRD_PARTY_DIR/python_24').abspath]
[email protected]25ab0c62008-10-14 00:28:34182
[email protected]4509f39a2008-10-29 18:35:46183 # Prepend them so our tools come first.
184 for each in reversed(paths):
185 env.PrependENVPath('PATH', each)
186 else:
187 # If we don't have a private third_party dir, we expect the system
188 # environment to be set up correctly to point to tool paths.
189 env['ENV']['PATH'] = os.environ['PATH']
190 env['ENV']['LIB'] = os.environ['LIB']
191 env['ENV']['INCLUDE'] = os.environ['INCLUDE']
[email protected]bfb2cf72008-10-21 20:42:29192
[email protected]4509f39a2008-10-29 18:35:46193 # HACK to disable manifest creation, since it breaks all the time.
194 env['LINKCOM'] = env['LINKCOM'][0]
195 env['SHLINKCOM'] = env['SHLINKCOM'][0]
[email protected]172914a2008-09-25 17:09:26196
[email protected]6b3531282008-10-10 00:01:37197# Building M4 files
[email protected]172914a2008-09-25 17:09:26198env.Tool('m4')
199
[email protected]6b3531282008-10-10 00:01:37200env.Append(
201 M4ARCH = (env['ARCH'] == 'i386' and 'x86' or '$ARCH'),
202 M4FLAGS = [
203 '--prefix-builtins',
204 '-DPRODUCT_VERSION=$VERSION',
205 '-DPRODUCT_VERSION_MAJOR=$MAJOR',
206 '-DPRODUCT_VERSION_MINOR=$MINOR',
207 '-DPRODUCT_VERSION_BUILD=$BUILD',
208 '-DPRODUCT_VERSION_PATCH=$PATCH',
209 '-DPRODUCT_OS=$OS',
210 '-DPRODUCT_ARCH="$M4ARCH"',
211 '-DPRODUCT_GCC_VERSION="gcc3"',
212 '-DPRODUCT_MAINTAINER="google"',
213 '-DPRODUCT_FRIENDLY_NAME_UQ="$FRIENDLY_NAME"',
214 '-DPRODUCT_SHORT_NAME_UQ="$SHORT_NAME"',
215 '-DI18N_LANGUAGES="(${",".join(I18N_LANGS)})"',
216 ],
217 M4PATH = [
218 '$OPEN_DIR',
219 '.',
220 ],
221)
222
223# SCons magic to make M4PATH work.
224env.Replace(
225 M4INCPREFIX = '-I',
226 M4INCSUFFIX = '',
227 _M4INCFLAGS = ('${_concat(M4INCPREFIX, M4PATH, M4INCSUFFIX, '
228 '__env__, RDirs, TARGET, SOURCE)}'),
229 M4COM = '$M4 $M4FLAGS ${_M4INCFLAGS} $SOURCE > $TARGET',
230)
231
232# TODO: Dependency scanner for m4 files - doesn't work. It can't detect files
233# that don't exist!
234#m4_include_re = re.compile(r'm4_include\((.*)\)', re.M)
235#def m4_scan(node, env, path):
236# contents = node.get_contents()
237# includes = m4_include_re.findall(contents)
238# ret_includes = []
239# for include in includes:
240# for dir in path:
241# file = os.path.join(dir, include)
242# if os.path.exists(file):
243# ret_includes.append(file)
244# break
245# return ret_includes
246#
247#m4_scanner = Scanner(function = m4_scan, skeys = ['.m4', '.html_m4'])
248#env.Append(SCANNERS = m4_scanner)
249
250
[email protected]7ef840ff2008-09-22 21:15:54251# C++ build flags.
[email protected]186f5602008-09-16 18:24:30252
[email protected]172914a2008-09-25 17:09:26253# Clear out the inherited defines from Chrome's build. I want to match Gears'
254# current build as closely as possible until we switch everyone to SCons, then
255# gradually integrate.
[email protected]7ef840ff2008-09-22 21:15:54256env.Replace(
[email protected]5affc15f2008-10-31 23:55:17257 ARFLAGS = [],
[email protected]186f5602008-09-16 18:24:30258 CPPPATH = [
259 '$OPEN_DIR',
260 '$OPEN_DIR/..',
261 '$THIRD_PARTY_DIR',
[email protected]186f5602008-09-16 18:24:30262 '$THIRD_PARTY_DIR/googleurl',
263 '$THIRD_PARTY_DIR/npapi',
264 '$THIRD_PARTY_DIR/zlib',
265 '$THIRD_PARTY_DIR/v8/bindings_local',
[email protected]c1a3747e2008-10-08 00:05:26266 '.',
[email protected]6b3531282008-10-10 00:01:37267 '$COMMON_OUTDIR',
[email protected]172914a2008-09-25 17:09:26268 ],
[email protected]b0faad62008-10-21 23:59:03269 CFLAGS = [],
[email protected]7ef840ff2008-09-22 21:15:54270 CCFLAGS = [],
[email protected]b0faad62008-10-21 23:59:03271 CXXFLAGS = [],
[email protected]4509f39a2008-10-29 18:35:46272 CCPDBFLAGS = [],
[email protected]b0faad62008-10-21 23:59:03273 CPPDEFINES = [
274 # SpiderMonkey (the Firefox JS engine)'s JS_GET_CLASS macro in jsapi.h needs
275 # this defined to work with the gecko SDK that we've built.
276 # The definition of JS_THREADSAFE must be kept in sync with MOZJS_CPPFLAGS.
277 'JS_THREADSAFE'
278 ],
279 FRAMEWORKPATH = [],
280 FRAMEWORKS = [],
[email protected]172914a2008-09-25 17:09:26281 LIBS = [],
[email protected]5affc15f2008-10-31 23:55:17282 LIBPATH = ['$COMPONENT_LIBRARY_DIR'],
[email protected]172914a2008-09-25 17:09:26283 LINKFLAGS = [],
[email protected]b0faad62008-10-21 23:59:03284 SHLINKFLAGS = [],
[email protected]5affc15f2008-10-31 23:55:17285 COMPONENT_LIBRARY_DIR = '$COMMON_OUTDIR/lib',
[email protected]186f5602008-09-16 18:24:30286)
287
[email protected]7ef840ff2008-09-22 21:15:54288if env['MODE'] == 'dbg':
[email protected]172914a2008-09-25 17:09:26289 env.Append(
[email protected]f9ef79b2008-09-25 17:19:21290 CPPDEFINES = [
291 'DEBUG=1',
292 '_DEBUG=1',
293 ],
[email protected]172914a2008-09-25 17:09:26294 M4FLAGS = '-DDEBUG=1',
295 )
296else:
297 env.Append(
298 CPPDEFINES = 'NDEBUG=1',
299 M4FLAGS = '-DNDEBUG=1',
300 )
[email protected]7ef840ff2008-09-22 21:15:54301if env['USING_CCTESTS']:
[email protected]172914a2008-09-25 17:09:26302 env.Append(
303 CPPDEFINES = 'USING_CCTESTS=1',
304 M4FLAGS = '-DUSING_CCTESTS=1',
305 )
[email protected]7ef840ff2008-09-22 21:15:54306if env['OFFICIAL_BUILD']:
[email protected]172914a2008-09-25 17:09:26307 env.Append(
308 CPPDEFINES = 'OFFICIAL_BUILD=1',
309 M4FLAGS = '-DOFFICIAL_BUILD=1',
310 )
[email protected]186f5602008-09-16 18:24:30311
312# TODO: if USING_PNG
[email protected]172914a2008-09-25 17:09:26313env.Append(CPPDEFINES = 'PNG_USER_CONFIG')
314# TODO: if USING_ZLIB
[email protected]186f5602008-09-16 18:24:30315env.Append(
316 CPPDEFINES = [
[email protected]172914a2008-09-25 17:09:26317 'NO_GZIP',
318 'NO_GZCOMPRESS',
319 ]
[email protected]186f5602008-09-16 18:24:30320)
[email protected]25ab0c62008-10-14 00:28:34321if env['OS'] == 'wince':
322 env.Append(CPPDEFINES = 'NO_ERRNO_H')
[email protected]186f5602008-09-16 18:24:30323
[email protected]5514903c2008-10-08 21:24:55324# Languages
325
326env['I18N_LANGS'] = [
327 'en-US',
328 'ar',
329 'bg',
330 'ca',
331 'cs',
332 'da',
333 'de',
334 'el',
335 'en-GB',
336 'es',
337 'et',
338 'fa',
339 'fi',
340 'fil',
341 'fr',
342 'he',
343 'hi',
344 'hr',
345 'hu',
346 'id',
347 'is',
348 'it',
349 'ja',
350 'ko',
351 'lt',
352 'lv',
353 'ms',
354 'nl',
355 'no',
356 'pl',
357 'pt-BR',
358 'pt-PT',
359 'ro',
360 'ru',
361 'sk',
362 'sl',
363 'sr',
364 'sv',
365 'th',
366 'tr',
367 'uk',
368 'ur',
369 'vi',
370 'zh-CN',
371 'zh-TW',
372 'ml',
373 'te',
374 'gu',
375 'kn',
376 'or',
377 'bn',
378 'ta',
379 'mr',
380]
381
[email protected]172914a2008-09-25 17:09:26382# Platform-specific flags follow.
383
[email protected]25ab0c62008-10-14 00:28:34384if env['OS'] in ['win32', 'wince']:
[email protected]172914a2008-09-25 17:09:26385 env.Append(
386 CPPDEFINES = [
387 'STRICT',
388 '_UNICODE',
389 'UNICODE',
390 '_USRDLL',
391 'WIN32',
392 '_WINDLL',
393 '_CRT_SECURE_NO_DEPRECATE',
394 'NOMINMAX',
395
[email protected]7ef840ff2008-09-22 21:15:54396# In VC8, the way to disable exceptions is to remove all /EH* flags, and to
397# define _HAS_EXCEPTIONS=0 (for C++ headers) and _ATL_NO_EXCEPTIONS (for ATL).
398 '_HAS_EXCEPTIONS=0',
399 '_ATL_NO_EXCEPTIONS',
400# Do not export UTF functions.
401 'U_STATIC_IMPLEMENTATION',
[email protected]186f5602008-09-16 18:24:30402 ],
[email protected]8f643b782008-10-20 18:49:49403# Static lib flags.
404 ARFLAGS = [
405 '/NOLOGO',
406 ],
407# Shared lib and exe flags.
[email protected]186f5602008-09-16 18:24:30408 LINKFLAGS = [
[email protected]7ef840ff2008-09-22 21:15:54409 '/NOLOGO',
410 '/DEBUG',
411 '/RELEASE',
[email protected]25ab0c62008-10-14 00:28:34412 '/PDB:${TARGET.base}.pdb',
[email protected]186f5602008-09-16 18:24:30413# Set the preferred base address. This value was chosen because (a) it's near
414# the top of the valid address range, and (b) it doesn't conflict with other
415# DLLs loaded by Chrome in either the browser or plugin process.
416 '/BASE:0x65000000',
[email protected]7ef840ff2008-09-22 21:15:54417 ],
418 CPPFLAGS = [
[email protected]25ab0c62008-10-14 00:28:34419 '/nologo',
[email protected]25ab0c62008-10-14 00:28:34420 '/Zc:wchar_t-',
421 '/c',
422 '/W3',
423 '/WX',
424 '/GR-',
[email protected]8f643b782008-10-20 18:49:49425 '/Fd"${TARGET.base}.pdb"',
[email protected]7ef840ff2008-09-22 21:15:54426 ],
427 CXXFLAGS = [
[email protected]25ab0c62008-10-14 00:28:34428 '/TP',
429 '/J',
[email protected]186f5602008-09-16 18:24:30430 ],
[email protected]777c7bf2008-09-30 20:01:24431 CPPPATH = [
[email protected]25ab0c62008-10-14 00:28:34432 '$VC80_CPPPATH',
[email protected]b0faad62008-10-21 23:59:03433 '$THIRD_PARTY_DIR/breakpad/src',
[email protected]25ab0c62008-10-14 00:28:34434 ],
[email protected]4509f39a2008-10-29 18:35:46435 CCPDBFLAGS = [
436 '/Zi', # TODO: Chrome defines /Z7, no idea what these are.
437 ],
[email protected]25ab0c62008-10-14 00:28:34438 LIBPATH = [
439 '$VC80_LIBPATH',
440 ],
441 )
442 if env['OS'] == 'win32':
443 env.Append(
444 CPPDEFINES = [
445# We require APPVER=5.0 for things like HWND_MESSAGE.
446# When APPVER=5.0, win32.mak in the Platform SDK sets:
447# C defines: WINVER=0x0500
448# _WIN32_WINNT=0x0500
449# _WIN32_IE=0x0500
450# _RICHEDIT_VER=0x0010
451# RC defines: WINVER=0x0500
452# MIDL flags: /target NT50
453# Note: _WIN32_WINDOWS was replaced by _WIN32_WINNT for post-Win95 builds.
454# Note: XP_WIN is only used by Firefox headers
455 '_WINDOWS',
456 'WINVER=0x0500',
457 '_WIN32_WINNT=0x0500',
458 '_WIN32_IE=0x0500',
459 '_RICHEDIT_VER=0x0010',
460 '_MERGE_PROXYSTUB',
461 'BREAKPAD_AVOID_STREAMS',
462 'XP_WIN',
463 ],
[email protected]8f643b782008-10-20 18:49:49464 ARFLAGS = [
465 '/MACHINE:X86',
466 ],
[email protected]25ab0c62008-10-14 00:28:34467 LINKFLAGS = [
468 '/MACHINE:X86',
469 '/NODEFAULTLIB:msvcrt',
470# Flags for security hardening (only available for win32, not wince).
471 '/DYNAMICBASE',
472 '/SAFESEH',
473
474# We only use /SUBSYSTEM on DLLs. For EXEs we omit the flag, and
475# the presence of main() or WinMain() determines the subsystem.
476 '/SUBSYSTEM:WINDOWS',
477 ],
478 VC80_CPPPATH = [
[email protected]777c7bf2008-09-30 20:01:24479# TODO: switch over to Chrome's SDK.
480# Note: these must come after $THIRD_PARTY_DIR/npapi because we want our own
481# npapi.h to take precedence.
[email protected]25ab0c62008-10-14 00:28:34482 '$PRIVATE_THIRD_PARTY_DIR/atlmfc_vc80/files/include',
483 '$PRIVATE_THIRD_PARTY_DIR/platformsdk_vc80/files/include',
[email protected]b9e30c22008-10-15 21:25:06484 '$PRIVATE_THIRD_PARTY_DIR/vc_80/files/vc/include',
[email protected]25ab0c62008-10-14 00:28:34485 ],
486 VC80_LIBPATH = [
487 '$PRIVATE_THIRD_PARTY_DIR/atlmfc_vc80/files/lib',
488 '$PRIVATE_THIRD_PARTY_DIR/platformsdk_vc80/files/lib',
489 '$PRIVATE_THIRD_PARTY_DIR/vc_80/files/vc/lib',
490 ],
491 )
492 else: # OS=wince
493 env.Append(
494 CPPDEFINES = [
495# For Windows Mobile we need:
496# C defines: _WIN32_WCE=0x0501
497# _UNDER_CE=0x0501
498 '_WIN32_WCE=0x501',
499 'WINVER=_WIN32_WCE',
500 'UNDER_CE=0x501',
[email protected]5affc15f2008-10-31 23:55:17501 'OS_WINCE',
[email protected]25ab0c62008-10-14 00:28:34502 'WIN32_PLATFORM_PSPC',
503 'ARM',
504 '_ARM_',
505 'POCKETPC2003_UI_MODEL',
506 '_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA',
507 '_CE_CRT_ALLOW_WIN_MINMAX',
508 ],
[email protected]8f643b782008-10-20 18:49:49509 ARFLAGS = [
510 '/MACHINE:THUMB',
511 ],
[email protected]25ab0c62008-10-14 00:28:34512 LINKFLAGS = [
513 '/MACHINE:THUMB',
514 '/NODEFAULTLIB:secchk.lib',
515 '/NODEFAULTLIB:oldnames.lib',
516 '/SUBSYSTEM:WINDOWSCE,5.01',
517 ],
518 VC80_CPPPATH = [
519 '$PRIVATE_THIRD_PARTY_DIR/atlmfc_vc80ce/files/include',
520 '$PRIVATE_THIRD_PARTY_DIR/vc_80ce/files/include',
521# Visual Studio must be setup before the PocketPC SDK.
522 '$PRIVATE_THIRD_PARTY_DIR/pocketpc_sdk_ce_50/files/include/armv4i',
523 ],
524 VC80_LIBPATH = [
525 '$PRIVATE_THIRD_PARTY_DIR/atlmfc_vc80ce/files/lib/armv4i',
526 '$PRIVATE_THIRD_PARTY_DIR/vc_80ce/files/lib/armv4i',
527 '$PRIVATE_THIRD_PARTY_DIR/pocketpc_sdk_ce_50/files/lib/armv4i',
528 ],
529 )
530
[email protected]172914a2008-09-25 17:09:26531 if env['MODE'] == 'dbg':
532 env.Append(
533 CPPFLAGS = [
534 '/MTd',
535 ],
536 )
537 else: # MODE=opt
538 env.Append(
539 CPPFLAGS = [
540 '/MT',
541 '/O2',
542 ],
543 LINKFLAGS = [
544 '/INCREMENTAL:NO',
545 '/OPT:REF',
546 '/OPT:ICF',
547 ],
548 )
[email protected]b0faad62008-10-21 23:59:03549#--------------------------- LINUX ---------------------------
[email protected]777c7bf2008-09-30 20:01:24550elif env['OS'] == 'linux':
551 env.Append(
552 CPPDEFINES = [
553 'LINUX',
554 ],
555 CPPPATH = [
556 '$THIRD_PARTY_DIR/gtk/include/gtk-2.0',
557 '$THIRD_PARTY_DIR/gtk/include/atk-1.0',
558 '$THIRD_PARTY_DIR/gtk/include/glib-2.0',
559 '$THIRD_PARTY_DIR/gtk/include/pango-1.0',
560 '$THIRD_PARTY_DIR/gtk/include/cairo',
561 '$THIRD_PARTY_DIR/gtk/lib/gtk-2.0/include',
562 '$THIRD_PARTY_DIR/gtk/lib/glib-2.0/include',
563 ],
564 CCFLAGS = [
565 '-fPIC',
566 '-fmessage-length=0',
567 '-Wall',
568 '-Werror',
569# NS_LITERAL_STRING does not work properly without this compiler option
570 '-fshort-wchar',
571# Additions to compile on hardy
572 '-Wno-unused-variable',
573 '-Wno-missing-braces',
574 '-Wno-address',
575 '-m32',
576 ],
577 CXXFLAGS = [
578 '-fno-exceptions',
579 '-fno-rtti',
580 '-Wno-non-virtual-dtor',
581 '-Wno-ctor-dtor-privacy',
582 '-funsigned-char',
583 '-Wno-char-subscripts',
584 ],
585 LINKFLAGS = [
586 '-fPIC',
587 '-Bsymbolic',
588 '-pthread',
589
590# TODO: Following are DLLFLAGS. Figure something out for non-lib targets.
591 '-shared',
592 '-Wl,--version-script',
593 '-Wl,$OPEN_DIR/tools/xpcom-ld-script',
594# for PortAudio: need pthread and math
595 '-lpthread',
596 '-lm',
597# Additions to compile on hardy
598 '-m32',
599 ],
600 )
601 if env['MODE'] == 'dbg':
602 env.Append(
603 CPPFLAGS = [
604 '-g',
605 '-O0',
606 ],
607 )
608 else: # MODE=opt
609 env.Append(
610 CPPFLAGS = [
611 '-O2',
612 ],
613 )
[email protected]b0faad62008-10-21 23:59:03614#--------------------------- OSX ---------------------------
615elif env['OS'] == 'osx':
616# Gears uses the 10.4 SDK, so we need to build with g++-4.0.
617# Chrome uses g++-4.2 so we override this here.
618 env['CC'] = 'gcc-4.0'
619 env['CXX'] = 'g++-4.0'
620# Compile assembly files with the same command line as C files.
621 env['ASCOM'] = '$CCCOM'
622
623 env.Append(OSX_SDK_ROOT = '/Developer/SDKs/MacOSX10.4u.sdk')
[email protected]172914a2008-09-25 17:09:26624
[email protected]b0faad62008-10-21 23:59:03625 env.Append(
626 CPPDEFINES = [
627 'OSX',
628 'OS_MACOSX',
629# for breakpad
630 'USE_PROTECTED_ALLOCATIONS=1',
631 ],
632 CPPPATH = [
633# Breakpad assumes it is in the include path
634 '$THIRD_PARTY_DIR/breakpad_osx/src',
635 ],
636 CCFLAGS = [
637 ('-arch', 'ppc'),
638 ('-arch', 'i386'),
639 '-fPIC',
640 '-fmessage-length=0',
641# TODO
642# '-Wall',
643# NS_LITERAL_STRING does not work properly without this compiler option
644 '-fshort-wchar',
645 '-fvisibility=hidden',
646# Breakpad on OSX needs debug symbols to use the STABS format, rather than the
647# default DWARF debug symbols format. Note that we enable gstabs for debug &
648# opt; we strip them later in opt.
649 '-gstabs+',
650 ],
651 CXXFLAGS = [
652 '-fvisibility-inlines-hidden',
653 '-fno-exceptions',
654 '-fno-rtti',
655 ('-Wall',
656 '-Wno-non-virtual-dtor',
657 '-Wno-ctor-dtor-privacy',
658 '-Wno-char-subscripts',
659# When a function is deprecated in gcc, it stupidly warns about all functions
660# and member functions that have the same name, regardless of signature.
661# Example: Standard osx headers deprecate 'SetPort', which causes a warning for
662# url_canon::Replacements::SetPort().
663 '-Wno-deprecated-declarations',
664 ),
665 '-funsigned-char',
666 ('-include', env.File('#/$OPEN_DIR/base/safari/prefix_header.h').abspath),
667 ('-isysroot', '$OSX_SDK_ROOT')
668 ],
669 LINKFLAGS = [
670 '-fPIC',
671 '-Bsymbolic',
672 '-arch',
673 'ppc',
674 '-arch',
675 'i386',
676 '-isysroot',
677 '$OSX_SDK_ROOT',
678 '-Wl,-dead_strip'
679 ],
680 )
681 if env['MODE'] == 'dbg':
682 env.Append(
683 CPPFLAGS = [
684 '-g',
685 '-O0',
686 ],
687 )
688 else: # MODE=opt
689 env.Append(
690 CPPFLAGS = [
691 '-O2',
692 ],
693 )
[email protected]b92ed9d22008-10-23 19:40:08694
695# TODO(mpcomplete): fix this and properly separate our DLL flags from EXE
696# flags.
[email protected]4509f39a2008-10-29 18:35:46697env.Append(SHLINKFLAGS = ['$LINKFLAGS'])
698if env['OS'] in ['wince', 'win32']:
699 env.Append(SHLINKFLAGS = ['/DLL'])
700
[email protected]17ee3a072008-11-06 22:45:50701# Custom builder to work around a scons and/or hammer bug. ComponentLibrary
702# tries to install the library to COMPONENT_LIBRARY_DIR, but since we overrode
703# that value, scons gets confused. I'm not sure who is at fault here.
704# See http://code.google.com/p/chromium/issues/detail?id=4177.
705def GearsStaticLibrary(env, *args, **kw):
706 lib = env.ChromeStaticLibrary(*args, **kw)
707 env.Install('$COMPONENT_LIBRARY_DIR', lib[0])
708 return lib
709env.AddMethod(GearsStaticLibrary)
710
[email protected]7ef840ff2008-09-22 21:15:54711# Load all the components
[email protected]186f5602008-09-16 18:24:30712
713sconscripts = [
[email protected]7ef840ff2008-09-22 21:15:54714 'SConscript.googleurl',
[email protected]186f5602008-09-16 18:24:30715 'SConscript.libjpeg',
716 'SConscript.libpng',
[email protected]b0faad62008-10-21 23:59:03717 'SConscript.libmozjs',
[email protected]186f5602008-09-16 18:24:30718 'SConscript.sqlite',
719 'SConscript.zlib',
720]
721
[email protected]b0faad62008-10-21 23:59:03722if env['OS'] == 'osx':
723 sconscripts += [
724 'SConscript.libbreakpad_osx',
725 ]
726
727if env['OS'] != 'osx':
728 sconscripts += [
729 'SConscript.libgd',
730 'SConscript.portaudio',
731 ]
[email protected]25ab0c62008-10-14 00:28:34732
[email protected]7ef840ff2008-09-22 21:15:54733for each in sconscripts:
734 env.SConscript(each,
735 exports=['env'],
[email protected]c1a3747e2008-10-08 00:05:26736 variant_dir='$COMMON_OUTDIR',
[email protected]7ef840ff2008-09-22 21:15:54737 duplicate=0)
[email protected]186f5602008-09-16 18:24:30738
[email protected]6b3531282008-10-10 00:01:37739# Must come before SConscript.dll because it Imports targets from this
740# SConscript.
741env.SConscript('SConscript.common',
742 exports=['env'],
743 variant_dir='$COMMON_OUTDIR',
744 duplicate=0)
745
[email protected]c1a3747e2008-10-08 00:05:26746browsers = [env['BROWSER']]
747if browsers[0] == 'all':
748 browsers = env['VALID_BROWSERS']
749print 'Building:', browsers
750
751for each in browsers:
[email protected]6b3531282008-10-10 00:01:37752 env.Replace(BROWSER = each)
[email protected]c1a3747e2008-10-08 00:05:26753 env.SConscript('SConscript.dll',
754 exports=['env'],
755 variant_dir='$BROWSER_OUTDIR',
756 duplicate=0)
757
758env.SConscript('SConscript.installers',
[email protected]7ef840ff2008-09-22 21:15:54759 exports=['env'],
[email protected]c1a3747e2008-10-08 00:05:26760 variant_dir='$BASE_OUTDIR',
[email protected]7ef840ff2008-09-22 21:15:54761 duplicate=0)