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"', {
310 '--sysroot=<(sysroot)',
313 '--sysroot=<(sysroot)',
315 # TODO(mcgrathr): This is copied from the arm section of
316 # chromium/src/build/common.gypi, but these details really
317 # should be more fully harmonized and shared.
328 '-mfloat-abi=<(arm_float_abi)',
332 'cflags': [ '-mfpu=neon', ],
334 'cflags': [ '-mfpu=<(arm_fpu)', ],
340 ['target_arch=="mipsel"', {
341 # Copied from chromium build/common.gypi
343 ['mips_arch_variant=="mips32r2"', {
344 'cflags': ['-mips32r2'],
346 'cflags': ['-mips32'],
350 ['target_arch=="ia32" or target_arch=="x64"', {
352 ['target_arch=="x64"', {
354 'mbits_flag': '-m64',
358 'mbits_flag': '-m32',
377 '-fno-threadsafe-statics',
381 '-Wl,-z,noexecstack',
389 '_POSIX_C_SOURCE=199506',
392 '__STDC_LIMIT_MACROS=1',
403 'debug_optimize%': '0',
409 '-O<(debug_optimize)',
411 # One can use '-gstabs' to enable building the debugging
412 # information in STABS format for breakpad's dumpsyms.
415 '-rdynamic', # Allows backtrace to resolve symbols.
420 'release_optimize%': '2',
423 '-O<(release_optimize)',
424 # Don't emit the GCC version ident directives, they just end up
425 # in the .comment section taking up binary size.
427 # Put data and code in their own sections, so that unused symbols
428 # can be removed at link time with --gc-sections.
430 '-ffunction-sections',
446 # This should be 'mac_real_dsym%', but there seems to be a bug
447 # with % in variables that are intended to be set to different
448 # values in different targets, like this one.
449 'mac_real_dsym': 0, # Fake .dSYMs are fine in most cases.
453 'ALWAYS_SEARCH_USER_PATHS': 'NO',
454 'GCC_C_LANGUAGE_STANDARD': 'gnu99',
455 'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks
456 'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic
457 # (Equivalent to -fPIC)
458 'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions
459 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti
460 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings
461 'GCC_INLINES_ARE_PRIVATE_EXTERN':
462 'YES', # -fvisibility-inlines-hidden
463 'GCC_OBJC_CALL_CXX_CDTORS': 'YES', # -fobjc-call-cxx-cdtors
464 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
465 'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics
466 'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES', # -Werror
467 # Don't set GCC_VERSION so that we default to /usr/bin/gcc
468 #'GCC_VERSION': '4.2',
469 'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES', # -Wnewline-eof
470 'PREBINDING': 'NO', # No -Wl,-prebind
471 'USE_HEADERMAP': 'NO',
472 # TODO(bradnelson): -Werror ?!?
473 'WARNING_CFLAGS': ['-Wall', '-Wendif-labels', '-Wno-long-long'],
475 ['chromium_mac_pch', {'GCC_PRECOMPILE_PREFIX_HEADER': 'YES'},
476 {'GCC_PRECOMPILE_PREFIX_HEADER': 'NO'}],
478 'CC': '$(SOURCE_ROOT)/<(clang_dir)/clang',
479 'LDPLUSPLUS': '$(SOURCE_ROOT)/<(clang_dir)/clang++',
480 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
483 # Don't die on dtoa code that uses a char as an array index.
484 # This is required solely for base/third_party/dmg_fp/dtoa.cc.
485 '-Wno-char-subscripts',
486 # Clang spots more unused functions.
487 '-Wno-unused-function',
488 # See comments on this flag higher up in this file.
489 '-Wno-unnamed-type-template-args',
490 # Allow 'default' label in switch even when all enumeration
491 # cases have been covered.
492 '-Wno-covered-switch-default',
493 # Allow C++11 extensions (for "override")
494 '-Wno-c++11-extensions',
495 # TODO(thakis): Reenable once the one instance this warns on
500 ['nacl_standalone==1', {
501 # If part of the Chromium build, use the Chromium default.
502 # Otherwise, when building standalone, use this.
503 'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)', # -mmacosx-version-min
504 'SDKROOT': 'macosx<(mac_sdk)', # -isysroot
512 '<(DEPTH)/third_party/llvm-build/Release+Asserts/bin',
515 ['nacl_standalone==1 and nacl_strict_warnings==1', {
517 # TODO(gregoryd): remove the condition when the issues in
518 # Chrome code are fixed.
526 '-fdiagnostics-show-option',
530 ['nacl_standalone==1 and target_arch=="x64"', {
531 'xcode_settings': {'ARCHS': ['x86_64']},
533 ['nacl_standalone==1', {
534 'target_conditions': [
535 ['_type!="static_library"', {
537 'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
540 'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-ObjC']},
542 ['_type=="executable"', {
543 'target_conditions': [
544 ['mac_real_dsym == 1', {
545 # To get a real .dSYM bundle produced by dsymutil, set the
546 # debug information format to dwarf-with-dsym. Since
547 # strip_from_xcode will not be used, set Xcode to do the
552 'DEBUG_INFORMATION_FORMAT': 'dwarf-with-dsym',
553 'DEPLOYMENT_POSTPROCESSING': 'YES',
554 'STRIP_INSTALLED_PRODUCT': 'YES',
558 }, { # mac_real_dsym != 1
559 # To get a fast fake .dSYM bundle, use a post-build step to
560 # produce the .dSYM and strip the executable. strip_from_xcode
561 # only operates in the Release configuration.
565 # Define strip_from_xcode in a variable ending in _path
566 # so that gyp understands it's a path and performs proper
567 # relativization during dict merging.
568 'strip_from_xcode_path':
569 'mac/strip_from_xcode',
571 'postbuild_name': 'Strip If Needed',
572 'action': ['<(strip_from_xcode_path)'],
592 'windows_asm_rule%': 1,
594 'target_conditions': [
595 ['windows_asm_rule==1', {
598 'rule_name': 'assembler (gnu-compatible)',
599 'msvs_cygwin_shell': 0,
603 '<(DEPTH)/native_client/tools/win_as.py',
607 '$(IntDir)/$(InputName).obj',
611 '<(DEPTH)/native_client/tools/win_as.py',
612 # target architecture: Win32 or x64
613 '-a', '$(PlatformName)',
615 '-o', '$(IntDir)/$(InputName).obj',
616 # path to top of tree, e.g. svn/nacl
621 'message': 'Building assembly language file $(InputPath)',
622 'process_outputs_as_sources': 1,
628 '_WIN32_WINNT=0x0600',
630 # WIN32 is used by ppapi
634 'CERT_CHAIN_PARA_HAS_EXTRA_FIELDS',
635 # WIN32_LEAN_AND_MEAN tells windows.h to omit obsolete and rarely
636 # used #include files. This allows use of Winsock 2.0 which otherwise
637 # would conflict with Winsock 1.x included by windows.h.
638 'WIN32_LEAN_AND_MEAN',
640 '__STDC_LIMIT_MACROS=1',
648 ['component=="static_library"', {
653 ['MSVS_VERSION=="2008"', {
659 'msvs_cygwin_dirs': ['../third_party/cygwin'],
660 # TODO(bsy) remove 4355 once cross-repo
661 # NACL_ALLOW_THIS_IN_INITIALIZER_LIST changes go in.
662 'msvs_disabled_warnings': [4355, 4396, 4503, 4800, 4819],
664 'VCCLCompilerTool': {
665 'MinimalRebuild': 'false',
666 'BufferSecurityCheck': 'true',
667 'EnableFunctionLevelLinking': 'true',
668 'RuntimeTypeInfo': 'false',
670 'WarnAsError': 'true',
671 'DebugInformationFormat': '3',
674 ['component=="shared_library"', {
675 'ExceptionHandling': '1', # /EHsc
677 'ExceptionHandling': '0',
682 'AdditionalOptions': ['/ignore:4221'],
685 'AdditionalOptions': [
692 'AdditionalDependencies': [
706 'GenerateDebugInformation': 'true',
707 'MapFileName': '$(OutDir)\\$(TargetName).map',
708 'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
709 'TargetMachine': '1',
710 'FixedBaseAddress': '1',
713 # 1 == /SUBSYSTEM:CONSOLE
714 # 2 == /SUBSYSTEM:WINDOWS
715 # Most of the executables we'll ever create are tests
716 # and utilities with console output.
720 'GenerateStublessProxies': 'true',
721 'TypeLibraryName': '$(InputName).tlb',
722 'OutputDirectory': '$(IntDir)',
723 'HeaderFileName': '$(InputName).h',
724 'DLLDataFileName': 'dlldata.c',
725 'InterfaceIdentifierFileName': '$(InputName)_i.c',
726 'ProxyFileName': '$(InputName)_p.c',
728 'VCResourceCompilerTool': {
730 'AdditionalIncludeDirectories': ['<(DEPTH)'],
735 ['chromium_code==0 and nacl_standalone==0', {
736 # This section must follow the other conditon sections above because
737 # external_code.gypi expects to be merged into those settings.
739 'external_code.gypi',
743 # In Chromium code, we define __STDC_FORMAT_MACROS in order to get the
744 # C99 macros on Mac and Linux.
746 '__STDC_FORMAT_MACROS',
749 'VCCLCompilerTool': {
750 'Detect64BitPortabilityProblems': 'false',
751 # TODO(new_hire): above line should go away
756 ['clang==1 and nacl_standalone==1', {
757 'make_global_settings': [
758 ['CC', 'third_party/llvm-build/Release+Asserts/bin/clang'],
759 ['CXX', 'third_party/llvm-build/Release+Asserts/bin/clang++'],
761 ['CC.host', '$(CC)'],
762 ['CXX.host', '$(CXX)'],
763 ['LINK.host', '$(LINK)'],
768 # The Xcode generator will look for an xcode_settings section at the root
769 # of each dict and use it to apply settings on a file-wide basis. Most
770 # settings should not be here, they should be in target-specific
771 # xcode_settings sections, or better yet, should use non-Xcode-specific
772 # settings in target dicts. SYMROOT is a special case, because many other
773 # Xcode variables depend on it, including variables such as
774 # PROJECT_DERIVED_FILE_DIR. When a source group corresponding to something
775 # like PROJECT_DERIVED_FILE_DIR is added to a project, in order for the
776 # files to appear (when present) in the UI as actual files and not red
777 # red "missing file" proxies, the correct path to PROJECT_DERIVED_FILE_DIR,
778 # and therefore SYMROOT, needs to be set at the project level.
779 'SYMROOT': '<(DEPTH)/xcodebuild',