1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
7 # .gyp files should set chromium_code to 1 if they build Chromium-specific
8 # code, as opposed to external code. This variable is used to control
9 # such things as the set of warnings to enable, and whether warnings are
13 # Variables expected to be overriden on the GYP command line (-D) or by
14 # ~/.gyp/include.gypi.
16 # Override chromium_mac_pch and set it to 0 to suppress the use of
17 # precompiled headers on the Mac. Prefix header injection may still be
18 # used, but prefix headers will not be precompiled. This is useful when
19 # using distcc to distribute a build to compile slaves that don't
20 # share the same compiler executable as the system driving the compilation,
21 # because precompiled headers rely on pointers into a specific compiler
22 # executable's image. Setting this to 0 is needed to use an experimental
23 # Linux-Mac cross compiler distcc farm.
24 'chromium_mac_pch%': 1,
26 # Enable building with ASAN (Clang's -fsanitize=address option).
27 # -fsanitize=address only works with clang, but asan=1 implies clang=1
28 # See https://sites.google.com/a/chromium.org/dev/developers/testing/addresssanitizer
31 # Set this to true when building with Clang.
34 # Set to 1 to enable code coverage. In addition to build changes
35 # (e.g. extra CFLAGS), also creates a new target in the src/chrome
36 # project file called "coverage".
37 # Currently ignored on Windows.
40 # TODO(sgk): eliminate this if possible.
41 # It would be nicer to support this via a setting in 'target_defaults'
42 # in chrome/app/locales/locales.gypi overriding the setting in the
43 # 'Debug' configuration in the 'target_defaults' dict below,
44 # but that doesn't work as we'd like.
45 'msvs_debug_link_incremental%': '2',
47 # NOTE: adapted from them chrome common.gypi file for arm
50 # Set Neon compilation flags (only meaningful if arm_version==7).
53 # Set Thumb compilation flags.
56 # Set ARM fpu compilation flags (only meaningful if arm_version==7 and
60 # Set ARM float abi compilation flag.
61 'arm_float_abi%': 'softfp',
63 # Version of the mac sdk to use.
66 'mac_deployment_target%': '10.6',
68 # NOTE: end adapted from them chrome common.gypi file for arm
70 # Doing this in a sub-dict so that it can be referred to below.
72 # By default we assume that we are building as part of Chrome
74 'nacl_standalone%': 0,
76 # Override branding to select the desired branding flavor.
77 'branding%': 'Chromium',
79 # Override buildtype to select the desired build flavor.
80 # Dev - everyday build for development/testing
81 # Official - release build (generally implies additional processing)
82 # TODO(mmoss) Once 'buildtype' is fully supported (e.g. Windows gyp
83 # conversion is done), some of the things which are now controlled by
84 # 'branding', such as symbol generation, will need to be refactored
85 # based on 'buildtype' (i.e. we don't care about saving symbols for
86 # non-Official builds).
90 # Compute the architecture that we're building for. Default to the
91 # architecture that we're building on.
92 ['OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
93 # This handles the Linux platforms we generally deal with. Anything
94 # else gets passed through, which probably won't work very well;
95 # such hosts should pass an explicit target_arch to gyp.
97 # NOTE: currently only nacl is generating gyp files on an arm board.
98 # The arm.* -> arm substitution in chrome's common.gypi isn't
99 # appropriate in that context as we actually use target_arch==arm
100 # to me x86 -> arm cross compile. When actually running on an arm
101 # board, we'll generate ia32 for now, so that the generation
104 '<!(uname -m | sed -e "s/i.86/ia32/;s/x86_64/x64/;s/amd64/x64/;s/arm.*/ia32/")'
106 'target_arch%': 'ia32',
110 # These come from the above variable scope.
111 'nacl_standalone%': '<(nacl_standalone)',
112 'target_arch%': '<(target_arch)',
113 'branding%': '<(branding)',
114 'buildtype%': '<(buildtype)',
117 # The system root for cross-compiles. Default: none.
118 # If we are building in chrome we want to rely on chrome's default, which
119 # means we can't set a default here.
120 ['nacl_standalone!=0', {
125 # This variable is to allow us to build components as either static
126 # libraries or dynamic shared libraries.
127 'component%': 'static_library',
129 # These come from the above variable scope.
130 'target_arch%': '<(target_arch)',
131 'sysroot%': '<(sysroot)',
132 'nacl_standalone%': '<(nacl_standalone)',
133 'branding%': '<(branding)',
134 'buildtype%': '<(buildtype)',
135 'component%': '<(component)',
137 'nacl_strict_warnings%': 1,
138 'nacl_validator_ragel%': 1,
145 # Putting this first so that people who include "ppapi/..." get the
146 # third_party version instead of any other version (the chrome location
148 '../src/third_party',
154 'target_conditions': [
155 ['win_target=="x64"', {
156 'target_arch': 'x64',
158 'NACL_TARGET_SUBARCH=32',
159 'NACL_BUILD_SUBARCH=32',
162 'NACL_TARGET_SUBARCH=64',
163 'NACL_BUILD_SUBARCH=64',
167 'msvs_target_platform': 'x64',
173 # TODO(gregoryd): split target and build subarchs
174 ['target_arch=="ia32"', {
176 'NACL_TARGET_SUBARCH=32',
177 'NACL_TARGET_ARCH=x86',
178 'NACL_BUILD_SUBARCH=32',
179 'NACL_BUILD_ARCH=x86',
182 ['target_arch=="x64"', {
184 'NACL_TARGET_SUBARCH=64',
185 'NACL_TARGET_ARCH=x86',
186 'NACL_BUILD_SUBARCH=64',
187 'NACL_BUILD_ARCH=x86',
190 ['target_arch=="arm"', {
192 'NACL_BUILD_ARCH=arm',
193 'NACL_BUILD_SUBARCH=32',
194 'NACL_TARGET_ARCH=arm',
195 'NACL_TARGET_SUBARCH=32',
198 ['target_arch=="mipsel"', {
200 'NACL_BUILD_ARCH=mips',
201 'NACL_BUILD_SUBARCH=32',
202 'NACL_TARGET_ARCH=mips',
203 'NACL_TARGET_SUBARCH=32',
207 'defines': ['LINUX2=1'],
210 'defines': [ 'NOMINMAX' ]
216 'GCC_INSTRUMENT_PROGRAM_FLOW_ARCS': 'YES',
217 'GCC_GENERATE_TEST_COVERAGE_FILES': 'YES',
219 # Add -lgcov for executables, not for static_libraries.
220 # This is a delayed conditional.
221 'target_conditions': [
222 ['_type=="executable"', {
223 'xcode_settings': { 'OTHER_LDFLAGS': [ '-lgcov' ] },
227 # Linux gyp (into scons) doesn't like target_conditions?
228 # TODO(???): track down why 'target_conditions' doesn't work
229 # on Linux gyp into scons like it does on Mac gyp into xcodeproj.
231 'cflags': [ '-ftest-coverage',
233 'link_settings': { 'libraries': [ '-lgcov' ] },
236 # TODO(jrg): options for code coverage on Windows
241 # Clang spots more unused functions.
242 '-Wno-unused-function',
243 # Don't die on dtoa code that uses a char as an array index.
244 '-Wno-char-subscripts',
245 # Especially needed for gtest macros using enum values from Mac
247 # TODO(pkasting): In C++11 this is legal, so this should be
248 # removed when we change to that. (This is also why we don't
249 # bother fixing all these cases today.)
250 '-Wno-unnamed-type-template-args',
251 # Allow 'default' label in switch even when all enumeration
252 # cases have been covered.
253 '-Wno-covered-switch-default',
254 # Allow C++11 extensions (for "override")
255 '-Wno-c++11-extensions',
258 # Clang doesn't seem to know know this flag.
267 # Enable -Werror by default, but put it in a variable so it can
268 # be disabled in ~/.gyp/include.gypi on the valgrind builders.
270 'werror%': '-Werror',
273 '<(werror)', # See note above about the werror variable.
276 '-Wall', # TODO(bradnelson): why does this disappear?!?
279 ['nacl_standalone==1 and OS=="linux"', {
282 ['nacl_standalone==1 and nacl_strict_warnings==1', {
283 # TODO(gregoryd): remove the condition when the issues in
284 # Chrome code are fixed.
286 # TODO(bradnelson): This was being masked by key naming
287 # collisions. Track down the items blocking enabling this.
294 '-fdiagnostics-show-option',
297 # Require defining functions as "foo(void)" rather than
298 # "foo()" because, in C (but not C++), the latter
299 # defines a function with unspecified arguments rather
301 '-Wstrict-prototypes',
304 ['target_arch=="arm"', {
305 'target_conditions': [
306 ['_toolset=="target"', {
312 '--sysroot=<(sysroot)',
315 '--sysroot=<(sysroot)',
317 # TODO(mcgrathr): This is copied from the arm section of
318 # chromium/src/build/common.gypi, but these details really
319 # should be more fully harmonized and shared.
330 '-mfloat-abi=<(arm_float_abi)',
334 'cflags': [ '-mfpu=neon', ],
336 'cflags': [ '-mfpu=<(arm_fpu)', ],
344 ['target_arch=="mipsel"', {
345 'target_conditions': [
346 ['_toolset=="target"', {
347 # Copied from chromium build/common.gypi
349 ['mips_arch_variant=="mips32r2"', {
350 'cflags': ['-mips32r2'],
352 'cflags': ['-mips32'],
358 ['target_arch=="ia32" or target_arch=="x64"', {
360 ['target_arch=="x64"', {
362 'mbits_flag': '-m64',
366 'mbits_flag': '-m32',
385 '-fno-threadsafe-statics',
389 '-Wl,-z,noexecstack',
397 '_POSIX_C_SOURCE=199506',
400 '__STDC_LIMIT_MACROS=1',
411 'debug_optimize%': '0',
417 '-O<(debug_optimize)',
419 # One can use '-gstabs' to enable building the debugging
420 # information in STABS format for breakpad's dumpsyms.
423 '-rdynamic', # Allows backtrace to resolve symbols.
428 'release_optimize%': '2',
431 '-O<(release_optimize)',
432 # Don't emit the GCC version ident directives, they just end up
433 # in the .comment section taking up binary size.
435 # Put data and code in their own sections, so that unused symbols
436 # can be removed at link time with --gc-sections.
438 '-ffunction-sections',
454 # This should be 'mac_real_dsym%', but there seems to be a bug
455 # with % in variables that are intended to be set to different
456 # values in different targets, like this one.
457 'mac_real_dsym': 0, # Fake .dSYMs are fine in most cases.
461 'ALWAYS_SEARCH_USER_PATHS': 'NO',
462 'GCC_C_LANGUAGE_STANDARD': 'gnu99',
463 'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks
464 'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic
465 # (Equivalent to -fPIC)
466 'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions
467 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti
468 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings
469 'GCC_INLINES_ARE_PRIVATE_EXTERN':
470 'YES', # -fvisibility-inlines-hidden
471 'GCC_OBJC_CALL_CXX_CDTORS': 'YES', # -fobjc-call-cxx-cdtors
472 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
473 'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics
474 'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES', # -Werror
475 # Don't set GCC_VERSION so that we default to /usr/bin/gcc
476 #'GCC_VERSION': '4.2',
477 'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES', # -Wnewline-eof
478 'PREBINDING': 'NO', # No -Wl,-prebind
479 'USE_HEADERMAP': 'NO',
480 # TODO(bradnelson): -Werror ?!?
481 'WARNING_CFLAGS': ['-Wall', '-Wendif-labels', '-Wno-long-long'],
483 ['chromium_mac_pch', {'GCC_PRECOMPILE_PREFIX_HEADER': 'YES'},
484 {'GCC_PRECOMPILE_PREFIX_HEADER': 'NO'}],
486 'CC': '$(SOURCE_ROOT)/<(clang_dir)/clang',
487 'LDPLUSPLUS': '$(SOURCE_ROOT)/<(clang_dir)/clang++',
488 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
491 # Don't die on dtoa code that uses a char as an array index.
492 # This is required solely for base/third_party/dmg_fp/dtoa.cc.
493 '-Wno-char-subscripts',
494 # Clang spots more unused functions.
495 '-Wno-unused-function',
496 # See comments on this flag higher up in this file.
497 '-Wno-unnamed-type-template-args',
498 # Allow 'default' label in switch even when all enumeration
499 # cases have been covered.
500 '-Wno-covered-switch-default',
501 # Allow C++11 extensions (for "override")
502 '-Wno-c++11-extensions',
503 # TODO(thakis): Reenable once the one instance this warns on
508 ['nacl_standalone==1', {
509 # If part of the Chromium build, use the Chromium default.
510 # Otherwise, when building standalone, use this.
511 'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)', # -mmacosx-version-min
512 'SDKROOT': 'macosx<(mac_sdk)', # -isysroot
520 '<(DEPTH)/third_party/llvm-build/Release+Asserts/bin',
523 ['nacl_standalone==1 and nacl_strict_warnings==1', {
525 # TODO(gregoryd): remove the condition when the issues in
526 # Chrome code are fixed.
534 '-fdiagnostics-show-option',
538 ['nacl_standalone==1 and target_arch=="x64"', {
539 'xcode_settings': {'ARCHS': ['x86_64']},
541 ['nacl_standalone==1', {
542 'target_conditions': [
543 ['_type!="static_library"', {
545 'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
548 'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-ObjC']},
550 ['_type=="executable"', {
551 'target_conditions': [
552 ['mac_real_dsym == 1', {
553 # To get a real .dSYM bundle produced by dsymutil, set the
554 # debug information format to dwarf-with-dsym. Since
555 # strip_from_xcode will not be used, set Xcode to do the
560 'DEBUG_INFORMATION_FORMAT': 'dwarf-with-dsym',
561 'DEPLOYMENT_POSTPROCESSING': 'YES',
562 'STRIP_INSTALLED_PRODUCT': 'YES',
566 }, { # mac_real_dsym != 1
567 # To get a fast fake .dSYM bundle, use a post-build step to
568 # produce the .dSYM and strip the executable. strip_from_xcode
569 # only operates in the Release configuration.
573 # Define strip_from_xcode in a variable ending in _path
574 # so that gyp understands it's a path and performs proper
575 # relativization during dict merging.
576 'strip_from_xcode_path':
577 'mac/strip_from_xcode',
579 'postbuild_name': 'Strip If Needed',
580 'action': ['<(strip_from_xcode_path)'],
600 'windows_asm_rule%': 1,
602 'target_conditions': [
603 ['windows_asm_rule==1', {
606 'rule_name': 'assembler (gnu-compatible)',
607 'msvs_cygwin_shell': 0,
611 '<(DEPTH)/native_client/tools/win_as.py',
615 '$(IntDir)/$(InputName).obj',
619 '<(DEPTH)/native_client/tools/win_as.py',
620 # target architecture: Win32 or x64
621 '-a', '$(PlatformName)',
623 '-o', '$(IntDir)/$(InputName).obj',
624 # path to top of tree, e.g. svn/nacl
629 'message': 'Building assembly language file $(InputPath)',
630 'process_outputs_as_sources': 1,
636 '_WIN32_WINNT=0x0600',
638 # WIN32 is used by ppapi
642 'CERT_CHAIN_PARA_HAS_EXTRA_FIELDS',
643 # WIN32_LEAN_AND_MEAN tells windows.h to omit obsolete and rarely
644 # used #include files. This allows use of Winsock 2.0 which otherwise
645 # would conflict with Winsock 1.x included by windows.h.
646 'WIN32_LEAN_AND_MEAN',
648 '__STDC_LIMIT_MACROS=1',
656 ['component=="static_library"', {
661 ['MSVS_VERSION=="2008"', {
667 'msvs_cygwin_dirs': ['../third_party/cygwin'],
668 # TODO(bsy) remove 4355 once cross-repo
669 # NACL_ALLOW_THIS_IN_INITIALIZER_LIST changes go in.
670 'msvs_disabled_warnings': [4355, 4396, 4503, 4800, 4819],
672 'VCCLCompilerTool': {
673 'MinimalRebuild': 'false',
674 'BufferSecurityCheck': 'true',
675 'EnableFunctionLevelLinking': 'true',
676 'RuntimeTypeInfo': 'false',
678 'WarnAsError': 'true',
679 'DebugInformationFormat': '3',
682 ['component=="shared_library"', {
683 'ExceptionHandling': '1', # /EHsc
685 'ExceptionHandling': '0',
690 'AdditionalOptions': ['/ignore:4221'],
693 'AdditionalOptions': [
700 'AdditionalDependencies': [
714 'GenerateDebugInformation': 'true',
715 'MapFileName': '$(OutDir)\\$(TargetName).map',
716 'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
717 'TargetMachine': '1',
718 'FixedBaseAddress': '1',
721 # 1 == /SUBSYSTEM:CONSOLE
722 # 2 == /SUBSYSTEM:WINDOWS
723 # Most of the executables we'll ever create are tests
724 # and utilities with console output.
728 'GenerateStublessProxies': 'true',
729 'TypeLibraryName': '$(InputName).tlb',
730 'OutputDirectory': '$(IntDir)',
731 'HeaderFileName': '$(InputName).h',
732 'DLLDataFileName': 'dlldata.c',
733 'InterfaceIdentifierFileName': '$(InputName)_i.c',
734 'ProxyFileName': '$(InputName)_p.c',
736 'VCResourceCompilerTool': {
738 'AdditionalIncludeDirectories': ['<(DEPTH)'],
743 ['chromium_code==0 and nacl_standalone==0', {
744 # This section must follow the other conditon sections above because
745 # external_code.gypi expects to be merged into those settings.
747 'external_code.gypi',
751 # In Chromium code, we define __STDC_FORMAT_MACROS in order to get the
752 # C99 macros on Mac and Linux.
754 '__STDC_FORMAT_MACROS',
757 'VCCLCompilerTool': {
758 'Detect64BitPortabilityProblems': 'false',
759 # TODO(new_hire): above line should go away
764 ['clang==1 and nacl_standalone==1', {
765 'make_global_settings': [
766 ['CC', 'third_party/llvm-build/Release+Asserts/bin/clang'],
767 ['CXX', 'third_party/llvm-build/Release+Asserts/bin/clang++'],
769 ['CC.host', '$(CC)'],
770 ['CXX.host', '$(CXX)'],
771 ['LINK.host', '$(LINK)'],
776 # The Xcode generator will look for an xcode_settings section at the root
777 # of each dict and use it to apply settings on a file-wide basis. Most
778 # settings should not be here, they should be in target-specific
779 # xcode_settings sections, or better yet, should use non-Xcode-specific
780 # settings in target dicts. SYMROOT is a special case, because many other
781 # Xcode variables depend on it, including variables such as
782 # PROJECT_DERIVED_FILE_DIR. When a source group corresponding to something
783 # like PROJECT_DERIVED_FILE_DIR is added to a project, in order for the
784 # files to appear (when present) in the UI as actual files and not red
785 # red "missing file" proxies, the correct path to PROJECT_DERIVED_FILE_DIR,
786 # and therefore SYMROOT, needs to be set at the project level.
787 'SYMROOT': '<(DEPTH)/xcodebuild',