Home | History | Annotate | Download | only in gyp
      1 # Copyright 2015 Google Inc.
      2 #
      3 # Use of this source code is governed by a BSD-style license that can be
      4 # found in the LICENSE file.
      5 
      6 # conditions used in both common.gypi and skia.gyp in chromium
      7 #
      8 {
      9   'defines': [
     10     'SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=<(skia_static_initializers)',
     11     'SK_SUPPORT_GPU=<(skia_gpu)',
     12     'SK_SUPPORT_OPENCL=<(skia_opencl)',
     13     'SK_FORCE_DISTANCE_FIELD_TEXT=<(skia_force_distance_field_text)',
     14   ],
     15   'conditions' : [
     16     ['skia_pic', {
     17      'cflags': [
     18        '-fPIC',
     19      ],
     20      'conditions' : [
     21       # FIXME: The reason we don't do this on Android is due to the way
     22       # we build the executables/skia_launcher on Android. See
     23       # https://codereview.chromium.org/406613003/diff/1/gyp/common_conditions.gypi#newcode455
     24       ['skia_os != "android"', {
     25        'target_conditions': [
     26          [ '_type == "executable"', {
     27            'cflags': [ '-fPIE' ],
     28            'ldflags': [ '-pie' ],
     29          }],
     30        ],
     31       }],
     32      ],
     33     }],
     34 
     35     # As of M35, Chrome requires SSE2 on x86 (and SSSE3 on Mac).
     36     [ 'skia_arch_type == "x86"', {
     37       'cflags': [
     38         '-msse2',
     39         '-mfpmath=sse',
     40       ],
     41     }],
     42 
     43     [ 'skia_os == "win"',
     44       {
     45         'defines': [
     46           'SK_BUILD_FOR_WIN32',
     47           '_CRT_SECURE_NO_WARNINGS',
     48           'GR_GL_FUNCTION_TYPE=__stdcall',
     49         ],
     50         'msvs_disabled_warnings': [
     51             4275,  # An exported class was derived from a class that was not exported
     52             4345,  # This is an FYI about a behavior change from long ago. Chrome stifles it too.
     53             4355,  # 'this' used in base member initializer list. Off by default in newer compilers.
     54         ],
     55         'msvs_cygwin_shell': 0,
     56         'msvs_settings': {
     57           'VCCLCompilerTool': {
     58             'WarningLevel': '3',
     59             'ProgramDataBaseFileName': '$(OutDir)\\$(ProjectName).pdb',
     60             'DebugInformationFormat': '3',
     61             'ExceptionHandling': '0',
     62             'AdditionalOptions': [ '/MP', ],
     63           },
     64           'VCLinkerTool': {
     65             'LargeAddressAware': 2,  # 2 means "Yes, please let me use more RAM on 32-bit builds."
     66             'AdditionalDependencies': [
     67               'OpenGL32.lib',
     68               'usp10.lib',
     69 
     70               # Prior to gyp r1584, the following were included automatically.
     71               'kernel32.lib',
     72               'gdi32.lib',
     73               'winspool.lib',
     74               'comdlg32.lib',
     75               'advapi32.lib',
     76               'shell32.lib',
     77               'ole32.lib',
     78               'oleaut32.lib',
     79               'user32.lib',
     80               'uuid.lib',
     81               'odbc32.lib',
     82               'odbccp32.lib',
     83               'DelayImp.lib',
     84             ],
     85           },
     86         },
     87         'configurations': {
     88           'Debug': {
     89             'msvs_settings': {
     90               'VCCLCompilerTool': {
     91                 'DebugInformationFormat': '4', # editAndContiue (/ZI)
     92                 'Optimization': '0',           # optimizeDisabled (/Od)
     93                 'PreprocessorDefinitions': ['_DEBUG'],
     94                 'RuntimeLibrary': '3',         # rtMultiThreadedDebugDLL (/MDd)
     95                 'RuntimeTypeInfo': 'false',      # /GR-
     96               },
     97               'VCLinkerTool': {
     98                 'GenerateDebugInformation': 'true', # /DEBUG
     99                 'LinkIncremental': '2',             # /INCREMENTAL
    100               },
    101             },
    102           },
    103           'Release': {
    104             'msvs_settings': {
    105               'VCCLCompilerTool': {
    106                 'DebugInformationFormat': '3',      # programDatabase (/Zi)
    107                 'Optimization': '<(skia_release_optimization_level)',
    108                # Changing the floating point model requires rebaseling gm images
    109                #'FloatingPointModel': '2',          # fast (/fp:fast)
    110                 'FavorSizeOrSpeed': '1',            # speed (/Ot)
    111                 'PreprocessorDefinitions': ['NDEBUG'],
    112                 'RuntimeLibrary': '2',              # rtMultiThreadedDLL (/MD)
    113                 'EnableEnhancedInstructionSet': '2',# /arch:SSE2
    114                 'RuntimeTypeInfo': 'false',         # /GR-
    115               },
    116               'VCLinkerTool': {
    117                 'GenerateDebugInformation': 'true', # /DEBUG
    118               },
    119             },
    120           },
    121         },
    122         'conditions' : [
    123           # Gyp's ninja generator depends on these specially named
    124           # configurations to build 64-bit on Windows.
    125           # See http://skbug.com/2348
    126           #
    127           # We handle the 64- vs 32-bit variations elsewhere, so I think it's
    128           # OK for us to just make these inherit non-archwidth-specific
    129           # configurations without modification.
    130           #
    131           # See http://skbug.com/2442 : These targets cause problems in the
    132           # MSVS build, so only include them if gyp is generating a ninja build.
    133           [ '"ninja" in "<!(echo %GYP_GENERATORS%)"', {
    134             'configurations': {
    135               'Debug_x64': {
    136                 'inherit_from': ['Debug'],
    137                 'msvs_settings': {
    138                   'VCCLCompilerTool': {
    139                      # /ZI is not supported on 64bit
    140                     'DebugInformationFormat': '3', # programDatabase (/Zi)
    141                   },
    142                 },
    143               },
    144               'Release_x64': {
    145                 'inherit_from': ['Release'],
    146                 'msvs_settings': {
    147                   'VCCLCompilerTool': {
    148                      # Don't specify /arch. SSE2 is implied by 64bit and specifying it warns.
    149                     'EnableEnhancedInstructionSet': '0', #
    150                   },
    151                 },
    152               },
    153               'Release_Developer_x64': {
    154                 'inherit_from': ['Release_Developer'],
    155                 'msvs_settings': {
    156                   'VCCLCompilerTool': {
    157                      # Don't specify /arch. SSE2 is implied by 64bit and specifying it warns.
    158                     'EnableEnhancedInstructionSet': '0', #
    159                   },
    160                 },
    161               },
    162             },
    163           }],
    164           [ 'skia_arch_width == 64', {
    165             'msvs_configuration_platform': 'x64',
    166           }],
    167           [ 'skia_arch_width == 32', {
    168             'msvs_configuration_platform': 'Win32',
    169           }],
    170           [ 'skia_warnings_as_errors', {
    171             'msvs_settings': {
    172               'VCCLCompilerTool': {
    173                 'WarnAsError': 'true',
    174                 'AdditionalOptions': [
    175                   '/we4189', # initialized but unused var warning
    176                 ],
    177               },
    178             },
    179           }],
    180           [ 'skia_win_exceptions', {
    181             'msvs_settings': {
    182               'VCCLCompilerTool': {
    183                 'AdditionalOptions': [
    184                   '/EHsc',
    185                 ],
    186               },
    187             },
    188           }],
    189           [ 'skia_win_ltcg', {
    190             'configurations': {
    191               'Release': {
    192                 'msvs_settings': {
    193                   'VCCLCompilerTool': {
    194                     'WholeProgramOptimization': 'true', #/GL
    195                   },
    196                   'VCLinkerTool': {
    197                     'LinkTimeCodeGeneration': '1',      # useLinkTimeCodeGeneration /LTCG
    198                   },
    199                   'VCLibrarianTool': {
    200                     'LinkTimeCodeGeneration': 'true',   # useLinkTimeCodeGeneration /LTCG
    201                   },
    202                 },
    203               },
    204             },
    205           }],
    206         ],
    207       },
    208     ],
    209 
    210     # The following section is common to linux + derivatives and android
    211     [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos", "android"]',
    212       {
    213         'cflags': [
    214           '-g',
    215           '-fno-exceptions',
    216           '-fstrict-aliasing',
    217 
    218           '-Wall',
    219           '-Wextra',
    220           '-Winit-self',
    221           '-Wpointer-arith',
    222           '-Wsign-compare',
    223 
    224           '-Wno-unused-parameter',
    225         ],
    226         'cflags_cc': [
    227           '-std=c++11',
    228           '-fno-rtti',
    229           '-Wnon-virtual-dtor',
    230           '-Wno-invalid-offsetof',  # GCC <4.6 is old-school strict about what is POD.
    231         ],
    232         'conditions': [
    233           [ 'skia_fast', { 'cflags': [ '<@(skia_fast_flags)' ] }],
    234           [ 'skia_os != "chromeos"', {
    235             'conditions': [
    236               [ 'skia_arch_type == "x86_64" and not skia_android_framework', {
    237                 'cflags': [
    238                   '-m64',
    239                 ],
    240                 'ldflags': [
    241                   '-m64',
    242                 ],
    243               }],
    244               [ 'skia_arch_type == "x86" and not skia_android_framework', {
    245                 'cflags': [
    246                   '-m32',
    247                 ],
    248                 'ldflags': [
    249                   '-m32',
    250                 ],
    251               }],
    252             ],
    253           }],
    254           [ 'skia_warnings_as_errors', {
    255             'cflags': [
    256               '-Werror',
    257             ],
    258           }],
    259           # For profiling; reveals some costs, exaggerates others (e.g. trivial setters & getters).
    260           [ 'skia_disable_inlining', {
    261             'cflags': [
    262               '-fno-inline',
    263               '-fno-default-inline',
    264               '-finline-limit=0',
    265               '-fno-omit-frame-pointer',
    266             ],
    267           }],
    268           [ 'skia_arch_type == "arm" and arm_version >= 7', {
    269             'cflags': [
    270               '-march=armv7-a',
    271               '-mthumb',
    272             ],
    273             'ldflags': [
    274               '-march=armv7-a',
    275             ],
    276             'conditions': [
    277               [ 'arm_neon == 1', {
    278                 'defines': [
    279                   'SK_ARM_HAS_NEON',
    280                 ],
    281                 'cflags': [
    282                   '-mfpu=neon',
    283                 ],
    284               }],
    285               [ 'arm_neon_optional == 1', {
    286                 'defines': [
    287                   'SK_ARM_HAS_OPTIONAL_NEON',
    288                 ],
    289               }],
    290               [ 'skia_os != "chromeos" and skia_os != "linux"', {
    291                 'cflags': [
    292                   '-mfloat-abi=softfp',
    293                 ],
    294               }],
    295             ],
    296           }],
    297           [ 'skia_arch_type == "mips"', {
    298             'cflags': [
    299               '-EL',
    300             ],
    301             'conditions': [
    302               [ 'mips_arch_variant == "mips32r2"', {
    303                 'cflags': [
    304                   '-march=mips32r2',
    305                 ],
    306                 'conditions': [
    307                   [ 'mips_dsp == 1', {
    308                     'cflags': [
    309                       '-mdsp',
    310                     ],
    311                     'defines': [
    312                       'SK_MIPS_HAS_DSP',
    313                     ],
    314                   }],
    315                   [ 'mips_dsp == 2', {
    316                     'cflags': [
    317                       '-mdspr2',
    318                     ],
    319                     'defines': [
    320                       'SK_MIPS_HAS_DSP',
    321                       'SK_MIPS_HAS_DSPR2',
    322                     ],
    323                   }],
    324                 ],
    325               }],
    326             ],
    327           }],
    328         ],
    329       },
    330     ],
    331 
    332     ['skia_android_framework', {
    333       'includes' : [
    334         'skia_for_android_framework_defines.gypi',
    335       ],
    336       'cflags': [
    337         # Skia does not enforce this usage pattern so we disable it here to avoid
    338         # unecessary log spew when building
    339         '-Wno-unused-parameter',
    340 
    341         # Android's -D_FORTIFY_SOURCE=2 extensions are incompatibile with SkString.
    342         # Revert to -D_FORTIFY_SOURCE=1
    343         '-U_FORTIFY_SOURCE',
    344         '-D_FORTIFY_SOURCE=1',
    345 
    346         # We can't use the skia_shared_library gyp setting because we need to
    347         # isolate this define to Skia sources. CFLAGS are local to Android.mk
    348         # and ensures that this define is not exported to clients of the library
    349         '-DSKIA_IMPLEMENTATION=1',
    350       ],
    351       # Remove flags which are either unnecessary or problematic for the
    352       # Android framework build. Many of these flags are removed simply because
    353       # they were not previously in the Android framework makefile, and we did
    354       # did not intend to add them when generating the makefile.
    355       # TODO (scroggo): Investigate whether any of these flags are actually
    356       # needed/would be beneficial.
    357       'cflags!': [
    358         # Android has one makefile, used for both debugging (after manual
    359         # modification) and release. Turn off debug info by default.
    360         '-g',
    361         '-march=armv7-a',
    362         '-mthumb',
    363         '-mfpu=neon',
    364         '-mfloat-abi=softfp',
    365         '-fno-exceptions',
    366         '-fstrict-aliasing',
    367         # Remove flags to turn on warnings, since most people building Android
    368         # are not focused on Skia and do not need the extra warning info.
    369         '-Wall',
    370         '-Wextra',
    371         '-Winit-self',
    372         '-Wpointer-arith',
    373         '-Wsign-compare',
    374       ],
    375       'cflags_cc!': [
    376         '-fno-rtti',
    377         '-Wnon-virtual-dtor',
    378       ],
    379       'defines': [
    380         'DCT_IFAST_SUPPORTED',
    381         # using freetype's embolden allows us to adjust fake bold settings at
    382         # draw-time, at which point we know which SkTypeface is being drawn
    383         'SK_USE_FREETYPE_EMBOLDEN',
    384         'SK_SFNTLY_SUBSETTER "sample/chromium/font_subsetter.h"',
    385         # When built as part of the system image we can enable certian non-NDK
    386         # compliant optimizations.
    387         'SK_BUILD_FOR_ANDROID_FRAMEWORK',
    388         # Optimizations for chromium (m30)
    389         'GR_GL_CUSTOM_SETUP_HEADER "gl/GrGLConfig_chrome.h"',
    390         'IGNORE_ROT_AA_RECT_OPT',
    391         'SK_DEFAULT_FONT_CACHE_LIMIT   (768 * 1024)',
    392         'SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024)',
    393         'SK_IGNORE_ETC1_SUPPORT',
    394         # We can't use the skia_shared_library gyp setting because we need expose
    395         # this define globally and the the implemention define as a cflag.
    396         'SKIA_DLL',
    397         'SK_PRINT_CODEC_MESSAGES',
    398         # Defines from skia_for_android_framework_defines.gypi
    399         '<@(skia_for_android_framework_defines)',
    400       ],
    401     }],
    402 
    403     [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]',
    404       {
    405         'defines': [
    406           'SK_SAMPLES_FOR_X',
    407           'SK_BUILD_FOR_UNIX',
    408         ],
    409         'configurations': {
    410           'Coverage': {
    411             'cflags': ['--coverage'],
    412             'ldflags': ['--coverage'],
    413           },
    414           'Debug': {
    415           },
    416           'Release': {
    417             'cflags': [
    418               '-O<(skia_release_optimization_level)',
    419             ],
    420             'defines': [ 'NDEBUG' ],
    421           },
    422         },
    423         'conditions' : [
    424           [ 'skia_shared_lib', {
    425             'defines': [
    426               'SKIA_DLL',
    427               'SKIA_IMPLEMENTATION=1',
    428             ],
    429           }],
    430           # Enable asan, tsan, etc.
    431           [ 'skia_sanitizer', {
    432             'cflags': [
    433               '-fsanitize=<(skia_sanitizer)',
    434             ],
    435             'ldflags': [
    436               '-fsanitize=<(skia_sanitizer)',
    437             ],
    438             'conditions' : [
    439               [ 'skia_sanitizer == "thread"', {
    440                 'defines': [ 'THREAD_SANITIZER' ],
    441               }],
    442               [ 'skia_sanitizer == "undefined"', {
    443                 'cflags_cc!': ['-fno-rtti'],
    444               }],
    445             ],
    446           }],
    447           [ 'skia_clang_build', {
    448             'cflags_cc': [
    449                 '-Wno-unknown-warning-option',  # Allows unknown warnings.
    450                 '-Wno-deprecated',              # From Qt, via debugger (older Clang).
    451                 '-Wno-deprecated-register',     # From Qt, via debugger (newer Clang).
    452             ],
    453             'cflags': [
    454                 # Extra warnings we like but that only Clang knows about.
    455                 '-Wstring-conversion',
    456             ],
    457             'cflags!': [
    458                 '-mfpmath=sse',  # Clang doesn't need to be told this, and sometimes gets confused.
    459             ],
    460           }],
    461           [ 'skia_keep_frame_pointer', {
    462             'cflags': [ '-fno-omit-frame-pointer' ],
    463           }],
    464         ],
    465       },
    466     ],
    467 
    468     [ 'skia_os == "mac"',
    469       {
    470         'defines': [ 'SK_BUILD_FOR_MAC' ],
    471         'configurations': {
    472           'Coverage': {
    473             'xcode_settings': {
    474                'GCC_OPTIMIZATION_LEVEL': '0',
    475                'GCC_GENERATE_TEST_COVERAGE_FILES': 'YES',
    476                'GCC_INSTRUMENT_PROGRAM_FLOW_ARCS' : 'YES',
    477             },
    478           },
    479           'Debug': {
    480             'xcode_settings': { 'GCC_OPTIMIZATION_LEVEL': '0' },
    481           },
    482           'Release': {
    483             'xcode_settings': { 'GCC_OPTIMIZATION_LEVEL': '<(skia_release_optimization_level)', },
    484             'defines': [ 'NDEBUG' ],
    485           },
    486         },
    487         'xcode_settings': {
    488           'conditions': [
    489             [ 'skia_fast', { 'WARNING_CFLAGS': [ '<@(skia_fast_flags)' ] } ],
    490             [ 'skia_warnings_as_errors', { 'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES' }],
    491             [ 'skia_arch_width == 32', { 'ARCHS': ['i386']   }],
    492             [ 'skia_arch_width == 64', { 'ARCHS': ['x86_64'] }],
    493             [ 'skia_osx_deployment_target==""', {
    494               'MACOSX_DEPLOYMENT_TARGET': '10.6', # -mmacos-version-min, passed in env to ld.
    495             }, {
    496               'MACOSX_DEPLOYMENT_TARGET': '<(skia_osx_deployment_target)',
    497             }],
    498           ],
    499           'CLANG_CXX_LANGUAGE_STANDARD':               'c++11',
    500           'GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS': 'YES',  # -mssse3
    501           'GCC_SYMBOLS_PRIVATE_EXTERN':                'NO',   # -fvisibility=hidden
    502           'GCC_INLINES_ARE_PRIVATE_EXTERN':            'NO',   # -fvisibility-inlines-hidden
    503           'GCC_CW_ASM_SYNTAX':                         'NO',   # remove -fasm-blocks
    504           'GCC_ENABLE_PASCAL_STRINGS':                 'NO',   # remove -mpascal-strings
    505           'GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO':     'NO',   # -Wno-invalid-offsetof
    506           'WARNING_CFLAGS': [
    507             '-Wall',
    508             '-Wextra',
    509             '-Winit-self',
    510             '-Wpointer-arith',
    511             '-Wsign-compare',
    512 
    513             '-Wno-unused-parameter',
    514           ],
    515         },
    516       },
    517     ],
    518 
    519     [ 'skia_os == "ios"',
    520       {
    521         'defines': [
    522           'SK_BUILD_FOR_IOS',
    523         ],
    524         'conditions' : [
    525           [ 'skia_warnings_as_errors', {
    526             'xcode_settings': {
    527               'OTHER_CPLUSPLUSFLAGS': [
    528                 '-Werror',
    529               ],
    530             },
    531           }],
    532         ],
    533         'configurations': {
    534           'Debug': {
    535             'xcode_settings': {
    536               'GCC_OPTIMIZATION_LEVEL': '0',
    537             },
    538           },
    539           'Release': {
    540             'xcode_settings': {
    541               'GCC_OPTIMIZATION_LEVEL': '<(skia_release_optimization_level)',
    542             },
    543             'defines': [ 'NDEBUG' ],
    544           },
    545         },
    546         'xcode_settings': {
    547           'ARCHS': ['armv7'],
    548           'CODE_SIGNING_REQUIRED': 'NO',
    549           'CODE_SIGN_IDENTITY[sdk=iphoneos*]': 'iPhone Developer: Google Development (3F4Y5873JF)',
    550           'IPHONEOS_DEPLOYMENT_TARGET': '<(ios_sdk_version)',
    551           'SDKROOT': 'iphoneos',
    552           'TARGETED_DEVICE_FAMILY': '1,2',
    553           'GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO': 'NO',   # -Wno-invalid-offsetof
    554           'OTHER_CPLUSPLUSFLAGS': [
    555             '-std=c++0x',
    556             '-fvisibility=hidden',
    557             '-fvisibility-inlines-hidden',
    558           ],
    559           'GCC_THUMB_SUPPORT': 'NO',
    560         },
    561       },
    562     ],
    563 
    564     [ 'skia_os == "android"',
    565       {
    566         'defines': [
    567           'SK_BUILD_FOR_ANDROID',
    568 
    569           # Android Text Tuning
    570           'SK_GAMMA_EXPONENT=1.4',
    571           'SK_GAMMA_CONTRAST=0.0',
    572         ],
    573         # Android defines a fixed gamma exponent instead of using SRGB
    574         'defines!': [
    575           'SK_GAMMA_SRGB',
    576         ],
    577         'configurations': {
    578           'Debug': {
    579             'cflags': ['-g']
    580           },
    581           'Release': {
    582             'cflags': ['-O2'],
    583           },
    584         },
    585         'libraries': [
    586           '-llog',
    587         ],
    588         'cflags': [
    589           '-fuse-ld=gold',
    590         ],
    591         'conditions': [
    592           [ '"x86" in skia_arch_type', {
    593             'cflags': [
    594               '-mssse3',
    595             ],
    596           }],
    597           [ 'skia_android_framework', {
    598             'cflags!': [
    599               '-fuse-ld=gold',
    600               '-mssse3',
    601             ],
    602           }],
    603           [ 'skia_shared_lib', {
    604             'defines': [
    605               'SKIA_DLL',
    606               'SKIA_IMPLEMENTATION=1',
    607               # Needed until we fix skbug.com/2440.
    608               'SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG',
    609             ],
    610           }],
    611           [ 'skia_profile_enabled == 1', {
    612             'cflags': ['-g', '-fno-omit-frame-pointer', '-marm', '-mapcs'],
    613           }],
    614         ],
    615       },
    616     ],
    617 
    618     [ 'skia_moz2d', {
    619       'defines': [
    620         # add flags here (e.g. SK_SUPPORT_LEGACY_...) needed by moz2d
    621       ],
    622     }],
    623 
    624   ], # end 'conditions'
    625   # The Xcode SYMROOT must be at the root. See build/common.gypi in chromium for more details
    626   'xcode_settings': {
    627     'SYMROOT': '<(DEPTH)/xcodebuild',
    628   },
    629 }
    630