Home | History | Annotate | Download | only in build
      1 # Copyright 2012 the V8 project authors. All rights reserved.
      2 # Redistribution and use in source and binary forms, with or without
      3 # modification, are permitted provided that the following conditions are
      4 # met:
      5 #
      6 #     * Redistributions of source code must retain the above copyright
      7 #       notice, this list of conditions and the following disclaimer.
      8 #     * Redistributions in binary form must reproduce the above
      9 #       copyright notice, this list of conditions and the following
     10 #       disclaimer in the documentation and/or other materials provided
     11 #       with the distribution.
     12 #     * Neither the name of Google Inc. nor the names of its
     13 #       contributors may be used to endorse or promote products derived
     14 #       from this software without specific prior written permission.
     15 #
     16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 
     28 # Definitions to be used when building stand-alone V8 binaries.
     29 
     30 {
     31   # We need to include toolchain.gypi here for third-party sources that don't
     32   # directly include it themselves.
     33   'includes': ['toolchain.gypi'],
     34   'variables': {
     35     'component%': 'static_library',
     36     'asan%': 0,
     37     'tsan%': 0,
     38     'visibility%': 'hidden',
     39     'v8_enable_backtrace%': 0,
     40     'v8_enable_i18n_support%': 1,
     41     'v8_deprecation_warnings': 1,
     42     'msvs_multi_core_compile%': '1',
     43     'mac_deployment_target%': '10.5',
     44     'variables': {
     45       'variables': {
     46         'variables': {
     47           'conditions': [
     48             ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or \
     49                OS=="netbsd" or OS=="mac" or OS=="qnx"', {
     50               # This handles the Unix platforms we generally deal with.
     51               # Anything else gets passed through, which probably won't work
     52               # very well; such hosts should pass an explicit target_arch
     53               # to gyp.
     54               'host_arch%': '<!pymod_do_main(detect_v8_host_arch)',
     55             }, {
     56               # OS!="linux" and OS!="freebsd" and OS!="openbsd" and
     57               # OS!="netbsd" and OS!="mac"
     58               'host_arch%': 'ia32',
     59             }],
     60           ],
     61         },
     62         'host_arch%': '<(host_arch)',
     63         'target_arch%': '<(host_arch)',
     64       },
     65       'host_arch%': '<(host_arch)',
     66       'target_arch%': '<(target_arch)',
     67       'v8_target_arch%': '<(target_arch)',
     68     },
     69     'host_arch%': '<(host_arch)',
     70     'target_arch%': '<(target_arch)',
     71     'v8_target_arch%': '<(v8_target_arch)',
     72     'werror%': '-Werror',
     73 
     74     # .gyp files or targets should set v8_code to 1 if they build V8 specific
     75     # code, as opposed to external code.  This variable is used to control such
     76     # things as the set of warnings to enable, and whether warnings are treated
     77     # as errors.
     78     'v8_code%': 0,
     79 
     80     # Speeds up Debug builds:
     81     # 0 - Compiler optimizations off (debuggable) (default). This may
     82     #     be 5x slower than Release (or worse).
     83     # 1 - Turn on compiler optimizations. This may be hard or impossible to
     84     #     debug. This may still be 2x slower than Release (or worse).
     85     # 2 - Turn on optimizations, and also #undef DEBUG / #define NDEBUG
     86     #     (but leave V8_ENABLE_CHECKS and most other assertions enabled.
     87     #     This may cause some v8 tests to fail in the Debug configuration.
     88     #     This roughly matches the performance of a Release build and can
     89     #     be used by embedders that need to build their own code as debug
     90     #     but don't want or need a debug version of V8. This should produce
     91     #     near-release speeds.
     92     'v8_optimized_debug%': 0,
     93 
     94     # Relative path to icu.gyp from this file.
     95     'icu_gyp_path': '../third_party/icu/icu.gyp',
     96 
     97     'conditions': [
     98       ['(v8_target_arch=="arm" and host_arch!="arm") or \
     99         (v8_target_arch=="arm64" and host_arch!="arm64") or \
    100         (v8_target_arch=="mipsel" and host_arch!="mipsel") or \
    101         (v8_target_arch=="mips64el" and host_arch!="mips64el") or \
    102         (v8_target_arch=="x64" and host_arch!="x64") or \
    103         (OS=="android" or OS=="qnx")', {
    104         'want_separate_host_toolset': 1,
    105       }, {
    106         'want_separate_host_toolset': 0,
    107       }],
    108       ['OS == "win"', {
    109         'os_posix%': 0,
    110       }, {
    111         'os_posix%': 1,
    112       }],
    113       ['(v8_target_arch=="ia32" or v8_target_arch=="x64" or v8_target_arch=="x87") and \
    114         (OS=="linux" or OS=="mac")', {
    115         'v8_enable_gdbjit%': 1,
    116       }, {
    117         'v8_enable_gdbjit%': 0,
    118       }],
    119       ['OS=="mac"', {
    120         'clang%': 1,
    121       }, {
    122         'clang%': 0,
    123       }],
    124     ],
    125     # Default ARM variable settings.
    126     'arm_version%': 'default',
    127     'arm_fpu%': 'vfpv3',
    128     'arm_float_abi%': 'default',
    129     'arm_thumb': 'default',
    130 
    131     # Default MIPS variable settings.
    132     'mips_arch_variant%': 'r2',
    133     # Possible values fp32, fp64, fpxx.
    134     # fp32 - 32 32-bit FPU registers are available, doubles are placed in
    135     #        register pairs.
    136     # fp64 - 32 64-bit FPU registers are available.
    137     # fpxx - compatibility mode, it chooses fp32 or fp64 depending on runtime
    138     #        detection
    139     'mips_fpu_mode%': 'fp32',
    140   },
    141   'target_defaults': {
    142     'variables': {
    143       'v8_code%': '<(v8_code)',
    144     },
    145     'default_configuration': 'Debug',
    146     'configurations': {
    147       'DebugBaseCommon': {
    148         'cflags': [ '-g', '-O0' ],
    149       },
    150       'Optdebug': {
    151         'inherit_from': [ 'DebugBaseCommon', 'DebugBase2' ],
    152       },
    153       'Debug': {
    154         # Xcode insists on this empty entry.
    155       },
    156       'Release': {
    157         # Xcode insists on this empty entry.
    158       },
    159     },
    160     'target_conditions': [
    161       ['v8_code == 0', {
    162         'defines!': [
    163           'DEBUG',
    164         ],
    165         'conditions': [
    166           ['os_posix == 1 and OS != "mac"', {
    167             'cflags!': [
    168               '-Werror',
    169             ],
    170           }],
    171           ['OS == "mac"', {
    172             'xcode_settings': {
    173               'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO',    # -Werror
    174             },
    175           }],
    176           ['OS == "win"', {
    177             'msvs_settings': {
    178               'VCCLCompilerTool': {
    179                 'WarnAsError': 'false',
    180               },
    181             },
    182           }],
    183         ],
    184       }],
    185     ],
    186   },
    187   'conditions': [
    188     ['asan==1', {
    189       'target_defaults': {
    190         'cflags_cc+': [
    191           '-fno-omit-frame-pointer',
    192           '-gline-tables-only',
    193           '-fsanitize=address',
    194           '-w',  # http://crbug.com/162783
    195         ],
    196         'cflags_cc!': [
    197           '-fomit-frame-pointer',
    198         ],
    199         'ldflags': [
    200           '-fsanitize=address',
    201         ],
    202       },
    203     }],
    204     ['tsan==1', {
    205       'target_defaults': {
    206         'cflags+': [
    207           '-fno-omit-frame-pointer',
    208           '-gline-tables-only',
    209           '-fsanitize=thread',
    210           '-fPIC',
    211           '-Wno-c++11-extensions',
    212         ],
    213         'cflags!': [
    214           '-fomit-frame-pointer',
    215         ],
    216         'ldflags': [
    217           '-fsanitize=thread',
    218           '-pie',
    219         ],
    220         'defines': [
    221           'THREAD_SANITIZER',
    222         ],
    223       },
    224     }],
    225     ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
    226        or OS=="netbsd"', {
    227       'target_defaults': {
    228         'cflags': [
    229           '-Wall',
    230           '<(werror)',
    231           '-W',
    232           '-Wno-unused-parameter',
    233           '-Wno-long-long',
    234           '-pthread',
    235           '-fno-exceptions',
    236           '-pedantic',
    237           # Don't warn about the "struct foo f = {0};" initialization pattern.
    238           '-Wno-missing-field-initializers',
    239         ],
    240         'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-std=gnu++0x' ],
    241         'ldflags': [ '-pthread', ],
    242         'conditions': [
    243           [ 'visibility=="hidden" and v8_enable_backtrace==0', {
    244             'cflags': [ '-fvisibility=hidden' ],
    245           }],
    246           [ 'component=="shared_library"', {
    247             'cflags': [ '-fPIC', ],
    248           }],
    249         ],
    250       },
    251     }],
    252     # 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"
    253     #  or OS=="netbsd"'
    254     ['OS=="qnx"', {
    255       'target_defaults': {
    256         'cflags': [
    257           '-Wall',
    258           '<(werror)',
    259           '-W',
    260           '-Wno-unused-parameter',
    261           '-fno-exceptions',
    262           # Don't warn about the "struct foo f = {0};" initialization pattern.
    263           '-Wno-missing-field-initializers',
    264         ],
    265         'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-std=gnu++0x' ],
    266         'conditions': [
    267           [ 'visibility=="hidden"', {
    268             'cflags': [ '-fvisibility=hidden' ],
    269           }],
    270           [ 'component=="shared_library"', {
    271             'cflags': [ '-fPIC' ],
    272           }],
    273         ],
    274         'target_conditions': [
    275           [ '_toolset=="host" and host_os=="linux"', {
    276             'cflags': [ '-pthread' ],
    277             'ldflags': [ '-pthread' ],
    278             'libraries': [ '-lrt' ],
    279           }],
    280           [ '_toolset=="target"', {
    281             'cflags': [ '-Wno-psabi' ],
    282             'libraries': [ '-lbacktrace', '-lsocket', '-lm' ],
    283           }],
    284         ],
    285       },
    286     }],  # OS=="qnx"
    287     ['OS=="win"', {
    288       'target_defaults': {
    289         'defines': [
    290           '_CRT_SECURE_NO_DEPRECATE',
    291           '_CRT_NONSTDC_NO_DEPRECATE',
    292           '_USING_V110_SDK71_',
    293         ],
    294         'conditions': [
    295           ['component=="static_library"', {
    296             'defines': [
    297               '_HAS_EXCEPTIONS=0',
    298             ],
    299           }],
    300         ],
    301         'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
    302         'msvs_disabled_warnings': [4355, 4800],
    303         'msvs_settings': {
    304           'VCCLCompilerTool': {
    305             'MinimalRebuild': 'false',
    306             'BufferSecurityCheck': 'true',
    307             'EnableFunctionLevelLinking': 'true',
    308             'RuntimeTypeInfo': 'false',
    309             'WarningLevel': '3',
    310             'WarnAsError': 'true',
    311             'DebugInformationFormat': '3',
    312             'Detect64BitPortabilityProblems': 'false',
    313             'conditions': [
    314               [ 'msvs_multi_core_compile', {
    315                 'AdditionalOptions': ['/MP'],
    316               }],
    317               ['component=="shared_library"', {
    318                 'ExceptionHandling': '1',  # /EHsc
    319               }, {
    320                 'ExceptionHandling': '0',
    321               }],
    322             ],
    323           },
    324           'VCLibrarianTool': {
    325             'AdditionalOptions': ['/ignore:4221'],
    326           },
    327           'VCLinkerTool': {
    328             'MinimumRequiredVersion': '5.01',  # XP.
    329             'AdditionalDependencies': [
    330               'ws2_32.lib',
    331             ],
    332             'GenerateDebugInformation': 'true',
    333             'MapFileName': '$(OutDir)\\$(TargetName).map',
    334             'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
    335             'FixedBaseAddress': '1',
    336             # LinkIncremental values:
    337             #   0 == default
    338             #   1 == /INCREMENTAL:NO
    339             #   2 == /INCREMENTAL
    340             'LinkIncremental': '1',
    341             # SubSystem values:
    342             #   0 == not set
    343             #   1 == /SUBSYSTEM:CONSOLE
    344             #   2 == /SUBSYSTEM:WINDOWS
    345             'SubSystem': '1',
    346 
    347             'conditions': [
    348               ['v8_enable_i18n_support==1', {
    349                 'AdditionalDependencies': [
    350                   'advapi32.lib',
    351                 ],
    352               }],
    353             ],
    354           },
    355         },
    356       },
    357     }],  # OS=="win"
    358     ['OS=="mac"', {
    359       'xcode_settings': {
    360         'SYMROOT': '<(DEPTH)/xcodebuild',
    361       },
    362       'target_defaults': {
    363         'xcode_settings': {
    364           'ALWAYS_SEARCH_USER_PATHS': 'NO',
    365           'GCC_C_LANGUAGE_STANDARD': 'c99',         # -std=c99
    366           'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
    367           'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
    368                                                     # (Equivalent to -fPIC)
    369           'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
    370           'GCC_ENABLE_CPP_RTTI': 'NO',              # -fno-rtti
    371           'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
    372           # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
    373           'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
    374           'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES',      # -fvisibility=hidden
    375           'GCC_THREADSAFE_STATICS': 'NO',           # -fno-threadsafe-statics
    376           'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
    377           # MACOSX_DEPLOYMENT_TARGET maps to -mmacosx-version-min
    378           'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
    379           'PREBINDING': 'NO',                       # No -Wl,-prebind
    380           'SYMROOT': '<(DEPTH)/xcodebuild',
    381           'USE_HEADERMAP': 'NO',
    382           'OTHER_CFLAGS': [
    383             '-fno-strict-aliasing',
    384           ],
    385           'WARNING_CFLAGS': [
    386             '-Wall',
    387             '-Wendif-labels',
    388             '-W',
    389             '-Wno-unused-parameter',
    390             # Don't warn about the "struct foo f = {0};" initialization pattern.
    391             '-Wno-missing-field-initializers',
    392           ],
    393         },
    394         'conditions': [
    395           ['werror==""', {
    396             'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO'},
    397           }, {
    398             'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES'},
    399           }],
    400           ['clang==1', {
    401             'xcode_settings': {
    402               'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
    403               'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x',  # -std=gnu++0x
    404             },
    405           }],
    406         ],
    407         'target_conditions': [
    408           ['_type!="static_library"', {
    409             'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
    410           }],
    411         ],  # target_conditions
    412       },  # target_defaults
    413     }],  # OS=="mac"
    414   ],
    415 }
    416