Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / platform / BUILD.gn
1 # Copyright 2014 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.
4
5 import("//build/config/ui.gni")
6 import("//third_party/WebKit/Source/build/scripts/scripts.gni")
7 import("//third_party/WebKit/Source/config.gni")
8 import("//third_party/WebKit/Source/platform/platform.gni")
9 import("//third_party/WebKit/Source/platform/platform_generated.gni")
10 import("//third_party/yasm/yasm_assemble.gni")
11
12 # Most targets in this file are private actions so use that as the default.
13 visibility = ":*"
14
15 heap_gypi = exec_script(
16     "//build/gypi_to_gn.py",
17     [ rebase_path("heap/blink_heap.gypi") ],
18     "scope",
19     [ "heap/blink_heap.gypi" ])
20
21 blink_platform_neon_files = [
22   "graphics/cpu/arm/WebGLImageConversionNEON.h",
23   "graphics/cpu/arm/filters/FEBlendNEON.h",
24   "graphics/cpu/arm/filters/FECompositeArithmeticNEON.h",
25   "graphics/cpu/arm/filters/FEGaussianBlurNEON.h",
26   "graphics/cpu/arm/filters/NEONHelpers.h",
27 ]
28
29 # blink_common in blink_platform.gyp
30 component("blink_common") {
31   visibility = "//third_party/WebKit/*"
32   sources = [
33     "exported/WebCString.cpp",
34     "exported/WebString.cpp",
35     "exported/WebCommon.cpp",
36   ]
37
38   defines = [
39     "BLINK_COMMON_IMPLEMENTATION=1",
40     "INSIDE_BLINK",
41   ]
42
43   configs += [
44     "//build/config/compiler:wexit_time_destructors",
45     "//third_party/WebKit/Source:config",
46     "//third_party/WebKit/Source:non_test_config",
47   ]
48
49   deps = [
50     "//third_party/WebKit/Source/wtf",
51   ]
52 }
53
54 # Chromium's version of WebCore includes the following Objective-C classes. The
55 # system-provided WebCore framework may also provide these classes. Because of
56 # the nature of Objective-C binding (dynamically at runtime), it's possible for
57 # the Chromium-provided versions to interfere with the system-provided
58 # versions. This may happen when a system framework attempts to use
59 # core.framework, such as when converting an HTML-flavored string to an
60 # NSAttributedString. The solution is to force Objective-C class names that
61 # would conflict to use alternate names.
62 #
63 # This list will hopefully shrink but may also grow. Its performance is
64 # monitored by the "Check Objective-C Rename" postbuild step, and any
65 # suspicious-looking symbols not handled here or whitelisted in that step will
66 # cause a build failure.
67 #
68 # If this is unhandled, the console will receive log messages
69 # such as:
70 # com.google.Chrome[] objc[]: Class ScrollbarPrefsObserver is implemented in both .../Google Chrome.app/Contents/Versions/.../Google Chrome Helper.app/Contents/MacOS/../../../Google Chrome Framework.framework/Google Chrome Framework and /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/WebCore. One of the two will be used. Which one is undefined.
71 if (is_mac) {
72   config("mac_objc_renaming") {
73     defines = [
74       "WebCascadeList=ChromiumWebCoreObjCWebCascadeList",
75       "WebFontCache=ChromiumWebCoreObjCWebFontCache",
76       "WebScrollAnimationHelperDelegate=ChromiumWebCoreObjCWebScrollAnimationHelperDelegate",
77       "WebScrollbarPainterControllerDelegate=ChromiumWebCoreObjCWebScrollbarPainterControllerDelegate",
78       "WebScrollbarPainterDelegate=ChromiumWebCoreObjCWebScrollbarPainterDelegate",
79       "WebScrollbarPartAnimation=ChromiumWebCoreObjCWebScrollbarPartAnimation",
80       "WebCoreFlippedView=ChromiumWebCoreObjCWebCoreFlippedView",
81       "WebCoreTextFieldCell=ChromiumWebCoreObjCWebCoreTextFieldCell",
82       "WebCoreRenderThemeNotificationObserver=ChromiumWebCoreObjCWebCoreRenderThemeNotificationObserver",
83     ]
84   }
85 }
86
87 # FontFamilyNames action in make_platform_generated in
88 # platform_generated.gyp
89 action("font_family_names") {
90   script = "../build/scripts/make_names.py"
91
92   font_family_names_in = "fonts/FontFamilyNames.in"
93   inputs = make_names_files + [ font_family_names_in ]
94
95   outputs = [
96     "$blink_platform_output_dir/FontFamilyNames.cpp",
97     "$blink_platform_output_dir/FontFamilyNames.h",
98   ]
99
100   args = [
101     rebase_path(font_family_names_in, root_build_dir),
102     "--output_dir",
103     rebase_path(blink_platform_output_dir, root_build_dir),
104   ]
105 }
106
107 # RuntimeEnabledFeatures action in make_platform_generated in
108 # platform_generated.gyp
109 action("runtime_enabled_features") {
110   script = "../build/scripts/make_runtime_features.py"
111
112   runtime_enabled_features_in = "RuntimeEnabledFeatures.in"
113   inputs = scripts_for_in_files + [
114     runtime_enabled_features_in,
115     "../build/scripts/templates/RuntimeEnabledFeatures.cpp.tmpl",
116     "../build/scripts/templates/RuntimeEnabledFeatures.h.tmpl",
117   ]
118
119   outputs = [
120     "$blink_platform_output_dir/RuntimeEnabledFeatures.cpp",
121     "$blink_platform_output_dir/RuntimeEnabledFeatures.h",
122   ]
123
124   args = [
125     rebase_path(runtime_enabled_features_in, root_build_dir),
126     "--output_dir",
127     rebase_path(blink_platform_output_dir, root_build_dir),
128   ]
129 }
130
131 # ColorData action in make_platform_generated in platform_generated.gyp
132 action("color_data") {
133   script = "../build/scripts/gperf.py"
134
135   color_data_gperf = "ColorData.gperf"
136   inputs = [ color_data_gperf ]
137
138   output_file = "$blink_platform_output_dir/ColorData.cpp"
139   outputs = [ output_file ]
140
141   args = [
142     gperf_exe,
143     "--key-positions=*",
144     "-D", "-s", "2",
145     rebase_path(color_data_gperf, root_build_dir),
146     "--output-file=" + rebase_path(output_file, root_build_dir),
147   ]
148 }
149
150 # This isn't strictly necessary since we can just add the deps to "platform",
151 # but it helps to have the targets match the GYP build.
152 group("make_platform_generated") {
153   visibility = "//third_party/WebKit/Source/*"
154   deps = [
155     ":blink_common",
156     ":color_data",
157     ":font_family_names",
158     ":runtime_enabled_features",
159   ]
160 }
161
162 # TODO(brettw) Objective C Renaming postbuild steps on Mac.
163 # blink_platform target in blink_platform.gyp
164 component("platform") {
165   visibility = "//third_party/WebKit/*"
166   output_name = "blink_platform"
167
168   sources = platform_files
169   sources -= blink_platform_neon_files
170
171   # Add in the generated files.
172   sources +=
173     get_target_outputs(":font_family_names") +
174     get_target_outputs(":runtime_enabled_features") +
175     get_target_outputs(":color_data")
176
177   configs += [
178     "//third_party/WebKit/Source:config",
179     "//third_party/WebKit/Source:non_test_config",
180   ]
181
182   defines = [
183     "BLINK_PLATFORM_IMPLEMENTATION=1",
184     "INSIDE_BLINK",
185   ]
186
187   include_dirs = [
188     #"$angle_path/include",
189     "$root_gen_dir/blink",
190   ]
191
192   deps = [
193     ":heap_asm_stubs",
194     ":make_platform_generated",
195     "//gpu/command_buffer/client:gles2_c_lib",
196     "//skia",
197     "//third_party:jpeg",
198     "//third_party/harfbuzz-ng",
199     "//third_party/iccjpeg",
200     "//third_party/icu",
201     "//third_party/libpng",
202     "//third_party/libwebp",
203     "//third_party/ots",
204     "//third_party/qcms",
205     "//third_party/WebKit/Source/wtf",
206     "//third_party/WebKit/Source/platform/heap",
207     "//url",
208     "//v8",
209   ]
210
211   forward_dependent_configs_from = [
212     "//gpu/command_buffer/client:gles2_c_lib",
213     "//skia",
214     "//third_party:jpeg",
215     "//third_party/iccjpeg",
216     "//third_party/libpng",
217     "//third_party/libwebp",
218     "//third_party/ots",
219     "//third_party/qcms",
220     "//url",
221     "//v8",
222   ]
223
224   if (is_mac) {
225     sources -= [
226       "fonts/harfbuzz/FontHarfBuzz.cpp",
227       "fonts/harfbuzz/FontPlatformDataHarfBuzz.cpp",
228       "fonts/harfbuzz/HarfBuzzFaceSkia.cpp",
229       "fonts/opentype/OpenTypeTypes.h",
230       "fonts/opentype/OpenTypeVerticalData.cpp",
231       "fonts/opentype/OpenTypeVerticalData.h",
232       # The Mac currently uses FontCustomPlatformDataMac.cpp instead.
233       "fonts/skia/FontCustomPlatformDataSkia.cpp",
234       "fonts/skia/FontCacheSkia.cpp",
235       "fonts/skia/SimpleFontDataSkia.cpp",
236       # Uses LocaleMac instead.
237       "text/LocaleICU.cpp",
238       "text/LocaleICU.h",
239       # Uses KillRingMac.mm instead.
240       "KillRingNone.cpp",
241       # Mac uses only ScrollAnimatorMac.
242       "scroll/ScrollbarThemeNonMacCommon.cpp",
243       "scroll/ScrollbarThemeNonMacCommon.h",
244       "scroll/ScrollAnimatorNone.cpp",
245       "scroll/ScrollAnimatorNone.h",
246     ]
247
248     # Some Mac-specific parts of WebKit won't compile without having this
249     # prefix header injected.
250     cflags = [
251       "-include",
252       rebase_path("../build/mac/Prefix.h", root_build_dir),
253     ]
254
255     defines += [ "WebFontCache=ChromiumWebCoreObjCWebFontCache" ]
256     configs += [ ":mac_objc_renaming" ]
257     libs = [
258       "Accelerate.framework",
259       "Carbon.framework",
260       "Foundation.framework",
261     ]
262   } else {
263     sources -= [
264       # FIXME: We will eventually compile this too, but for now it's
265       # only used on mac.
266       "fonts/FontPlatformData.cpp",
267       "fonts/harfbuzz/HarfBuzzFaceCoreText.cpp",
268       "geometry/cg/FloatPointCG.cpp",
269       "geometry/cg/FloatRectCG.cpp",
270       "geometry/cg/FloatSizeCG.cpp",
271       "geometry/cg/IntPointCG.cpp",
272       "geometry/cg/IntRectCG.cpp",
273       "geometry/cg/IntSizeCG.cpp",
274     ]
275   }
276
277   if (is_win) {
278     sources -= [
279       # Uses LocaleWin instead.
280       "text/LocaleICU.cpp",
281       "text/LocaleICU.h",
282     ]
283     cflags = [
284       "/wd4267",  # Conversion from 'size_t' to 'type', possible loss of data.
285       "/wd4334",  # Result of 32-bit shift implicitly converted to 64 bits.
286       "/wd4724",  # Modulo by 0.
287     ]
288   } else {
289     sources -= [
290       "clipboard/ClipboardUtilitiesWin.cpp",
291       "fonts/opentype/OpenTypeUtilities.cpp",
292       "fonts/opentype/OpenTypeUtilities.h",
293       "text/LocaleWin.cpp",
294     ]
295   }
296
297   if (is_android) {
298     # Add in some Linux files also shared with Android.
299     set_sources_assignment_filter([])
300     sources += [
301       "exported/linux/WebFontRenderStyle.cpp",
302       "fonts/linux/FontPlatformDataLinux.cpp",
303     ]
304     set_sources_assignment_filter(sources_assignment_filter)
305   } else {
306     sources -= [
307       "scroll/ScrollbarThemeAndroid.cpp",
308     ]
309   }
310
311   if (is_linux) {
312     direct_dependent_configs = [ "//build/config/linux:fontconfig" ]
313   }
314
315   if (!use_default_render_theme) {
316     sources -= [
317       "scroll/ScrollbarThemeAura.cpp",
318       "scroll/ScrollbarThemeAura.h",
319     ]
320   }
321
322   if (cpu_arch == "arm") {
323     deps += [ ":blink_arm_neon" ]
324   }
325
326   if (use_webaudio_ffmpeg) {
327     include_dirs += [ "//third_party/ffmpeg" ]
328     deps += [ "//third_party/ffmpeg" ]
329   }
330   if (use_openmax_dl_fft) {
331     include_dirs += [ "//third_party/openmax_dl" ]
332     # TODO(GYP)
333     # deps += [ "//third_party/openmax_dl/dl" ]
334   }
335 }
336
337 yasm_assemble("heap_asm_stubs") {
338   if (cpu_arch == "x86" || cpu_arch == "x64") {
339     sources = [ "heap/asm/SaveRegisters_x86.asm" ]
340   } else if (cpu_arch == "arm") {
341     sources = [ "heap/asm/SaveRegisters_arm.S" ]
342   } else if (cpu_arch == "arm64") {
343     sources = [ "heap/asm/SaveRegisters_arm64.S" ]
344   } else if (cpu_arch == "mipsel") {
345     sources = [ "heap/asm/SaveRegisters_mips.S" ]
346   }
347
348   yasm_flags = []
349   if (is_mac) {
350     # Necessary to ensure symbols end up with a _ prefix; added by
351     # yasm_compile.gypi for Windows, but not Mac.
352     yasm_flags += [ "-DPREFIX" ]
353   }
354   if (cpu_arch == "x64") {
355     if (is_win) {
356       yasm_flags += [ "-DX64WIN=1" ]
357     } else {
358       yasm_flags += [ "-DX64POSIX=1" ]
359     }
360   } else if (cpu_arch == "x86") {
361     yasm_flags += [ "-DIA32=1" ]
362   } else if (cpu_arch == "arm") {
363     yasm_flags += [ "-DARM=1" ]
364   }
365 }
366
367
368 test("heap_unittests") {
369   visibility = "//third_party/WebKit/*"
370   output_name = "blink_heap_unittests"
371
372   sources = rebase_path(heap_gypi.platform_heap_test_files, ".", "heap")
373   sources += [ "heap/RunAllTests.cpp" ]
374
375   configs += [
376     "//third_party/WebKit/Source/wtf:wtf_config",
377     "//third_party/WebKit/Source:config",
378   ]
379
380   deps = [
381     ":platform",
382     "//base",
383     "//base/allocator",
384     "//base/test:test_support",
385     "//testing/gmock",
386     "//testing/gtest",
387     "//third_party/WebKit/Source/wtf",
388     "//third_party/WebKit/Source/wtf:test_support",
389   ]
390 }
391
392 test("platform_unittests") {
393   visibility = "//third_party/WebKit/*"
394   output_name = "blink_platform_unittests"
395
396   sources = platform_test_files
397
398   sources += [ "testing/RunAllTests.cpp" ]
399
400   configs += [
401     "//third_party/WebKit/Source/wtf:wtf_config",
402     "//third_party/WebKit/Source:config",
403   ]
404
405   deps = [
406     ":blink_common",
407     ":platform",
408     "//base",
409     "//base/allocator",
410     "//base/test:test_support",
411     "//skia",
412     "//testing/gmock",
413     "//testing/gtest",
414     "//third_party/WebKit/Source/wtf",
415     "//third_party/WebKit/Source/wtf:test_support",
416     "//url",
417   ]
418
419   defines = [
420     "INSIDE_BLINK",
421   ]
422
423   include_dirs = [
424     "$root_gen_dir/blink",
425   ]
426 }
427
428
429 if (cpu_arch == "arm") {
430   source_set("blink_arm_neon") {
431     sources = blink_platform_neon_files
432
433     # The *NEON.cpp files fail to compile when -mthumb is passed. Force
434     # them to build in ARM mode.
435     # See https://bugs.webkit.org/show_bug.cgi?id=62916.
436     # TODO(GYP)
437     #'cflags': ['-marm'],
438     #    'conditions': [
439     #      ['OS=="android"', {
440     #        'cflags!': ['-mthumb'],
441     #      }],
442     #    ],
443
444     deps = [ ":blink_common" ]
445   }
446 }