3
# All the helper functions are defined in:
5
# Use 'import talk' in any .scons file to get access to it.
6
# Add any new helper functions to it; unittest are available
9
# Each 'component' that is built is defined in a .scons file.
10
# See talk.Components(...) for further info on file naming convention.
12
# To add a new platform clone and modify the root_env object. Remember to add
13
# the new environment object to the envs list otherwise it will not be included
22
#-------------------------------------------------------------------------------
23
# The build files/directories to 'build'.
24
# If the name is the name of a directory then that directory shall contain a
25
# .scons file with the same name as the directory itself:
26
# Ex: The directory session/phone contains a file called phone.scons
27
# This list must be in order of library dependencies. e.g., if
28
# session/phone/phone.scons defines a target that links to a library target
29
# defined in sound/sound.scons, then 'sound' must come first.
30
# When no particular order is imposed by library dependencies, try to keep in
31
# mostly alphabetical order.
33
components = talk.Components("libjingle.scons")
35
#-------------------------------------------------------------------------------
39
# The list of build environments.
42
# The root of all builds.
43
root_env = Environment(
51
BUILD_SCONSCRIPTS = components,
52
DESTINATION_ROOT = '$MAIN_DIR/build',
54
'$OBJ_ROOT', # generated headers are relative to here
55
'$MAIN_DIR/..', # TODO: how can we use GOOGLECLIENT instead?
62
'FEATURE_ENABLE_VOICEMAIL',
63
'FEATURE_ENABLE_PSTN',
66
# Ensure the os environment is captured for any scripts we call out to
70
# This is where we set common environments
72
# Detect if building on 64-bit or 32-bit platform.
73
DeclareBit('build_platform_64bit', 'Platform of the build machine is 64-bit')
74
if platform.architecture()[0] == "64bit":
75
root_env.SetBits('build_platform_64bit')
77
# This bit denotes that an env is for 64-bit builds. When set, all build
78
# artifacts will be 64-bit. When unset, all build artifacts will be 32-bit.
79
DeclareBit('host_platform_64bit', 'Platform of the host machine (where artifacts will execute) is 64-bit')
81
def CrossBuilding(env):
82
return env.Bit('host_platform_64bit') != env.Bit('build_platform_64bit')
83
root_env.AddMethod(CrossBuilding)
85
DeclareBit('use_static_openssl', 'Build OpenSSL as a static library')
87
DeclareBit('have_dbus_glib',
88
'Whether the build system has the dbus-glib-1 package')
89
DeclareBit('have_libpulse',
90
'Whether the build system has the libpulse package')
93
# List all the locales we localize to.
94
root_env.AppendUnique(locales = [
95
'ar', 'bg', 'bn', 'ca', 'cs', 'da', 'de', 'el', 'en', 'en-GB', 'es',
96
'es-419', 'et', 'fa', 'fi', 'fil', 'fr', 'gu', 'hi', 'hr', 'hu', 'id',
97
'is', 'it', 'iw', 'ja', 'kn', 'ko', 'lt', 'lv', 'ml', 'mr', 'ms', 'nl',
98
'no', 'or', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sk', 'sl', 'sr', 'sv',
99
'ta', 'te', 'th', 'tl', 'tr', 'uk', 'ur', 'vi', 'zh-CN', 'zh-TW'])
101
AddTargetGroup('all_breakpads', 'breakpad files can be built')
103
#-------------------------------------------------------------------------------
106
win_env = root_env.Clone(
110
'component_targets_msvs',
114
'target_platform_windows'
116
# Don't use default vc80 midl.exe. It doesn't understand vista_sdk idl files.
117
MIDL = '$PLATFORM_SDK_VISTA_6_0_DIR/Bin/midl.exe ',
118
WIX_DIR = '$GOOGLECLIENT/third_party/wix/v3_0_2925/files',
119
# Flags for debug and optimization are added to CCFLAGS instead
122
CCFLAGS_OPTIMIZED = '',
123
# We force a x86 target even when building on x64 Windows platforms.
127
win_env.Decider('MD5-timestamp')
129
COMPONENT_LIBRARY_PUBLISH = True, # Put dlls in output dir too
131
'/Fd${TARGET}.pdb', # pdb per object allows --jobs=
132
'/WX', # warnings are errors
133
'/Zc:forScope', # handle 'for (int i = 0 ...)' right
134
'/EHs-c-', # disable C++ EH
135
'/GR-', # disable RTTI
136
'/Gy', # enable function level linking
137
'/wd4996', # ignore POSIX deprecated warnings
139
# promote certain level 4 warnings
140
'/w14701', # potentially uninitialized var
141
'/w14702', # unreachable code
142
'/w14706', # assignment within a conditional
143
'/w14709', # comma operator within array index
144
'/w14063', # case 'identifier' is not a valid value for switch of enum
145
'/w14064', # switch of incomplete enum 'enumeration'
146
'/w14057', # 'identifier1' indirection to slightly different base
147
# types from 'identifier2'
148
'/w14263', # member function does not override any base class virtual
150
'/w14266', # no override available for virtual memberfunction from base
151
# 'type'; function is hidden
152
'/w14296', # expression is always false
153
'/w14355', # 'this' : used in base member initializer list
156
'_ATL_CSTRING_EXPLICIT_CONSTRUCTORS',
157
# TODO: encapsulate all string operations that are not based
158
# on std::string/std::wstring and make sure we use the safest versions
159
# available on all platforms.
160
'_CRT_SECURE_NO_WARNINGS',
161
'_SCL_SECURE_NO_WARNINGS',
167
# TODO: remove this from logging.cc and enable here instead.
168
#'WIN32_LEAN_AND_MEAN',
171
'_WIN32_WINNT=0x0501',
173
# The Vista platform SDK 6.0 needs at least
174
# this NTDDI version or else the headers
175
# that LMI includes from it won't compile.
176
'NTDDI_VERSION=NTDDI_WINXP',
178
# npapi.h requires the following:
182
'$THIRD_PARTY/wtl_71/include',
183
'$PLATFORM_SDK_VISTA_6_0_DIR/Include',
186
'$PLATFORM_SDK_VISTA_6_0_DIR/Lib'
189
'-manifest' # TODO: Why do we need this?
193
'/I$PLATFORM_SDK_VISTA_6_0_DIR/include'
197
# Merge in additional windows locales not supported yet on posix
198
win_env.AppendUnique(locales = [
199
'af', 'am', 'ar', 'bg', 'bn', 'ca', 'cs', 'da', 'de', 'el', 'en', 'en-GB',
200
'es', 'es-419', 'et', 'eu', 'fa', 'fi', 'fil', 'fr', 'fr-CA', 'gl', 'gu',
201
'hi', 'hr', 'hu', 'id', 'is', 'it', 'iw', 'ja', 'kn', 'ko', 'lt', 'lv',
202
'ml', 'mr', 'ms', 'nl', 'no', 'or', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru',
203
'sk', 'sl', 'sr', 'sv', 'sw', 'ta', 'te', 'th', 'tl', 'tr', 'uk', 'ur',
204
'vi', 'zh-CN', 'zh-HK', 'zh-TW', 'zu'])
206
# TODO: Figure out what this does; found it in
207
# omaha/main.scons. This fixes the problem with redefinition
208
# of OS_WINDOWS symbol.
209
win_env.FilterOut(CPPDEFINES = ['OS_WINDOWS=OS_WINDOWS'])
211
# Set up digital signing
212
DeclareBit('test_signing', 'Sign binaries with the test certificate')
213
win_env.SetBitFromOption('test_signing', False)
214
if win_env.Bit('test_signing'):
216
CERTIFICATE_PATH = win_env.File(
217
'$GOOGLECLIENT/tools/test_key/testkey.pfx').abspath,
218
CERTIFICATE_PASSWORD = 'test',
220
AddTargetGroup('signed_binaries', 'digitally signed binaries can be built')
222
win_dbg_env = win_env.Clone(
224
BUILD_TYPE_DESCRIPTION = 'Windows debug build',
225
BUILD_GROUPS = ['default', 'all'],
226
tools = ['target_debug'],
231
'/ZI', # enable debugging
232
'/Od', # disable optimizations
233
'/MTd', # link with LIBCMTD.LIB debug lib
234
'/RTC1', # enable runtime checks
238
envs.append(win_dbg_env)
240
win_dbg64_env = win_dbg_env.Clone(
241
BUILD_TYPE = 'dbg64',
242
BUILD_TYPE_DESCRIPTION = 'Windows debug 64bit build',
243
BUILD_GROUPS = ['all'],
246
win_dbg64_env.Append(
262
win_dbg64_env.FilterOut(CPPDEFINES = ['_USE_32BIT_TIME_T'])
264
win_dbg64_env.Prepend(
266
'$VC80_DIR/vc/lib/amd64',
267
'$ATLMFC_VC80_DIR/lib/amd64',
268
'$PLATFORM_SDK_VISTA_6_0_DIR/Lib/x64',
271
win_dbg64_env.PrependENVPath(
273
win_dbg64_env.Dir('$VC80_DIR/vc/bin/x86_amd64'))
275
envs.append(win_dbg64_env)
278
win_coverage_env = win_dbg_env.Clone(
279
tools = ['code_coverage'],
280
BUILD_TYPE = 'coverage',
281
BUILD_TYPE_DESCRIPTION = 'Windows code coverage build',
282
BUILD_GROUPS = ['all'],
285
win_coverage_env.Append(
291
envs.append(win_coverage_env)
293
win_opt_env = win_env.Clone(
295
BUILD_TYPE_DESCRIPTION = 'Windows opt build',
296
BUILD_GROUPS = ['all'],
297
tools = ['target_optimized'],
302
'/Zi', # enable debugging
303
'/O1', # optimize for size
304
'/MT', # link with LIBCMT.LIB (multi-threaded, static linked crt)
305
'/GS', # enable security checks
308
'/safeseh', # protect against attacks against exception handlers
309
'/opt:ref', # Remove unused references (functions/data).
313
envs.append(win_opt_env)
315
#-------------------------------------------------------------------------------
318
posix_env = root_env.Clone()
321
'HASHNAMESPACE=__gnu_cxx',
322
'HASH_NAMESPACE=__gnu_cxx',
324
'DISABLE_DYNAMIC_CAST',
325
'HAVE_OPENSSL_SSL_H=1',
326
# The POSIX standard says we have to define this.
334
# Needed for a clean ABI and for link-time dead-code removal to work
336
'-fvisibility=hidden',
337
# Generate debugging info in the DWARF2 format.
339
# Generate maximal debugging information. (It is stripped from what we ship
340
# to users, so we want it for both dbg and opt.)
341
# Note that hammer automatically supplies "-g" for mac/linux dbg, so that
342
# flag must be filtered out of linux_dbg and mac_dbg envs below.
346
'-Wno-non-virtual-dtor',
347
'-Wno-ctor-dtor-privacy',
352
#-------------------------------------------------------------------------------
355
mac_env = posix_env.Clone(
357
'target_platform_mac',
362
# Use static OpenSSL on mac so that we can use the latest APIs on all
363
# supported mac platforms (10.5+).
364
mac_env.SetBits('use_static_openssl')
372
'-isysroot', '/Developer/SDKs/MacOSX10.5.sdk',
376
'-Wl,-search_paths_first',
377
# This flag makes all members of a static library be included in the
378
# final exe - that increases the size of the exe, but without it
379
# Obj-C categories aren't properly included in the exe.
380
# TODO: consider only defining for libs that actually have objc.
383
'-mmacosx-version-min=10.5',
384
'-isysroot', '/Developer/SDKs/MacOSX10.5.sdk',
392
'SystemConfiguration',
402
mac_dbg_env = mac_env.Clone(
404
BUILD_TYPE_DESCRIPTION = 'Mac debug build',
405
BUILD_GROUPS = ['default', 'all'],
406
tools = ['target_debug'],
416
# Remove -g set by hammer, which is not what we want (we have set -g3 above).
417
mac_dbg_env.FilterOut(CCFLAGS = ['-g'])
418
envs.append(mac_dbg_env)
420
mac_opt_env = mac_env.Clone(
422
BUILD_TYPE_DESCRIPTION = 'Mac opt build',
423
BUILD_GROUPS = ['all'],
424
tools = ['target_optimized'],
428
# TODO: Figure out how hammer can compile without
429
# this flag, then remove. Confirmed asserts are preprocessed
430
# out. Maybe it's a different version of gcc?
431
'-Wno-unused-variable',
433
# Hammer automatically specifies -Os for mac opt.
435
envs.append(mac_opt_env)
437
#-------------------------------------------------------------------------------
440
linux_common_env = posix_env.Clone(
442
'target_platform_linux',
447
linux_common_env.Append(
452
# Needed for link-time dead-code removal to work properly.
453
'-ffunction-sections',
457
# Enable dead-code removal.
459
# Elide dependencies on shared libraries that we're not actually using.
463
_LIBFLAGS = ['-Wl,--end-group'],
466
# Remove default rpath set by Hammer. Hammer sets it to LIB_DIR, which is wrong.
467
# The rpath is the _run-time_ library search path for the resulting binary, i.e.
468
# the one used by ld.so at load time. Setting it equal to the path to build
469
# output on the build machine is nonsense.
470
linux_common_env.Replace(
474
# Enable the optional DBus-GLib code if the build machine has the required
476
linux_common_env.EnableFeatureWherePackagePresent('have_dbus_glib',
480
def linux_common_include_x86_32(env):
481
"""Include x86-32 settings into an env based on linux_common."""
491
def linux_common_include_x86_64(env):
492
"""Include x86-64 settings into an env based on linux_common."""
502
env.SetBits('host_platform_64bit')
504
#-------------------------------------------------------------------------------
505
# L I N U X -- T R A D I T I O N A L -- X 8 6
507
# Settings that are specific to our desktop Linux x86 targets.
508
linux_x86_32_env = linux_common_env.Clone()
509
linux_common_include_x86_32(linux_x86_32_env)
511
linux_x86_64_env = linux_common_env.Clone()
512
linux_common_include_x86_64(linux_x86_64_env)
514
def gen_linux_x86(base_env, type_suffix, desc_suffix):
515
linux_env = base_env.Clone()
516
# OpenSSL has infamously poor ABI stability, so that building against one
517
# version and running against a different one often will not work. Since our
518
# non-ChromeOS Linux builds are used on many different distros and distro
519
# versions, this means we can't safely dynamically link to OpenSSL because the
520
# product would end up being broken on any computer with a different version
521
# installed. So instead we build it ourself and statically link to it.
522
linux_env.SetBits('use_static_openssl')
523
# Enable the optional PulseAudio code if the build machine has the required
524
# dependency. (Not doing this for linux_common_env because we don't want
525
# PulseAudio used on ChromeOS.)
526
linux_env.EnableFeatureWherePackagePresent('have_libpulse',
531
if not linux_env.CrossBuilding():
532
groups = groups + ['all-native']
533
# The native-arch dbg build is the default.
534
dbg_groups = groups + ['default']
535
native_desc = ', native '
536
# No suffix for native modes.
539
groups = groups + ['all-cross']
541
native_desc = ', cross-built for '
543
linux_dbg_env = linux_env.Clone(
544
BUILD_TYPE = 'dbg' + type_suffix,
545
BUILD_TYPE_DESCRIPTION = 'Linux debug build%s%s' % (native_desc,
547
BUILD_GROUPS = dbg_groups,
548
tools = ['target_debug'],
550
# Remove -g set by hammer, which is not what we want (we have set -g3 above).
551
linux_dbg_env.FilterOut(CCFLAGS = ['-g'])
552
envs.append(linux_dbg_env)
554
linux_opt_env = linux_env.Clone(
555
BUILD_TYPE = 'opt' + type_suffix,
556
BUILD_TYPE_DESCRIPTION = 'Linux optimized build%s%s' % (native_desc,
558
BUILD_GROUPS = groups,
559
tools = ['target_optimized'],
561
# Remove -O2 set by hammer, which is not what we want.
562
linux_opt_env.FilterOut(CCFLAGS = ['-O2'])
563
linux_opt_env.Append(CCFLAGS = ['-Os'])
564
envs.append(linux_opt_env)
566
gen_linux_x86(linux_x86_32_env, '32', '32-bit')
567
gen_linux_x86(linux_x86_64_env, '64', '64-bit')
569
#-------------------------------------------------------------------------------
570
# L I N U X -- C R O S S -- B U I L D
572
# Cross build requires the following tool names be provided by the environment:
573
linux_cross_common_env = linux_common_env.Clone(
574
AR = os.environ.get("AR"),
575
AS = os.environ.get("AS"),
576
LD = os.environ.get("LD"),
577
NM = os.environ.get("NM"),
578
RANLIB = os.environ.get("RANLIB"),
579
CC = str(os.environ.get("CC")) +
580
' --sysroot=' + str(os.environ.get("SYSROOT")),
581
CXX = str(os.environ.get("CXX")) +
582
' --sysroot=' + str(os.environ.get("SYSROOT")),
585
# The rest of these paths and flags are optional:
586
if os.environ.get("CPPPATH"):
587
linux_cross_common_env.Append(
588
CPPPATH = os.environ.get("CPPPATH").split(':'),
590
if os.environ.get("LIBPATH"):
591
linux_cross_common_env.Append(
592
LIBPATH = os.environ.get("LIBPATH").split(':'),
594
if os.environ.get("CFLAGS"):
595
linux_cross_common_env.Append(
596
CFLAGS = os.environ.get("CFLAGS").split(' '),
598
if os.environ.get("CCFLAGS"):
599
linux_cross_common_env.Append(
600
CCFLAGS = os.environ.get("CCFLAGS").split(' '),
602
if os.environ.get("CXXFLAGS"):
603
linux_cross_common_env.Append(
604
CXXFLAGS = os.environ.get("CXXFLAGS").split(' '),
606
if os.environ.get("LIBFLAGS"):
607
linux_cross_common_env.Append(
608
_LIBFLAGS = os.environ.get("LIBFLAGS").split(' '),
610
if os.environ.get("LINKFLAGS"):
611
linux_cross_common_env.Prepend(
612
LINKFLAGS = os.environ.get("LINKFLAGS").split(' '),
615
#-------------------------------------------------------------------------------
616
# L I N U X -- C R O S S -- B U I L D -- A R M
618
linux_cross_arm_env = linux_cross_common_env.Clone()
619
linux_cross_arm_env.Append(
621
'NACL_BUILD_ARCH=arm',
628
DeclareBit('arm', 'ARM build')
629
linux_cross_arm_env.SetBits('arm')
631
# Detect NEON support from the -mfpu build flag.
632
DeclareBit('arm_neon', 'ARM supporting neon')
633
if '-mfpu=neon' in linux_cross_arm_env['CFLAGS'] or \
634
'-mfpu=neon' in linux_cross_arm_env['CCFLAGS'] or \
635
'-mfpu=neon' in linux_cross_arm_env['CXXFLAGS']:
636
print "Building with ARM NEON support."
637
linux_cross_arm_env.SetBits('arm_neon')
640
linux_cross_arm_dbg_env = linux_cross_arm_env.Clone(
641
BUILD_TYPE = 'arm-dbg',
642
BUILD_TYPE_DESCRIPTION = 'Cross-compiled ARM debug build',
643
BUILD_GROUPS = ['arm'],
644
tools = ['target_debug'],
646
envs.append(linux_cross_arm_dbg_env)
648
linux_cross_arm_opt_env = linux_cross_arm_env.Clone(
649
BUILD_TYPE = 'arm-opt',
650
BUILD_TYPE_DESCRIPTION = 'Cross-compiled ARM optimized build',
651
BUILD_GROUPS = ['arm'],
652
tools = ['target_optimized'],
654
envs.append(linux_cross_arm_opt_env)
658
# TODO(): Clone linux envs for 64bit. See 'variant' documentation.
660
# Create a group for installers
661
AddTargetGroup('all_installers', 'installers that can be built')
663
# Parse child .scons files
664
BuildEnvironments(envs)
666
# Explicitly set which targets to build when not stated on commandline
668
# Build the following, which excludes unit test output (ie running them)
669
# To run unittests, specify the test to run, or run_all_tests. See -h option.
670
Default(['all_libraries', 'all_programs', 'all_test_programs'])
672
# .sln creation code lifted from googleclient/bar/main.scons. Must be after
673
# the call to BuildEnvironments for all_foo aliases to be defined.
674
# Run 'hammer --mode=all --vsproj' to generate
675
DeclareBit('vsproj', 'Generate Visual Studio projects and solution files.')
676
win_env.SetBitFromOption('vsproj', False)
678
if win_env.Bit('vsproj'):
679
vs_env = win_env.Clone()
681
COMPONENT_VS_SOURCE_SUFFIXES = [
695
p = vs_env.ComponentVSDirProject(
699
COMPONENT_VS_SOURCE_FOLDERS = [
700
# Files are assigned to first matching folder. Folder names of None
702
(None, '$DESTINATION_ROOT'),
703
('flute', '$MAIN_DIR'),
704
('google3', '$GOOGLE3'),
705
('third_party', '$THIRD_PARTY'),
707
# Force source project to main dir, so that Visual Studio can find the
708
# source files corresponding to build errors.
709
COMPONENT_VS_PROJECT_DIR = '$MAIN_DIR',
711
vs_env.AlwaysBuild(p)
713
# Solution and target projects
714
s = vs_env.ComponentVSSolution(
715
# 'libjingle', # Please uncomment this line if you build VS proj files.
716
['all_libraries', 'all_programs', 'all_test_programs'],
720
print '***Unfortunately the vsproj creator isn\'t smart enough to '
721
print '***automatically get the correct output locations. It is very easy'
722
print '***though to change it in the properties pane to the following'
723
print '***$(SolutionDir)/build/<foo>/staging/<bar>.exe'