• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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%': 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      # Whether to use multiple cores to compile with visual studio. This is
207      # optional because it sometimes causes corruption on VS 2005.
208      # It is on by default on VS 2008 and off on VS 2005.
209      ['OS=="win"', {
210        'conditions': [
211          ['MSVS_VERSION=="2005"', {
212            'msvs_multi_core_compile%': 0,
213          },{
214            'msvs_multi_core_compile%': 1,
215          }],
216          # Don't do incremental linking for large modules on 32-bit.
217          ['MSVS_OS_BITS==32', {
218            'msvs_large_module_debug_link_mode%': '1',  # No
219          },{
220            'msvs_large_module_debug_link_mode%': '2',  # Yes
221          }],
222        ],
223        'nacl_win64_defines': [
224          # This flag is used to minimize dependencies when building
225          # Native Client loader for 64-bit Windows.
226          'NACL_WIN64',
227        ],
228      }],
229    ],
230
231    # NOTE: When these end up in the Mac bundle, we need to replace '-' for '_'
232    # so Cocoa is happy (http://crbug.com/20441).
233    'locales': [
234      'am', 'ar', 'bg', 'bn', 'ca', 'cs', 'da', 'de', 'el', 'en-GB',
235      'en-US', 'es-419', 'es', 'et', 'fi', 'fil', 'fr', 'gu', 'he',
236      'hi', 'hr', 'hu', 'id', 'it', 'ja', 'kn', 'ko', 'lt', 'lv',
237      'ml', 'mr', 'nb', 'nl', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru',
238      'sk', 'sl', 'sr', 'sv', 'sw', 'ta', 'te', 'th', 'tr', 'uk',
239      'vi', 'zh-CN', 'zh-TW',
240    ],
241  },
242  'target_defaults': {
243    'includes': [
244      'filename_rules.gypi',
245    ],
246    'variables': {
247      # See http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Optimize-Options.html
248      'mac_release_optimization%': '3', # Use -O3 unless overridden
249      'mac_debug_optimization%': '0',   # Use -O0 unless overridden
250      # See http://msdn.microsoft.com/en-us/library/aa652360(VS.71).aspx
251      'win_release_Optimization%': '2', # 2 = /Os
252      'win_debug_Optimization%': '0',   # 0 = /Od
253      # See http://msdn.microsoft.com/en-us/library/aa652367(VS.71).aspx
254      'win_release_RuntimeLibrary%': '0', # 0 = /MT (nondebug static)
255      'win_debug_RuntimeLibrary%': '1',   # 1 = /MTd (debug static)
256
257      'release_extra_cflags%': '',
258      'debug_extra_cflags%': '',
259      'release_valgrind_build%': 0,
260    },
261    'conditions': [
262      ['selinux==1', {
263        'defines': ['CHROMIUM_SELINUX=1'],
264      }],
265      ['win_use_allocator_shim==0', {
266        'conditions': [
267          ['OS=="win"', {
268            'defines': ['NO_TCMALLOC'],
269          }],
270        ],
271      }],
272      ['coverage!=0', {
273        'conditions': [
274          ['OS=="mac"', {
275            'xcode_settings': {
276              'GCC_INSTRUMENT_PROGRAM_FLOW_ARCS': 'YES',  # -fprofile-arcs
277              'GCC_GENERATE_TEST_COVERAGE_FILES': 'YES',  # -ftest-coverage
278            },
279            # Add -lgcov for types executable, shared_library, and
280            # loadable_module; not for static_library.
281            # This is a delayed conditional.
282            'target_conditions': [
283              ['_type!="static_library"', {
284                'xcode_settings': { 'OTHER_LDFLAGS': [ '-lgcov' ] },
285              }],
286            ],
287          }],
288          # Linux gyp (into scons) doesn't like target_conditions?
289          # TODO(???): track down why 'target_conditions' doesn't work
290          # on Linux gyp into scons like it does on Mac gyp into xcodeproj.
291          ['OS=="linux"', {
292            'cflags': [ '-ftest-coverage',
293                        '-fprofile-arcs' ],
294            'link_settings': { 'libraries': [ '-lgcov' ] },
295          }],
296          # Finally, for Windows, we simply turn on profiling.
297          ['OS=="win"', {
298            'msvs_settings': {
299              'VCLinkerTool': {
300                'Profile': 'true',
301              },
302              'VCCLCompilerTool': {
303                # /Z7, not /Zi, so coverage is happyb
304                'DebugInformationFormat': '1',
305                'AdditionalOptions': ['/Yd'],
306              }
307            }
308         }],  # OS==win
309        ],  # conditions for coverage
310      }],  # coverage!=0
311    ],  # conditions for 'target_defaults'
312    'target_conditions': [
313      [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
314        'cflags!': [
315          '-Wall',
316          '-Wextra',
317          '-Werror',
318        ],
319      }],
320      [ 'OS=="win"', {
321        'defines': [
322          '_CRT_SECURE_NO_DEPRECATE',
323          '_CRT_NONSTDC_NO_WARNINGS',
324          '_CRT_NONSTDC_NO_DEPRECATE',
325          # This is required for ATL to use XP-safe versions of its functions.
326          '_USING_V110_SDK71_',
327        ],
328        'msvs_disabled_warnings': [4800],
329        'msvs_settings': {
330          'VCCLCompilerTool': {
331            'WarnAsError': 'true',
332            'Detect64BitPortabilityProblems': 'false',
333          },
334        },
335      }],
336      [ 'OS=="mac"', {
337        'xcode_settings': {
338          'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO',
339          'WARNING_CFLAGS!': ['-Wall'],
340        },
341      }],
342    ],  # target_conditions for 'target_defaults'
343    'default_configuration': 'Debug',
344    'configurations': {
345      # VCLinkerTool LinkIncremental values below:
346      #   0 == default
347      #   1 == /INCREMENTAL:NO
348      #   2 == /INCREMENTAL
349      # Debug links incremental, Release does not.
350      #
351      # Abstract base configurations to cover common
352      # attributes.
353      #
354      'Common_Base': {
355        'abstract': 1,
356        'msvs_configuration_attributes': {
357          'OutputDirectory': '$(SolutionDir)$(ConfigurationName)',
358          'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)',
359          'CharacterSet': '1',
360        },
361      },
362      'x86_Base': {
363        'abstract': 1,
364        'msvs_settings': {
365          'VCLinkerTool': {
366            'MinimumRequiredVersion': '5.01',  # XP.
367            'TargetMachine': '1',
368          },
369        },
370        'msvs_configuration_platform': 'Win32',
371      },
372      'x64_Base': {
373        'abstract': 1,
374        'msvs_configuration_platform': 'x64',
375        'msvs_settings': {
376          'VCLinkerTool': {
377            'TargetMachine': '17', # x86 - 64
378            'AdditionalLibraryDirectories!':
379              ['<(DEPTH)/third_party/platformsdk_win7/files/Lib'],
380            'AdditionalLibraryDirectories':
381              ['<(DEPTH)/third_party/platformsdk_win7/files/Lib/x64'],
382          },
383          'VCLibrarianTool': {
384            'AdditionalLibraryDirectories!':
385              ['<(DEPTH)/third_party/platformsdk_win7/files/Lib'],
386            'AdditionalLibraryDirectories':
387              ['<(DEPTH)/third_party/platformsdk_win7/files/Lib/x64'],
388          },
389        },
390        'defines': [
391          # Not sure if tcmalloc works on 64-bit Windows.
392          'NO_TCMALLOC',
393        ],
394      },
395      'Debug_Base': {
396        'abstract': 1,
397        'xcode_settings': {
398          'COPY_PHASE_STRIP': 'NO',
399          'GCC_OPTIMIZATION_LEVEL': '<(mac_debug_optimization)',
400          'OTHER_CFLAGS': [ '<@(debug_extra_cflags)', ],
401        },
402        'msvs_settings': {
403          'VCCLCompilerTool': {
404            'Optimization': '<(win_debug_Optimization)',
405            'PreprocessorDefinitions': ['_DEBUG'],
406            'BasicRuntimeChecks': '3',
407            'RuntimeLibrary': '<(win_debug_RuntimeLibrary)',
408          },
409          'VCLinkerTool': {
410            'LinkIncremental': '<(msvs_debug_link_incremental)',
411          },
412          'VCResourceCompilerTool': {
413            'PreprocessorDefinitions': ['_DEBUG'],
414          },
415        },
416        'conditions': [
417          ['OS=="linux"', {
418            'cflags': [
419              '<@(debug_extra_cflags)',
420            ],
421          }],
422        ],
423      },
424      'Release_Base': {
425        'abstract': 1,
426        'defines': [
427          'NDEBUG',
428        ],
429        'xcode_settings': {
430          'DEAD_CODE_STRIPPING': 'YES',  # -Wl,-dead_strip
431          'GCC_OPTIMIZATION_LEVEL': '<(mac_release_optimization)',
432          'OTHER_CFLAGS': [ '<@(release_extra_cflags)', ],
433        },
434        'msvs_settings': {
435          'VCCLCompilerTool': {
436            'Optimization': '<(win_release_Optimization)',
437            'RuntimeLibrary': '<(win_release_RuntimeLibrary)',
438          },
439          'VCLinkerTool': {
440            'LinkIncremental': '1',
441          },
442        },
443        'conditions': [
444          ['release_valgrind_build==0', {
445            'defines': ['NVALGRIND'],
446          }],
447          ['win_use_allocator_shim==0', {
448            'defines': ['NO_TCMALLOC'],
449          }],
450          ['win_release_RuntimeLibrary==2', {
451            # Visual C++ 2008 barfs when building anything with /MD (msvcrt):
452            #  VC\include\typeinfo(139) : warning C4275: non dll-interface
453            #  class 'stdext::exception' used as base for dll-interface
454            #  class 'std::bad_cast'
455            'msvs_disabled_warnings': [4275],
456          }],
457          ['OS=="linux"', {
458            'cflags': [
459             '<@(release_extra_cflags)',
460            ],
461          }],
462        ],
463      },
464      'Purify_Base': {
465        'abstract': 1,
466        'defines': [
467          'PURIFY',
468          'NO_TCMALLOC',
469        ],
470        'msvs_settings': {
471          'VCCLCompilerTool': {
472            'Optimization': '0',
473            'RuntimeLibrary': '0',
474            'BufferSecurityCheck': 'false',
475          },
476          'VCLinkerTool': {
477            'EnableCOMDATFolding': '1',
478            'LinkIncremental': '1',
479          },
480        },
481      },
482      #
483      # Concrete configurations
484      #
485      'Debug': {
486        'inherit_from': ['Common_Base', 'x86_Base', 'Debug_Base'],
487      },
488      'Release': {
489        'inherit_from': ['Common_Base', 'x86_Base', 'Release_Base'],
490        'conditions': [
491          ['msvs_use_common_release', {
492            'defines': ['OFFICIAL_BUILD'],
493            'msvs_settings': {
494              'VCCLCompilerTool': {
495                'Optimization': '3',
496                'StringPooling': 'true',
497                'OmitFramePointers': 'true',
498                'InlineFunctionExpansion': '2',
499                'EnableIntrinsicFunctions': 'true',
500                'FavorSizeOrSpeed': '2',
501                'OmitFramePointers': 'true',
502                'EnableFiberSafeOptimizations': 'true',
503                'WholeProgramOptimization': 'true',
504              },
505              'VCLibrarianTool': {
506                'AdditionalOptions': ['/ltcg', '/expectedoutputsize:120000000'],
507              },
508              'VCLinkerTool': {
509                'LinkIncremental': '1',
510                'OptimizeReferences': '2',
511                'EnableCOMDATFolding': '2',
512                'OptimizeForWindows98': '1',
513                'LinkTimeCodeGeneration': '1',
514              },
515            },
516          }],
517        ]
518      },
519      'conditions': [
520        [ 'OS=="win"', {
521          # TODO(bradnelson): add a gyp mechanism to make this more graceful.
522          'Purify': {
523            'inherit_from': ['Common_Base', 'x86_Base', 'Release_Base', 'Purify'],
524          },
525          'Debug_x64': {
526            'inherit_from': ['Common_Base', 'x64_Base', 'Debug_Base'],
527          },
528          'Release_x64': {
529            'inherit_from': ['Common_Base', 'x64_Base', 'Release_Base'],
530          },
531          'Purify_x64': {
532            'inherit_from': ['Common_Base', 'x64_Base', 'Release_Base', 'Purify_Base'],
533          },
534        }],
535      ],
536    },
537  },
538  'conditions': [
539    ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
540      'target_defaults': {
541        # Enable -Werror by default, but put it in a variable so it can
542        # be disabled in ~/.gyp/include.gypi on the valgrind builders.
543        'variables': {
544          # Use -fno-strict-aliasing by default since gcc 4.4 has periodic
545          # issues that slip through the cracks. We could do this just for
546          # gcc 4.4 but it makes more sense to be consistent on all
547          # compilers in use. TODO(Craig): turn this off again when
548          # there is some 4.4 test infrastructure in place and existing
549          # aliasing issues have been fixed.
550          'no_strict_aliasing%': 1,
551          'conditions': [['OS=="linux"', {'werror%': '-Werror',}],
552                         ['OS=="freebsd"', {'werror%': '',}],
553                         ['OS=="openbsd"', {'werror%': '',}],
554          ],
555        },
556        'cflags': [
557          '<(werror)',  # See note above about the werror variable.
558          '-pthread',
559          '-fno-exceptions',
560          '-Wall',
561          # TODO(evan): turn this back on once all the builds work.
562          # '-Wextra',
563          # Don't warn about unused function params.  We use those everywhere.
564          '-Wno-unused-parameter',
565          # Don't warn about the "struct foo f = {0};" initialization pattern.
566          '-Wno-missing-field-initializers',
567          '-D_FILE_OFFSET_BITS=64',
568          # Don't export any symbols (for example, to plugins we dlopen()).
569          # Note: this is *required* to make some plugins work.
570          '-fvisibility=hidden',
571        ],
572        'cflags_cc': [
573          '-frtti',
574          '-fno-threadsafe-statics',
575          # Make inline functions have hidden visiblity by default.
576          # Surprisingly, not covered by -fvisibility=hidden.
577          '-fvisibility-inlines-hidden',
578        ],
579        'ldflags': [
580          '-pthread', '-Wl,-z,noexecstack',
581        ],
582        'scons_variable_settings': {
583          'LIBPATH': ['$LIB_DIR'],
584          # Linking of large files uses lots of RAM, so serialize links
585          # using the handy flock command from util-linux.
586          'FLOCK_LINK': ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'],
587          'FLOCK_SHLINK': ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'],
588          'FLOCK_LDMODULE': ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'],
589
590          # We have several cases where archives depend on each other in
591          # a cyclic fashion.  Since the GNU linker does only a single
592          # pass over the archives we surround the libraries with
593          # --start-group and --end-group (aka -( and -) ). That causes
594          # ld to loop over the group until no more undefined symbols
595          # are found. In an ideal world we would only make groups from
596          # those libraries which we knew to be in cycles. However,
597          # that's tough with SCons, so we bodge it by making all the
598          # archives a group by redefining the linking command here.
599          #
600          # TODO:  investigate whether we still have cycles that
601          # require --{start,end}-group.  There has been a lot of
602          # refactoring since this was first coded, which might have
603          # eliminated the circular dependencies.
604          #
605          # Note:  $_LIBDIRFLAGS comes before ${LINK,SHLINK,LDMODULE}FLAGS
606          # so that we prefer our own built libraries (e.g. -lpng) to
607          # system versions of libraries that pkg-config might turn up.
608          # TODO(sgk): investigate handling this not by re-ordering the
609          # flags this way, but by adding a hook to use the SCons
610          # ParseFlags() option on the output from pkg-config.
611          'LINKCOM': [['$FLOCK_LINK', '-o', '$TARGET',
612                       '$_LIBDIRFLAGS', '$LINKFLAGS', '$SOURCES',
613                       '-Wl,--start-group', '$_LIBFLAGS', '-Wl,--end-group']],
614          'SHLINKCOM': [['$FLOCK_SHLINK', '-o', '$TARGET',
615                         '$_LIBDIRFLAGS', '$SHLINKFLAGS', '$SOURCES',
616                         '-Wl,--start-group', '$_LIBFLAGS', '-Wl,--end-group']],
617          'LDMODULECOM': [['$FLOCK_LDMODULE', '-o', '$TARGET',
618                           '$_LIBDIRFLAGS', '$LDMODULEFLAGS', '$SOURCES',
619                           '-Wl,--start-group', '$_LIBFLAGS', '-Wl,--end-group']],
620          'IMPLICIT_COMMAND_DEPENDENCIES': 0,
621        },
622        'scons_import_variables': [
623          'AS',
624          'CC',
625          'CXX',
626          'LINK',
627        ],
628        'scons_propagate_variables': [
629          'AS',
630          'CC',
631          'CCACHE_DIR',
632          'CXX',
633          'DISTCC_DIR',
634          'DISTCC_HOSTS',
635          'HOME',
636          'INCLUDE_SERVER_ARGS',
637          'INCLUDE_SERVER_PORT',
638          'LINK',
639          'CHROME_BUILD_TYPE',
640          'CHROMIUM_BUILD',
641          'OFFICIAL_BUILD',
642        ],
643        'configurations': {
644          'Debug_Base': {
645            'variables': {
646              'debug_optimize%': '0',
647            },
648            'defines': [
649              '_DEBUG',
650            ],
651            'cflags': [
652              '-O>(debug_optimize)',
653              '-g',
654              # One can use '-gstabs' to enable building the debugging
655              # information in STABS format for breakpad's dumpsyms.
656            ],
657            'ldflags': [
658              '-rdynamic',  # Allows backtrace to resolve symbols.
659            ],
660          },
661          'Release_Base': {
662            'variables': {
663              'release_optimize%': '2',
664            },
665            'cflags': [
666              '-O>(release_optimize)',
667              # Don't emit the GCC version ident directives, they just end up
668              # in the .comment section taking up binary size.
669              '-fno-ident',
670              # Put data and code in their own sections, so that unused symbols
671              # can be removed at link time with --gc-sections.
672              '-fdata-sections',
673              '-ffunction-sections',
674            ],
675            'ldflags': [
676              '-Wl,--gc-sections',
677            ],
678          },
679        },
680        'variants': {
681          'coverage': {
682            'cflags': ['-fprofile-arcs', '-ftest-coverage'],
683            'ldflags': ['-fprofile-arcs'],
684          },
685          'profile': {
686            'cflags': ['-pg', '-g'],
687            'ldflags': ['-pg'],
688          },
689          'symbols': {
690            'cflags': ['-g'],
691          },
692        },
693        'conditions': [
694          [ 'target_arch=="ia32"', {
695            'asflags': [
696              # Needed so that libs with .s files (e.g. libicudata.a)
697              # are compatible with the general 32-bit-ness.
698              '-32',
699            ],
700            # All floating-point computations on x87 happens in 80-bit
701            # precision.  Because the C and C++ language standards allow
702            # the compiler to keep the floating-point values in higher
703            # precision than what's specified in the source and doing so
704            # is more efficient than constantly rounding up to 64-bit or
705            # 32-bit precision as specified in the source, the compiler,
706            # especially in the optimized mode, tries very hard to keep
707            # values in x87 floating-point stack (in 80-bit precision)
708            # as long as possible. This has important side effects, that
709            # the real value used in computation may change depending on
710            # how the compiler did the optimization - that is, the value
711            # kept in 80-bit is different than the value rounded down to
712            # 64-bit or 32-bit. There are possible compiler options to make
713            # this behavior consistent (e.g. -ffloat-store would keep all
714            # floating-values in the memory, thus force them to be rounded
715            # to its original precision) but they have significant runtime
716            # performance penalty.
717            #
718            # -mfpmath=sse -msse2 makes the compiler use SSE instructions
719            # which keep floating-point values in SSE registers in its
720            # native precision (32-bit for single precision, and 64-bit for
721            # double precision values). This means the floating-point value
722            # used during computation does not change depending on how the
723            # compiler optimized the code, since the value is always kept
724            # in its specified precision.
725            'conditions': [
726              ['disable_sse2==0', {
727                'cflags': [
728                  '-march=pentium4',
729                  '-msse2',
730                  '-mfpmath=sse',
731                ],
732              }],
733            ],
734            # -mmmx allows mmintrin.h to be used for mmx intrinsics.
735            # video playback is mmx and sse2 optimized.
736            'cflags': [
737              '-m32',
738              '-mmmx',
739            ],
740            'ldflags': [
741              '-m32',
742            ],
743          }],
744          ['target_arch=="arm"', {
745            'target_conditions': [
746              ['_toolset=="target"', {
747                'cflags_cc': [
748                  # The codesourcery arm-2009q3 toolchain warns at that the ABI
749                  # has changed whenever it encounters a varargs function. This
750                  # silences those warnings, as they are not helpful and
751                  # clutter legitimate warnings.
752                  '-Wno-abi',
753                ],
754                'conditions': [
755                  ['arm_thumb == 1', {
756                    'cflags': [
757                    '-mthumb',
758                    # TODO(piman): -Wa,-mimplicit-it=thumb is needed for
759                    # inline assembly that uses condition codes but it's
760                    # suboptimal. Better would be to #ifdef __thumb__ at the
761                    # right place and have a separate thumb path.
762                    '-Wa,-mimplicit-it=thumb',
763                    ]
764                  }],
765                  ['arm_version==7', {
766                    'cflags': [
767                      '-march=armv7-a',
768                      '-mtune=cortex-a8',
769                      '-mfloat-abi=softfp',
770                    ],
771                    'conditions': [
772                      ['arm_neon==1', {
773                        'cflags': [ '-mfpu=neon', ],
774                      }, {
775                        'cflags': [ '-mfpu=<(arm_fpu)', ],
776                      }]
777                    ],
778                  }],
779                ],
780              }],
781            ],
782          }],
783          ['linux_fpic==1', {
784            'cflags': [
785              '-fPIC',
786            ],
787          }],
788          ['sysroot!=""', {
789            'target_conditions': [
790              ['_toolset=="target"', {
791                'cflags': [
792                  '--sysroot=<(sysroot)',
793                ],
794                'ldflags': [
795                  '--sysroot=<(sysroot)',
796                ],
797              }]]
798          }],
799          ['no_strict_aliasing==1', {
800            'cflags': [
801              '-fno-strict-aliasing',
802            ],
803          }],
804          ['linux_use_heapchecker==1', {
805            'variables': {'linux_use_tcmalloc%': 1},
806          }],
807          ['linux_use_tcmalloc==0', {
808            'defines': ['NO_TCMALLOC'],
809          }],
810          ['linux_use_heapchecker==0', {
811            'defines': ['NO_HEAPCHECKER'],
812          }],
813        ],
814      },
815    }],
816    # FreeBSD-specific options; note that most FreeBSD options are set above,
817    # with Linux.
818    ['OS=="freebsd"', {
819      'target_defaults': {
820        'ldflags': [
821          '-Wl,--no-keep-memory',
822        ],
823      },
824    }],
825    ['OS=="solaris"', {
826      'cflags!': ['-fvisibility=hidden'],
827      'cflags_cc!': ['-fvisibility-inlines-hidden'],
828    }],
829    ['OS=="mac"', {
830      'target_defaults': {
831        'variables': {
832          # This should be 'mac_real_dsym%', but there seems to be a bug
833          # with % in variables that are intended to be set to different
834          # values in different targets, like this one.
835          'mac_real_dsym': 0,  # Fake .dSYMs are fine in most cases.
836        },
837        'mac_bundle': 0,
838        'xcode_settings': {
839          'ALWAYS_SEARCH_USER_PATHS': 'NO',
840          'GCC_C_LANGUAGE_STANDARD': 'c99',         # -std=c99
841          'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
842          'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
843                                                    # (Equivalent to -fPIC)
844          'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
845          'GCC_ENABLE_CPP_RTTI': 'YES',             # -frtti
846          'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
847          # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
848          'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
849          'GCC_OBJC_CALL_CXX_CDTORS': 'YES',        # -fobjc-call-cxx-cdtors
850          'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES',      # -fvisibility=hidden
851          'GCC_THREADSAFE_STATICS': 'NO',           # -fno-threadsafe-statics
852          'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES',    # -Werror
853          'GCC_VERSION': '4.2',
854          'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES',  # -Wnewline-eof
855          # MACOSX_DEPLOYMENT_TARGET maps to -mmacosx-version-min
856          'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
857          'PREBINDING': 'NO',                       # No -Wl,-prebind
858          'USE_HEADERMAP': 'NO',
859          'WARNING_CFLAGS': ['-Wall', '-Wendif-labels'],
860          'conditions': [
861            ['chromium_mac_pch', {'GCC_PRECOMPILE_PREFIX_HEADER': 'YES'},
862                                 {'GCC_PRECOMPILE_PREFIX_HEADER': 'NO'}
863            ],
864          ],
865        },
866        'target_conditions': [
867          ['_type!="static_library"', {
868            'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
869          }],
870          ['_mac_bundle', {
871            'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-ObjC']},
872          }],
873        ],  # target_conditions
874      },  # target_defaults
875    }],  # OS=="mac"
876    ['OS=="win"', {
877      'target_defaults': {
878        'defines': [
879          '_WIN32_WINNT=0x0600',
880          'WINVER=0x0600',
881          'WIN32',
882          '_WINDOWS',
883          '_HAS_EXCEPTIONS=0',
884          'NOMINMAX',
885          '_CRT_RAND_S',
886          'CERT_CHAIN_PARA_HAS_EXTRA_FIELDS',
887          'WIN32_LEAN_AND_MEAN',
888          '_SECURE_ATL',
889          '_HAS_TR1=0',
890        ],
891        'msvs_system_include_dirs': [
892          '<(DEPTH)/third_party/platformsdk_win7/files/Include',
893          '$(VSInstallDir)/VC/atlmfc/include',
894        ],
895        'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
896        'msvs_disabled_warnings': [
897          4091, 4100, 4127, 4366, 4396, 4503, 4512, 4819, 4995, 4702
898        ],
899        'msvs_settings': {
900          'VCCLCompilerTool': {
901            'MinimalRebuild': 'false',
902            'ExceptionHandling': '0',
903            'BufferSecurityCheck': 'true',
904            'EnableFunctionLevelLinking': 'true',
905            'RuntimeTypeInfo': 'false',
906            'WarningLevel': '4',
907            'WarnAsError': 'true',
908            'DebugInformationFormat': '3',
909            'conditions': [
910              [ 'msvs_multi_core_compile', {
911                'AdditionalOptions': ['/MP'],
912              }],
913            ],
914          },
915          'VCLibrarianTool': {
916            'AdditionalOptions': ['/ignore:4221'],
917            'AdditionalLibraryDirectories':
918              ['<(DEPTH)/third_party/platformsdk_win7/files/Lib'],
919          },
920          'VCLinkerTool': {
921            'AdditionalDependencies': [
922              'wininet.lib',
923              'version.lib',
924              'msimg32.lib',
925              'ws2_32.lib',
926              'usp10.lib',
927              'psapi.lib',
928              'dbghelp.lib',
929            ],
930            'AdditionalLibraryDirectories':
931              ['<(DEPTH)/third_party/platformsdk_win7/files/Lib'],
932            'GenerateDebugInformation': 'true',
933            'MapFileName': '$(OutDir)\\$(TargetName).map',
934            'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
935            'FixedBaseAddress': '1',
936            # SubSystem values:
937            #   0 == not set
938            #   1 == /SUBSYSTEM:CONSOLE
939            #   2 == /SUBSYSTEM:WINDOWS
940            # Most of the executables we'll ever create are tests
941            # and utilities with console output.
942            'SubSystem': '1',
943          },
944          'VCMIDLTool': {
945            'GenerateStublessProxies': 'true',
946            'TypeLibraryName': '$(InputName).tlb',
947            'OutputDirectory': '$(IntDir)',
948            'HeaderFileName': '$(InputName).h',
949            'DLLDataFileName': 'dlldata.c',
950            'InterfaceIdentifierFileName': '$(InputName)_i.c',
951            'ProxyFileName': '$(InputName)_p.c',
952          },
953          'VCResourceCompilerTool': {
954            'Culture' : '1033',
955            'AdditionalIncludeDirectories': ['<(DEPTH)'],
956          },
957        },
958      },
959    }],
960    ['disable_nacl==1 or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
961      'target_defaults': {
962        'defines': [
963          'DISABLE_NACL',
964        ],
965      },
966    }],
967    ['OS=="win" and msvs_use_common_linker_extras', {
968      'target_defaults': {
969        'msvs_settings': {
970          'VCLinkerTool': {
971            'DelayLoadDLLs': [
972              'dbghelp.dll',
973              'dwmapi.dll',
974              'uxtheme.dll',
975            ],
976          },
977        },
978        'configurations': {
979          'x86_Base': {
980            'msvs_settings': {
981              'VCLinkerTool': {
982                'AdditionalOptions': [
983                  '/safeseh',
984                  '/dynamicbase',
985                  '/ignore:4199',
986                  '/ignore:4221',
987                  '/nxcompat',
988                ],
989              },
990            },
991          },
992          'x64_Base': {
993            'msvs_settings': {
994              'VCLinkerTool': {
995                'AdditionalOptions': [
996                  # safeseh is not compatible with x64
997                  '/dynamicbase',
998                  '/ignore:4199',
999                  '/ignore:4221',
1000                  '/nxcompat',
1001                ],
1002              },
1003            },
1004          },
1005        },
1006      },
1007    }],
1008    ['enable_new_npdevice_api==1', {
1009      'target_defaults': {
1010        'defines': [
1011          'ENABLE_NEW_NPDEVICE_API',
1012        ],
1013      },
1014    }],
1015  ],
1016  'scons_settings': {
1017    'sconsbuild_dir': '<(DEPTH)/sconsbuild',
1018    'tools': ['ar', 'as', 'gcc', 'g++', 'gnulink', 'chromium_builders'],
1019  },
1020  'xcode_settings': {
1021    # DON'T ADD ANYTHING NEW TO THIS BLOCK UNLESS YOU REALLY REALLY NEED IT!
1022    # This block adds *project-wide* configuration settings to each project
1023    # file.  It's almost always wrong to put things here.  Specify your
1024    # custom xcode_settings in target_defaults to add them to targets instead.
1025
1026    # In an Xcode Project Info window, the "Base SDK for All Configurations"
1027    # setting sets the SDK on a project-wide basis.  In order to get the
1028    # configured SDK to show properly in the Xcode UI, SDKROOT must be set
1029    # here at the project level.
1030    'SDKROOT': 'macosx<(mac_sdk)',  # -isysroot
1031
1032    # The Xcode generator will look for an xcode_settings section at the root
1033    # of each dict and use it to apply settings on a file-wide basis.  Most
1034    # settings should not be here, they should be in target-specific
1035    # xcode_settings sections, or better yet, should use non-Xcode-specific
1036    # settings in target dicts.  SYMROOT is a special case, because many other
1037    # Xcode variables depend on it, including variables such as
1038    # PROJECT_DERIVED_FILE_DIR.  When a source group corresponding to something
1039    # like PROJECT_DERIVED_FILE_DIR is added to a project, in order for the
1040    # files to appear (when present) in the UI as actual files and not red
1041    # red "missing file" proxies, the correct path to PROJECT_DERIVED_FILE_DIR,
1042    # and therefore SYMROOT, needs to be set at the project level.
1043    'SYMROOT': '<(DEPTH)/xcodebuild',
1044  },
1045}
1046