Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / breakpad / src / build / common.gypi
1 # Copyright 2010 Google Inc. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met:
6 #
7 #     * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 #     * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
12 # distribution.
13 #     * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 # IMPORTANT:
30 # Please don't directly include this file if you are building via gyp_chromium,
31 # since gyp_chromium is automatically forcing its inclusion.
32 {
33   'variables': {
34     # Variables expected to be overriden on the GYP command line (-D) or by
35     # ~/.gyp/include.gypi.
36
37     # Putting a variables dict inside another variables dict looks kind of
38     # weird. This is necessary to get these variables defined for the conditions
39     # within this variables dict that operate on these variables.
40     'variables': {
41       'variables': {
42         # Compute the architecture that we're building on.
43         'conditions': [
44           [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
45             # This handles the Linux platforms we generally deal with. Anything
46             # else gets passed through, which probably won't work very well; such
47             # hosts should pass an explicit target_arch to gyp.
48             'host_arch%':
49               '<!(uname -m | sed -e "s/i.86/ia32/;s/x86_64/x64/;s/amd64/x64/;s/arm.*/arm/")',
50           }, {  # OS!="linux"
51             'host_arch%': 'ia32',
52           }],
53         ],
54       },
55
56       'host_arch%': '<(host_arch)',
57
58       # Default architecture we're building for is the architecture we're
59       # building on.
60       'target_arch%': '<(host_arch)',
61
62       # This variable tells WebCore.gyp and JavaScriptCore.gyp whether they are
63       # are built under a chromium full build (1) or a webkit.org chromium
64       # build (0).
65       'inside_chromium_build%': 1,
66
67       # Set to 1 compile with -fPIC cflag on linux. This is a must for shared
68       # libraries on linux x86-64 and arm.
69       'linux_fpic%': 0,
70
71       # Python version.
72       'python_ver%': '2.5',
73
74       # Determine ARM compilation flags.
75       'arm_version%': 7,
76
77       # Set Neon compilation flags (only meaningful if arm_version==7).
78       'arm_neon%': 1,
79
80       # The system root for cross-compiles. Default: none.
81       'sysroot%': '',
82
83       # On Linux, we build with sse2 for Chromium builds.
84       'disable_sse2%': 0,
85     },
86
87     'target_arch%': '<(target_arch)',
88     'host_arch%': '<(host_arch)',
89     'inside_chromium_build%': '<(inside_chromium_build)',
90     'linux_fpic%': '<(linux_fpic)',
91     'python_ver%': '<(python_ver)',
92     'arm_version%': '<(arm_version)',
93     'arm_neon%': '<(arm_neon)',
94     'sysroot%': '<(sysroot)',
95     'disable_sse2%': '<(disable_sse2)',
96
97     # The release channel that this build targets. This is used to restrict
98     # channel-specific build options, like which installer packages to create.
99     # The default is 'all', which does no channel-specific filtering.
100     'channel%': 'all',
101
102     # Override chromium_mac_pch and set it to 0 to suppress the use of
103     # precompiled headers on the Mac.  Prefix header injection may still be
104     # used, but prefix headers will not be precompiled.  This is useful when
105     # using distcc to distribute a build to compile slaves that don't
106     # share the same compiler executable as the system driving the compilation,
107     # because precompiled headers rely on pointers into a specific compiler
108     # executable's image.  Setting this to 0 is needed to use an experimental
109     # Linux-Mac cross compiler distcc farm.
110     'chromium_mac_pch%': 1,
111
112     # Mac OS X SDK and deployment target support.
113     # The SDK identifies the version of the system headers that will be used,
114     # and corresponds to the MAC_OS_X_VERSION_MAX_ALLOWED compile-time macro.
115     # "Maximum allowed" refers to the operating system version whose APIs are
116     # available in the headers.
117     # The deployment target identifies the minimum system version that the
118     # built products are expected to function on.  It corresponds to the
119     # MAC_OS_X_VERSION_MIN_REQUIRED compile-time macro.
120     # To ensure these macros are available, #include <AvailabilityMacros.h>.
121     # Additional documentation on these macros is available at
122     # http://developer.apple.com/mac/library/technotes/tn2002/tn2064.html#SECTION3
123     # Chrome normally builds with the Mac OS X 10.5 SDK and sets the
124     # deployment target to 10.5.  Other projects, such as O3D, may override
125     # these defaults.
126     'mac_sdk%': '10.5',
127     'mac_deployment_target%': '10.5',
128
129     # Set to 1 to enable code coverage.  In addition to build changes
130     # (e.g. extra CFLAGS), also creates a new target in the src/chrome
131     # project file called "coverage".
132     # Currently ignored on Windows.
133     'coverage%': 0,
134
135     # Although base/allocator lets you select a heap library via an
136     # environment variable, the libcmt shim it uses sometimes gets in
137     # the way.  To disable it entirely, and switch to normal msvcrt, do e.g.
138     #  'win_use_allocator_shim': 0,
139     #  'win_release_RuntimeLibrary': 2
140     # to ~/.gyp/include.gypi, gclient runhooks --force, and do a release build.
141     'win_use_allocator_shim%': 1, # 0 = shim allocator via libcmt; 1 = msvcrt
142
143     # Whether usage of OpenMAX is enabled.
144     'enable_openmax%': 0,
145
146     # TODO(bradnelson): eliminate this when possible.
147     # To allow local gyp files to prevent release.vsprops from being included.
148     # Yes(1) means include release.vsprops.
149     # Once all vsprops settings are migrated into gyp, this can go away.
150     'msvs_use_common_release%': 1,
151
152     # TODO(bradnelson): eliminate this when possible.
153     # To allow local gyp files to override additional linker options for msvs.
154     # Yes(1) means set use the common linker options.
155     'msvs_use_common_linker_extras%': 1,
156
157     # TODO(sgk): eliminate this if possible.
158     # It would be nicer to support this via a setting in 'target_defaults'
159     # in chrome/app/locales/locales.gypi overriding the setting in the
160     # 'Debug' configuration in the 'target_defaults' dict below,
161     # but that doesn't work as we'd like.
162     'msvs_debug_link_incremental%': '2',
163
164     # This is the location of the sandbox binary. Chrome looks for this before
165     # running the zygote process. If found, and SUID, it will be used to
166     # sandbox the zygote process and, thus, all renderer processes.
167     'linux_sandbox_path%': '',
168
169     # Set this to true to enable SELinux support.
170     'selinux%': 0,
171
172     # Strip the binary after dumping symbols.
173     'linux_strip_binary%': 0,
174
175     # Enable TCMalloc.
176     'linux_use_tcmalloc%': 1,
177
178     # Disable TCMalloc's debugallocation.
179     'linux_use_debugallocation%': 0,
180
181     # Disable TCMalloc's heapchecker.
182     'linux_use_heapchecker%': 0,
183
184     # Set to 1 to turn on seccomp sandbox by default.
185     # (Note: this is ignored for official builds.)
186     'linux_use_seccomp_sandbox%': 0,
187
188     # Set to select the Title Case versions of strings in GRD files.
189     'use_titlecase_in_grd_files%': 0,
190
191     # Used to disable Native Client at compile time, for platforms where it
192     # isn't supported
193     'disable_nacl%': 0,
194
195     # Set Thumb compilation flags.
196     'arm_thumb%': 0,
197
198     # Set ARM fpu compilation flags (only meaningful if arm_version==7 and
199     # arm_neon==0).
200     'arm_fpu%': 'vfpv3',
201
202     # Enable new NPDevice API.
203     'enable_new_npdevice_api%': 0,
204
205     'conditions': [
206       ['OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
207         # This will set gcc_version to XY if you are running gcc X.Y.*.
208         # This is used to tweak build flags for gcc 4.4.
209         'gcc_version%': '<!(python <(DEPTH)/build/compiler_version.py)',
210         # Figure out the python architecture to decide if we build pyauto.
211         'python_arch%': '<!(<(DEPTH)/build/linux/python_arch.sh <(sysroot)/usr/lib/libpython<(python_ver).so.1.0)',
212         'linux_breakpad%': 1,
213         'linux_dump_symbols%': 1,
214       }],  # OS=="linux" or OS=="freebsd" or OS=="openbsd"
215       ['OS=="mac"', {
216         # Mac wants Title Case strings
217         'use_titlecase_in_grd_files%': 1,
218         'mac_breakpad%': 0,
219         'mac_keystone%': 0,
220       }],  # OS=="mac"
221       # Whether to use multiple cores to compile with visual studio. This is
222       # optional because it sometimes causes corruption on VS 2005.
223       # It is on by default on VS 2008 and off on VS 2005.
224       ['OS=="win"', {
225         'conditions': [
226           ['MSVS_VERSION=="2005"', {
227             'msvs_multi_core_compile%': 0,
228           },{
229             'msvs_multi_core_compile%': 1,
230           }],
231           # Don't do incremental linking for large modules on 32-bit.
232           ['MSVS_OS_BITS==32', {
233             'msvs_large_module_debug_link_mode%': '1',  # No
234           },{
235             'msvs_large_module_debug_link_mode%': '2',  # Yes
236           }],
237         ],
238         'nacl_win64_defines': [
239           # This flag is used to minimize dependencies when building
240           # Native Client loader for 64-bit Windows.
241           'NACL_WIN64',
242         ],
243       }],
244       # Compute based on OS and target architecture whether the GPU
245       # plugin / process is supported.
246       [ 'OS=="win" or (OS=="linux" and target_arch!="arm") or OS=="mac"', {
247         # Enable a variable used elsewhere throughout the GYP files to determine
248         # whether to compile in the sources for the GPU plugin / process.
249         'enable_gpu%': 1,
250       }, {  # GPU plugin not supported
251         'enable_gpu%': 0,
252       }],
253       # Compute based on OS, target architecture and device whether GLES
254       # is supported
255       [ 'OS=="linux" and target_arch=="arm"', {
256         # Enable a variable used elsewhere throughout the GYP files to determine
257         # whether to compile in the sources for the GLES support.
258         'enable_gles%': 1,
259       }, {  # GLES not supported
260         'enable_gles%': 0,
261       }],
262     ],
263
264     # NOTE: When these end up in the Mac bundle, we need to replace '-' for '_'
265     # so Cocoa is happy (http://crbug.com/20441).
266     'locales': [
267       'am', 'ar', 'bg', 'bn', 'ca', 'cs', 'da', 'de', 'el', 'en-GB',
268       'en-US', 'es-419', 'es', 'et', 'fi', 'fil', 'fr', 'gu', 'he',
269       'hi', 'hr', 'hu', 'id', 'it', 'ja', 'kn', 'ko', 'lt', 'lv',
270       'ml', 'mr', 'nb', 'nl', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru',
271       'sk', 'sl', 'sr', 'sv', 'sw', 'ta', 'te', 'th', 'tr', 'uk',
272       'vi', 'zh-CN', 'zh-TW',
273     ],
274   },
275   'target_defaults': {
276     'variables': {
277       # See http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Optimize-Options.html
278       'mac_release_optimization%': '3', # Use -O3 unless overridden
279       'mac_debug_optimization%': '0',   # Use -O0 unless overridden
280       # See http://msdn.microsoft.com/en-us/library/aa652360(VS.71).aspx
281       'win_release_Optimization%': '2', # 2 = /Os
282       'win_debug_Optimization%': '0',   # 0 = /Od
283       # See http://msdn.microsoft.com/en-us/library/aa652367(VS.71).aspx
284       'win_release_RuntimeLibrary%': '0', # 0 = /MT (nondebug static)
285       'win_debug_RuntimeLibrary%': '1',   # 1 = /MTd (debug static)
286
287       'release_extra_cflags%': '',
288       'debug_extra_cflags%': '',
289       'release_valgrind_build%': 0,
290     },
291     'conditions': [
292       ['selinux==1', {
293         'defines': ['CHROMIUM_SELINUX=1'],
294       }],
295       ['win_use_allocator_shim==0', {
296         'conditions': [
297           ['OS=="win"', {
298             'defines': ['NO_TCMALLOC'],
299           }],
300         ],
301       }],
302       ['enable_gpu==1', {
303         'defines': [
304           'ENABLE_GPU=1',
305         ],
306       }],
307       ['enable_gles==1', {
308         'defines': [
309           'ENABLE_GLES=1',
310         ],
311       }],
312       ['coverage!=0', {
313         'conditions': [
314           ['OS=="mac"', {
315             'xcode_settings': {
316               'GCC_INSTRUMENT_PROGRAM_FLOW_ARCS': 'YES',  # -fprofile-arcs
317               'GCC_GENERATE_TEST_COVERAGE_FILES': 'YES',  # -ftest-coverage
318             },
319             # Add -lgcov for types executable, shared_library, and
320             # loadable_module; not for static_library.
321             # This is a delayed conditional.
322             'target_conditions': [
323               ['_type!="static_library"', {
324                 'xcode_settings': { 'OTHER_LDFLAGS': [ '-lgcov' ] },
325               }],
326             ],
327           }],
328           # Linux gyp (into scons) doesn't like target_conditions?
329           # TODO(???): track down why 'target_conditions' doesn't work
330           # on Linux gyp into scons like it does on Mac gyp into xcodeproj.
331           ['OS=="linux"', {
332             'cflags': [ '-ftest-coverage',
333                         '-fprofile-arcs' ],
334             'link_settings': { 'libraries': [ '-lgcov' ] },
335           }],
336           # Finally, for Windows, we simply turn on profiling.
337           ['OS=="win"', {
338             'msvs_settings': {
339               'VCLinkerTool': {
340                 'Profile': 'true',
341               },
342               'VCCLCompilerTool': {
343                 # /Z7, not /Zi, so coverage is happyb
344                 'DebugInformationFormat': '1',
345                 'AdditionalOptions': ['/Yd'],
346               }
347             }
348          }],  # OS==win
349         ],  # conditions for coverage
350       }],  # coverage!=0
351     ],  # conditions for 'target_defaults'
352     'target_conditions': [
353       [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
354         'cflags!': [
355           '-Wall',
356           '-Wextra',
357           '-Werror',
358         ],
359       }],
360       [ 'OS=="win"', {
361         'defines': [
362           '_CRT_SECURE_NO_DEPRECATE',
363           '_CRT_NONSTDC_NO_WARNINGS',
364           '_CRT_NONSTDC_NO_DEPRECATE',
365         ],
366         'msvs_disabled_warnings': [4800],
367         'msvs_settings': {
368           'VCCLCompilerTool': {
369             'WarnAsError': 'true',
370             'Detect64BitPortabilityProblems': 'false',
371           },
372         },
373       }],
374       [ 'OS=="mac"', {
375         'xcode_settings': {
376           'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO',
377           'WARNING_CFLAGS!': ['-Wall'],
378         },
379       }],
380     ],  # target_conditions for 'target_defaults'
381     'default_configuration': 'Debug',
382     'configurations': {
383       # VCLinkerTool LinkIncremental values below:
384       #   0 == default
385       #   1 == /INCREMENTAL:NO
386       #   2 == /INCREMENTAL
387       # Debug links incremental, Release does not.
388       #
389       # Abstract base configurations to cover common
390       # attributes.
391       #
392       'Common_Base': {
393         'abstract': 1,
394         'msvs_configuration_attributes': {
395           'OutputDirectory': '$(SolutionDir)$(ConfigurationName)',
396           'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)',
397           'CharacterSet': '1',
398         },
399       },
400       'x86_Base': {
401         'abstract': 1,
402         'msvs_settings': {
403           'VCLinkerTool': {
404             'TargetMachine': '1',
405           },
406         },
407         'msvs_configuration_platform': 'Win32',
408       },
409       'x64_Base': {
410         'abstract': 1,
411         'msvs_configuration_platform': 'x64',
412         'msvs_settings': {
413           'VCLinkerTool': {
414             'TargetMachine': '17', # x86 - 64
415             'AdditionalLibraryDirectories!':
416               ['<(DEPTH)/third_party/platformsdk_win7/files/Lib'],
417             'AdditionalLibraryDirectories':
418               ['<(DEPTH)/third_party/platformsdk_win7/files/Lib/x64'],
419           },
420           'VCLibrarianTool': {
421             'AdditionalLibraryDirectories!':
422               ['<(DEPTH)/third_party/platformsdk_win7/files/Lib'],
423             'AdditionalLibraryDirectories':
424               ['<(DEPTH)/third_party/platformsdk_win7/files/Lib/x64'],
425           },
426         },
427         'defines': [
428           # Not sure if tcmalloc works on 64-bit Windows.
429           'NO_TCMALLOC',
430         ],
431       },
432       'Debug_Base': {
433         'abstract': 1,
434         'xcode_settings': {
435           'COPY_PHASE_STRIP': 'NO',
436           'GCC_OPTIMIZATION_LEVEL': '<(mac_debug_optimization)',
437           'OTHER_CFLAGS': [ '<@(debug_extra_cflags)', ],
438         },
439         'msvs_settings': {
440           'VCCLCompilerTool': {
441             'Optimization': '<(win_debug_Optimization)',
442             'PreprocessorDefinitions': ['_DEBUG'],
443             'BasicRuntimeChecks': '3',
444             'RuntimeLibrary': '<(win_debug_RuntimeLibrary)',
445           },
446           'VCLinkerTool': {
447             'LinkIncremental': '<(msvs_debug_link_incremental)',
448           },
449           'VCResourceCompilerTool': {
450             'PreprocessorDefinitions': ['_DEBUG'],
451           },
452         },
453         'conditions': [
454           ['OS=="linux"', {
455             'cflags': [
456               '<@(debug_extra_cflags)',
457             ],
458           }],
459         ],
460       },
461       'Release_Base': {
462         'abstract': 1,
463         'defines': [
464           'NDEBUG',
465         ],
466         'xcode_settings': {
467           'DEAD_CODE_STRIPPING': 'YES',  # -Wl,-dead_strip
468           'GCC_OPTIMIZATION_LEVEL': '<(mac_release_optimization)',
469           'OTHER_CFLAGS': [ '<@(release_extra_cflags)', ],
470         },
471         'msvs_settings': {
472           'VCCLCompilerTool': {
473             'Optimization': '<(win_release_Optimization)',
474             'RuntimeLibrary': '<(win_release_RuntimeLibrary)',
475           },
476           'VCLinkerTool': {
477             'LinkIncremental': '1',
478           },
479         },
480         'conditions': [
481           ['release_valgrind_build==0', {
482             'defines': ['NVALGRIND'],
483           }],
484           ['win_use_allocator_shim==0', {
485             'defines': ['NO_TCMALLOC'],
486           }],
487           ['win_release_RuntimeLibrary==2', {
488             # Visual C++ 2008 barfs when building anything with /MD (msvcrt):
489             #  VC\include\typeinfo(139) : warning C4275: non dll-interface
490             #  class 'stdext::exception' used as base for dll-interface
491             #  class 'std::bad_cast'
492             'msvs_disabled_warnings': [4275],
493           }],
494           ['OS=="linux"', {
495             'cflags': [
496              '<@(release_extra_cflags)',
497             ],
498           }],
499         ],
500       },
501       'Purify_Base': {
502         'abstract': 1,
503         'defines': [
504           'PURIFY',
505           'NO_TCMALLOC',
506         ],
507         'msvs_settings': {
508           'VCCLCompilerTool': {
509             'Optimization': '0',
510             'RuntimeLibrary': '0',
511             'BufferSecurityCheck': 'false',
512           },
513           'VCLinkerTool': {
514             'EnableCOMDATFolding': '1',
515             'LinkIncremental': '1',
516           },
517         },
518       },
519       #
520       # Concrete configurations
521       #
522       'Debug': {
523         'inherit_from': ['Common_Base', 'x86_Base', 'Debug_Base'],
524       },
525       'Release': {
526         'inherit_from': ['Common_Base', 'x86_Base', 'Release_Base'],
527         'conditions': [
528           ['msvs_use_common_release', {
529             'defines': ['OFFICIAL_BUILD'],
530             'msvs_settings': {
531               'VCCLCompilerTool': {
532                 'Optimization': '3',
533                 'StringPooling': 'true',
534                 'OmitFramePointers': 'true',
535                 'InlineFunctionExpansion': '2',
536                 'EnableIntrinsicFunctions': 'true',
537                 'FavorSizeOrSpeed': '2',
538                 'OmitFramePointers': 'true',
539                 'EnableFiberSafeOptimizations': 'true',
540                 'WholeProgramOptimization': 'true',
541               },
542               'VCLibrarianTool': {
543                 'AdditionalOptions': ['/ltcg', '/expectedoutputsize:120000000'],
544               },
545               'VCLinkerTool': {
546                 'LinkIncremental': '1',
547                 'OptimizeReferences': '2',
548                 'EnableCOMDATFolding': '2',
549                 'OptimizeForWindows98': '1',
550                 'LinkTimeCodeGeneration': '1',
551               },
552             },
553           }],
554         ]
555       },
556       'conditions': [
557         [ 'OS=="win"', {
558           # TODO(bradnelson): add a gyp mechanism to make this more graceful.
559           'Purify': {
560             'inherit_from': ['Common_Base', 'x86_Base', 'Release_Base', 'Purify'],
561           },
562           'Debug_x64': {
563             'inherit_from': ['Common_Base', 'x64_Base', 'Debug_Base'],
564           },
565           'Release_x64': {
566             'inherit_from': ['Common_Base', 'x64_Base', 'Release_Base'],
567           },
568           'Purify_x64': {
569             'inherit_from': ['Common_Base', 'x64_Base', 'Release_Base', 'Purify_Base'],
570           },
571         }],
572       ],
573     },
574   },
575   'conditions': [
576     ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
577       'target_defaults': {
578         # Enable -Werror by default, but put it in a variable so it can
579         # be disabled in ~/.gyp/include.gypi on the valgrind builders.
580         'variables': {
581           # Use -fno-strict-aliasing by default since gcc 4.4 has periodic
582           # issues that slip through the cracks. We could do this just for
583           # gcc 4.4 but it makes more sense to be consistent on all
584           # compilers in use. TODO(Craig): turn this off again when
585           # there is some 4.4 test infrastructure in place and existing
586           # aliasing issues have been fixed.
587           'no_strict_aliasing%': 1,
588           'conditions': [['OS=="linux"', {'werror%': '-Werror',}],
589                          ['OS=="freebsd"', {'werror%': '',}],
590                          ['OS=="openbsd"', {'werror%': '',}],
591           ],
592         },
593         'cflags': [
594           '<(werror)',  # See note above about the werror variable.
595           '-pthread',
596           '-fno-exceptions',
597           '-Wall',
598           # TODO(evan): turn this back on once all the builds work.
599           # '-Wextra',
600           # Don't warn about unused function params.  We use those everywhere.
601           '-Wno-unused-parameter',
602           # Don't warn about the "struct foo f = {0};" initialization pattern.
603           '-Wno-missing-field-initializers',
604           '-D_FILE_OFFSET_BITS=64',
605           # Don't export any symbols (for example, to plugins we dlopen()).
606           # Note: this is *required* to make some plugins work.
607           '-fvisibility=hidden',
608         ],
609         'cflags_cc': [
610           '-fno-rtti',
611           '-fno-threadsafe-statics',
612           # Make inline functions have hidden visiblity by default.
613           # Surprisingly, not covered by -fvisibility=hidden.
614           '-fvisibility-inlines-hidden',
615         ],
616         'ldflags': [
617           '-pthread', '-Wl,-z,noexecstack',
618         ],
619         'scons_variable_settings': {
620           'LIBPATH': ['$LIB_DIR'],
621           # Linking of large files uses lots of RAM, so serialize links
622           # using the handy flock command from util-linux.
623           'FLOCK_LINK': ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'],
624           'FLOCK_SHLINK': ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'],
625           'FLOCK_LDMODULE': ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'],
626
627           # We have several cases where archives depend on each other in
628           # a cyclic fashion.  Since the GNU linker does only a single
629           # pass over the archives we surround the libraries with
630           # --start-group and --end-group (aka -( and -) ). That causes
631           # ld to loop over the group until no more undefined symbols
632           # are found. In an ideal world we would only make groups from
633           # those libraries which we knew to be in cycles. However,
634           # that's tough with SCons, so we bodge it by making all the
635           # archives a group by redefining the linking command here.
636           #
637           # TODO:  investigate whether we still have cycles that
638           # require --{start,end}-group.  There has been a lot of
639           # refactoring since this was first coded, which might have
640           # eliminated the circular dependencies.
641           #
642           # Note:  $_LIBDIRFLAGS comes before ${LINK,SHLINK,LDMODULE}FLAGS
643           # so that we prefer our own built libraries (e.g. -lpng) to
644           # system versions of libraries that pkg-config might turn up.
645           # TODO(sgk): investigate handling this not by re-ordering the
646           # flags this way, but by adding a hook to use the SCons
647           # ParseFlags() option on the output from pkg-config.
648           'LINKCOM': [['$FLOCK_LINK', '-o', '$TARGET',
649                        '$_LIBDIRFLAGS', '$LINKFLAGS', '$SOURCES',
650                        '-Wl,--start-group', '$_LIBFLAGS', '-Wl,--end-group']],
651           'SHLINKCOM': [['$FLOCK_SHLINK', '-o', '$TARGET',
652                          '$_LIBDIRFLAGS', '$SHLINKFLAGS', '$SOURCES',
653                          '-Wl,--start-group', '$_LIBFLAGS', '-Wl,--end-group']],
654           'LDMODULECOM': [['$FLOCK_LDMODULE', '-o', '$TARGET',
655                            '$_LIBDIRFLAGS', '$LDMODULEFLAGS', '$SOURCES',
656                            '-Wl,--start-group', '$_LIBFLAGS', '-Wl,--end-group']],
657           'IMPLICIT_COMMAND_DEPENDENCIES': 0,
658           # -rpath is only used when building with shared libraries.
659           'conditions': [
660             [ 'component=="shared_library"', {
661               'RPATH': '$LIB_DIR',
662             }],
663           ],
664         },
665         'scons_import_variables': [
666           'AS',
667           'CC',
668           'CXX',
669           'LINK',
670         ],
671         'scons_propagate_variables': [
672           'AS',
673           'CC',
674           'CCACHE_DIR',
675           'CXX',
676           'DISTCC_DIR',
677           'DISTCC_HOSTS',
678           'HOME',
679           'INCLUDE_SERVER_ARGS',
680           'INCLUDE_SERVER_PORT',
681           'LINK',
682           'CHROME_BUILD_TYPE',
683           'CHROMIUM_BUILD',
684           'OFFICIAL_BUILD',
685         ],
686         'configurations': {
687           'Debug_Base': {
688             'variables': {
689               'debug_optimize%': '0',
690             },
691             'defines': [
692               '_DEBUG',
693             ],
694             'cflags': [
695               '-O>(debug_optimize)',
696               '-g',
697               # One can use '-gstabs' to enable building the debugging
698               # information in STABS format for breakpad's dumpsyms.
699             ],
700             'ldflags': [
701               '-rdynamic',  # Allows backtrace to resolve symbols.
702             ],
703           },
704           'Release_Base': {
705             'variables': {
706               'release_optimize%': '2',
707             },
708             'cflags': [
709               '-O>(release_optimize)',
710               # Don't emit the GCC version ident directives, they just end up
711               # in the .comment section taking up binary size.
712               '-fno-ident',
713               # Put data and code in their own sections, so that unused symbols
714               # can be removed at link time with --gc-sections.
715               '-fdata-sections',
716               '-ffunction-sections',
717             ],
718             'ldflags': [
719               '-Wl,--gc-sections',
720             ],
721           },
722         },
723         'variants': {
724           'coverage': {
725             'cflags': ['-fprofile-arcs', '-ftest-coverage'],
726             'ldflags': ['-fprofile-arcs'],
727           },
728           'profile': {
729             'cflags': ['-pg', '-g'],
730             'ldflags': ['-pg'],
731           },
732           'symbols': {
733             'cflags': ['-g'],
734           },
735         },
736         'conditions': [
737           [ 'target_arch=="ia32"', {
738             'asflags': [
739               # Needed so that libs with .s files (e.g. libicudata.a)
740               # are compatible with the general 32-bit-ness.
741               '-32',
742             ],
743             # All floating-point computations on x87 happens in 80-bit
744             # precision.  Because the C and C++ language standards allow
745             # the compiler to keep the floating-point values in higher
746             # precision than what's specified in the source and doing so
747             # is more efficient than constantly rounding up to 64-bit or
748             # 32-bit precision as specified in the source, the compiler,
749             # especially in the optimized mode, tries very hard to keep
750             # values in x87 floating-point stack (in 80-bit precision)
751             # as long as possible. This has important side effects, that
752             # the real value used in computation may change depending on
753             # how the compiler did the optimization - that is, the value
754             # kept in 80-bit is different than the value rounded down to
755             # 64-bit or 32-bit. There are possible compiler options to make
756             # this behavior consistent (e.g. -ffloat-store would keep all
757             # floating-values in the memory, thus force them to be rounded
758             # to its original precision) but they have significant runtime
759             # performance penalty.
760             #
761             # -mfpmath=sse -msse2 makes the compiler use SSE instructions
762             # which keep floating-point values in SSE registers in its
763             # native precision (32-bit for single precision, and 64-bit for
764             # double precision values). This means the floating-point value
765             # used during computation does not change depending on how the
766             # compiler optimized the code, since the value is always kept
767             # in its specified precision.
768             'conditions': [
769               ['disable_sse2==0', {
770                 'cflags': [
771                   '-march=pentium4',
772                   '-msse2',
773                   '-mfpmath=sse',
774                 ],
775               }],
776             ],
777             # -mmmx allows mmintrin.h to be used for mmx intrinsics.
778             # video playback is mmx and sse2 optimized.
779             'cflags': [
780               '-m32',
781               '-mmmx',
782             ],
783             'ldflags': [
784               '-m32',
785             ],
786           }],
787           ['target_arch=="arm"', {
788             'target_conditions': [
789               ['_toolset=="target"', {
790                 'cflags_cc': [
791                   # The codesourcery arm-2009q3 toolchain warns at that the ABI
792                   # has changed whenever it encounters a varargs function. This
793                   # silences those warnings, as they are not helpful and
794                   # clutter legitimate warnings.
795                   '-Wno-abi',
796                 ],
797                 'conditions': [
798                   ['arm_thumb == 1', {
799                     'cflags': [
800                     '-mthumb',
801                     # TODO(piman): -Wa,-mimplicit-it=thumb is needed for
802                     # inline assembly that uses condition codes but it's
803                     # suboptimal. Better would be to #ifdef __thumb__ at the
804                     # right place and have a separate thumb path.
805                     '-Wa,-mimplicit-it=thumb',
806                     ]
807                   }],
808                   ['arm_version==7', {
809                     'cflags': [
810                       '-march=armv7-a',
811                       '-mtune=cortex-a8',
812                       '-mfloat-abi=softfp',
813                     ],
814                     'conditions': [
815                       ['arm_neon==1', {
816                         'cflags': [ '-mfpu=neon', ],
817                       }, {
818                         'cflags': [ '-mfpu=<(arm_fpu)', ],
819                       }]
820                     ],
821                   }],
822                 ],
823               }],
824             ],
825           }],
826           ['linux_fpic==1', {
827             'cflags': [
828               '-fPIC',
829             ],
830           }],
831           ['sysroot!=""', {
832             'target_conditions': [
833               ['_toolset=="target"', {
834                 'cflags': [
835                   '--sysroot=<(sysroot)',
836                 ],
837                 'ldflags': [
838                   '--sysroot=<(sysroot)',
839                 ],
840               }]]
841           }],
842           ['no_strict_aliasing==1', {
843             'cflags': [
844               '-fno-strict-aliasing',
845             ],
846           }],
847           ['linux_breakpad==1', {
848             'cflags': [ '-gstabs' ],
849             'defines': ['USE_LINUX_BREAKPAD'],
850           }],
851           ['library=="shared_library"', {
852             # When building with shared libraries, remove the visiblity-hiding
853             # flag.
854             'cflags!': [ '-fvisibility=hidden' ],
855             'conditions': [
856               ['target_arch=="x64" or target_arch=="arm"', {
857                 # Shared libraries need -fPIC on x86-64 and arm
858                 'cflags': ['-fPIC']
859               }]
860             ],
861           }],
862           ['linux_use_heapchecker==1', {
863             'variables': {'linux_use_tcmalloc%': 1},
864           }],
865           ['linux_use_tcmalloc==0', {
866             'defines': ['NO_TCMALLOC'],
867           }],
868           ['linux_use_heapchecker==0', {
869             'defines': ['NO_HEAPCHECKER'],
870           }],
871         ],
872       },
873     }],
874     # FreeBSD-specific options; note that most FreeBSD options are set above,
875     # with Linux.
876     ['OS=="freebsd"', {
877       'target_defaults': {
878         'ldflags': [
879           '-Wl,--no-keep-memory',
880         ],
881       },
882     }],
883     ['OS=="solaris"', {
884       'cflags!': ['-fvisibility=hidden'],
885       'cflags_cc!': ['-fvisibility-inlines-hidden'],
886     }],
887     ['OS=="mac"', {
888       'target_defaults': {
889         'variables': {
890           # This should be 'mac_real_dsym%', but there seems to be a bug
891           # with % in variables that are intended to be set to different
892           # values in different targets, like this one.
893           'mac_real_dsym': 0,  # Fake .dSYMs are fine in most cases.
894         },
895         'mac_bundle': 0,
896         'xcode_settings': {
897           'ALWAYS_SEARCH_USER_PATHS': 'NO',
898           'GCC_C_LANGUAGE_STANDARD': 'c99',         # -std=c99
899           'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
900           'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
901                                                     # (Equivalent to -fPIC)
902           'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
903           'GCC_ENABLE_CPP_RTTI': 'NO',              # -fno-rtti
904           'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
905           # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
906           'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
907           'GCC_OBJC_CALL_CXX_CDTORS': 'YES',        # -fobjc-call-cxx-cdtors
908           'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES',      # -fvisibility=hidden
909           'GCC_THREADSAFE_STATICS': 'NO',           # -fno-threadsafe-statics
910           'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES',    # -Werror
911           'GCC_VERSION': '4.2',
912           'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES',  # -Wnewline-eof
913           # MACOSX_DEPLOYMENT_TARGET maps to -mmacosx-version-min
914           'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
915           'PREBINDING': 'NO',                       # No -Wl,-prebind
916           'USE_HEADERMAP': 'NO',
917           'WARNING_CFLAGS': ['-Wall', '-Wendif-labels'],
918           'conditions': [
919             ['chromium_mac_pch', {'GCC_PRECOMPILE_PREFIX_HEADER': 'YES'},
920                                  {'GCC_PRECOMPILE_PREFIX_HEADER': 'NO'}
921             ],
922           ],
923         },
924         'target_conditions': [
925           ['_type!="static_library"', {
926             'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
927           }],
928           ['_mac_bundle', {
929             'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-ObjC']},
930           }],
931           ['_type=="executable" or _type=="shared_library"', {
932             'target_conditions': [
933               ['mac_real_dsym == 1', {
934                 # To get a real .dSYM bundle produced by dsymutil, set the
935                 # debug information format to dwarf-with-dsym.  Since
936                 # strip_from_xcode will not be used, set Xcode to do the
937                 # stripping as well.
938                 'configurations': {
939                   'Release_Base': {
940                     'xcode_settings': {
941                       'DEBUG_INFORMATION_FORMAT': 'dwarf-with-dsym',
942                       'DEPLOYMENT_POSTPROCESSING': 'YES',
943                       'STRIP_INSTALLED_PRODUCT': 'YES',
944                       'target_conditions': [
945                         ['_type=="shared_library"', {
946                           # The Xcode default is to strip debugging symbols
947                           # only (-S).  Local symbols should be stripped as
948                           # well, which will be handled by -x.  Xcode will
949                           # continue to insert -S when stripping even when
950                           # additional flags are added with STRIPFLAGS.
951                           'STRIPFLAGS': '-x',
952                         }],  # _type=="shared_library"
953                       ],  # target_conditions
954                     },  # xcode_settings
955                   },  # configuration "Release"
956                 },  # configurations
957               }, {  # mac_real_dsym != 1
958                 # To get a fast fake .dSYM bundle, use a post-build step to
959                 # produce the .dSYM and strip the executable.  strip_from_xcode
960                 # only operates in the Release configuration.
961                 'postbuilds': [
962                   {
963                     'variables': {
964                       # Define strip_from_xcode in a variable ending in _path
965                       # so that gyp understands it's a path and performs proper
966                       # relativization during dict merging.
967                       'strip_from_xcode_path': 'mac/strip_from_xcode',
968                     },
969                     'postbuild_name': 'Strip If Needed',
970                     'action': ['<(strip_from_xcode_path)'],
971                   },
972                 ],  # postbuilds
973               }],  # mac_real_dsym
974             ],  # target_conditions
975           }],  # _type=="executable" or _type=="shared_library"
976         ],  # target_conditions
977       },  # target_defaults
978     }],  # OS=="mac"
979     ['OS=="win"', {
980       'target_defaults': {
981         'defines': [
982           '_WIN32_WINNT=0x0600',
983           'WINVER=0x0600',
984           'WIN32',
985           '_WINDOWS',
986           '_HAS_EXCEPTIONS=0',
987           'NOMINMAX',
988           '_CRT_RAND_S',
989           'CERT_CHAIN_PARA_HAS_EXTRA_FIELDS',
990           'WIN32_LEAN_AND_MEAN',
991           '_SECURE_ATL',
992           '_HAS_TR1=0',
993         ],
994         'msvs_system_include_dirs': [
995           '<(DEPTH)/third_party/platformsdk_win7/files/Include',
996           '$(VSInstallDir)/VC/atlmfc/include',
997         ],
998         'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
999         'msvs_disabled_warnings': [
1000           4100, 4127, 4396, 4503, 4512, 4819, 4995, 4702
1001         ],
1002         'msvs_settings': {
1003           'VCCLCompilerTool': {
1004             'MinimalRebuild': 'false',
1005             'ExceptionHandling': '0',
1006             'BufferSecurityCheck': 'true',
1007             'EnableFunctionLevelLinking': 'true',
1008             'RuntimeTypeInfo': 'false',
1009             'WarningLevel': '4',
1010             'WarnAsError': 'true',
1011             'DebugInformationFormat': '3',
1012             'conditions': [
1013               [ 'msvs_multi_core_compile', {
1014                 'AdditionalOptions': ['/MP'],
1015               }],
1016             ],
1017           },
1018           'VCLibrarianTool': {
1019             'AdditionalOptions': ['/ignore:4221'],
1020             'AdditionalLibraryDirectories':
1021               ['<(DEPTH)/third_party/platformsdk_win7/files/Lib'],
1022           },
1023           'VCLinkerTool': {
1024             'AdditionalDependencies': [
1025               'wininet.lib',
1026               'version.lib',
1027               'msimg32.lib',
1028               'ws2_32.lib',
1029               'usp10.lib',
1030               'psapi.lib',
1031               'dbghelp.lib',
1032             ],
1033             'AdditionalLibraryDirectories':
1034               ['<(DEPTH)/third_party/platformsdk_win7/files/Lib'],
1035             'GenerateDebugInformation': 'true',
1036             'MapFileName': '$(OutDir)\\$(TargetName).map',
1037             'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
1038             'FixedBaseAddress': '1',
1039             # SubSystem values:
1040             #   0 == not set
1041             #   1 == /SUBSYSTEM:CONSOLE
1042             #   2 == /SUBSYSTEM:WINDOWS
1043             # Most of the executables we'll ever create are tests
1044             # and utilities with console output.
1045             'SubSystem': '1',
1046           },
1047           'VCMIDLTool': {
1048             'GenerateStublessProxies': 'true',
1049             'TypeLibraryName': '$(InputName).tlb',
1050             'OutputDirectory': '$(IntDir)',
1051             'HeaderFileName': '$(InputName).h',
1052             'DLLDataFileName': 'dlldata.c',
1053             'InterfaceIdentifierFileName': '$(InputName)_i.c',
1054             'ProxyFileName': '$(InputName)_p.c',
1055           },
1056           'VCResourceCompilerTool': {
1057             'Culture' : '1033',
1058             'AdditionalIncludeDirectories': ['<(DEPTH)'],
1059           },
1060         },
1061       },
1062     }],
1063     ['disable_nacl==1 or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
1064       'target_defaults': {
1065         'defines': [
1066           'DISABLE_NACL',
1067         ],
1068       },
1069     }],
1070     ['OS=="win" and msvs_use_common_linker_extras', {
1071       'target_defaults': {
1072         'msvs_settings': {
1073           'VCLinkerTool': {
1074             'DelayLoadDLLs': [
1075               'dbghelp.dll',
1076               'dwmapi.dll',
1077               'uxtheme.dll',
1078             ],
1079           },
1080         },
1081         'configurations': {
1082           'x86_Base': {
1083             'msvs_settings': {
1084               'VCLinkerTool': {
1085                 'AdditionalOptions': [
1086                   '/safeseh',
1087                   '/dynamicbase',
1088                   '/ignore:4199',
1089                   '/ignore:4221',
1090                   '/nxcompat',
1091                 ],
1092               },
1093             },
1094           },
1095           'x64_Base': {
1096             'msvs_settings': {
1097               'VCLinkerTool': {
1098                 'AdditionalOptions': [
1099                   # safeseh is not compatible with x64
1100                   '/dynamicbase',
1101                   '/ignore:4199',
1102                   '/ignore:4221',
1103                   '/nxcompat',
1104                 ],
1105               },
1106             },
1107           },
1108         },
1109       },
1110     }],
1111     ['enable_new_npdevice_api==1', {
1112       'target_defaults': {
1113         'defines': [
1114           'ENABLE_NEW_NPDEVICE_API',
1115         ],
1116       },
1117     }],
1118   ],
1119   'scons_settings': {
1120     'sconsbuild_dir': '<(DEPTH)/sconsbuild',
1121     'tools': ['ar', 'as', 'gcc', 'g++', 'gnulink', 'chromium_builders'],
1122   },
1123   'xcode_settings': {
1124     # DON'T ADD ANYTHING NEW TO THIS BLOCK UNLESS YOU REALLY REALLY NEED IT!
1125     # This block adds *project-wide* configuration settings to each project
1126     # file.  It's almost always wrong to put things here.  Specify your
1127     # custom xcode_settings in target_defaults to add them to targets instead.
1128
1129     # In an Xcode Project Info window, the "Base SDK for All Configurations"
1130     # setting sets the SDK on a project-wide basis.  In order to get the
1131     # configured SDK to show properly in the Xcode UI, SDKROOT must be set
1132     # here at the project level.
1133     'SDKROOT': 'macosx<(mac_sdk)',  # -isysroot
1134
1135     # The Xcode generator will look for an xcode_settings section at the root
1136     # of each dict and use it to apply settings on a file-wide basis.  Most
1137     # settings should not be here, they should be in target-specific
1138     # xcode_settings sections, or better yet, should use non-Xcode-specific
1139     # settings in target dicts.  SYMROOT is a special case, because many other
1140     # Xcode variables depend on it, including variables such as
1141     # PROJECT_DERIVED_FILE_DIR.  When a source group corresponding to something
1142     # like PROJECT_DERIVED_FILE_DIR is added to a project, in order for the
1143     # files to appear (when present) in the UI as actual files and not red
1144     # red "missing file" proxies, the correct path to PROJECT_DERIVED_FILE_DIR,
1145     # and therefore SYMROOT, needs to be set at the project level.
1146     'SYMROOT': '<(DEPTH)/xcodebuild',
1147   },
1148 }