Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: skia/BUILD.gn

Issue 1932683003: Skia GN build. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « DEPS ('k') | skia/skia_gn_files.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 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.
4
5 import("//build/config/features.gni")
6 import("//build/config/ui.gni")
7 import("//testing/test.gni")
8
9 if (current_cpu == "arm") {
10 import("//build/config/arm.gni")
11 }
12 if (current_cpu == "mipsel" || current_cpu == "mips64el") {
13 import("//build/config/mips.gni")
14 }
15
16 skia_support_gpu = !is_ios
17 skia_support_pdf = false #!is_ios && (enable_basic_printing || enable_print_pre view)
18
19 # The list of Skia core sources that are to be set for chromium.
20 gypi_skia_core =
21 exec_script("//build/gypi_to_gn.py",
22 [
23 rebase_path("//third_party/skia/gyp/core.gypi"),
24 "--replace=<(skia_include_path)=//third_party/skia/include",
25 "--replace=<(skia_src_path)=//third_party/skia/src",
26 ],
27 "scope",
28 [ "//third_party/skia/gyp/core.gypi" ])
29
30 # The list of Skia gpu sources that are to be set for chromium.
31 if (skia_support_gpu) {
32 gypi_skia_gpu =
33 exec_script("//build/gypi_to_gn.py",
34 [
35 rebase_path("//third_party/skia/gyp/gpu.gypi"),
36 "--replace=<(skia_include_path)=//third_party/skia/include",
37 "--replace=<(skia_src_path)=//third_party/skia/src",
38 ],
39 "scope",
40 [ "//third_party/skia/gyp/gpu.gypi" ])
41 }
42
43 # The list of Skia pdf sources that are to be set for chromium.
44 if (skia_support_pdf) {
45 gypi_skia_pdf =
46 exec_script("//build/gypi_to_gn.py",
47 [
48 rebase_path("//third_party/skia/gyp/pdf.gypi"),
49 "--replace=<(skia_include_path)=//third_party/skia/include",
50 "--replace=<(skia_src_path)=//third_party/skia/src",
51 ],
52 "scope",
53 [ "//third_party/skia/gyp/pdf.gypi" ])
54 }
55
56 # The list of Skia effects that are to be set for chromium.
57 gypi_skia_effects =
58 exec_script("//build/gypi_to_gn.py",
59 [
60 rebase_path("//third_party/skia/gyp/effects.gypi"),
61 "--replace=<(skia_include_path)=//third_party/skia/include",
62 "--replace=<(skia_src_path)=//third_party/skia/src",
63 ],
64 "scope",
65 [ "//third_party/skia/gyp/effects.gypi" ])
66
67 # The list of Skia utils that are to be set for chromium.
68 gypi_skia_utils =
69 exec_script("//build/gypi_to_gn.py",
70 [
71 rebase_path("//third_party/skia/gyp/utils.gypi"),
72 "--replace=<(skia_include_path)=//third_party/skia/include",
73 "--replace=<(skia_src_path)=//third_party/skia/src",
74 ],
75 "scope",
76 [ "//third_party/skia/gyp/utils.gypi" ])
77
78 gypi_skia_opts =
79 exec_script("//build/gypi_to_gn.py",
80 [
81 rebase_path("//third_party/skia/gyp/opts.gypi"),
82 "--replace=<(skia_include_path)=//third_party/skia/include",
83 "--replace=<(skia_src_path)=//third_party/skia/src",
84 ],
85 "scope",
86 [ "//third_party/skia/gyp/opts.gypi" ])
87
88 # The list of Skia files is kept in skia_gn_files.gypi. Read it.
89 gypi_values =
90 exec_script("//build/gypi_to_gn.py",
91 [
92 rebase_path("skia_gn_files.gypi"),
93 "--replace=<(skia_include_path)=//third_party/skia/include",
94 "--replace=<(skia_src_path)=//third_party/skia/src",
95 ],
96 "scope",
97 [ "skia_gn_files.gypi" ])
98
99 # External-facing config for dependent code.
100 config("skia_config") {
101 include_dirs = [
102 "config",
103 "ext",
104 "//third_party/skia/include/c",
105 "//third_party/skia/include/config",
106 "//third_party/skia/include/core",
107 "//third_party/skia/include/effects",
108 "//third_party/skia/include/images",
109 "//third_party/skia/include/lazy",
110 "//third_party/skia/include/pathops",
111 "//third_party/skia/include/pdf",
112 "//third_party/skia/include/pipe",
113 "//third_party/skia/include/ports",
114 "//third_party/skia/include/utils",
115 ]
116
117 defines = []
118
119 if (skia_support_gpu) {
120 include_dirs += [
121 "//third_party/skia/include/gpu",
122 "//third_party/skia/src/gpu",
123 ]
124 defines += [ "SK_SUPPORT_GPU=1" ]
125 } else {
126 defines += [ "SK_SUPPORT_GPU=0" ]
127 }
128
129 if (is_android) {
130 defines += [
131 "SK_BUILD_FOR_ANDROID",
132 "USE_CHROMIUM_SKIA",
133 ]
134 }
135
136 if (is_mac) {
137 defines += [ "SK_BUILD_FOR_MAC" ]
138 }
139
140 if (is_win) {
141 defines += [ "GR_GL_FUNCTION_TYPE=__stdcall" ]
142 }
143 }
144
145 # Internal-facing config for Skia library code.
146 config("skia_library_config") {
147 # These include directories are only included for Skia code and are not
148 # exported to dependents. It's not clear if this is on purpose, but this
149 # matches the GYP build.
150 include_dirs = [
151 "//third_party/skia/include/private",
152 "//third_party/skia/include/client/android",
153 "//third_party/skia/src/core",
154 "//third_party/skia/src/image",
155 "//third_party/skia/src/opts",
156 "//third_party/skia/src/pdf",
157 "//third_party/skia/src/ports",
158 "//third_party/skia/src/sfnt",
159 "//third_party/skia/src/utils",
160 "//third_party/skia/src/lazy",
161 ]
162 if (is_mac || is_ios) {
163 include_dirs += [ "//third_party/skia/include/utils/mac" ]
164 }
165 if (is_mac) {
166 include_dirs += [ "//third_party/skia/include/utils/ios" ]
167 }
168
169 defines = []
170
171 if (current_cpu == "arm") {
172 if (arm_use_neon) {
173 defines += [ "SK_ARM_HAS_NEON" ]
174 } else if (arm_optionally_use_neon) {
175 defines += [ "SK_ARM_HAS_OPTIONAL_NEON" ]
176 }
177 }
178
179 # Settings for text blitting, chosen to approximate the system browser.
180 if (is_linux) {
181 defines += [
182 "SK_GAMMA_EXPONENT=1.2",
183 "SK_GAMMA_CONTRAST=0.2",
184 ]
185 } else if (is_android) {
186 defines += [
187 "SK_GAMMA_APPLY_TO_A8",
188 "SK_GAMMA_EXPONENT=1.4",
189 "SK_GAMMA_CONTRAST=0.0",
190 ]
191 } else if (is_win) {
192 defines += [
193 "SK_GAMMA_SRGB",
194 "SK_GAMMA_CONTRAST=0.5",
195 ]
196 } else if (is_mac) {
197 defines += [
198 "SK_GAMMA_SRGB",
199 "SK_GAMMA_CONTRAST=0.0",
200 ]
201 }
202
203 if (is_android) {
204 defines += [
205 # Android devices are typically more memory constrained, so default to a
206 # smaller glyph cache (it may be overriden at runtime when the renderer
207 # starts up, depending on the actual device memory).
208 "SK_DEFAULT_FONT_CACHE_LIMIT=1048576", # 1024 * 1024
209 ]
210 } else {
211 defines += [ "SK_DEFAULT_FONT_CACHE_LIMIT=20971520" ] # 20 * 1024 * 1024
212 }
213
214 if (is_win) {
215 include_dirs += [
216 "//third_party/skia/include/utils/win",
217 "//third_party/skia/src/utils/win",
218 ]
219
220 defines += [
221 # On windows, GDI handles are a scarse system-wide resource so we have to
222 # keep the glyph cache, which holds up to 4 GDI handles per entry, to a
223 # fairly small size. http://crbug.com/314387
224 "SK_DEFAULT_FONT_CACHE_COUNT_LIMIT=256",
225 ]
226
227 cflags = [
228 "/wd4244", # conversion from 'type1( __int64)' to 'type2 (unsigned int)'
229 "/wd4267", # conversion from 'size_t' (64 bit) to 'type'(32 bit).
230 "/wd4341", # signed value is out of range for enum constant.
231 "/wd4345", # Object is default-initialized if initialization is omitted.
232 "/wd4390", # ';'empty statement found in looping;is it what was intended?
233 "/wd4554", # 'operator' : check operator precedence for possible error
234 "/wd4748", # compiler will disable optimizations if a function has inline
235 # assembly code contains flow control(jmp or jcc) statements.
236
237 "/wd4800", # forcing value to bool 'true/false'(assigning int to bool).
238 ]
239 }
240 }
241
242 component("skia") {
243 sources = [
244 # Chrome sources.
245 "config/SkUserConfig.h",
246 "ext/google_logging.cc",
247 ]
248
249 # The skia gypi values are relative to the skia_dir, so we need to rebase.
250 sources += gypi_skia_core.sources
251 sources += gypi_skia_effects.sources
252 sources += gypi_skia_utils.sources
253 sources += gypi_values.skia_library_sources
254
255 # This and skia_opts are really the same conceptual target so share headers.
256 allow_circular_includes_from = [ ":skia_opts" ]
257
258 if (current_cpu == "arm") {
259 sources += [ "//third_party/skia/src/core/SkUtilsArm.cpp" ]
260 }
261
262 # GPU
263 if (skia_support_gpu) {
264 sources += gypi_skia_gpu.skgpu_sources
265 sources += gypi_skia_gpu.skgpu_null_gl_sources
266 }
267
268 # Remove unused util files include in utils.gypi
269 sources -= [
270 "//third_party/skia/src/utils/SkBoundaryPatch.cpp",
271 "//third_party/skia/src/utils/SkCamera.cpp",
272 "//third_party/skia/src/utils/SkDumpCanvas.cpp",
273 "//third_party/skia/src/utils/SkFrontBufferedStream.cpp",
274 "//third_party/skia/src/utils/SkInterpolator.cpp",
275 "//third_party/skia/src/utils/SkLayer.cpp",
276 "//third_party/skia/src/utils/SkMeshUtils.cpp",
277 "//third_party/skia/src/utils/SkNinePatch.cpp",
278 "//third_party/skia/src/utils/SkOSFile.cpp",
279 "//third_party/skia/src/utils/SkParsePath.cpp",
280
281 #testing
282 "//third_party/skia/src/fonts/SkGScalerContext.cpp",
283 ]
284
285 if (is_win) {
286 sources -= [
287 # Keeping _win.cpp
288 "//third_party/skia/src/utils/SkThreadUtils_pthread.cpp",
289 ]
290 } else {
291 sources -= [
292 # Keeping _pthread.cpp
293 "//third_party/skia/src/utils/SkThreadUtils_win.cpp",
294 ]
295 }
296
297 # need separate win section to handle chromes auto gn filter
298 # (build/config/BUILDCONFIG.gn)
299 if (is_win) {
300 sources -= [
301 #windows
302 "//third_party/skia/src/utils/win/SkAutoCoInitialize.cpp",
303 "//third_party/skia/src/utils/win/SkIStream.cpp",
304 "//third_party/skia/src/utils/win/SkWGL_win.cpp",
305 ]
306 }
307
308 # Fixup skia library sources.
309 if (is_win) {
310 sources -= [
311 "//third_party/skia/src/ports/SkOSFile_posix.cpp",
312 "//third_party/skia/src/ports/SkTLS_pthread.cpp",
313 ]
314 } else {
315 sources -= [
316 "//third_party/skia/src/ports/SkFontHost_win.cpp",
317 "//third_party/skia/src/ports/SkFontMgr_win_dw.cpp",
318 "//third_party/skia/src/ports/SkOSFile_win.cpp",
319 "//third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp",
320 "//third_party/skia/src/ports/SkScalerContext_win_dw.cpp",
321 "//third_party/skia/src/ports/SkTLS_win.cpp",
322 "//third_party/skia/src/ports/SkTypeface_win_dw.cpp",
323 ]
324 }
325 if (!is_android) {
326 sources -= [
327 "//third_party/skia/src/ports/SkFontMgr_android.cpp",
328 "//third_party/skia/src/ports/SkFontMgr_android_factory.cpp",
329 "//third_party/skia/src/ports/SkFontMgr_android_parser.cpp",
330 ]
331 }
332 if (!is_mac) {
333 sources -= [ "//third_party/skia/src/ports/SkFontHost_mac.cpp" ]
334 }
335
336 if (!is_linux) {
337 sources -= [
338 "//third_party/skia/src/fonts/SkFontMgr_fontconfig.cpp",
339 "//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp",
340 "//third_party/skia/src/ports/SkFontConfigInterface_direct_factory.cpp",
341 "//third_party/skia/src/ports/SkFontHost_fontconfig.cpp",
342 ]
343 }
344
345 # Add the files for the SkFontMgr_Android. This is used to emulate android
346 # fonts on linux. See content/zygote/zygote_main_linux.cc
347 if (is_linux) {
348 sources += [
349 "//third_party/skia/src/ports/SkFontMgr_android.cpp",
350 "//third_party/skia/src/ports/SkFontMgr_android_parser.cpp",
351 ]
352 }
353
354 if (!is_linux && !is_android) {
355 sources -= [
356 "//third_party/skia/src/ports/SkFontHost_FreeType.cpp",
357 "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp",
358 ]
359 }
360
361 if (is_clang && !is_nacl) {
362 # Skia won't compile with some of the more strict clang warnings.
363 # e.g. it does:
364 # SkASSERT(!"sk_out_of_memory");
365 configs -= [ "//build/config/clang:extra_warnings" ]
366 }
367
368 configs -= [ "//build/config/compiler:chromium_code" ]
369 configs += [
370 ":skia_config",
371 ":skia_library_config",
372 "//build/config/compiler:no_chromium_code",
373 ]
374 public_configs = [ ":skia_config" ]
375
376 deps = [
377 ":skia_opts",
378 "../third_party:fx_zlib",
379 ]
380
381 if (is_linux) {
382 if (use_pango) {
383 configs += [ "//build/config/linux/pangocairo" ]
384 }
385 deps += [
386 "//build/linux:fontconfig",
387 "//build/linux:freetype2",
388
389 # "//third_party/expat",
390 "//third_party/icu:icuuc",
391 ]
392 }
393
394 if (is_android) {
395 set_sources_assignment_filter([])
396 set_sources_assignment_filter(sources_assignment_filter)
397 deps += [
398 "//third_party/android_tools:cpu_features",
399 "//third_party/expat",
400 "//third_party/freetype-android:freetype",
401 ]
402 }
403
404 if (skia_support_pdf) {
405 deps += [ "//third_party/sfntly" ]
406 sources += gypi_skia_pdf.sources
407 } else {
408 sources += [ "//third_party/skia/src/pdf/SkDocument_PDF_None.cpp" ]
409 }
410
411 if (is_android && !is_debug) {
412 configs -= [ "//build/config/compiler:default_optimization" ]
413 configs += [ "//build/config/compiler:optimize_max" ]
414 }
415
416 if (is_ios) {
417 libs = [ "ImageIO.framework" ]
418 set_sources_assignment_filter([])
419 sources += [
420 "//third_party/skia/src/ports/SkFontHost_mac.cpp",
421 "//third_party/skia/src/utils/mac/SkCreateCGImageRef.cpp",
422 "//third_party/skia/src/utils/mac/SkStream_mac.cpp",
423 ]
424 set_sources_assignment_filter(sources_assignment_filter)
425
426 # To disable warning "CGContextSelectFont' is deprecated"
427 cflags = [ "-Wno-deprecated-declarations" ]
428 }
429 }
430
431 # Separated out so it can be compiled with different flags for SSE.
432 if (current_cpu == "x86" || current_cpu == "x64") {
433 source_set("skia_opts_sse3") {
434 sources = gypi_skia_opts.ssse3_sources
435 if (!is_win || is_clang) {
436 cflags = [ "-mssse3" ]
437 }
438 if (is_win) {
439 defines = [ "SK_CPU_SSE_LEVEL=31" ]
440 }
441 visibility = [ ":skia_opts" ]
442 configs -= [ "//build/config/compiler:chromium_code" ]
443 configs += [
444 ":skia_config",
445 ":skia_library_config",
446 "//build/config/compiler:no_chromium_code",
447 ]
448 }
449 source_set("skia_opts_sse41") {
450 sources = gypi_skia_opts.sse41_sources
451 if (!is_win || is_clang) {
452 cflags = [ "-msse4.1" ]
453 }
454 if (is_win) {
455 defines = [ "SK_CPU_SSE_LEVEL=41" ]
456 }
457 visibility = [ ":skia_opts" ]
458 configs -= [ "//build/config/compiler:chromium_code" ]
459 configs += [
460 ":skia_config",
461 ":skia_library_config",
462 "//build/config/compiler:no_chromium_code",
463 ]
464 }
465 source_set("skia_opts_sse42") {
466 sources = gypi_skia_opts.sse42_sources
467 if (!is_win || is_clang) {
468 cflags = [ "-msse4.2" ]
469 }
470 if (is_win) {
471 defines = [ "SK_CPU_SSE_LEVEL=42" ]
472 }
473 visibility = [ ":skia_opts" ]
474 configs -= [ "//build/config/compiler:chromium_code" ]
475 configs += [
476 ":skia_config",
477 ":skia_library_config",
478 "//build/config/compiler:no_chromium_code",
479 ]
480 }
481 source_set("skia_opts_avx") {
482 sources = gypi_skia_opts.avx_sources
483 if (!is_win) {
484 cflags = [ "-mavx" ]
485 }
486 if (is_win) {
487 cflags = [ "/arch:AVX" ]
488 }
489 visibility = [ ":skia_opts" ]
490 configs -= [ "//build/config/compiler:chromium_code" ]
491 configs += [
492 ":skia_config",
493 ":skia_library_config",
494 "//build/config/compiler:no_chromium_code",
495 ]
496 }
497 source_set("skia_opts_avx2") {
498 sources = gypi_skia_opts.avx2_sources
499 if (!is_win) {
500 cflags = [ "-mavx2" ]
501 }
502 if (is_win) {
503 cflags = [ "/arch:AVX2" ]
504 }
505 visibility = [ ":skia_opts" ]
506 configs -= [ "//build/config/compiler:chromium_code" ]
507 configs += [
508 ":skia_config",
509 ":skia_library_config",
510 "//build/config/compiler:no_chromium_code",
511 ]
512 }
513 }
514 source_set("skia_opts") {
515 cflags = []
516 defines = []
517
518 if (current_cpu == "x86" || current_cpu == "x64") {
519 sources = gypi_skia_opts.sse2_sources
520 deps = [
521 ":skia_opts_avx",
522 ":skia_opts_avx2",
523 ":skia_opts_sse3",
524 ":skia_opts_sse41",
525 ":skia_opts_sse42",
526 ]
527 } else if (current_cpu == "arm") {
528 # The assembly uses the frame pointer register (r7 in Thumb/r11 in
529 # ARM), the compiler doesn't like that.
530 cflags += [ "-fomit-frame-pointer" ]
531
532 if (arm_version >= 7) {
533 sources = gypi_skia_opts.armv7_sources
534 if (arm_use_neon || arm_optionally_use_neon) {
535 sources += gypi_skia_opts.neon_sources
536
537 # Root build config sets -mfpu=$arm_fpu, which we expect to be neon
538 # when running this.
539 if (!arm_use_neon) {
540 configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
541 cflags += [ "-mfpu=neon" ]
542 }
543 }
544 } else {
545 sources = gypi_skia_opts.none_sources
546 }
547 } else if (current_cpu == "arm64") {
548 sources = gypi_skia_opts.arm64_sources
549 } else if (current_cpu == "mipsel") {
550 cflags += [ "-fomit-frame-pointer" ]
551
552 if (mips_dsp_rev >= 1) {
553 sources = gypi_skia_opts.mips_dsp_sources
554 } else {
555 sources = gypi_skia_opts.none_sources
556 }
557 } else if (current_cpu == "mips64el") {
558 cflags += [ "-fomit-frame-pointer" ]
559 sources = gypi_skia_opts.none_sources
560 } else {
561 assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp")
562 }
563
564 if (is_android && !is_debug) {
565 configs -= [ "//build/config/compiler:default_optimization" ]
566 configs += [ "//build/config/compiler:optimize_max" ]
567 }
568
569 configs -= [ "//build/config/compiler:chromium_code" ]
570 configs += [
571 ":skia_config",
572 ":skia_library_config",
573 "//build/config/compiler:no_chromium_code",
574 ]
575
576 visibility = [ ":skia" ]
577 }
OLDNEW
« no previous file with comments | « DEPS ('k') | skia/skia_gn_files.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698