Roll src/third_party/WebKit 54f3f4a:06d33f1 (svn 199721:199723)
[chromium-blink-merge.git] / skia / skia_library_opts.gyp
blob545ef17e4b2e2961a852fee2322c2a13c3bf227a
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 # This gyp file contains the platform-specific optimizations for Skia
7   'variables': {
8       'skia_src_path': '../third_party/skia/src',
9       'includes': [ '../third_party/skia/gyp/opts.gypi' ],
10       'include_dirs': [
11         '../third_party/skia/include/core',
12         '../third_party/skia/include/effects',
13         '../third_party/skia/include/utils',
14         '../third_party/skia/src/core',
15         '../third_party/skia/src/opts',
16         '../third_party/skia/src/utils',
17       ],
18    },
20   'targets': [
21     # SSE files have to be built in a separate target, because gcc needs
22     # different -msse flags for different SSE levels which enable use of SSE
23     # intrinsics but also allow emission of SSE2 instructions for scalar code.
24     # gyp does not allow per-file compiler flags.
25     # For about the same reason, we need to compile the ARM opts files
26     # separately as well.
27     {
28       'target_name': 'skia_opts',
29       'type': 'static_library',
30       'includes': [
31         'skia_common.gypi',
32         '../build/android/increase_size_for_speed.gypi',
33         # Disable LTO due to compiler error
34         # in mems_in_disjoint_alias_sets_p, at alias.c:393
35         # crbug.com/422255
36         '../build/android/disable_lto.gypi',
37       ],
38       'include_dirs': [ '<@(include_dirs)' ],
39       'conditions': [
40         [ 'target_arch != "arm" and target_arch != "mipsel" and \
41            target_arch != "arm64" and target_arch != "mips64el"', {
42           # Chrome builds with -msse2 locally, so sse2_sources could in theory
43           # be in the regular skia target. But we need skia_opts for arm
44           # anyway, so putting sse2_sources here is simpler than making this
45           # conditionally a type none target on x86.
46           'sources': [ '<@(sse2_sources)' ],
47           'dependencies': [
48             'skia_opts_ssse3',
49             'skia_opts_sse41',
50           ],
51         }],
52         [ 'target_arch == "arm"', {
53           'conditions': [
54             [ 'arm_version >= 7', {
55               'sources': [ '<@(armv7_sources)' ],
56             }, {  # arm_version < 7
57               'sources': [ '<@(none_sources)' ],
58             }],
59             [ 'arm_version >= 7 and (arm_neon == 1 or arm_neon_optional == 1)', {
60               'dependencies': [
61                 'skia_opts_neon',
62               ]
63             }],
64           ],
65           # The assembly uses the frame pointer register (r7 in Thumb/r11 in
66           # ARM), the compiler doesn't like that. Explicitly remove the
67           # -fno-omit-frame-pointer flag for Android, as that gets added to all
68           # targets via common.gypi.
69           'cflags!': [
70             '-fno-omit-frame-pointer',
71             '-marm',
72             '-mapcs-frame',
73           ],
74           'cflags': [
75             '-fomit-frame-pointer',
76           ],
77         }],
78         [ 'target_arch == "mipsel"',{
79           'cflags': [ '-fomit-frame-pointer' ],
80           'conditions': [
81             [ 'mips_dsp_rev >= 1', {
82               'sources': [ '<@(mips_dsp_sources)' ],
83             }, {  # mips_dsp_rev == 0
84               'sources': [ '<@(none_sources)' ],
85             }],
86           ],
87         }],
88         [ 'target_arch == "mips64el"',{
89           'cflags': [ '-fomit-frame-pointer' ],
90           'sources': [ '<@(none_sources)' ],
91         }],
92         [ 'target_arch == "arm64"', {
93           'sources': [ '<@(arm64_sources)' ],
94         }],
95       ],
96     },
97     # For the same lame reasons as what is done for skia_opts, we have to
98     # create another target specifically for SSSE3 code as we would not want
99     # to compile the SSE2 code with -mssse3 which would potentially allow
100     # gcc to generate SSSE3 code.
101     {
102       'target_name': 'skia_opts_ssse3',
103       'type': 'static_library',
104       'includes': [
105         'skia_common.gypi',
106         '../build/android/increase_size_for_speed.gypi',
107       ],
108       'include_dirs': [ '<@(include_dirs)' ],
109       'conditions': [
110         [ 'OS in ["linux", "freebsd", "openbsd", "solaris", "android"]', {
111           'cflags': [ '-mssse3' ],
112         }],
113         [ 'OS == "mac"', {
114           'xcode_settings': {
115             'GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS': 'YES',
116           },
117         }],
118         [ 'OS == "win" and clang == 1', {
119           # cl.exe's /arch flag doesn't have a setting for SSSE3, and cl.exe
120           # doesn't need it for intrinsics. clang-cl does need it, though.
121           'msvs_settings': {
122             'VCCLCompilerTool': { 'AdditionalOptions': [ '-mssse3' ] },
123           },
124         }],
125         [ 'OS == "win"', {
126           'defines' : [ 'SK_CPU_SSE_LEVEL=31' ],
127         }],
128         [ 'target_arch != "arm" and target_arch != "arm64" and \
129            target_arch != "mipsel" and target_arch != "mips64el"', {
130           'sources': [ '<@(ssse3_sources)' ],
131         }],
132       ],
133     },
134     # For the same lame reasons as what is done for skia_opts, we also have to
135     # create another target specifically for SSE4.1 code as we would not want
136     # to compile the SSE2 code with -msse4.1 which would potentially allow
137     # gcc to generate SSE4.1 code.
138     {
139       'target_name': 'skia_opts_sse41',
140       'type': 'static_library',
141       'includes': [
142         'skia_common.gypi',
143         '../build/android/increase_size_for_speed.gypi',
144       ],
145       'include_dirs': [ '<@(include_dirs)' ],
146       'sources': [ '<@(sse41_sources)' ],
147       'conditions': [
148         [ 'OS in ["linux", "freebsd", "openbsd", "solaris", "android"]', {
149           'cflags': [ '-msse4.1' ],
150         }],
151         [ 'OS == "mac"', {
152           'xcode_settings': {
153             'GCC_ENABLE_SSE41_EXTENSIONS': 'YES',
154           },
155         }],
156         [ 'OS == "win" and clang == 1', {
157           # cl.exe's /arch flag doesn't have a setting for SSE4.1, and cl.exe
158           # doesn't need it for intrinsics. clang-cl does need it, though.
159           'msvs_settings': {
160             'VCCLCompilerTool': { 'AdditionalOptions': [ '-msse4.1' ] },
161           },
162         }],
163         [ 'OS == "win"', {
164           'defines' : [ 'SK_CPU_SSE_LEVEL=41' ],
165         }],
166       ],
167     },
168     {
169       'target_name': 'skia_opts_none',
170       'type': 'static_library',
171       'includes': [
172         'skia_common.gypi',
173         '../build/android/increase_size_for_speed.gypi',
174       ],
175       'include_dirs': [ '<@(include_dirs)' ],
176       'sources': [ '<@(none_sources)' ],
177     },
178   ],
179   'conditions': [
180     # NEON code must be compiled with -mfpu=neon which also affects scalar
181     # code. To support dynamic NEON code paths, we need to build all
182     # NEON-specific sources in a separate static library. The situation
183     # is very similar to the SSSE3 one.
184     ['target_arch == "arm" and (arm_neon == 1 or arm_neon_optional == 1)', {
185       'targets': [
186         {
187           'target_name': 'skia_opts_neon',
188           'type': 'static_library',
189           'includes': [
190             'skia_common.gypi',
191             '../build/android/increase_size_for_speed.gypi',
192             # Disable LTO due to Neon issues
193             # crbug.com/408997
194             '../build/android/disable_lto.gypi',
195           ],
196           'include_dirs': [ '<@(include_dirs)' ],
197           'cflags!': [
198             '-fno-omit-frame-pointer',
199             '-mfpu=vfp',  # remove them all, just in case.
200             '-mfpu=vfpv3',
201             '-mfpu=vfpv3-d16',
202           ],
203           'cflags': [
204             '-mfpu=neon',
205             '-fomit-frame-pointer',
206           ],
207           'ldflags': [
208             '-march=armv7-a',
209             '-Wl,--fix-cortex-a8',
210           ],
211           'sources': [ '<@(neon_sources)' ],
212         },
213       ],
214     }],
215   ],