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     'visibility%': 'hidden',
     38     'v8_enable_backtrace%': 0,
     39     'v8_enable_i18n_support%': 1,
     40     'v8_deprecation_warnings': 1,
     41     'msvs_multi_core_compile%': '1',
     42     'mac_deployment_target%': '10.5',
     43     'variables': {
     44       'variables': {
     45         'variables': {
     46           'conditions': [
     47             ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or \
     48                OS=="netbsd" or OS=="mac"', {
     49               # This handles the Unix platforms we generally deal with.
     50               # Anything else gets passed through, which probably won't work
     51               # very well; such hosts should pass an explicit target_arch
     52               # to gyp.
     53               'host_arch%':
     54                 '<!(uname -m | sed -e "s/i.86/ia32/;\
     55                   s/x86_64/x64/;s/amd64/x64/;s/arm.*/arm/;s/mips.*/mipsel/")',
     56             }, {
     57               # OS!="linux" and OS!="freebsd" and OS!="openbsd" and
     58               # OS!="netbsd" and OS!="mac"
     59               'host_arch%': 'ia32',
     60             }],
     61           ],
     62         },
     63         'host_arch%': '<(host_arch)',
     64         'target_arch%': '<(host_arch)',
     65       },
     66       'host_arch%': '<(host_arch)',
     67       'target_arch%': '<(target_arch)',
     68       'v8_target_arch%': '<(target_arch)',
     69     },
     70     'host_arch%': '<(host_arch)',
     71     'target_arch%': '<(target_arch)',
     72     'v8_target_arch%': '<(v8_target_arch)',
     73     'werror%': '-Werror',
     74 
     75     # .gyp files or targets should set v8_code to 1 if they build V8 specific
     76     # code, as opposed to external code.  This variable is used to control such
     77     # things as the set of warnings to enable, and whether warnings are treated
     78     # as errors.
     79     'v8_code%': 0,
     80 
     81     # Speeds up Debug builds:
     82     # 0 - Compiler optimizations off (debuggable) (default). This may
     83     #     be 5x slower than Release (or worse).
     84     # 1 - Turn on compiler optimizations. This may be hard or impossible to
     85     #     debug. This may still be 2x slower than Release (or worse).
     86     # 2 - Turn on optimizations, and also #undef DEBUG / #define NDEBUG
     87     #     (but leave V8_ENABLE_CHECKS and most other assertions enabled.
     88     #     This may cause some v8 tests to fail in the Debug configuration.
     89     #     This roughly matches the performance of a Release build and can
     90     #     be used by embedders that need to build their own code as debug
     91     #     but don't want or need a debug version of V8. This should produce
     92     #     near-release speeds.
     93     'v8_optimized_debug%': 0,
     94 
     95     # Relative path to icu.gyp from this file.
     96     'icu_gyp_path': '../third_party/icu/icu.gyp',
     97 
     98     'conditions': [
     99       ['(v8_target_arch=="arm" and host_arch!="arm") or \
    100         (v8_target_arch=="mipsel" and host_arch!="mipsel") or \
    101         (v8_target_arch=="x64" and host_arch!="x64") or \
    102         (OS=="android")', {
    103         'want_separate_host_toolset': 1,
    104       }, {
    105         'want_separate_host_toolset': 0,
    106       }],
    107       ['OS == "win"', {
    108         'os_posix%': 0,
    109       }, {
    110         'os_posix%': 1,
    111       }],
    112       ['(v8_target_arch=="ia32" or v8_target_arch=="x64") and \
    113         (OS=="linux" or OS=="mac")', {
    114         'v8_enable_gdbjit%': 1,
    115       }, {
    116         'v8_enable_gdbjit%': 0,
    117       }],
    118     ],
    119     # Default ARM variable settings.
    120     'armv7%': 'default',
    121     'arm_neon%': 0,
    122     'arm_fpu%': 'vfpv3',
    123     'arm_float_abi%': 'default',
    124     'arm_thumb': 'default',
    125   },
    126   'target_defaults': {
    127     'variables': {
    128       'v8_code%': '<(v8_code)',
    129     },
    130     'default_configuration': 'Debug',
    131     'configurations': {
    132       'Debug': {
    133         'cflags': [ '-g', '-O0' ],
    134       },
    135       'Release': {
    136         # Xcode insists on this empty entry.
    137       },
    138     },
    139     'target_conditions': [
    140       ['v8_code == 0', {
    141         'defines!': [
    142           'DEBUG',
    143         ],
    144         'conditions': [
    145           ['os_posix == 1 and OS != "mac"', {
    146             'cflags!': [
    147               '-Werror',
    148             ],
    149           }],
    150           ['OS == "mac"', {
    151             'xcode_settings': {
    152               'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO',    # -Werror
    153             },
    154           }],
    155           ['OS == "win"', {
    156             'msvs_settings': {
    157               'VCCLCompilerTool': {
    158                 'WarnAsError': 'false',
    159               },
    160             },
    161           }],
    162         ],
    163       }],
    164     ],
    165   },
    166   'conditions': [
    167     ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
    168        or OS=="netbsd"', {
    169       'target_defaults': {
    170         'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
    171                     '-pthread', '-fno-exceptions', '-pedantic' ],
    172         'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti' ],
    173         'ldflags': [ '-pthread', ],
    174         'conditions': [
    175           [ 'OS=="linux"', {
    176             'cflags': [ '-ansi' ],
    177           }],
    178           [ 'visibility=="hidden" and v8_enable_backtrace==0', {
    179             'cflags': [ '-fvisibility=hidden' ],
    180           }],
    181           [ 'component=="shared_library"', {
    182             'cflags': [ '-fPIC', ],
    183           }],
    184         ],
    185       },
    186     }],
    187     # 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"
    188     #  or OS=="netbsd"'
    189     ['OS=="win"', {
    190       'target_defaults': {
    191         'defines': [
    192           '_CRT_SECURE_NO_DEPRECATE',
    193           '_CRT_NONSTDC_NO_DEPRECATE',
    194         ],
    195         'conditions': [
    196           ['component=="static_library"', {
    197             'defines': [
    198               '_HAS_EXCEPTIONS=0',
    199             ],
    200           }],
    201         ],
    202         'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
    203         'msvs_disabled_warnings': [4355, 4800],
    204         'msvs_settings': {
    205           'VCCLCompilerTool': {
    206             'MinimalRebuild': 'false',
    207             'BufferSecurityCheck': 'true',
    208             'EnableFunctionLevelLinking': 'true',
    209             'RuntimeTypeInfo': 'false',
    210             'WarningLevel': '3',
    211             'WarnAsError': 'true',
    212             'DebugInformationFormat': '3',
    213             'Detect64BitPortabilityProblems': 'false',
    214             'conditions': [
    215               [ 'msvs_multi_core_compile', {
    216                 'AdditionalOptions': ['/MP'],
    217               }],
    218               ['component=="shared_library"', {
    219                 'ExceptionHandling': '1',  # /EHsc
    220               }, {
    221                 'ExceptionHandling': '0',
    222               }],
    223             ],
    224           },
    225           'VCLibrarianTool': {
    226             'AdditionalOptions': ['/ignore:4221'],
    227           },
    228           'VCLinkerTool': {
    229             'AdditionalDependencies': [
    230               'ws2_32.lib',
    231             ],
    232             'GenerateDebugInformation': 'true',
    233             'MapFileName': '$(OutDir)\\$(TargetName).map',
    234             'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
    235             'FixedBaseAddress': '1',
    236             # LinkIncremental values:
    237             #   0 == default
    238             #   1 == /INCREMENTAL:NO
    239             #   2 == /INCREMENTAL
    240             'LinkIncremental': '1',
    241             # SubSystem values:
    242             #   0 == not set
    243             #   1 == /SUBSYSTEM:CONSOLE
    244             #   2 == /SUBSYSTEM:WINDOWS
    245             'SubSystem': '1',
    246 
    247             'conditions': [
    248               ['v8_enable_i18n_support==1', {
    249                 'AdditionalDependencies': [
    250                   'advapi32.lib',
    251                 ],
    252               }],
    253             ],
    254           },
    255         },
    256       },
    257     }],  # OS=="win"
    258     ['OS=="mac"', {
    259       'xcode_settings': {
    260         'SYMROOT': '<(DEPTH)/xcodebuild',
    261       },
    262       'target_defaults': {
    263         'xcode_settings': {
    264           'ALWAYS_SEARCH_USER_PATHS': 'NO',
    265           'GCC_C_LANGUAGE_STANDARD': 'ansi',        # -ansi
    266           'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
    267           'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
    268                                                     # (Equivalent to -fPIC)
    269           'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
    270           'GCC_ENABLE_CPP_RTTI': 'NO',              # -fno-rtti
    271           'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
    272           # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
    273           'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
    274           'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES',      # -fvisibility=hidden
    275           'GCC_THREADSAFE_STATICS': 'NO',           # -fno-threadsafe-statics
    276           'GCC_VERSION': 'com.apple.compilers.llvmgcc42',
    277           'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES',  # -Wnewline-eof
    278           'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
    279           # MACOSX_DEPLOYMENT_TARGET maps to -mmacosx-version-min
    280           'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
    281           'PREBINDING': 'NO',                       # No -Wl,-prebind
    282           'SYMROOT': '<(DEPTH)/xcodebuild',
    283           'USE_HEADERMAP': 'NO',
    284           'OTHER_CFLAGS': [
    285             '-fno-strict-aliasing',
    286           ],
    287           'WARNING_CFLAGS': [
    288             '-Wall',
    289             '-Wendif-labels',
    290             '-W',
    291             '-Wno-unused-parameter',
    292           ],
    293         },
    294         'conditions': [
    295           ['werror==""', {
    296             'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO'},
    297           }, {
    298             'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES'},
    299           }],
    300         ],
    301         'target_conditions': [
    302           ['_type!="static_library"', {
    303             'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
    304           }],
    305         ],  # target_conditions
    306       },  # target_defaults
    307     }],  # OS=="mac"
    308   ],
    309 }
    310