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

Side by Side Diff: public.bzl

Issue 1577353002: Move BUILD.public to public.bzl. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 | « BUILD.public ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Description: 1 ################################################################################
2 # Skia graphics library. 2 # Skylark macros
3 # 3 ################################################################################
4 # Definitions for Google BUILD file.
5 4
6 exports_files(["BUILD.public"]) 5 is_bazel = not hasattr(native, "genmpm")
6
7 def portable_select(select_dict, bazel_condition, default_condition):
8 """Replaces select() with a Bazel-friendly wrapper.
9
10 Args:
11 select_dict: Dictionary in the same format as select().
12 Returns:
13 If Blaze platform, returns select() using select_dict.
14 If Bazel platform, returns dependencies for condition
15 bazel_condition, or empty list if none specified.
16 """
17 if is_bazel:
18 return select_dict.get(bazel_condition, select_dict[default_condition])
19 else:
20 return select(select_dict)
21
22 def skia_select(conditions, results):
23 """Replaces select() for conditions [UNIX, ANDROID, IOS]
24
25 Args:
26 conditions: [CONDITION_UNIX, CONDITION_ANDROID, CONDITION_IOS]
27 results: [RESULT_UNIX, RESULT_ANDROID, RESULT_IOS]
28 Returns:
29 The result matching the platform condition.
30 """
31 if len(conditions) != 3 or len(results) != 3:
32 fail("Must provide exactly 3 conditions and 3 results")
33
34 selector = {}
35 for i in range(3):
36 selector[conditions[i]] = results[i]
37 return portable_select(selector, conditions[2], conditions[0])
38
39 def skia_glob(srcs):
40 """Replaces glob() with a version that accepts a struct.
41
42 Args:
43 srcs: struct(include=[], exclude=[])
44 Returns:
45 Equivalent of glob(srcs.include, exclude=srcs.exclude)
46 """
47 if hasattr(srcs, 'include'):
48 if hasattr(srcs, 'exclude'):
49 return native.glob(srcs.include, exclude=srcs.exclude)
50 else:
51 return native.glob(srcs.include)
52 return []
53
54 ################################################################################
55 ## BASE_SRCS
56 ################################################################################
7 57
8 # All platform-independent SRCS. 58 # All platform-independent SRCS.
9 BASE_SRCS = glob( 59 BASE_SRCS_ALL = struct(
10 [ 60 include = [
11 "include/private/*.h", 61 "include/private/*.h",
12 "src/**/*.h", 62 "src/**/*.h",
13 "src/**/*.cpp", 63 "src/**/*.cpp",
14 64
15 # Third Party 65 # Third Party
16 "third_party/etc1/*.cpp", 66 "third_party/etc1/*.cpp",
17 "third_party/etc1/*.h", 67 "third_party/etc1/*.h",
18 "third_party/ktx/*.cpp", 68 "third_party/ktx/*.cpp",
19 "third_party/ktx/*.h", 69 "third_party/ktx/*.h",
20 ], 70 ],
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 # Not used. 109 # Not used.
60 "src/animator/**/*", 110 "src/animator/**/*",
61 "src/views/**/*", 111 "src/views/**/*",
62 "src/xml/SkBML_Verbs.h", 112 "src/xml/SkBML_Verbs.h",
63 "src/xml/SkBML_XMLParser.cpp", 113 "src/xml/SkBML_XMLParser.cpp",
64 "src/xml/SkXMLPullParser.cpp", 114 "src/xml/SkXMLPullParser.cpp",
65 ], 115 ],
66 ) 116 )
67 117
68 # Platform-dependent SRCS for google3-default platform. 118 # Platform-dependent SRCS for google3-default platform.
69 BASE_SRCS_UNIX = glob( 119 BASE_SRCS_UNIX = struct(
70 [ 120 include = [
71 "src/codec/*", 121 "src/codec/*",
72 "src/fonts/SkFontMgr_fontconfig.cpp", 122 "src/fonts/SkFontMgr_fontconfig.cpp",
73 "src/images/*", 123 "src/images/*",
74 "src/opts/**/*.cpp", 124 "src/opts/**/*.cpp",
75 "src/opts/**/*.h", 125 "src/opts/**/*.h",
76 "src/ports/**/*.cpp", 126 "src/ports/**/*.cpp",
77 "src/ports/**/*.h", 127 "src/ports/**/*.h",
78 ], 128 ],
79 exclude = [ 129 exclude = [
80 "src/codec/SkJpegCodec.cpp", # libjpeg_turbo version mismatch. 130 "src/codec/SkJpegCodec.cpp", # libjpeg_turbo version mismatch.
(...skipping 26 matching lines...) Expand all
107 "src/ports/SkImageDecoder_CG.cpp", 157 "src/ports/SkImageDecoder_CG.cpp",
108 "src/ports/SkFontMgr_fontconfig_factory.cpp", 158 "src/ports/SkFontMgr_fontconfig_factory.cpp",
109 "src/ports/SkImageDecoder_WIC.cpp", 159 "src/ports/SkImageDecoder_WIC.cpp",
110 "src/ports/SkImageDecoder_empty.cpp", 160 "src/ports/SkImageDecoder_empty.cpp",
111 "src/ports/SkImageGenerator_none.cpp", 161 "src/ports/SkImageGenerator_none.cpp",
112 "src/ports/SkTLS_none.cpp", 162 "src/ports/SkTLS_none.cpp",
113 ], 163 ],
114 ) 164 )
115 165
116 # Platform-dependent SRCS for google3-default Android. 166 # Platform-dependent SRCS for google3-default Android.
117 BASE_SRCS_ANDROID = glob( 167 BASE_SRCS_ANDROID = struct(
118 [ 168 include = [
119 "src/codec/*", 169 "src/codec/*",
120 "src/images/*", 170 "src/images/*",
121 # TODO(benjaminwagner): Figure out how to compile with EGL. 171 # TODO(benjaminwagner): Figure out how to compile with EGL.
122 "src/opts/**/*.cpp", 172 "src/opts/**/*.cpp",
123 "src/opts/**/*.h", 173 "src/opts/**/*.h",
124 "src/ports/**/*.cpp", 174 "src/ports/**/*.cpp",
125 "src/ports/**/*.h", 175 "src/ports/**/*.h",
126 ], 176 ],
127 exclude = [ 177 exclude = [
128 "src/codec/SkJpegCodec.cpp", # libjpeg_turbo version mismatch. 178 "src/codec/SkJpegCodec.cpp", # libjpeg_turbo version mismatch.
(...skipping 23 matching lines...) Expand all
152 "src/ports/SkFontMgr_empty_factory.cpp", 202 "src/ports/SkFontMgr_empty_factory.cpp",
153 "src/ports/SkImageDecoder_CG.cpp", 203 "src/ports/SkImageDecoder_CG.cpp",
154 "src/ports/SkImageDecoder_WIC.cpp", 204 "src/ports/SkImageDecoder_WIC.cpp",
155 "src/ports/SkImageDecoder_empty.cpp", 205 "src/ports/SkImageDecoder_empty.cpp",
156 "src/ports/SkImageGenerator_none.cpp", 206 "src/ports/SkImageGenerator_none.cpp",
157 "src/ports/SkTLS_none.cpp", 207 "src/ports/SkTLS_none.cpp",
158 ], 208 ],
159 ) 209 )
160 210
161 # Platform-dependent SRCS for google3-default iOS. 211 # Platform-dependent SRCS for google3-default iOS.
162 BASE_SRCS_IOS = glob( 212 BASE_SRCS_IOS = struct(
163 [ 213 include = [
164 "src/opts/**/*.cpp", 214 "src/opts/**/*.cpp",
165 "src/opts/**/*.h", 215 "src/opts/**/*.h",
166 "src/ports/**/*.cpp", 216 "src/ports/**/*.cpp",
167 "src/ports/**/*.h", 217 "src/ports/**/*.h",
168 ], 218 ],
169 exclude = [ 219 exclude = [
170 "src/opts/*mips*", 220 "src/opts/*mips*",
171 "src/opts/*NEON*", 221 "src/opts/*NEON*",
172 "src/opts/*neon*", 222 "src/opts/*neon*",
173 "src/opts/*SSE2*", 223 "src/opts/*SSE2*",
(...skipping 22 matching lines...) Expand all
196 "src/ports/SkFontMgr_custom_embedded_factory.cpp", 246 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
197 "src/ports/SkFontMgr_empty_factory.cpp", 247 "src/ports/SkFontMgr_empty_factory.cpp",
198 "src/ports/SkImageDecoder_CG.cpp", 248 "src/ports/SkImageDecoder_CG.cpp",
199 "src/ports/SkImageDecoder_WIC.cpp", 249 "src/ports/SkImageDecoder_WIC.cpp",
200 "src/ports/SkImageDecoder_empty.cpp", 250 "src/ports/SkImageDecoder_empty.cpp",
201 "src/ports/SkImageGenerator_none.cpp", 251 "src/ports/SkImageGenerator_none.cpp",
202 "src/ports/SkTLS_none.cpp", 252 "src/ports/SkTLS_none.cpp",
203 ], 253 ],
204 ) 254 )
205 255
206 BASE_SRCS_PLATFORM = select({ 256 ################################################################################
207 CONDITION_ANDROID: BASE_SRCS_ANDROID, 257 ## SSSE3/SSE4/AVX/AVX2 SRCS
208 CONDITION_IOS: BASE_SRCS_IOS, 258 ################################################################################
209 "//conditions:default": BASE_SRCS_UNIX,
210 })
211 259
212 SSSE3_SRCS = glob( 260 SSSE3_SRCS = struct(
213 [ 261 include = [
214 "src/opts/*SSSE3*.cpp", 262 "src/opts/*SSSE3*.cpp",
215 "src/opts/*ssse3*.cpp", 263 "src/opts/*ssse3*.cpp",
216 ], 264 ])
217 )
218 265
219 SSE4_SRCS = glob( 266 SSE4_SRCS = struct(
220 [ 267 include = [
221 "src/opts/*SSE4*.cpp", 268 "src/opts/*SSE4*.cpp",
222 "src/opts/*sse4*.cpp", 269 "src/opts/*sse4*.cpp",
223 ], 270 ])
224 )
225 271
226 AVX_SRCS = glob( 272 AVX_SRCS = struct(
227 [ 273 include = [
228 "src/opts/*_avx.cpp", 274 "src/opts/*_avx.cpp",
229 ], 275 ])
230 )
231 276
232 AVX2_SRCS = glob( 277 AVX2_SRCS = struct(
233 [ 278 include = [
234 "src/opts/*_avx2.cpp", 279 "src/opts/*_avx2.cpp",
235 ], 280 ])
236 )
237 281
238 BASE_HDRS = glob( 282 ################################################################################
239 [ 283 ## BASE_HDRS
284 ################################################################################
285
286 BASE_HDRS = struct(
287 include = [
240 "include/**/*.h", 288 "include/**/*.h",
241 ], 289 ],
242 exclude = [ 290 exclude = [
243 "include/private/**/*", 291 "include/private/**/*",
244 292
245 # Not used. 293 # Not used.
246 "include/animator/**/*", 294 "include/animator/**/*",
247 "include/views/**/*", 295 "include/views/**/*",
248 "include/xml/SkBML_WXMLParser.h", 296 "include/xml/SkBML_WXMLParser.h",
249 "include/xml/SkBML_XMLParser.h", 297 "include/xml/SkBML_XMLParser.h",
250 ], 298 ])
251 )
252 299
253 # Dependencies. 300 ################################################################################
301 ## BASE_DEPS
302 ################################################################################
303
304 BASE_DEPS_ALL = []
305
254 BASE_DEPS_UNIX = [ 306 BASE_DEPS_UNIX = [
307 ":opts_ssse3",
308 ":opts_sse4",
309 ":opts_avx",
255 ":opts_avx2", 310 ":opts_avx2",
256 ":opts_avx",
257 ":opts_sse4",
258 ":opts_ssse3",
259 ] 311 ]
260 312
261 BASE_DEPS_ANDROID = [] 313 BASE_DEPS_ANDROID = []
262 314
263 BASE_DEPS_IOS = [] 315 BASE_DEPS_IOS = []
264 316
265 BASE_DEPS = select({ 317 ################################################################################
266 CONDITION_ANDROID: BASE_DEPS_ANDROID + BASE_EXTERNAL_DEPS_ANDROID, 318 ## INCLUDES
267 CONDITION_IOS: BASE_DEPS_IOS + BASE_EXTERNAL_DEPS_IOS, 319 ################################################################################
268 "//conditions:default": BASE_DEPS_UNIX + BASE_EXTERNAL_DEPS_UNIX,
269 }) + EXTERNAL_DEPS_ALL
270 320
271 # Includes needed by Skia implementation. Not public includes. 321 # Includes needed by Skia implementation. Not public includes.
272 INCLUDES = [ 322 INCLUDES = [
273 "include/android", 323 "include/android",
274 "include/c", 324 "include/c",
275 "include/codec", 325 "include/codec",
276 "include/config", 326 "include/config",
277 "include/core", 327 "include/core",
278 "include/effects", 328 "include/effects",
279 "include/gpu", 329 "include/gpu",
(...skipping 12 matching lines...) Expand all
292 "src/gpu", 342 "src/gpu",
293 "src/image", 343 "src/image",
294 "src/lazy", 344 "src/lazy",
295 "src/opts", 345 "src/opts",
296 "src/ports", 346 "src/ports",
297 "src/pdf", 347 "src/pdf",
298 "src/sfnt", 348 "src/sfnt",
299 "src/utils", 349 "src/utils",
300 "third_party/etc1", 350 "third_party/etc1",
301 "third_party/ktx", 351 "third_party/ktx",
302 ] + EXTERNAL_INCLUDES 352 ]
303 353
304 ## :dm 354 ################################################################################
355 ## DM_SRCS
356 ################################################################################
305 357
306 # Platform-independent SRCS for DM. 358 DM_SRCS_ALL = struct(
307 DM_SRCS = glob( 359 include = [
308 [
309 "dm/*.cpp", 360 "dm/*.cpp",
310 "dm/*.h", 361 "dm/*.h",
311 "gm/*.c", 362 "gm/*.c",
312 "gm/*.cpp", 363 "gm/*.cpp",
313 "gm/*.h", 364 "gm/*.h",
314 "tests/*.cpp", 365 "tests/*.cpp",
315 "tests/*.h", 366 "tests/*.h",
316 "tools/CrashHandler.cpp", 367 "tools/CrashHandler.cpp",
317 "tools/CrashHandler.h", 368 "tools/CrashHandler.h",
318 "tools/LazyDecodeBitmap.cpp", 369 "tools/LazyDecodeBitmap.cpp",
(...skipping 22 matching lines...) Expand all
341 "dm/DMSrcSinkAndroid.cpp", # Android-only. 392 "dm/DMSrcSinkAndroid.cpp", # Android-only.
342 "tests/FontMgrAndroidParserTest.cpp", # Android-only. 393 "tests/FontMgrAndroidParserTest.cpp", # Android-only.
343 "tests/PathOpsSkpClipTest.cpp", # Alternate main. 394 "tests/PathOpsSkpClipTest.cpp", # Alternate main.
344 "tests/skia_test.cpp", # Old main. 395 "tests/skia_test.cpp", # Old main.
345 "tests/SkpSkGrTest.cpp", # Alternate main. 396 "tests/SkpSkGrTest.cpp", # Alternate main.
346 "tools/timer/SysTimer_mach.cpp", 397 "tools/timer/SysTimer_mach.cpp",
347 "tools/timer/SysTimer_windows.cpp", 398 "tools/timer/SysTimer_windows.cpp",
348 ], 399 ],
349 ) 400 )
350 401
351 DM_SRCS_UNIX = [] 402 DM_SRCS_UNIX = struct()
352 403
353 DM_SRCS_ANDROID = glob( 404 DM_SRCS_ANDROID = struct(
354 [ 405 include = [
355 # Depends on Android HWUI library that is not available in google3. 406 # Depends on Android HWUI library that is not available in google3.
356 #"dm/DMSrcSinkAndroid.cpp", 407 #"dm/DMSrcSinkAndroid.cpp",
357 "tests/FontMgrAndroidParserTest.cpp", 408 "tests/FontMgrAndroidParserTest.cpp",
358 ], 409 ],
359 ) 410 )
360 411
361 DM_PLATFORM_SRCS = select({ 412 DM_SRCS_IOS = struct()
362 CONDITION_ANDROID: DM_SRCS_ANDROID, 413
363 "//conditions:default": DM_SRCS_UNIX, 414 ################################################################################
364 }) 415 ## DM_INCLUDES
416 ################################################################################
365 417
366 DM_INCLUDES = [ 418 DM_INCLUDES = [
367 "gm", 419 "gm",
368 "src/codec", 420 "src/codec",
369 "src/effects", 421 "src/effects",
370 "src/fonts", 422 "src/fonts",
371 "src/pathops", 423 "src/pathops",
372 "src/pipe/utils", 424 "src/pipe/utils",
373 "src/ports", 425 "src/ports",
374 "src/utils/debugger", 426 "src/utils/debugger",
375 "tests", 427 "tests",
376 "tools", 428 "tools",
377 "tools/flags", 429 "tools/flags",
378 "tools/timer", 430 "tools/timer",
379 ] 431 ]
380 432
433 ################################################################################
434 ## DM_ARGS
435 ################################################################################
436
437 def DM_ARGS(base_dir):
438 return [
439 "--nogpu",
440 "--verbose",
441 # TODO(mtklein): maybe investigate why these fail?
442 "--match ~FontMgr ~Scalar ~Canvas ~Codec_stripes ~Codec_Dimensions ~Code c ~Stream ~skps ~RecordDraw_TextBounds",
443 "--resourcePath %s/resources" % base_dir,
444 "--images %s/resources" % base_dir,
445 ]
446
447 ################################################################################
448 ## COPTS
449 ################################################################################
450
451 COPTS_UNIX = [
452 "-Wno-implicit-fallthrough", # Some intentional fallthrough.
453 "-Wno-deprecated-declarations", # Internal use of deprecated methods. :(
454 ]
455
381 COPTS_ANDROID = ["-mfpu=neon"] 456 COPTS_ANDROID = ["-mfpu=neon"]
382 457
383 COPTS_IOS = [] 458 COPTS_IOS = []
384 459
385 COPTS_UNIX = [ 460 COPTS_ALL = []
386 "-Wno-implicit-fallthrough", # Some intentional fallthrough. 461
387 "-Wno-deprecated-declarations", # Internal use of deprecated methods. :( 462 ################################################################################
463 ## DEFINES
464 ################################################################################
465
466 DEFINES_UNIX = [
467 "SK_BUILD_FOR_UNIX",
468 "SK_SAMPLES_FOR_X",
469 "SK_SFNTLY_SUBSETTER",
388 ] 470 ]
389 471
390 COPTS = select({
391 CONDITION_ANDROID: COPTS_ANDROID,
392 CONDITION_IOS: COPTS_IOS,
393 "//conditions:default": COPTS_UNIX,
394 })
395
396 DEFINES_ANDROID = [ 472 DEFINES_ANDROID = [
397 "SK_BUILD_FOR_ANDROID", 473 "SK_BUILD_FOR_ANDROID",
398 # TODO(benjaminwagner): Try to get png library updated? 474 # TODO(benjaminwagner): Try to get png library updated?
399 "SK_PNG_NO_INDEX_SUPPORTED", 475 "SK_PNG_NO_INDEX_SUPPORTED",
400 ] 476 ]
401 477
402 DEFINES_IOS = [ 478 DEFINES_IOS = [
403 "SK_BUILD_FOR_IOS", 479 "SK_BUILD_FOR_IOS",
404 "SK_IGNORE_ETC1_SUPPORT", 480 "SK_IGNORE_ETC1_SUPPORT",
405 ] 481 ]
406 482
407 DEFINES_UNIX = [
408 "SK_BUILD_FOR_UNIX",
409 "SK_SAMPLES_FOR_X",
410 "SK_SFNTLY_SUBSETTER",
411 ]
412
413 DEFINES_ALL = [ 483 DEFINES_ALL = [
414 # Chrome DEFINES. 484 # Chrome DEFINES.
415 "SK_USE_FLOATBITS", 485 "SK_USE_FLOATBITS",
416 "SK_USE_FREETYPE_EMBOLDEN", 486 "SK_USE_FREETYPE_EMBOLDEN",
417 # Turn on a few Google3-specific build fixes. 487 # Turn on a few Google3-specific build fixes.
418 "GOOGLE3", 488 "GOOGLE3",
419 ] 489 ]
420 490
421 DEFINES = select({ 491 ################################################################################
422 CONDITION_ANDROID: DEFINES_ANDROID, 492 ## LINKOPTS
423 CONDITION_IOS: DEFINES_IOS, 493 ################################################################################
424 "//conditions:default": DEFINES_UNIX,
425 }) + DEFINES_ALL
426 494
427 LINKOPTS = select({ 495 LINKOPTS_UNIX = []
428 CONDITION_ANDROID: [
429 "-ldl",
430 "-lEGL",
431 ],
432 "//conditions:default": ["-ldl"],
433 })
434 496
435 cc_library( 497 LINKOPTS_ANDROID = [
436 name = "opts_ssse3", 498 "-lEGL",
437 srcs = SSSE3_SRCS, 499 ]
438 copts = COPTS + ["-mssse3"],
439 defines = DEFINES,
440 includes = INCLUDES,
441 deps = EXTERNAL_DEPS_ALL,
442 )
443 500
444 cc_library( 501 LINKOPTS_IOS = []
445 name = "opts_sse4",
446 srcs = SSE4_SRCS,
447 copts = COPTS + ["-msse4"],
448 defines = DEFINES,
449 includes = INCLUDES,
450 deps = EXTERNAL_DEPS_ALL,
451 )
452 502
453 cc_library( 503 LINKOPTS_ALL = [
454 name = "opts_avx", 504 "-ldl",
455 srcs = AVX_SRCS, 505 ]
456 copts = COPTS + ["-mavx"],
457 defines = DEFINES,
458 includes = INCLUDES,
459 deps = EXTERNAL_DEPS_ALL,
460 )
461 506
462 cc_library(
463 name = "opts_avx2",
464 srcs = AVX2_SRCS,
465 copts = COPTS + ["-mavx2"],
466 defines = DEFINES,
467 includes = INCLUDES,
468 deps = EXTERNAL_DEPS_ALL,
469 )
470
471 # If you need Ganesh (GPU) support in Skia, please contact skia-team@google.com
472 # for help.
473 cc_library(
474 name = "skia",
475 srcs = BASE_SRCS + BASE_SRCS_PLATFORM,
476 hdrs = BASE_HDRS,
477 copts = COPTS,
478 defines = DEFINES,
479 includes = INCLUDES,
480 linkopts = LINKOPTS,
481 visibility = [":skia_clients"],
482 deps = BASE_DEPS,
483 alwayslink = 1,
484 )
485
486 cc_test(
487 name = "dm",
488 size = "large",
489 srcs = DM_SRCS + DM_PLATFORM_SRCS,
490 args = [
491 "--nogpu",
492 "--verbose",
493 # TODO(mtklein): maybe investigate why these fail?
494 "--match ~FontMgr ~Scalar ~Canvas ~Codec_stripes ~Codec_Dimensions ~Code c ~Stream ~skps ~RecordDraw_TextBounds",
495 "--resourcePath %s/resources" % BASE_DIR,
496 "--images %s/resources" % BASE_DIR,
497 ],
498 copts = COPTS,
499 data = glob(["resources/**/*"]),
500 defines = DEFINES,
501 includes = DM_INCLUDES,
502 deps = DM_EXTERNAL_DEPS + [
503 ":skia",
504 ] + EXTERNAL_DEPS_ALL,
505 )
OLDNEW
« no previous file with comments | « BUILD.public ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698