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.
36 # On Mac only clang is new enough to build the trusted code.
38 # The Mac SDK is set for iOS builds and passed through to Mac
39 # sub-builds. This allows the Mac sub-build SDK in an iOS build to be
40 # overridden from the command line the same way it is for a Mac build.
41 'mac_sdk%': '<!(python <(DEPTH)/native_client/build/mac/find_sdk.py 10.6)',
44 # Set ARM float abi compilation flag.
46 'arm_float_abi%': 'softfp',
48 'arm_float_abi%': 'hard',
52 # Set to 1 to enable code coverage. In addition to build changes
53 # (e.g. extra CFLAGS), also creates a new target in the src/chrome
54 # project file called "coverage".
55 # Currently ignored on Windows.
58 # TODO(sgk): eliminate this if possible.
59 # It would be nicer to support this via a setting in 'target_defaults'
60 # in chrome/app/locales/locales.gypi overriding the setting in the
61 # 'Debug' configuration in the 'target_defaults' dict below,
62 # but that doesn't work as we'd like.
63 'msvs_debug_link_incremental%': '2',
65 # NOTE: adapted from them chrome common.gypi file for arm
68 # Set Neon compilation flags (only meaningful if arm_version==7).
71 # Set Thumb compilation flags.
74 # Set ARM fpu compilation flags (only meaningful if arm_version==7 and
78 'mac_deployment_target%': '10.6',
80 # NOTE: end adapted from them chrome common.gypi file for arm
82 # Doing this in a sub-dict so that it can be referred to below.
84 # By default we assume that we are building as part of Chrome
86 'nacl_standalone%': 0,
88 # Override branding to select the desired branding flavor.
89 'branding%': 'Chromium',
91 # Override buildtype to select the desired build flavor.
92 # Dev - everyday build for development/testing
93 # Official - release build (generally implies additional processing)
94 # TODO(mmoss) Once 'buildtype' is fully supported (e.g. Windows gyp
95 # conversion is done), some of the things which are now controlled by
96 # 'branding', such as symbol generation, will need to be refactored
97 # based on 'buildtype' (i.e. we don't care about saving symbols for
98 # non-Official builds).
102 # Compute the architecture that we're building on.
103 ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="android"', {
104 # This handles the Linux platforms we generally deal with. Anything
105 # else gets passed through, which probably won't work very well;
106 # such hosts should pass an explicit target_arch to gyp.
108 # NOTE: currently only nacl is generating gyp files on an arm board.
109 # The arm.* -> arm substitution in chrome's common.gypi isn't
110 # appropriate in that context as we actually use target_arch==arm
111 # to mean x86 -> arm cross compile. When actually running on an
112 # arm board, we'll generate ia32 for now, so that the generation
115 '<!(echo "<!pymod_do_main(detect_nacl_host_arch)" | sed -e "s/arm.*/ia32/")',
118 'host_arch%': 'ia32',
122 # These come from the above variable scope.
123 'nacl_standalone%': '<(nacl_standalone)',
124 'host_arch%': '<(host_arch)',
125 'branding%': '<(branding)',
126 'buildtype%': '<(buildtype)',
128 # By default, build for the architecture that we're building on.
129 'target_arch%': '<(host_arch)',
132 # The system root for cross-compiles. Default: none.
133 # If we are building in chrome we want to rely on chrome's default, which
134 # means we can't set a default here.
135 ['nacl_standalone!=0', {
139 # A flag for POSIX platforms
145 ['OS=="android"', { # Android target_arch defaults to ARM.
146 'target_arch%': 'arm',
150 # This variable is to allow us to build components as either static
151 # libraries or dynamic shared libraries.
152 'component%': 'static_library',
154 # These come from the above variable scope.
155 'target_arch%': '<(target_arch)',
156 'host_arch%': '<(host_arch)',
157 'sysroot%': '<(sysroot)',
158 'nacl_standalone%': '<(nacl_standalone)',
159 'branding%': '<(branding)',
160 'buildtype%': '<(buildtype)',
161 'component%': '<(component)',
163 'nacl_strict_warnings%': 1,
167 'os_posix%': '<(os_posix)',
172 # Putting this first so that people who include "ppapi/..." get the
173 # third_party version instead of any other version (the chrome location
175 '../src/third_party',
181 'target_conditions': [
182 ['win_target=="x64"', {
183 'target_arch': 'x64',
185 'NACL_TARGET_SUBARCH=32',
186 'NACL_BUILD_SUBARCH=32',
189 'NACL_TARGET_SUBARCH=64',
190 'NACL_BUILD_SUBARCH=64',
194 'msvs_target_platform': 'x64',
200 # TODO(gregoryd): split target and build subarchs
201 ['target_arch=="ia32"', {
203 'NACL_TARGET_SUBARCH=32',
204 'NACL_TARGET_ARCH=x86',
205 'NACL_BUILD_SUBARCH=32',
206 'NACL_BUILD_ARCH=x86',
209 ['target_arch=="x64"', {
211 'NACL_TARGET_SUBARCH=64',
212 'NACL_TARGET_ARCH=x86',
213 'NACL_BUILD_SUBARCH=64',
214 'NACL_BUILD_ARCH=x86',
217 ['target_arch=="arm"', {
219 'NACL_BUILD_ARCH=arm',
220 'NACL_BUILD_SUBARCH=32',
221 'NACL_TARGET_ARCH=arm',
222 'NACL_TARGET_SUBARCH=32',
225 ['target_arch=="mipsel"', {
227 'NACL_BUILD_ARCH=mips',
228 'NACL_BUILD_SUBARCH=32',
229 'NACL_TARGET_ARCH=mips',
230 'NACL_TARGET_SUBARCH=32',
234 'defines': ['LINUX2=1'],
237 'defines': [ 'NOMINMAX' ]
243 'GCC_INSTRUMENT_PROGRAM_FLOW_ARCS': 'YES',
244 'GCC_GENERATE_TEST_COVERAGE_FILES': 'YES',
246 # Add -lgcov for executables, not for static_libraries.
247 # This is a delayed conditional.
248 'target_conditions': [
249 ['_type=="executable"', {
250 'xcode_settings': { 'OTHER_LDFLAGS': [ '-lgcov' ] },
254 # Linux gyp (into scons) doesn't like target_conditions?
255 # TODO(???): track down why 'target_conditions' doesn't work
256 # on Linux gyp into scons like it does on Mac gyp into xcodeproj.
258 'cflags': [ '-ftest-coverage',
260 'link_settings': { 'libraries': [ '-lgcov' ] },
263 # TODO(jrg): options for code coverage on Windows
268 # Clang spots more unused functions.
269 '-Wno-unused-function',
270 # Don't die on dtoa code that uses a char as an array index.
271 '-Wno-char-subscripts',
272 # Especially needed for gtest macros using enum values from Mac
274 # TODO(pkasting): In C++11 this is legal, so this should be
275 # removed when we change to that. (This is also why we don't
276 # bother fixing all these cases today.)
277 '-Wno-unnamed-type-template-args',
278 # Allow 'default' label in switch even when all enumeration
279 # cases have been covered.
280 '-Wno-covered-switch-default',
281 # Allow C++11 extensions (for "override")
282 '-Wno-c++11-extensions',
285 # Clang doesn't seem to know know this flag.
292 ['OS=="linux" or OS=="android"', {
294 # Enable -Werror by default, but put it in a variable so it can
295 # be disabled in ~/.gyp/include.gypi on the valgrind builders.
297 'werror%': '-Werror',
300 '<(werror)', # See note above about the werror variable.
303 '-Wall', # TODO(bradnelson): why does this disappear?!?
306 ['nacl_standalone==1 and OS=="linux"', {
310 'target_conditions': [
311 ['_toolset=="target"', {
312 'defines': ['NACL_ANDROID=1'],
314 'defines': ['NACL_ANDROID=0'],
318 'defines': ['NACL_ANDROID=0'],
326 ['nacl_standalone==1 and nacl_strict_warnings==1', {
327 # TODO(gregoryd): remove the condition when the issues in
328 # Chrome code are fixed.
330 # TODO(bradnelson): This was being masked by key naming
331 # collisions. Track down the items blocking enabling this.
338 '-fdiagnostics-show-option',
341 # Require defining functions as "foo(void)" rather than
342 # "foo()" because, in C (but not C++), the latter
343 # defines a function with unspecified arguments rather
345 '-Wstrict-prototypes',
348 ['target_arch=="arm"', {
349 'target_conditions': [
350 ['_toolset=="target"', {
357 # TODO(mcgrathr): This is copied from the arm section of
358 # chromium/src/build/common.gypi, but these details really
359 # should be more fully harmonized and shared.
363 '--sysroot=<(sysroot)',
366 '--sysroot=<(sysroot)',
378 '-mfloat-abi=<(arm_float_abi)',
382 'cflags': [ '-mfpu=neon', ],
384 'cflags': [ '-mfpu=<(arm_fpu)', ],
392 ['target_arch=="mipsel"', {
393 'target_conditions': [
394 ['_toolset=="target"', {
395 # Copied from chromium build/common.gypi
397 ['mips_arch_variant=="mips32r2"', {
398 'cflags': ['-mips32r2'],
400 'cflags': ['-mips32'],
406 ['target_arch=="ia32" or target_arch=="x64"', {
408 ['target_arch=="x64"', {
410 'mbits_flag': '-m64',
414 'mbits_flag': '-m32',
418 'target_conditions': [
419 ['_toolset=="target"', {
420 'asflags': [ '<(mbits_flag)', ],
421 'cflags': [ '<(mbits_flag)', ],
422 'ldflags': [ '<(mbits_flag)', ],
430 ['host_arch=="ia32" or host_arch=="x64"', {
432 ['host_arch=="x64"', {
433 'variables': { 'host_mbits_flag': '-m64', },
435 'variables': { 'host_mbits_flag': '-m32', }
438 'target_conditions': [
439 ['_toolset=="host"', {
440 'asflags': [ '<(host_mbits_flag)', ],
441 'cflags': [ '<(host_mbits_flag)', ],
442 'ldflags': [ '<(host_mbits_flag)', ],
449 '-fno-threadsafe-statics',
453 '-Wl,-z,noexecstack',
461 '_POSIX_C_SOURCE=199506',
464 '__STDC_LIMIT_MACROS=1',
469 'debug_optimize%': '0',
475 '-O<(debug_optimize)',
477 # One can use '-gstabs' to enable building the debugging
478 # information in STABS format for breakpad's dumpsyms.
481 '-rdynamic', # Allows backtrace to resolve symbols.
486 'release_optimize%': '2',
489 '-O<(release_optimize)',
490 # Don't emit the GCC version ident directives, they just end up
491 # in the .comment section taking up binary size.
493 # Put data and code in their own sections, so that unused symbols
494 # can be removed at link time with --gc-sections.
496 '-ffunction-sections',
512 # This should be 'mac_real_dsym%', but there seems to be a bug
513 # with % in variables that are intended to be set to different
514 # values in different targets, like this one.
515 'mac_real_dsym': 0, # Fake .dSYMs are fine in most cases.
519 'ALWAYS_SEARCH_USER_PATHS': 'NO',
520 'GCC_C_LANGUAGE_STANDARD': 'gnu99',
521 'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks
522 'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic
523 # (Equivalent to -fPIC)
524 'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions
525 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti
526 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings
527 'GCC_INLINES_ARE_PRIVATE_EXTERN':
528 'YES', # -fvisibility-inlines-hidden
529 'GCC_OBJC_CALL_CXX_CDTORS': 'YES', # -fobjc-call-cxx-cdtors
530 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
531 'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics
532 'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES', # -Werror
533 # Don't set GCC_VERSION so that we default to /usr/bin/gcc
534 #'GCC_VERSION': '4.2',
535 'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES', # -Wnewline-eof
536 'PREBINDING': 'NO', # No -Wl,-prebind
537 'USE_HEADERMAP': 'NO',
538 # TODO(bradnelson): -Werror ?!?
539 'WARNING_CFLAGS': ['-Wall', '-Wendif-labels', '-Wno-long-long'],
541 ['chromium_mac_pch', {'GCC_PRECOMPILE_PREFIX_HEADER': 'YES'},
542 {'GCC_PRECOMPILE_PREFIX_HEADER': 'NO'}],
544 'CC': '$(SOURCE_ROOT)/<(clang_dir)/clang',
545 'LDPLUSPLUS': '$(SOURCE_ROOT)/<(clang_dir)/clang++',
546 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
549 # Don't die on dtoa code that uses a char as an array index.
550 # This is required solely for base/third_party/dmg_fp/dtoa.cc.
551 '-Wno-char-subscripts',
552 # Clang spots more unused functions.
553 '-Wno-unused-function',
554 # See comments on this flag higher up in this file.
555 '-Wno-unnamed-type-template-args',
556 # Allow 'default' label in switch even when all enumeration
557 # cases have been covered.
558 '-Wno-covered-switch-default',
559 # Allow C++11 extensions (for "override")
560 '-Wno-c++11-extensions',
561 # TODO(thakis): Reenable once the one instance this warns on
566 ['nacl_standalone==1', {
567 # If part of the Chromium build, use the Chromium default.
568 # Otherwise, when building standalone, use this.
569 'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)', # -mmacosx-version-min
570 'SDKROOT': 'macosx<(mac_sdk)', # -isysroot
578 '<(DEPTH)/third_party/llvm-build/Release+Asserts/bin',
581 ['nacl_standalone==1 and nacl_strict_warnings==1', {
583 # TODO(gregoryd): remove the condition when the issues in
584 # Chrome code are fixed.
592 '-fdiagnostics-show-option',
596 ['nacl_standalone==1 and target_arch=="x64"', {
597 'xcode_settings': {'ARCHS': ['x86_64']},
599 ['nacl_standalone==1 and target_arch=="ia32"', {
600 'xcode_settings': {'ARCHS': ['i386']},
602 ['nacl_standalone==1', {
603 'target_conditions': [
604 ['_type!="static_library"', {
606 'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
609 'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-ObjC']},
611 ['_type=="executable"', {
612 'target_conditions': [
613 ['mac_real_dsym == 1', {
614 # To get a real .dSYM bundle produced by dsymutil, set the
615 # debug information format to dwarf-with-dsym. Since
616 # strip_from_xcode will not be used, set Xcode to do the
621 'DEBUG_INFORMATION_FORMAT': 'dwarf-with-dsym',
622 'DEPLOYMENT_POSTPROCESSING': 'YES',
623 'STRIP_INSTALLED_PRODUCT': 'YES',
627 }, { # mac_real_dsym != 1
628 # To get a fast fake .dSYM bundle, use a post-build step to
629 # produce the .dSYM and strip the executable. strip_from_xcode
630 # only operates in the Release configuration.
634 # Define strip_from_xcode in a variable ending in _path
635 # so that gyp understands it's a path and performs proper
636 # relativization during dict merging.
637 'strip_from_xcode_path':
638 'mac/strip_from_xcode',
640 'postbuild_name': 'Strip If Needed',
641 'action': ['<(strip_from_xcode_path)'],
661 'windows_asm_rule%': 1,
663 'target_conditions': [
664 ['windows_asm_rule==1', {
667 'rule_name': 'assembler (gnu-compatible)',
668 'msvs_cygwin_shell': 0,
672 '<(DEPTH)/native_client/tools/win_as.py',
675 '$(IntDir)/$(InputName).obj',
679 '<(DEPTH)/native_client/tools/win_as.py',
680 # target architecture: Win32 or x64
681 '-a', '$(PlatformName)',
683 '-o', '$(IntDir)/$(InputName).obj',
684 # path to top of tree, e.g. svn/nacl
689 'message': 'Building assembly language file $(InputPath)',
690 'process_outputs_as_sources': 1,
696 '_WIN32_WINNT=0x0602',
698 # WIN32 is used by ppapi
702 'CERT_CHAIN_PARA_HAS_EXTRA_FIELDS',
703 # WIN32_LEAN_AND_MEAN tells windows.h to omit obsolete and rarely
704 # used #include files. This allows use of Winsock 2.0 which otherwise
705 # would conflict with Winsock 1.x included by windows.h.
706 'WIN32_LEAN_AND_MEAN',
708 '__STDC_LIMIT_MACROS=1',
717 ['MSVS_VERSION=="2008"', {
723 'msvs_cygwin_dirs': ['../third_party/cygwin'],
724 # TODO(bsy) remove 4355 once cross-repo
725 # NACL_ALLOW_THIS_IN_INITIALIZER_LIST changes go in.
726 'msvs_disabled_warnings': [4355, 4396, 4503, 4800, 4819],
728 'VCCLCompilerTool': {
729 'MinimalRebuild': 'false',
730 'BufferSecurityCheck': 'true',
731 'EnableFunctionLevelLinking': 'true',
732 'RuntimeTypeInfo': 'false',
734 'WarnAsError': 'true',
735 'DebugInformationFormat': '3',
736 'ExceptionHandling': '0',
739 'AdditionalOptions': ['/ignore:4221'],
742 'AdditionalOptions': [
749 'AdditionalDependencies': [
764 'GenerateDebugInformation': 'true',
765 'MapFileName': '$(OutDir)\\$(TargetName).map',
766 'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
767 'TargetMachine': '1',
768 'FixedBaseAddress': '1',
771 # 1 == /SUBSYSTEM:CONSOLE
772 # 2 == /SUBSYSTEM:WINDOWS
773 # Most of the executables we'll ever create are tests
774 # and utilities with console output.
778 'GenerateStublessProxies': 'true',
779 'TypeLibraryName': '$(InputName).tlb',
780 'OutputDirectory': '$(IntDir)',
781 'HeaderFileName': '$(InputName).h',
782 'DLLDataFileName': 'dlldata.c',
783 'InterfaceIdentifierFileName': '$(InputName)_i.c',
784 'ProxyFileName': '$(InputName)_p.c',
786 'VCResourceCompilerTool': {
788 'AdditionalIncludeDirectories': ['<(DEPTH)'],
793 ['chromium_code==0 and nacl_standalone==0', {
794 # This section must follow the other conditon sections above because
795 # external_code.gypi expects to be merged into those settings.
797 'external_code.gypi',
801 # In Chromium code, we define __STDC_FORMAT_MACROS in order to get the
802 # C99 macros on Mac and Linux.
804 '__STDC_FORMAT_MACROS',
807 'VCCLCompilerTool': {
808 'Detect64BitPortabilityProblems': 'false',
809 # TODO(new_hire): above line should go away
814 ['clang==1 and nacl_standalone==1', {
815 'make_global_settings': [
816 ['CC', 'third_party/llvm-build/Release+Asserts/bin/clang'],
817 ['CXX', 'third_party/llvm-build/Release+Asserts/bin/clang++'],
819 ['CC.host', '$(CC)'],
820 ['CXX.host', '$(CXX)'],
821 ['LINK.host', '$(LINK)'],
824 ['OS=="android" and nacl_standalone==1', {
826 'android_settings.gypi',
828 }], # OS=="android" and nacl_standalone==1
831 # The Xcode generator will look for an xcode_settings section at the root
832 # of each dict and use it to apply settings on a file-wide basis. Most
833 # settings should not be here, they should be in target-specific
834 # xcode_settings sections, or better yet, should use non-Xcode-specific
835 # settings in target dicts. SYMROOT is a special case, because many other
836 # Xcode variables depend on it, including variables such as
837 # PROJECT_DERIVED_FILE_DIR. When a source group corresponding to something
838 # like PROJECT_DERIVED_FILE_DIR is added to a project, in order for the
839 # files to appear (when present) in the UI as actual files and not red
840 # red "missing file" proxies, the correct path to PROJECT_DERIVED_FILE_DIR,
841 # and therefore SYMROOT, needs to be set at the project level.
842 'SYMROOT': '<(DEPTH)/xcodebuild',