BUILD.gn 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038
  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. import("//build/buildflag_header.gni")
  5. import("//build/config/compiler/compiler.gni")
  6. import("//build/config/features.gni")
  7. import("//build/config/freetype/freetype.gni")
  8. import("//build/config/sanitizers/sanitizers.gni")
  9. import("//gpu/vulkan/features.gni")
  10. import("//printing/buildflags/buildflags.gni")
  11. import("//testing/test.gni")
  12. import("//third_party/libgifcodec/libgifcodec.gni")
  13. import("//third_party/skia/gn/shared_sources.gni")
  14. import("//third_party/skia/modules/skcms/skcms.gni")
  15. import("//tools/grit/grit_rule.gni")
  16. import("features.gni")
  17. if (current_cpu == "arm") {
  18. import("//build/config/arm.gni")
  19. }
  20. if (current_cpu == "mipsel" || current_cpu == "mips64el") {
  21. import("//build/config/mips.gni")
  22. }
  23. skia_support_gpu = !is_ios
  24. skia_support_pdf = !is_ios && enable_basic_printing
  25. declare_args() {
  26. enable_skia_wuffs_gif = true
  27. }
  28. buildflag_header("buildflags") {
  29. header = "buildflags.h"
  30. flags = [
  31. "SKIA_SUPPORT_SKOTTIE=$skia_support_skottie",
  32. "SKIA_USE_DAWN=$skia_use_dawn",
  33. ]
  34. }
  35. # External-facing config for dependent code.
  36. config("skia_config") {
  37. defines = [
  38. "SK_CODEC_DECODES_PNG",
  39. "SK_CODEC_DECODES_WEBP",
  40. "SK_ENCODE_PNG",
  41. "SK_ENCODE_WEBP",
  42. "SK_ENABLE_SKSL",
  43. "SK_UNTIL_CRBUG_1187654_IS_FIXED",
  44. "SK_USER_CONFIG_HEADER=\"../../skia/config/SkUserConfig.h\"",
  45. "SK_WIN_FONTMGR_NO_SIMULATIONS",
  46. ]
  47. include_dirs = [ "//third_party/skia" ]
  48. if (!is_ios) {
  49. if (enable_skia_wuffs_gif) {
  50. include_dirs += [ "//third_party/wuffs/src/release/c" ]
  51. } else {
  52. include_dirs += [ "//third_party/libgifcodec" ]
  53. }
  54. }
  55. if (enable_vulkan) {
  56. include_dirs += [ "//third_party/vulkan/include" ]
  57. configs =
  58. [ "//third_party/vulkan-deps/vulkan-headers/src:vulkan_headers_config" ]
  59. }
  60. if (skia_use_gl) {
  61. defines += [ "SK_GL" ]
  62. }
  63. if (!is_ios) {
  64. defines += [
  65. "SK_CODEC_DECODES_JPEG",
  66. "SK_ENCODE_JPEG",
  67. ]
  68. if (enable_skia_wuffs_gif) {
  69. defines += [ "SK_HAS_WUFFS_LIBRARY" ]
  70. } else {
  71. defines += [ "SK_USE_LIBGIFCODEC" ]
  72. }
  73. }
  74. if (enable_vulkan) {
  75. defines += [ "SK_VULKAN=1" ]
  76. }
  77. if (skia_use_dawn) {
  78. defines += [ "SK_DAWN" ]
  79. }
  80. if (is_component_build) {
  81. defines += [ "SKIA_DLL" ]
  82. if (is_win) {
  83. defines += [ "SKCMS_API=__declspec(dllexport)" ]
  84. } else {
  85. defines += [ "SKCMS_API=__attribute__((visibility(\"default\")))" ]
  86. }
  87. }
  88. if (skia_support_gpu) {
  89. workaround_header = "gpu/config/gpu_driver_bug_workaround_autogen.h"
  90. defines += [
  91. "SK_SUPPORT_GPU=1",
  92. "SK_GPU_WORKAROUNDS_HEADER=\"$workaround_header\"",
  93. ]
  94. } else {
  95. defines += [ "SK_SUPPORT_GPU=0" ]
  96. }
  97. if (is_android) {
  98. defines += [
  99. "SK_BUILD_FOR_ANDROID",
  100. "USE_CHROMIUM_SKIA",
  101. ]
  102. }
  103. if (is_mac) {
  104. defines += [
  105. "SK_BUILD_FOR_MAC",
  106. "SK_METAL",
  107. ]
  108. }
  109. if (is_win) {
  110. defines += [ "GR_GL_FUNCTION_TYPE=__stdcall" ]
  111. }
  112. }
  113. # Internal-facing config for Skia library code.
  114. config("skia_library_config") {
  115. defines = []
  116. # Skia uses C++17 language features in its internal code. Previously Skia was built with
  117. # "-std=c++17". See http://crbug.com/1257145 for why this was a bad idea.
  118. cflags_cc = [ "-Wno-c++17-extensions" ]
  119. cflags_objcc = [ "-Wno-c++17-extensions" ]
  120. if (!is_ios && !use_system_freetype) {
  121. defines += [ "SK_FREETYPE_MINIMUM_RUNTIME_VERSION=(((FREETYPE_MAJOR) * 0x01000000) | ((FREETYPE_MINOR) * 0x00010000) | ((FREETYPE_PATCH) * 0x00000100))" ]
  122. }
  123. defines += [ "SKIA_IMPLEMENTATION=1" ]
  124. if (current_cpu == "arm") {
  125. if (arm_use_neon) {
  126. defines += [ "SK_ARM_HAS_NEON" ]
  127. } else if (arm_optionally_use_neon) {
  128. defines += [ "SK_ARM_HAS_OPTIONAL_NEON" ]
  129. }
  130. }
  131. # Settings for text blitting, chosen to approximate the system browser.
  132. if (is_linux || is_chromeos) {
  133. defines += [
  134. "SK_GAMMA_EXPONENT=1.2",
  135. "SK_GAMMA_CONTRAST=0.2",
  136. ]
  137. } else if (is_android) {
  138. defines += [
  139. "SK_GAMMA_APPLY_TO_A8",
  140. "SK_GAMMA_EXPONENT=1.4",
  141. "SK_GAMMA_CONTRAST=0.0",
  142. ]
  143. } else if (is_win) {
  144. defines += [
  145. "SK_GAMMA_SRGB",
  146. "SK_GAMMA_CONTRAST=0.5",
  147. ]
  148. } else if (is_mac) {
  149. defines += [
  150. "SK_GAMMA_SRGB",
  151. "SK_GAMMA_CONTRAST=0.0",
  152. ]
  153. }
  154. if (is_android) {
  155. defines += [
  156. # Android devices are typically more memory constrained, so default to a
  157. # smaller glyph cache (it may be overriden at runtime when the renderer
  158. # starts up, depending on the actual device memory).
  159. "SK_DEFAULT_FONT_CACHE_LIMIT=1048576", # 1024 * 1024
  160. ]
  161. } else {
  162. defines += [ "SK_DEFAULT_FONT_CACHE_LIMIT=20971520" ] # 20 * 1024 * 1024
  163. }
  164. if (is_win) {
  165. defines += [
  166. # On windows, GDI handles are a scarse system-wide resource so we have to
  167. # keep the glyph cache, which holds up to 4 GDI handles per entry, to a
  168. # fairly small size. http://crbug.com/314387
  169. "SK_DEFAULT_FONT_CACHE_COUNT_LIMIT=256",
  170. ]
  171. }
  172. }
  173. source_set("skcms") {
  174. cflags = []
  175. if (!is_win || is_clang) {
  176. cflags += [
  177. "-w",
  178. "-std=c11",
  179. ]
  180. }
  181. # LLVM automatically sets the equivalent of GCC's -mfp16-format=ieee on ARM
  182. # builds by default, while GCC itself does not. We need it to enable support
  183. # for half-precision floating point data types used by SKCMS on ARM.
  184. if ((is_linux || is_chromeos) && !is_clang && current_cpu == "arm") {
  185. cflags += [ "-mfp16-format=ieee" ]
  186. }
  187. public = [ "//third_party/skia/modules/skcms/skcms.h" ]
  188. include_dirs = [ "//third_party/skia/modules/skcms" ]
  189. sources =
  190. rebase_path(skcms_sources, ".", "//third_party/skia/modules/skcms")
  191. }
  192. component("skia") {
  193. deps = []
  194. sources = [
  195. # Chrome sources.
  196. "config/SkUserConfig.h",
  197. "config/sk_ref_cnt_ext_debug.h",
  198. "config/sk_ref_cnt_ext_release.h",
  199. "ext/SkDiscardableMemory_chrome.cc",
  200. "ext/SkDiscardableMemory_chrome.h",
  201. "ext/SkMemory_new_handler.cpp",
  202. "ext/benchmarking_canvas.cc",
  203. "ext/benchmarking_canvas.h",
  204. "ext/convolver.cc",
  205. "ext/convolver.h",
  206. "ext/event_tracer_impl.cc",
  207. "ext/event_tracer_impl.h",
  208. "ext/google_logging.cc",
  209. "ext/image_operations.cc",
  210. "ext/image_operations.h",
  211. "ext/legacy_display_globals.cc",
  212. "ext/legacy_display_globals.h",
  213. "ext/opacity_filter_canvas.cc",
  214. "ext/opacity_filter_canvas.h",
  215. "ext/recursive_gaussian_convolution.cc",
  216. "ext/recursive_gaussian_convolution.h",
  217. "ext/rgba_to_yuva.cc",
  218. "ext/rgba_to_yuva.h",
  219. "ext/skia_histogram.cc",
  220. "ext/skia_histogram.h",
  221. "ext/skia_memory_dump_provider.cc",
  222. "ext/skia_memory_dump_provider.h",
  223. "ext/skia_trace_memory_dump_impl.cc",
  224. "ext/skia_trace_memory_dump_impl.h",
  225. "ext/skia_utils_base.cc",
  226. "ext/skia_utils_base.h",
  227. ]
  228. if (!is_apple) {
  229. sources += [
  230. "ext/fontmgr_default.cc",
  231. "ext/fontmgr_default.h",
  232. ]
  233. }
  234. if (is_android) {
  235. sources += [ "ext/fontmgr_default_android.cc" ]
  236. }
  237. if (is_linux || is_chromeos) {
  238. sources += [ "ext/fontmgr_default_linux.cc" ]
  239. }
  240. if (is_ios) {
  241. sources += [
  242. "ext/skia_utils_ios.h",
  243. "ext/skia_utils_ios.mm",
  244. ]
  245. }
  246. if (is_mac) {
  247. sources += [
  248. "ext/skia_utils_mac.h",
  249. "ext/skia_utils_mac.mm",
  250. ]
  251. }
  252. if (is_win) {
  253. sources += [
  254. "ext/fontmgr_default_win.cc",
  255. "ext/skia_utils_win.cc",
  256. "ext/skia_utils_win.h",
  257. ]
  258. }
  259. if (!is_ios) {
  260. sources += [
  261. "ext/platform_canvas.cc",
  262. "ext/platform_canvas.h",
  263. ]
  264. }
  265. if (!is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
  266. sources += [
  267. "ext/convolver_SSE2.cc",
  268. "ext/convolver_SSE2.h",
  269. ]
  270. } else if (current_cpu == "mipsel" && mips_dsp_rev >= 2) {
  271. sources += [
  272. "ext/convolver_mips_dspr2.cc",
  273. "ext/convolver_mips_dspr2.h",
  274. ]
  275. } else if (current_cpu == "arm" || current_cpu == "arm64") {
  276. if (arm_use_neon) {
  277. sources += [
  278. "ext/convolver_neon.cc",
  279. "ext/convolver_neon.h",
  280. ]
  281. }
  282. }
  283. if (is_win) {
  284. sources += [
  285. # Select the right BitmapPlatformDevice.
  286. "ext/raster_handle_allocator_win.cc",
  287. ]
  288. }
  289. # The *_public variables should be added to 'public' not 'sources'.
  290. # However, Skia does not export enough *_public variables to make Chromium
  291. # 'gn check' clean. Until that can be done add the *_public variables to
  292. # 'sources' so that the buildbot 'analyze' step is aware of their existence.
  293. sources += skia_core_public
  294. sources += skia_utils_public
  295. sources += skia_effects_public
  296. sources += skia_effects_imagefilter_public
  297. # The imported Skia gni source paths are made absolute by gn.
  298. defines = []
  299. sources += skia_sksl_sources
  300. sources += skia_utils_sources
  301. sources += skia_xps_sources
  302. sources += [
  303. "//third_party/skia/src/fonts/SkFontMgr_indirect.cpp",
  304. "//third_party/skia/src/fonts/SkRemotableFontMgr.cpp",
  305. "//third_party/skia/src/images/SkImageEncoder.cpp",
  306. "//third_party/skia/src/images/SkPngEncoder.cpp",
  307. "//third_party/skia/src/images/SkWebpEncoder.cpp",
  308. "//third_party/skia/src/ports/SkGlobalInitialization_default.cpp",
  309. "//third_party/skia/src/ports/SkImageGenerator_none.cpp",
  310. "//third_party/skia/src/ports/SkOSFile_stdio.cpp",
  311. "//third_party/skia/src/sfnt/SkOTTable_name.cpp",
  312. "//third_party/skia/src/sfnt/SkOTUtils.cpp",
  313. ]
  314. if (!is_ios) {
  315. sources -= [ "//third_party/skia/src/ports/SkImageGenerator_none.cpp" ]
  316. sources += [
  317. "//third_party/skia/src/codec/SkBmpBaseCodec.cpp",
  318. "//third_party/skia/src/codec/SkBmpCodec.cpp",
  319. "//third_party/skia/src/codec/SkBmpMaskCodec.cpp",
  320. "//third_party/skia/src/codec/SkBmpRLECodec.cpp",
  321. "//third_party/skia/src/codec/SkBmpStandardCodec.cpp",
  322. "//third_party/skia/src/codec/SkCodec.cpp",
  323. "//third_party/skia/src/codec/SkCodecImageGenerator.cpp",
  324. "//third_party/skia/src/codec/SkColorTable.cpp",
  325. "//third_party/skia/src/codec/SkEncodedInfo.cpp",
  326. "//third_party/skia/src/codec/SkIcoCodec.cpp",
  327. "//third_party/skia/src/codec/SkJpegCodec.cpp",
  328. "//third_party/skia/src/codec/SkJpegDecoderMgr.cpp",
  329. "//third_party/skia/src/codec/SkJpegUtility.cpp",
  330. "//third_party/skia/src/codec/SkMaskSwizzler.cpp",
  331. "//third_party/skia/src/codec/SkMasks.cpp",
  332. "//third_party/skia/src/codec/SkParseEncodedOrigin.cpp",
  333. "//third_party/skia/src/codec/SkPngCodec.cpp",
  334. "//third_party/skia/src/codec/SkSampler.cpp",
  335. "//third_party/skia/src/codec/SkStreamBuffer.cpp",
  336. "//third_party/skia/src/codec/SkSwizzler.cpp",
  337. "//third_party/skia/src/codec/SkWbmpCodec.cpp",
  338. "//third_party/skia/src/codec/SkWebpCodec.cpp",
  339. "//third_party/skia/src/images/SkJPEGWriteUtility.cpp",
  340. "//third_party/skia/src/images/SkJpegEncoder.cpp",
  341. "//third_party/skia/src/ports/SkImageGenerator_skia.cpp",
  342. ]
  343. if (enable_skia_wuffs_gif) {
  344. deps += [ "//third_party/wuffs" ]
  345. sources += [ "//third_party/skia/src/codec/SkWuffsCodec.cpp" ]
  346. } else {
  347. sources += rebase_path(libgifcodec_sources + libgifcodec_public,
  348. ".",
  349. "//third_party/libgifcodec")
  350. }
  351. }
  352. if (current_cpu == "arm") {
  353. sources += [ "//third_party/skia/src/core/SkUtilsArm.cpp" ]
  354. }
  355. # Remove unused util sources.
  356. sources -= [ "//third_party/skia/src/utils/SkParsePath.cpp" ]
  357. if (is_win) {
  358. sources -= [
  359. # Keeping _win.cpp
  360. "//third_party/skia/src/utils/SkThreadUtils_pthread.cpp",
  361. ]
  362. libs = [ "fontsub.lib" ]
  363. } else {
  364. sources -= [
  365. # Keeping _pthread.cpp
  366. "//third_party/skia/src/utils/SkThreadUtils_win.cpp",
  367. ]
  368. }
  369. # need separate win section to handle chromes auto gn filter
  370. # (build/config/BUILDCONFIG.gn)
  371. if (is_win) {
  372. sources -= [
  373. #windows
  374. "//third_party/skia/src/utils/win/SkWGL_win.cpp",
  375. ]
  376. }
  377. # Select Skia ports.
  378. # FreeType is needed everywhere (except on iOS), on Linux and Android as main
  379. # font backend, on Windows and Mac as fallback backend for Variations.
  380. if (!is_ios) {
  381. sources += [
  382. "//third_party/skia/src/ports/SkFontHost_FreeType.cpp",
  383. "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp",
  384. ]
  385. }
  386. if (is_win) {
  387. sources += [
  388. "//third_party/skia/src/ports/SkFontHost_win.cpp",
  389. "//third_party/skia/src/ports/SkFontMgr_win_dw.cpp",
  390. "//third_party/skia/src/ports/SkOSFile_win.cpp",
  391. "//third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp",
  392. "//third_party/skia/src/ports/SkScalerContext_win_dw.cpp",
  393. "//third_party/skia/src/ports/SkTLS_win.cpp",
  394. "//third_party/skia/src/ports/SkTypeface_win_dw.cpp",
  395. ]
  396. } else {
  397. sources += [
  398. "//third_party/skia/src/ports/SkOSFile_posix.cpp",
  399. "//third_party/skia/src/ports/SkTLS_pthread.cpp",
  400. ]
  401. }
  402. if (is_apple) {
  403. sources += [
  404. "//third_party/skia/include/ports/SkFontMgr_mac_ct.h",
  405. "//third_party/skia/src/ports/SkFontMgr_mac_ct.cpp",
  406. "//third_party/skia/src/ports/SkFontMgr_mac_ct_factory.cpp",
  407. "//third_party/skia/src/ports/SkScalerContext_mac_ct.cpp",
  408. "//third_party/skia/src/ports/SkScalerContext_mac_ct.h",
  409. "//third_party/skia/src/ports/SkTypeface_mac_ct.cpp",
  410. "//third_party/skia/src/ports/SkTypeface_mac_ct.h",
  411. ]
  412. }
  413. if (is_linux || is_chromeos) {
  414. sources += [
  415. "//third_party/skia/src/ports/SkFontConfigInterface.cpp",
  416. "//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp",
  417. "//third_party/skia/src/ports/SkFontConfigInterface_direct_factory.cpp",
  418. "//third_party/skia/src/ports/SkFontMgr_FontConfigInterface.cpp",
  419. ]
  420. }
  421. if (is_linux || is_chromeos || is_android) {
  422. sources += [
  423. # Retain the files for the SkFontMgr_Android on linux to emulate android
  424. # fonts. See content/zygote/zygote_main_linux.cc
  425. # Note that this requires expat.
  426. "//third_party/skia/src/ports/SkFontMgr_android.cpp",
  427. "//third_party/skia/src/ports/SkFontMgr_android_parser.cpp",
  428. ]
  429. }
  430. if (is_win || is_mac) {
  431. sources += [
  432. # Add the FreeType custom font manager as a fallback backend for variable fonts.
  433. "//third_party/skia/src/ports/SkFontMgr_custom.cpp",
  434. "//third_party/skia/src/ports/SkFontMgr_custom_empty.cpp",
  435. ]
  436. }
  437. if (is_fuchsia) {
  438. sources += [
  439. "//third_party/skia/src/ports/SkFontMgr_custom.cpp",
  440. "//third_party/skia/src/ports/SkFontMgr_fuchsia.cpp",
  441. "ext/fontmgr_default_fuchsia.cc",
  442. ]
  443. deps += [
  444. "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.fonts",
  445. "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.io",
  446. "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.sys",
  447. "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
  448. "//third_party/fuchsia-sdk/sdk/pkg/zx",
  449. "//third_party/icu:icuuc",
  450. ]
  451. }
  452. if (is_clang && !is_nacl) {
  453. # Skia won't compile with some of the more strict clang warnings.
  454. # e.g. it does:
  455. # SkASSERT(!"sk_out_of_memory");
  456. configs -= [ "//build/config/clang:extra_warnings" ]
  457. }
  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. public_configs = [ ":skia_config" ]
  465. deps += [
  466. ":skcms",
  467. ":skia_opts",
  468. "//base",
  469. "//base/third_party/dynamic_annotations",
  470. "//third_party/libpng",
  471. "//third_party/libwebp",
  472. "//third_party/libwebp:libwebp_webp",
  473. ]
  474. public_deps = [
  475. ":buildflags",
  476. ":skia_core_and_effects",
  477. ]
  478. if (skia_use_dawn) {
  479. public_deps += [ "//third_party/dawn/include/dawn:cpp_headers" ]
  480. deps += [
  481. "//third_party/dawn/src/dawn:cpp",
  482. "//third_party/dawn/src/dawn:proc",
  483. "//third_party/dawn/src/dawn/native",
  484. ]
  485. }
  486. if (!is_ios) {
  487. deps += [
  488. "//build/config/freetype",
  489. "//third_party:jpeg",
  490. ]
  491. }
  492. if (is_linux || is_chromeos) {
  493. deps += [
  494. "//third_party/expat",
  495. "//third_party/fontconfig",
  496. "//third_party/icu:icuuc",
  497. ]
  498. }
  499. if (is_android) {
  500. deps += [
  501. "//third_party/android_ndk:cpu_features",
  502. "//third_party/expat",
  503. ]
  504. }
  505. if (!is_debug) {
  506. configs -= [ "//build/config/compiler:default_optimization" ]
  507. configs += [ "//build/config/compiler:optimize_max" ]
  508. }
  509. if (is_mac) {
  510. deps += [ ":skia_metal" ]
  511. defines += [ "SK_METAL" ]
  512. frameworks = [
  513. "AppKit.framework",
  514. "CoreFoundation.framework",
  515. "CoreGraphics.framework",
  516. "CoreText.framework",
  517. "Metal.framework",
  518. "Foundation.framework",
  519. ]
  520. }
  521. if (skia_use_dawn) {
  522. sources += skia_dawn_sources
  523. }
  524. if (is_ios) {
  525. frameworks = [ "ImageIO.framework" ]
  526. }
  527. if (is_fuchsia) {
  528. deps += [ "//third_party/expat" ]
  529. }
  530. if (skia_support_gpu) {
  531. sources += skia_gpu_sources
  532. sources += skia_null_gpu_sources
  533. sources += skia_sksl_gpu_sources
  534. sources += skia_shared_gpu_sources
  535. if (skia_use_gl) {
  536. sources += skia_gl_gpu_sources
  537. }
  538. if (enable_vulkan) {
  539. sources += skia_vk_sources
  540. }
  541. deps += [ "//gpu/config:workaround_list" ]
  542. }
  543. if (skia_support_pdf) {
  544. deps += [
  545. "//third_party:freetype_harfbuzz",
  546. "//third_party/zlib",
  547. ]
  548. sources += skia_pdf_sources
  549. } else {
  550. sources += [ "//third_party/skia/src/pdf/SkDocument_PDF_None.cpp" ]
  551. }
  552. if (skia_support_skottie) {
  553. import("//third_party/skia/modules/skottie/skottie.gni")
  554. import("//third_party/skia/modules/skresources/skresources.gni")
  555. import("//third_party/skia/modules/sksg/sksg.gni")
  556. import("//third_party/skia/modules/skshaper/skshaper.gni")
  557. sources += skia_skottie_sources + skia_skottie_public
  558. sources += skia_skresources_sources
  559. sources += skia_sksg_sources
  560. sources += skia_shaper_primitive_sources
  561. }
  562. }
  563. # Template for things that are logically part of :skia, but need to be split out
  564. # so custom compile flags can be applied.
  565. #
  566. # These are all opted out of check_includes, due to (logically) being part of
  567. # skia.
  568. template("skia_source_set") {
  569. source_set(target_name) {
  570. forward_variables_from(invoker, "*")
  571. check_includes = false
  572. if (!is_debug) {
  573. configs -= [ "//build/config/compiler:default_optimization" ]
  574. configs += [ "//build/config/compiler:optimize_max" ]
  575. }
  576. configs -= [ "//build/config/compiler:chromium_code" ]
  577. configs += [
  578. ":skia_config",
  579. ":skia_library_config",
  580. "//build/config/compiler:no_chromium_code",
  581. ]
  582. public_configs = [ ":skia_config" ]
  583. # Android, the only user of mismatched sample files (for now), gets a small
  584. # binary size decrease by using AFDO to optimize for size in these
  585. # source_sets. However, that also comes at a relatively big performance
  586. # cost.
  587. if (using_mismatched_sample_profile) {
  588. configs -= [ "//build/config/compiler:afdo_optimize_size" ]
  589. }
  590. if (is_win) {
  591. cflags_cc = [
  592. "/std:c++17",
  593. "/wd5041", # out-of-line definition for constexpr static data member is
  594. # not needed and is deprecated in C++17
  595. ]
  596. } else {
  597. cflags_cc = [ "-std=c++17" ]
  598. }
  599. }
  600. }
  601. # Split out for targeted removal of the afdo_optimize_size config on Android.
  602. skia_source_set("skia_core_and_effects") {
  603. defines = []
  604. sources = skia_core_sources
  605. sources += skia_effects_sources
  606. sources += skia_effects_imagefilter_sources
  607. if (skia_support_gpu) {
  608. deps = [ "//gpu/config:workaround_list" ]
  609. }
  610. if (skia_use_dawn) {
  611. deps += [ "//third_party/dawn/include/dawn:cpp_headers" ]
  612. }
  613. visibility = [ ":skia" ]
  614. }
  615. # Bits that involve special vector-y hardware.
  616. if (current_cpu == "arm64") {
  617. skia_source_set("skia_opts_crc32") {
  618. sources = skia_opts.crc32_sources
  619. cflags = [ "-march=armv8-a+crc" ]
  620. visibility = [ ":skia_opts" ]
  621. }
  622. }
  623. if (current_cpu == "x86" || current_cpu == "x64") {
  624. skia_source_set("skia_opts_sse3") {
  625. sources = skia_opts.ssse3_sources
  626. if (!is_win || is_clang) {
  627. cflags = [ "-mssse3" ]
  628. }
  629. if (is_win) {
  630. defines = [ "SK_CPU_SSE_LEVEL=31" ]
  631. }
  632. visibility = [ ":skia_opts" ]
  633. }
  634. skia_source_set("skia_opts_sse41") {
  635. sources = skia_opts.sse41_sources
  636. if (!is_win || is_clang) {
  637. cflags = [ "-msse4.1" ]
  638. }
  639. if (is_win) {
  640. defines = [ "SK_CPU_SSE_LEVEL=41" ]
  641. }
  642. visibility = [ ":skia_opts" ]
  643. }
  644. skia_source_set("skia_opts_sse42") {
  645. sources = skia_opts.sse42_sources
  646. if (!is_win || is_clang) {
  647. cflags = [ "-msse4.2" ]
  648. }
  649. if (is_win) {
  650. defines = [ "SK_CPU_SSE_LEVEL=42" ]
  651. }
  652. visibility = [ ":skia_opts" ]
  653. }
  654. skia_source_set("skia_opts_avx") {
  655. sources = skia_opts.avx_sources
  656. if (!is_win) {
  657. cflags = [ "-mavx" ]
  658. }
  659. if (is_win) {
  660. cflags = [ "/arch:AVX" ]
  661. }
  662. visibility = [ ":skia_opts" ]
  663. }
  664. skia_source_set("skia_opts_hsw") {
  665. sources = skia_opts.hsw_sources
  666. if (!is_win) {
  667. cflags = [
  668. "-mavx2",
  669. "-mbmi",
  670. "-mbmi2",
  671. "-mf16c",
  672. "-mfma",
  673. ]
  674. }
  675. if (is_win) {
  676. cflags = [ "/arch:AVX2" ]
  677. }
  678. visibility = [ ":skia_opts" ]
  679. }
  680. skia_source_set("skia_opts_skx") {
  681. sources = skia_opts.skx_sources
  682. if (!is_win) {
  683. cflags = [ "-march=skylake-avx512" ]
  684. }
  685. if (is_win) {
  686. cflags = [ "/arch:AVX512" ]
  687. }
  688. visibility = [ ":skia_opts" ]
  689. }
  690. }
  691. skia_source_set("skia_opts") {
  692. cflags = []
  693. defines = []
  694. deps = [ "//base" ]
  695. if (current_cpu == "x86" || current_cpu == "x64") {
  696. sources = skia_opts.sse2_sources
  697. deps += [
  698. ":skia_opts_avx",
  699. ":skia_opts_hsw",
  700. ":skia_opts_skx",
  701. ":skia_opts_sse3",
  702. ":skia_opts_sse41",
  703. ":skia_opts_sse42",
  704. ]
  705. } else if (current_cpu == "arm") {
  706. # The assembly uses the frame pointer register (r7 in Thumb/r11 in
  707. # ARM), the compiler doesn't like that.
  708. if (!is_ios) {
  709. cflags += [ "-fomit-frame-pointer" ]
  710. }
  711. if (arm_version >= 7) {
  712. sources = skia_opts.armv7_sources
  713. if (arm_use_neon || arm_optionally_use_neon) {
  714. sources += skia_opts.neon_sources
  715. # Root build config sets -mfpu=$arm_fpu, which we expect to be neon
  716. # when running this.
  717. if (!arm_use_neon) {
  718. configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
  719. cflags += [ "-mfpu=neon" ]
  720. }
  721. }
  722. } else {
  723. sources = skia_opts.none_sources
  724. }
  725. } else if (current_cpu == "arm64") {
  726. sources = skia_opts.arm64_sources
  727. deps += [ ":skia_opts_crc32" ]
  728. } else if (current_cpu == "mipsel") {
  729. cflags += [ "-fomit-frame-pointer" ]
  730. if (mips_dsp_rev >= 1) {
  731. sources = skia_opts.mips_dsp_sources
  732. } else {
  733. sources = skia_opts.none_sources
  734. }
  735. } else if (current_cpu == "mips64el") {
  736. cflags += [ "-fomit-frame-pointer" ]
  737. sources = skia_opts.none_sources
  738. } else if (current_cpu == "ppc64") {
  739. sources = skia_opts.none_sources
  740. } else if (current_cpu == "s390x") {
  741. sources = skia_opts.none_sources
  742. } else if (current_cpu == "riscv64") {
  743. sources = skia_opts.none_sources
  744. } else {
  745. assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp")
  746. }
  747. visibility = [ ":skia" ]
  748. }
  749. # Split out metal sources, because they require ARC.
  750. if (is_mac) {
  751. skia_source_set("skia_metal") {
  752. defines = [ "SK_METAL" ]
  753. sources = skia_metal_sources
  754. cflags_objcc = [
  755. "-Wno-unguarded-availability",
  756. "-fobjc-arc",
  757. ]
  758. deps = [ "//gpu/config:workaround_list" ]
  759. if (skia_use_dawn) {
  760. deps += [ "//third_party/dawn/include/dawn:cpp_headers" ]
  761. }
  762. }
  763. }
  764. # Font copies.
  765. if (is_fuchsia) {
  766. copy("copy_fuchsia_fonts_manifest") {
  767. sources = [ "ext/data/test_fonts/fuchsia_test_fonts_manifest.json" ]
  768. outputs = [ "$root_out_dir/test_fonts/all.font_manifest.json" ]
  769. }
  770. }
  771. if (is_apple) {
  772. bundle_data("test_fonts_bundle_data") {
  773. public_deps = [ "//third_party/test_fonts" ]
  774. sources = [
  775. "$root_out_dir/test_fonts/Ahem.ttf",
  776. "ext/data/test_fonts/ChromiumAATTest.ttf",
  777. ]
  778. outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
  779. }
  780. }
  781. group("test_fonts_resources") {
  782. testonly = true
  783. deps = []
  784. data_deps = []
  785. if (is_apple) {
  786. deps += [ ":test_fonts_bundle_data" ]
  787. data_deps += [ ":test_fonts_bundle_data" ]
  788. } else {
  789. deps += [ "//third_party/test_fonts" ]
  790. data_deps += [ "//third_party/test_fonts" ]
  791. }
  792. if (is_fuchsia) {
  793. deps += [ ":copy_fuchsia_fonts_manifest" ]
  794. data_deps += [ ":copy_fuchsia_fonts_manifest" ]
  795. }
  796. }
  797. source_set("test_fonts") {
  798. testonly = true
  799. deps = [ ":test_fonts_resources" ]
  800. if (is_fuchsia) {
  801. public = [
  802. "ext/test_fonts.h",
  803. "ext/test_fonts_fuchsia.h",
  804. ]
  805. sources = [
  806. "ext/test_fonts_fuchsia.cc",
  807. "ext/test_fonts_fuchsia_cfv1.cc",
  808. ]
  809. public_deps = [ "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.fonts" ]
  810. deps += [
  811. "//base",
  812. "//skia",
  813. "//third_party/abseil-cpp:absl",
  814. "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.io",
  815. "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.sys",
  816. "//third_party/fuchsia-sdk/sdk/pkg/fidl_cpp_base",
  817. "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
  818. ]
  819. }
  820. if (is_mac) {
  821. public = [ "ext/test_fonts.h" ]
  822. sources = [ "ext/test_fonts_mac.mm" ]
  823. deps += [ "//base" ]
  824. }
  825. }
  826. # Fuchsia components that use the test fonts must include
  827. # "//build/config/fuchsia/test/test_fonts.shard.test-cml" in their
  828. # `additional_manifest_fragments`.
  829. # TODO(https://crbug.com/1287051): Once all consumers are migrated to CFv2,
  830. # move the `is_fuchsia` section below up into `test_fonts` above and remove this
  831. # target.
  832. source_set("test_fonts_cfv2") {
  833. testonly = true
  834. deps = [ ":test_fonts_resources" ]
  835. if (is_fuchsia) {
  836. public = [
  837. "ext/test_fonts.h",
  838. "ext/test_fonts_fuchsia.h",
  839. ]
  840. sources = [
  841. "ext/test_fonts_fuchsia.cc",
  842. "ext/test_fonts_fuchsia_cfv2.cc",
  843. ]
  844. public_deps = [ "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.fonts" ]
  845. deps += [
  846. "//base",
  847. "//skia",
  848. "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
  849. ]
  850. }
  851. }
  852. test("skia_unittests") {
  853. sources = [
  854. "ext/convolver_unittest.cc",
  855. "ext/image_operations_unittest.cc",
  856. "ext/platform_canvas_unittest.cc",
  857. "ext/recursive_gaussian_convolution_unittest.cc",
  858. "ext/skia_memory_dump_provider_unittest.cc",
  859. "ext/skia_utils_base_unittest.cc",
  860. ]
  861. if (is_ios) {
  862. sources += [ "ext/skia_utils_ios_unittest.mm" ]
  863. }
  864. if (is_mac) {
  865. sources += [ "ext/skia_utils_mac_unittest.mm" ]
  866. }
  867. if (!is_win) {
  868. sources -= [ "ext/platform_canvas_unittest.cc" ]
  869. }
  870. deps = [
  871. ":skia",
  872. "//base",
  873. "//base/test:test_support",
  874. "//mojo/core/test:run_all_unittests",
  875. "//testing/gtest",
  876. "//ui/gfx",
  877. "//ui/gfx/geometry",
  878. ]
  879. data_deps = [ "//testing/buildbot/filters:skia_unittests_filters" ]
  880. if (!is_ios) {
  881. sources += [ "public/mojom/test/mojom_traits_unittest.cc" ]
  882. deps += [
  883. "//mojo/public/cpp/bindings",
  884. "//mojo/public/cpp/test_support:test_utils",
  885. "//skia/public/mojom",
  886. ]
  887. }
  888. if (is_fuchsia) {
  889. use_cfv1 = false
  890. sources += [ "ext/fontmgr_fuchsia_unittest.cc" ]
  891. deps += [
  892. ":test_fonts_cfv2",
  893. "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.fonts",
  894. ]
  895. additional_manifest_fragments =
  896. [ "//build/config/fuchsia/test/test_fonts.shard.test-cml" ]
  897. } else {
  898. deps += [ ":test_fonts" ]
  899. }
  900. if (skia_support_skottie) {
  901. sources += [ "ext/skottie_unittest.cc" ]
  902. }
  903. }
  904. if (!is_ios) {
  905. executable("image_operations_bench") {
  906. sources = [ "ext/image_operations_bench.cc" ]
  907. deps = [
  908. ":skia",
  909. "//base",
  910. "//build/win:default_exe_manifest",
  911. ]
  912. }
  913. executable("filter_fuzz_stub") {
  914. testonly = true
  915. sources = [ "tools/filter_fuzz_stub/filter_fuzz_stub.cc" ]
  916. deps = [
  917. ":skia",
  918. "//base",
  919. "//base/test:test_support",
  920. "//build/win:default_exe_manifest",
  921. ]
  922. }
  923. }
  924. group("fuzzers") {
  925. deps = [ "//skia/tools/fuzzers" ]
  926. }
  927. grit("skia_resources") {
  928. source = "skia_resources.grd"
  929. outputs = [
  930. "grit/skia_resources.h",
  931. "grit/skia_resources_map.cc",
  932. "grit/skia_resources_map.h",
  933. "skia_resources.pak",
  934. ]
  935. deps = [
  936. "//skia/public/mojom:mojom_js",
  937. "//skia/public/mojom:mojom_webui_js",
  938. ]
  939. }