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     'clang%': 0,
     37     'asan%': 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%':
     55                 '<!(uname -m | sed -e "s/i.86/ia32/;\
     56                                        s/x86_64/x64/;\
     57                                        s/amd64/x64/;\
     58                                        s/arm.*/arm/;\
     59                                        s/aarch64/arm64/;\
     60                                        s/mips.*/mipsel/")',
     61             }, {
     62               # OS!="linux" and OS!="freebsd" and OS!="openbsd" and
     63               # OS!="netbsd" and OS!="mac"
     64               'host_arch%': 'ia32',
     65             }],
     66           ],
     67         },
     68         'host_arch%': '<(host_arch)',
     69         'target_arch%': '<(host_arch)',
     70       },
     71       'host_arch%': '<(host_arch)',
     72       'target_arch%': '<(target_arch)',
     73       'v8_target_arch%': '<(target_arch)',
     74     },
     75     'host_arch%': '<(host_arch)',
     76     'target_arch%': '<(target_arch)',
     77     'v8_target_arch%': '<(v8_target_arch)',
     78     'werror%': '-Werror',
     79 
     80     # .gyp files or targets should set v8_code to 1 if they build V8 specific
     81     # code, as opposed to external code.  This variable is used to control such
     82     # things as the set of warnings to enable, and whether warnings are treated
     83     # as errors.
     84     'v8_code%': 0,
     85 
     86     # Speeds up Debug builds:
     87     # 0 - Compiler optimizations off (debuggable) (default). This may
     88     #     be 5x slower than Release (or worse).
     89     # 1 - Turn on compiler optimizations. This may be hard or impossible to
     90     #     debug. This may still be 2x slower than Release (or worse).
     91     # 2 - Turn on optimizations, and also #undef DEBUG / #define NDEBUG
     92     #     (but leave V8_ENABLE_CHECKS and most other assertions enabled.
     93     #     This may cause some v8 tests to fail in the Debug configuration.
     94     #     This roughly matches the performance of a Release build and can
     95     #     be used by embedders that need to build their own code as debug
     96     #     but don't want or need a debug version of V8. This should produce
     97     #     near-release speeds.
     98     'v8_optimized_debug%': 0,
     99 
    100     # Relative path to icu.gyp from this file.
    101     'icu_gyp_path': '../third_party/icu/icu.gyp',
    102 
    103     'conditions': [
    104       ['(v8_target_arch=="arm" and host_arch!="arm") or \
    105         (v8_target_arch=="arm64" and host_arch!="arm64") or \
    106         (v8_target_arch=="mipsel" and host_arch!="mipsel") or \
    107         (v8_target_arch=="x64" and host_arch!="x64") or \
    108         (OS=="android" or OS=="qnx")', {
    109         'want_separate_host_toolset': 1,
    110       }, {
    111         'want_separate_host_toolset': 0,
    112       }],
    113       ['OS == "win"', {
    114         'os_posix%': 0,
    115       }, {
    116         'os_posix%': 1,
    117       }],
    118       ['(v8_target_arch=="ia32" or v8_target_arch=="x64" or v8_target_arch=="x87") and \
    119         (OS=="linux" or OS=="mac")', {
    120         'v8_enable_gdbjit%': 1,
    121       }, {
    122         'v8_enable_gdbjit%': 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   'target_defaults': {
    132     'variables': {
    133       'v8_code%': '<(v8_code)',
    134     },
    135     'default_configuration': 'Debug',
    136     'configurations': {
    137       'DebugBaseCommon': {
    138         'cflags': [ '-g', '-O0' ],
    139       },
    140       'Optdebug': {
    141         'inherit_from': [ 'DebugBaseCommon', 'DebugBase2' ],
    142       },
    143       'Debug': {
    144         # Xcode insists on this empty entry.
    145       },
    146       'Release': {
    147         # Xcode insists on this empty entry.
    148       },
    149     },
    150     'target_conditions': [
    151       ['v8_code == 0', {
    152         'defines!': [
    153           'DEBUG',
    154         ],
    155         'conditions': [
    156           ['os_posix == 1 and OS != "mac"', {
    157             'cflags!': [
    158               '-Werror',
    159             ],
    160           }],
    161           ['OS == "mac"', {
    162             'xcode_settings': {
    163               'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO',    # -Werror
    164             },
    165           }],
    166           ['OS == "win"', {
    167             'msvs_settings': {
    168               'VCCLCompilerTool': {
    169                 'WarnAsError': 'false',
    170               },
    171             },
    172           }],
    173         ],
    174       }],
    175     ],
    176   },
    177   'conditions': [
    178     ['asan==1', {
    179       'target_defaults': {
    180         'cflags_cc+': [
    181           '-fno-omit-frame-pointer',
    182           '-gline-tables-only',
    183           '-fsanitize=address',
    184           '-w',  # http://crbug.com/162783
    185         ],
    186         'cflags_cc!': [
    187           '-fomit-frame-pointer',
    188         ],
    189         'ldflags': [
    190           '-fsanitize=address',
    191         ],
    192       },
    193     }],
    194     ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
    195        or OS=="netbsd"', {
    196       'target_defaults': {
    197         'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
    198                     '-pthread', '-fno-exceptions', '-pedantic' ],
    199         'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti' ],
    200         'ldflags': [ '-pthread', ],
    201         'conditions': [
    202           [ 'OS=="linux"', {
    203             'cflags': [ '-ansi' ],
    204           }],
    205           [ 'visibility=="hidden" and v8_enable_backtrace==0', {
    206             'cflags': [ '-fvisibility=hidden' ],
    207           }],
    208           [ 'component=="shared_library"', {
    209             'cflags': [ '-fPIC', ],
    210           }],
    211         ],
    212       },
    213     }],
    214     # 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"
    215     #  or OS=="netbsd"'
    216     ['OS=="qnx"', {
    217       'target_defaults': {
    218         'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
    219                     '-fno-exceptions' ],
    220         'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti' ],
    221         'conditions': [
    222           [ 'visibility=="hidden"', {
    223             'cflags': [ '-fvisibility=hidden' ],
    224           }],
    225           [ 'component=="shared_library"', {
    226             'cflags': [ '-fPIC' ],
    227           }],
    228         ],
    229         'target_conditions': [
    230           [ '_toolset=="host" and host_os=="linux"', {
    231             'cflags': [ '-pthread' ],
    232             'ldflags': [ '-pthread' ],
    233             'libraries': [ '-lrt' ],
    234           }],
    235           [ '_toolset=="target"', {
    236             'cflags': [ '-Wno-psabi' ],
    237             'libraries': [ '-lbacktrace', '-lsocket', '-lm' ],
    238           }],
    239         ],
    240       },
    241     }],  # OS=="qnx"
    242     ['OS=="win"', {
    243       'target_defaults': {
    244         'defines': [
    245           '_CRT_SECURE_NO_DEPRECATE',
    246           '_CRT_NONSTDC_NO_DEPRECATE',
    247         ],
    248         'conditions': [
    249           ['component=="static_library"', {
    250             'defines': [
    251               '_HAS_EXCEPTIONS=0',
    252             ],
    253           }],
    254         ],
    255         'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
    256         'msvs_disabled_warnings': [4355, 4800],
    257         'msvs_settings': {
    258           'VCCLCompilerTool': {
    259             'MinimalRebuild': 'false',
    260             'BufferSecurityCheck': 'true',
    261             'EnableFunctionLevelLinking': 'true',
    262             'RuntimeTypeInfo': 'false',
    263             'WarningLevel': '3',
    264             'WarnAsError': 'true',
    265             'DebugInformationFormat': '3',
    266             'Detect64BitPortabilityProblems': 'false',
    267             'conditions': [
    268               [ 'msvs_multi_core_compile', {
    269                 'AdditionalOptions': ['/MP'],
    270               }],
    271               ['component=="shared_library"', {
    272                 'ExceptionHandling': '1',  # /EHsc
    273               }, {
    274                 'ExceptionHandling': '0',
    275               }],
    276             ],
    277           },
    278           'VCLibrarianTool': {
    279             'AdditionalOptions': ['/ignore:4221'],
    280           },
    281           'VCLinkerTool': {
    282             'AdditionalDependencies': [
    283               'ws2_32.lib',
    284             ],
    285             'GenerateDebugInformation': 'true',
    286             'MapFileName': '$(OutDir)\\$(TargetName).map',
    287             'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
    288             'FixedBaseAddress': '1',
    289             # LinkIncremental values:
    290             #   0 == default
    291             #   1 == /INCREMENTAL:NO
    292             #   2 == /INCREMENTAL
    293             'LinkIncremental': '1',
    294             # SubSystem values:
    295             #   0 == not set
    296             #   1 == /SUBSYSTEM:CONSOLE
    297             #   2 == /SUBSYSTEM:WINDOWS
    298             'SubSystem': '1',
    299 
    300             'conditions': [
    301               ['v8_enable_i18n_support==1', {
    302                 'AdditionalDependencies': [
    303                   'advapi32.lib',
    304                 ],
    305               }],
    306             ],
    307           },
    308         },
    309       },
    310     }],  # OS=="win"
    311     ['OS=="mac"', {
    312       'xcode_settings': {
    313         'SYMROOT': '<(DEPTH)/xcodebuild',
    314       },
    315       'target_defaults': {
    316         'xcode_settings': {
    317           'ALWAYS_SEARCH_USER_PATHS': 'NO',
    318           'GCC_C_LANGUAGE_STANDARD': 'ansi',        # -ansi
    319           'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
    320           'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
    321                                                     # (Equivalent to -fPIC)
    322           'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
    323           'GCC_ENABLE_CPP_RTTI': 'NO',              # -fno-rtti
    324           'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
    325           # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
    326           'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
    327           'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES',      # -fvisibility=hidden
    328           'GCC_THREADSAFE_STATICS': 'NO',           # -fno-threadsafe-statics
    329           'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
    330           # MACOSX_DEPLOYMENT_TARGET maps to -mmacosx-version-min
    331           'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
    332           'PREBINDING': 'NO',                       # No -Wl,-prebind
    333           'SYMROOT': '<(DEPTH)/xcodebuild',
    334           'USE_HEADERMAP': 'NO',
    335           'OTHER_CFLAGS': [
    336             '-fno-strict-aliasing',
    337           ],
    338           'WARNING_CFLAGS': [
    339             '-Wall',
    340             '-Wendif-labels',
    341             '-W',
    342             '-Wno-unused-parameter',
    343           ],
    344         },
    345         'conditions': [
    346           ['werror==""', {
    347             'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO'},
    348           }, {
    349             'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES'},
    350           }],
    351           ['clang==1', {
    352             'xcode_settings': {
    353               'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
    354               'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++11',  # -std=gnu++11
    355             },
    356           }],
    357         ],
    358         'target_conditions': [
    359           ['_type!="static_library"', {
    360             'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
    361           }],
    362         ],  # target_conditions
    363       },  # target_defaults
    364     }],  # OS=="mac"
    365   ],
    366 }
    367