Home | History | Annotate | Download | only in gyp
      1 # Gyp file for opts projects
      2 {
      3   'targets': [
      4     # Due to an unfortunate intersection of lameness between gcc and gyp,
      5     # we have to build the *_SSE2.cpp files in a separate target.  The
      6     # gcc lameness is that, in order to compile SSE2 intrinsics code, it
      7     # must be passed the -msse2 flag.  However, with this flag, it may
      8     # emit SSE2 instructions even for scalar code, such as the CPUID
      9     # test used to test for the presence of SSE2.  So that, and all other
     10     # code must be compiled *without* -msse2.  The gyp lameness is that it
     11     # does not allow file-specific CFLAGS, so we must create this extra
     12     # target for those files to be compiled with -msse2.
     13     #
     14     # This is actually only a problem on 32-bit Linux (all Intel Macs have
     15     # SSE2, Linux x86_64 has SSE2 by definition, and MSC will happily emit
     16     # SSE2 from instrinsics, while generating plain ol' 386 for everything
     17     # else).  However, to keep the .gyp file simple and avoid platform-specific
     18     # build breakage, we do this on all platforms.
     19 
     20     # For about the same reason, we need to compile the ARM opts files
     21     # separately as well.
     22     {
     23       'target_name': 'opts',
     24       'product_name': 'skia_opts',
     25       'type': 'static_library',
     26       'standalone_static_library': 1,
     27       'dependencies': [
     28         'core.gyp:*',
     29         'effects.gyp:*'
     30       ],
     31       'include_dirs': [
     32         '../src/core',
     33         '../src/opts',
     34         '../src/utils',
     35       ],
     36       'conditions': [
     37         [ 'skia_arch_type == "x86" and skia_os != "ios"', {
     38           'conditions': [
     39             [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl", "chromeos", "android"]', {
     40               'cflags': [
     41                 '-msse2',
     42               ],
     43             }],
     44           ],
     45           'include_dirs': [
     46             '../include/utils',
     47           ],
     48           'dependencies': [
     49             'opts_ssse3',
     50             'opts_sse4',
     51           ],
     52           'sources': [
     53             '../src/opts/opts_check_x86.cpp',
     54             '../src/opts/SkBitmapProcState_opts_SSE2.cpp',
     55             '../src/opts/SkBitmapFilter_opts_SSE2.cpp',
     56             '../src/opts/SkBlitRow_opts_SSE2.cpp',
     57             '../src/opts/SkBlitRect_opts_SSE2.cpp',
     58             '../src/opts/SkBlurImage_opts_SSE2.cpp',
     59             '../src/opts/SkMorphology_opts_SSE2.cpp',
     60             '../src/opts/SkTextureCompression_opts_none.cpp',
     61             '../src/opts/SkUtils_opts_SSE2.cpp',
     62             '../src/opts/SkXfermode_opts_SSE2.cpp',
     63           ],
     64         }],
     65         [ 'skia_arch_type == "arm" and arm_version >= 7', {
     66           # The assembly uses the frame pointer register (r7 in Thumb/r11 in
     67           # ARM), the compiler doesn't like that.
     68           'cflags!': [
     69             '-fno-omit-frame-pointer',
     70             '-mapcs-frame',
     71             '-mapcs',
     72           ],
     73           'cflags': [
     74             '-fomit-frame-pointer',
     75             '-mno-apcs-frame',
     76           ],
     77           'variables': {
     78             'arm_neon_optional%': '<(arm_neon_optional>',
     79           },
     80           'sources': [
     81             '../src/opts/memset.arm.S',
     82             '../src/opts/SkBitmapProcState_opts_arm.cpp',
     83             '../src/opts/SkBlitMask_opts_arm.cpp',
     84             '../src/opts/SkBlitRow_opts_arm.cpp',
     85             '../src/opts/SkBlurImage_opts_arm.cpp',
     86             '../src/opts/SkMorphology_opts_arm.cpp',
     87             '../src/opts/SkTextureCompression_opts_arm.cpp',
     88             '../src/opts/SkUtils_opts_arm.cpp',
     89             '../src/opts/SkXfermode_opts_arm.cpp',
     90           ],
     91           'conditions': [
     92             [ 'arm_neon == 1 or arm_neon_optional == 1', {
     93               'dependencies': [
     94                 'opts_neon',
     95               ]
     96             }],
     97             [ 'skia_os == "ios"', {
     98               'sources!': [
     99                 # these fail to compile under xcode for ios
    100                 '../src/opts/memset.arm.S',
    101                 '../src/opts/SkBitmapProcState_opts_arm.cpp',
    102                 '../src/opts/SkBlitRow_opts_arm.cpp',
    103               ],
    104             }],
    105           ],
    106         }],
    107         [ 'skia_arch_type == "mips"', {
    108           'sources': [
    109             '../src/opts/SkBlitMask_opts_none.cpp',
    110             '../src/opts/SkBlurImage_opts_none.cpp',
    111             '../src/opts/SkMorphology_opts_none.cpp',
    112             '../src/opts/SkUtils_opts_none.cpp',
    113             '../src/opts/SkTextureCompression_opts_none.cpp',
    114             '../src/opts/SkXfermode_opts_none.cpp',
    115           ],
    116           'conditions': [
    117             [ '(mips_arch_variant == "mips32r2") \
    118                 and (mips_dsp == 1 or mips_dsp == 2)', {
    119               'sources': [
    120                 '../src/opts/SkBitmapProcState_opts_mips_dsp.cpp',
    121                 '../src/opts/SkBlitRow_opts_mips_dsp.cpp',
    122               ],
    123             }, {
    124               'sources': [
    125                 '../src/opts/SkBitmapProcState_opts_none.cpp',
    126                 '../src/opts/SkBlitRow_opts_none.cpp',
    127               ],
    128             }],
    129           ],
    130         }],
    131         [ '(skia_arch_type == "arm" and arm_version < 7) \
    132             or (skia_os == "ios") \
    133             or (skia_os == "android" and skia_arch_type not in ["x86", "arm", "mips", "arm64"])', {
    134           'sources': [
    135             '../src/opts/SkBitmapProcState_opts_none.cpp',
    136             '../src/opts/SkBlitMask_opts_none.cpp',
    137             '../src/opts/SkBlitRow_opts_none.cpp',
    138             '../src/opts/SkBlurImage_opts_none.cpp',
    139             '../src/opts/SkMorphology_opts_none.cpp',
    140             '../src/opts/SkUtils_opts_none.cpp',
    141             '../src/opts/SkTextureCompression_opts_none.cpp',
    142             '../src/opts/SkXfermode_opts_none.cpp',
    143           ],
    144         }],
    145         [ 'skia_android_framework', {
    146           'cflags!': [
    147             '-msse2',
    148             '-mfpu=neon',
    149             '-fomit-frame-pointer',
    150             '-mno-apcs-frame',
    151           ]
    152         }],
    153         [ 'skia_arch_type == "arm64"', {
    154           'sources': [
    155             '../src/opts/SkBitmapProcState_arm_neon.cpp',
    156             '../src/opts/SkBitmapProcState_matrixProcs_neon.cpp',
    157             '../src/opts/SkBitmapProcState_opts_arm.cpp',
    158             '../src/opts/SkBlitMask_opts_arm.cpp',
    159             '../src/opts/SkBlitMask_opts_arm_neon.cpp',
    160             '../src/opts/SkBlitRow_opts_arm.cpp',
    161             '../src/opts/SkBlitRow_opts_arm_neon.cpp',
    162             '../src/opts/SkBlurImage_opts_arm.cpp',
    163             '../src/opts/SkBlurImage_opts_neon.cpp',
    164             '../src/opts/SkMorphology_opts_arm.cpp',
    165             '../src/opts/SkMorphology_opts_neon.cpp',
    166             '../src/opts/SkTextureCompression_opts_none.cpp',
    167             '../src/opts/SkUtils_opts_none.cpp',
    168             '../src/opts/SkXfermode_opts_arm.cpp',
    169             '../src/opts/SkXfermode_opts_arm_neon.cpp',
    170           ],
    171         }],
    172       ],
    173     },
    174     # For the same lame reasons as what is done for skia_opts, we have to
    175     # create another target specifically for SSSE3 code as we would not want
    176     # to compile the SSE2 code with -mssse3 which would potentially allow
    177     # gcc to generate SSSE3 code.
    178     {
    179       'target_name': 'opts_ssse3',
    180       'product_name': 'skia_opts_ssse3',
    181       'type': 'static_library',
    182       'standalone_static_library': 1,
    183       'dependencies': [
    184         'core.gyp:*',
    185         'effects.gyp:*'
    186       ],
    187       'include_dirs': [
    188         '../src/core',
    189         '../src/utils',
    190       ],
    191       'sources': [
    192         '../src/opts/SkBitmapProcState_opts_SSSE3.cpp',
    193       ],
    194       'conditions': [
    195         [ 'skia_os == "win"', {
    196             'defines' : [ 'SK_CPU_SSE_LEVEL=31' ],
    197         }],
    198         # (Mac has -mssse3 globally.)
    199         [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl", "chromeos", "android"] \
    200            and not skia_android_framework', {
    201           'cflags': [
    202             '-mssse3',
    203           ],
    204         }],
    205       ],
    206     },
    207     # For the same lame reasons as what is done for skia_opts, we also have to
    208     # create another target specifically for SSE4 code as we would not want
    209     # to compile the SSE2 code with -msse4 which would potentially allow
    210     # gcc to generate SSE4 code.
    211     {
    212       'target_name': 'opts_sse4',
    213       'product_name': 'skia_opts_sse4',
    214       'type': 'static_library',
    215       'standalone_static_library': 1,
    216       'dependencies': [
    217         'core.gyp:*',
    218         'effects.gyp:*'
    219       ],
    220       'include_dirs': [
    221         '../src/core',
    222         '../src/utils',
    223       ],
    224       'sources': [
    225         '../src/opts/SkBlurImage_opts_SSE4.cpp',
    226       ],
    227       'conditions': [
    228         [ 'skia_arch_width == 64', {
    229           'sources': [
    230             '../src/opts/SkBlitRow_opts_SSE4_x64_asm.S',
    231           ],
    232         }],
    233         [ 'skia_arch_width == 32', {
    234           'sources': [
    235             '../src/opts/SkBlitRow_opts_SSE4_asm.S',
    236           ],
    237         }],
    238         [ 'skia_os == "win"', {
    239             'defines' : [ 'SK_CPU_SSE_LEVEL=41' ],
    240         }],
    241         [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl", "chromeos", "android"] \
    242            and not skia_android_framework', {
    243           'cflags': [
    244             '-msse4.1',
    245           ],
    246         }],
    247         [ 'skia_os == "mac"', {
    248           'xcode_settings': {
    249             'OTHER_CPLUSPLUSFLAGS!': [
    250               '-mssse3',
    251             ],
    252             'OTHER_CPLUSPLUSFLAGS': [
    253               '-msse4.1',
    254             ],
    255           },
    256         }],
    257       ],
    258     },
    259     # NEON code must be compiled with -mfpu=neon which also affects scalar
    260     # code. To support dynamic NEON code paths, we need to build all
    261     # NEON-specific sources in a separate static library. The situation
    262     # is very similar to the SSSE3 and SSE4 one.
    263     {
    264       'target_name': 'opts_neon',
    265       'product_name': 'skia_opts_neon',
    266       'type': 'static_library',
    267       'standalone_static_library': 1,
    268       'dependencies': [
    269         'core.gyp:*',
    270         'effects.gyp:*'
    271       ],
    272       'include_dirs': [
    273         '../src/core',
    274         '../src/opts',
    275         '../src/utils',
    276       ],
    277       'cflags!': [
    278         '-fno-omit-frame-pointer',
    279         '-mfpu=vfp',  # remove them all, just in case.
    280         '-mfpu=vfpv3',
    281         '-mfpu=vfpv3-d16',
    282       ],
    283       'conditions': [
    284         [ 'not skia_android_framework', {
    285           'cflags': [
    286             '-mfpu=neon',
    287             '-fomit-frame-pointer',
    288           ],
    289         }],
    290       ],
    291       'ldflags': [
    292         '-march=armv7-a',
    293         '-Wl,--fix-cortex-a8',
    294       ],
    295       'sources': [
    296         '../src/opts/memset16_neon.S',
    297         '../src/opts/memset32_neon.S',
    298         '../src/opts/SkBitmapProcState_arm_neon.cpp',
    299         '../src/opts/SkBitmapProcState_matrixProcs_neon.cpp',
    300         '../src/opts/SkBitmapProcState_matrix_neon.h',
    301         '../src/opts/SkBlitMask_opts_arm_neon.cpp',
    302         '../src/opts/SkBlitRow_opts_arm_neon.cpp',
    303         '../src/opts/SkBlurImage_opts_neon.cpp',
    304         '../src/opts/SkMorphology_opts_neon.cpp',
    305         '../src/opts/SkTextureCompression_opts_neon.cpp',
    306         '../src/opts/SkXfermode_opts_arm_neon.cpp',
    307       ],
    308     },
    309   ],
    310 }
    311