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