BUILD.gn 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  1. # Copyright 2019 The ANGLE Project 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 the use_x11 variable
  5. import("//build/config/linux/pkg_config.gni")
  6. import("//build/config/ui.gni")
  7. import("//testing/libfuzzer/fuzzer_test.gni")
  8. import("gni/angle.gni")
  9. if (is_android) {
  10. # android/rules.gni can only be imported for Android targets
  11. import("//build/config/android/config.gni")
  12. import("//build/config/android/rules.gni")
  13. import("android/angle_apk.gni")
  14. }
  15. declare_args() {
  16. # Use the PCI lib to collect GPU information on Linux.
  17. use_libpci = is_linux && (!is_chromecast || is_cast_desktop_build) &&
  18. (use_x11 || use_ozone)
  19. # Link in system libGL, to work with apitrace. See doc/DebuggingTips.md.
  20. angle_link_glx = false
  21. }
  22. if (!build_with_chromium) {
  23. group("all") {
  24. testonly = true
  25. deps = [
  26. ":angle_shader_translator",
  27. ":translator_fuzzer",
  28. ":xxhash_fuzzer",
  29. "//samples:all",
  30. "//src/tests:all",
  31. ]
  32. }
  33. }
  34. if (ozone_platform_gbm) {
  35. pkg_config("libdrm") {
  36. packages = [ "libdrm" ]
  37. }
  38. }
  39. angle_git_is_present = exec_script("src/commit_id.py",
  40. [
  41. "check",
  42. rebase_path(".", root_build_dir),
  43. ],
  44. "value")
  45. angle_use_commit_id = angle_git_is_present == 1
  46. import("src/compiler.gni")
  47. import("src/libGLESv2.gni")
  48. # This config is exported to dependent targets (and also applied to internal
  49. # ones).
  50. config("external_config") {
  51. include_dirs = [ "include" ]
  52. }
  53. # Prevent the GL headers from redeclaring ANGLE entry points.
  54. config("no_gl_prototypes") {
  55. defines = [
  56. "GL_GLES_PROTOTYPES=0",
  57. "EGL_EGL_PROTOTYPES=0",
  58. ]
  59. }
  60. config("gl_prototypes") {
  61. defines = [
  62. "GL_GLES_PROTOTYPES=1",
  63. "EGL_EGL_PROTOTYPES=1",
  64. "GL_GLEXT_PROTOTYPES",
  65. "EGL_EGLEXT_PROTOTYPES",
  66. ]
  67. }
  68. # This config is applied to internal Angle targets (not pushed to dependents).
  69. config("internal_config") {
  70. include_dirs = [
  71. "include",
  72. "src",
  73. ]
  74. defines = []
  75. if (angle_64bit_current_cpu) {
  76. defines += [ "ANGLE_IS_64_BIT_CPU" ]
  77. } else {
  78. defines += [ "ANGLE_IS_32_BIT_CPU" ]
  79. }
  80. if (angle_enable_vulkan) {
  81. if (angle_enable_vulkan_gpu_trace_events) {
  82. defines += [ "ANGLE_ENABLE_VULKAN_GPU_TRACE_EVENTS=1" ]
  83. }
  84. }
  85. if (angle_enable_trace) {
  86. defines += [ "ANGLE_ENABLE_DEBUG_TRACE=1" ]
  87. }
  88. }
  89. config("extra_warnings") {
  90. cflags = []
  91. # Enable more default warnings on Windows.
  92. if (is_win) {
  93. cflags += [
  94. "/we4244", # Conversion: possible loss of data.
  95. "/we4456", # Variable shadowing.
  96. "/we4458", # declaration hides class member.
  97. "/we4715", # not all control paths return a value
  98. "/we4800", # forcing value to bool.
  99. "/we4838", # narrowing conversion.
  100. ]
  101. }
  102. if (is_clang) {
  103. cflags += [
  104. # Enable after anglebug.com/3128 is fixed.
  105. # "-Wextra-semi-stmt",
  106. "-Wnon-virtual-dtor",
  107. "-Wunneeded-internal-declaration",
  108. ]
  109. }
  110. }
  111. # This config adds build-ids to the associated library.
  112. # -Wl is a special option that indicates that clang should pass the associated
  113. # option --build-id to the linker. This will cause a build-id section to be added
  114. # to the associated library. The build-id makes it possible for a debugger to
  115. # find the right symbol file to use.
  116. config("build_id_config") {
  117. ldflags = [ "-Wl,--build-id" ]
  118. }
  119. # Useful for more informative stack traces.
  120. config("better_linux_stack_traces") {
  121. if (angle_better_stack_traces) {
  122. ldflags = [ "-Wl,--export-dynamic" ]
  123. }
  124. }
  125. # Windows ARM64 is available since 10.0.16299 so no need to copy
  126. # d3dcompiler_47.dll because this file is available as inbox.
  127. if (is_win && target_cpu != "arm64") {
  128. # We also ship an older DLL for compatiblity with Windows 7 machines without
  129. # the UCRT. This DLL isn't available in the standard SDK distribution.
  130. _old_compiler = "$windows_sdk_path/Redist/D3D/$target_cpu/d3dcompiler_old.dll"
  131. _has_old_compiler =
  132. exec_script("scripts/file_exists.py", [ _old_compiler ], "value")
  133. copy("copy_compiler_dll") {
  134. sources = [
  135. "$windows_sdk_path/Redist/D3D/$target_cpu/d3dcompiler_47.dll",
  136. ]
  137. if (_has_old_compiler) {
  138. sources += [ _old_compiler ]
  139. }
  140. outputs = [
  141. "$root_out_dir/{{source_file_part}}",
  142. ]
  143. }
  144. }
  145. # Holds the shared includes so we only need to list them once.
  146. config("includes_config") {
  147. include_dirs = [ "include" ]
  148. }
  149. angle_source_set("includes") {
  150. sources = libangle_includes
  151. public_configs = [ ":includes_config" ]
  152. }
  153. angle_static_library("preprocessor") {
  154. sources = angle_preprocessor_sources
  155. public_deps = [
  156. ":angle_common",
  157. ]
  158. }
  159. config("angle_disable_pool_alloc") {
  160. defines = [ "ANGLE_DISABLE_POOL_ALLOC" ]
  161. }
  162. config("debug_annotations_config") {
  163. if (is_debug) {
  164. defines = [ "ANGLE_ENABLE_DEBUG_ANNOTATIONS" ]
  165. }
  166. }
  167. config("angle_release_asserts_config") {
  168. if (dcheck_always_on) {
  169. defines = [ "ANGLE_ENABLE_RELEASE_ASSERTS" ]
  170. }
  171. }
  172. config("angle_common_config") {
  173. include_dirs = [ "src/common/third_party/base" ]
  174. if (is_android) {
  175. libs = [ "log" ]
  176. }
  177. }
  178. if (is_win) {
  179. angle_source_set("angle_stack_walker") {
  180. sources = [
  181. "util/windows/third_party/StackWalker/src/StackWalker.cpp",
  182. "util/windows/third_party/StackWalker/src/StackWalker.h",
  183. ]
  184. if (is_clang) {
  185. cflags_cc = [
  186. "-Wno-c++98-compat-extra-semi",
  187. "-Wno-missing-declarations",
  188. "-Wno-switch",
  189. ]
  190. } else {
  191. cflags_cc = [ "/wd4740" ]
  192. }
  193. }
  194. }
  195. angle_source_set("angle_system_utils") {
  196. sources = angle_system_utils_sources
  197. }
  198. angle_source_set("xxhash") {
  199. sources = xxhash_sources
  200. configs -= [ "${angle_root}:extra_warnings" ]
  201. }
  202. fuzzer_test("xxhash_fuzzer") {
  203. sources = [
  204. "src/common/third_party/xxhash/xxhash_fuzzer.cpp",
  205. ]
  206. deps = [
  207. ":xxhash",
  208. ]
  209. }
  210. angle_static_library("angle_common") {
  211. sources = libangle_common_sources
  212. configs += [
  213. ":angle_common_config",
  214. ":debug_annotations_config",
  215. ]
  216. deps = [
  217. ":xxhash",
  218. ]
  219. public_deps = [
  220. ":angle_system_utils",
  221. ":angle_version",
  222. ":includes",
  223. ]
  224. public_configs += [ ":angle_common_config" ]
  225. all_dependent_configs = [ ":angle_release_asserts_config" ]
  226. if (use_fuzzing_engine) {
  227. all_dependent_configs += [ ":angle_disable_pool_alloc" ]
  228. }
  229. }
  230. config("angle_image_util_config") {
  231. include_dirs = [
  232. "include",
  233. "src",
  234. ]
  235. }
  236. angle_static_library("angle_image_util") {
  237. sources = libangle_image_util_sources
  238. public_configs += [ ":angle_image_util_config" ]
  239. public_deps = [
  240. ":angle_common",
  241. ]
  242. }
  243. config("angle_gl_visibility_config") {
  244. if (is_win) {
  245. defines = [
  246. "GL_APICALL=",
  247. "GL_API=",
  248. ]
  249. } else {
  250. defines = [
  251. "GL_APICALL=__attribute__((visibility(\"default\")))",
  252. "GL_API=__attribute__((visibility(\"default\")))",
  253. ]
  254. }
  255. }
  256. config("angle_gpu_info_util_config") {
  257. include_dirs = [
  258. "include",
  259. "src",
  260. ]
  261. }
  262. angle_static_library("angle_gpu_info_util") {
  263. public_configs += [
  264. ":angle_gpu_info_util_config",
  265. ":angle_backend_config",
  266. ]
  267. public_deps = [
  268. ":angle_common",
  269. ]
  270. sources = libangle_gpu_info_util_sources
  271. deps = []
  272. libs = []
  273. defines = []
  274. if (is_android) {
  275. sources += [ "src/gpu_info_util/SystemInfo_android.cpp" ]
  276. }
  277. if (is_win) {
  278. sources += libangle_gpu_info_util_win_sources
  279. libs += [ "setupapi.lib" ]
  280. libs += [ "dxgi.lib" ]
  281. }
  282. if (is_linux || is_fuchsia) {
  283. sources += libangle_gpu_info_util_linux_sources
  284. if (use_x11) {
  285. sources += libangle_gpu_info_util_x11_sources
  286. deps += [ "src/third_party/libXNVCtrl:libXNVCtrl" ]
  287. defines += [ "GPU_INFO_USE_X11" ]
  288. libs += [
  289. "X11",
  290. "Xi",
  291. "Xext",
  292. ]
  293. }
  294. }
  295. if (use_libpci) {
  296. sources += libangle_gpu_info_util_libpci_sources
  297. defines += [ "GPU_INFO_USE_LIBPCI" ]
  298. libs += [ "pci" ]
  299. }
  300. if (is_mac) {
  301. sources += libangle_gpu_info_util_mac_sources
  302. libs += [
  303. "IOKit.framework",
  304. "CoreFoundation.framework",
  305. "CoreGraphics.framework",
  306. ]
  307. }
  308. }
  309. angle_static_library("translator") {
  310. sources = angle_translator_sources
  311. defines = []
  312. if (angle_enable_essl || use_fuzzing_engine) {
  313. sources += angle_translator_essl_sources
  314. defines += [ "ANGLE_ENABLE_ESSL" ]
  315. }
  316. if (angle_enable_glsl || use_fuzzing_engine) {
  317. sources += angle_translator_glsl_sources
  318. defines += [ "ANGLE_ENABLE_GLSL" ]
  319. }
  320. if (angle_enable_hlsl || use_fuzzing_engine) {
  321. sources += angle_translator_hlsl_sources
  322. defines += [ "ANGLE_ENABLE_HLSL" ]
  323. }
  324. if (angle_enable_vulkan || use_fuzzing_engine) {
  325. sources += angle_translator_lib_vulkan_sources
  326. defines += [ "ANGLE_ENABLE_VULKAN" ]
  327. }
  328. public_configs += [ ":external_config" ]
  329. deps = [
  330. ":includes",
  331. ":preprocessor",
  332. ]
  333. public_deps = [
  334. ":angle_common",
  335. ]
  336. if (is_win) {
  337. # Necessary to suppress some system header xtree warnigns in Release.
  338. # For some reason this warning doesn't get triggered in Chromium
  339. cflags = [ "/wd4718" ]
  340. }
  341. }
  342. angle_source_set("translator_fuzzer") {
  343. sources = [
  344. "src/compiler/fuzz/translator_fuzzer.cpp",
  345. ]
  346. include_dirs = [
  347. "include",
  348. "src",
  349. ]
  350. deps = [
  351. ":translator",
  352. ]
  353. }
  354. config("commit_id_config") {
  355. include_dirs = [ "$root_gen_dir/angle" ]
  356. visibility = [ ":commit_id" ]
  357. }
  358. commit_id_output_file = "$root_gen_dir/angle/id/commit.h"
  359. if (angle_use_commit_id) {
  360. action("commit_id") {
  361. script = "src/commit_id.py"
  362. outputs = [
  363. commit_id_output_file,
  364. ]
  365. # commit id should depend on angle's HEAD revision
  366. inputs = [
  367. ".git/HEAD",
  368. ]
  369. args = [
  370. "gen",
  371. rebase_path(".", root_build_dir),
  372. rebase_path(commit_id_output_file, root_build_dir),
  373. ]
  374. public_configs = [ ":commit_id_config" ]
  375. }
  376. } else {
  377. copy("commit_id") {
  378. sources = [
  379. "src/commit.h",
  380. ]
  381. outputs = [
  382. commit_id_output_file,
  383. ]
  384. public_configs = [ ":commit_id_config" ]
  385. }
  386. }
  387. angle_source_set("angle_version") {
  388. sources = [
  389. "src/common/version.h",
  390. ]
  391. public_deps = [
  392. ":commit_id",
  393. ]
  394. }
  395. config("angle_backend_config") {
  396. defines = []
  397. if (angle_enable_d3d9) {
  398. defines += [ "ANGLE_ENABLE_D3D9" ]
  399. }
  400. if (angle_enable_d3d11) {
  401. defines += [ "ANGLE_ENABLE_D3D11" ]
  402. }
  403. if (angle_enable_gl) {
  404. defines += [ "ANGLE_ENABLE_OPENGL" ]
  405. if (use_x11) {
  406. defines += [ "ANGLE_USE_X11" ]
  407. }
  408. if (angle_enable_gl_null) {
  409. defines += [ "ANGLE_ENABLE_OPENGL_NULL" ]
  410. }
  411. }
  412. if (angle_enable_vulkan) {
  413. defines += [ "ANGLE_ENABLE_VULKAN" ]
  414. if (angle_enable_custom_vulkan_cmd_buffers) {
  415. defines += [ "ANGLE_USE_CUSTOM_VULKAN_CMD_BUFFERS=1" ]
  416. }
  417. }
  418. if (angle_enable_null) {
  419. defines += [ "ANGLE_ENABLE_NULL" ]
  420. }
  421. }
  422. config("libANGLE_config") {
  423. cflags = []
  424. defines = []
  425. libs = []
  426. ldflags = []
  427. if (angle_enable_d3d9) {
  428. ldflags += [ "/DELAYLOAD:d3d9.dll" ]
  429. }
  430. defines += [ "LIBANGLE_IMPLEMENTATION" ]
  431. if (is_win) {
  432. cflags += [ "/wd4530" ] # C++ exception handler used, but unwind semantics are not enabled.
  433. }
  434. if (is_android && (angle_enable_gl || angle_enable_vulkan)) {
  435. # In API level 26 ANativeWindow APIs were moved from libandroid.so
  436. # into a separate library, libnativewindow.so
  437. if (ndk_api_level_at_least_26) {
  438. libs += [ "nativewindow" ]
  439. } else {
  440. libs += [ "android" ]
  441. }
  442. }
  443. }
  444. if (angle_enable_vulkan) {
  445. config("vulkan_config") {
  446. if (is_android) {
  447. libs = [ "vulkan" ]
  448. }
  449. }
  450. # Use this target to include everything ANGLE needs for Vulkan.
  451. group("angle_vulkan") {
  452. public_deps = [
  453. "$angle_root/third_party/vulkan-headers:vulkan_headers",
  454. ]
  455. public_configs = [ ":vulkan_config" ]
  456. data_deps = []
  457. if (!is_android && !is_fuchsia) {
  458. deps = [
  459. "$angle_root/third_party/vulkan-loader:libvulkan",
  460. ]
  461. data_deps += [ "$angle_root/third_party/vulkan-tools:VkICD_mock_icd" ]
  462. public_configs +=
  463. [ "$angle_root/third_party/vulkan-loader:vulkan_loader_config" ]
  464. }
  465. if (is_fuchsia) {
  466. public_deps += [
  467. "$angle_root/src/common/fuchsia_egl",
  468. "//third_party/fuchsia-sdk:vulkan_base",
  469. "//third_party/fuchsia-sdk/sdk:vulkan",
  470. ]
  471. }
  472. if (angle_enable_vulkan_validation_layers) {
  473. if (is_fuchsia) {
  474. deps = [
  475. "//third_party/fuchsia-sdk:vulkan_validation",
  476. ]
  477. } else {
  478. data_deps += [ "$angle_root/third_party/vulkan-validation-layers:vulkan_validation_layers" ]
  479. if (!is_android) {
  480. data_deps += [ "$angle_root/third_party/vulkan-validation-layers:vulkan_gen_json_files" ]
  481. }
  482. }
  483. }
  484. }
  485. }
  486. angle_source_set("libANGLE") {
  487. sources = libangle_sources
  488. include_dirs = []
  489. libs = []
  490. defines = []
  491. if (angle_link_glx) {
  492. libs += [ "GL" ]
  493. defines += [ "ANGLE_LINK_GLX" ]
  494. }
  495. public_deps = [
  496. ":angle_common",
  497. ":angle_gpu_info_util",
  498. ":angle_version",
  499. ":translator",
  500. ]
  501. deps = [
  502. ":angle_image_util",
  503. ":includes",
  504. ]
  505. # Enable extra Chromium style warnings for libANGLE.
  506. if (is_clang) {
  507. suppressed_configs -= [ "//build/config/clang:find_bad_constructs" ]
  508. }
  509. # Shared D3D sources.
  510. if (angle_enable_d3d9 || angle_enable_d3d11) {
  511. sources += libangle_d3d_shared_sources
  512. defines += [ "ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ " + "\"d3dcompiler_47.dll\", \"d3dcompiler_46.dll\", \"d3dcompiler_43.dll\" }" ]
  513. }
  514. if (angle_enable_d3d9) {
  515. sources += libangle_d3d9_sources
  516. libs += [ "d3d9.lib" ]
  517. }
  518. if (angle_enable_d3d11) {
  519. sources += libangle_d3d11_sources
  520. sources += libangle_d3d11_win32_sources
  521. libs += [ "dxguid.lib" ]
  522. import("src/libANGLE/renderer/d3d/d3d11/d3d11_blit_shaders_autogen.gni")
  523. sources += libangle_d3d11_blit_shaders
  524. }
  525. if (angle_enable_gl) {
  526. sources += libangle_gl_sources
  527. include_dirs += [ "src/third_party/khronos" ]
  528. if (angle_enable_gl_null) {
  529. sources += libangle_gl_null_sources
  530. }
  531. if (is_win) {
  532. sources += libangle_gl_wgl_sources
  533. }
  534. if (use_x11) {
  535. sources += libangle_gl_glx_sources
  536. deps += [ "src/third_party/libXNVCtrl:libXNVCtrl" ]
  537. libs += [
  538. "X11",
  539. "Xi",
  540. "Xext",
  541. ]
  542. }
  543. if (is_mac) {
  544. sources += libangle_gl_cgl_sources
  545. libs += [
  546. "Cocoa.framework",
  547. "IOSurface.framework",
  548. "OpenGL.framework",
  549. "QuartzCore.framework",
  550. ]
  551. }
  552. if (is_android) {
  553. sources += libangle_gl_egl_sources
  554. sources += libangle_gl_egl_dl_sources
  555. sources += libangle_gl_egl_android_sources
  556. }
  557. if (ozone_platform_gbm) {
  558. configs += [ ":libdrm" ]
  559. defines += [ "ANGLE_USE_OZONE" ]
  560. deps += [ "//third_party/minigbm" ]
  561. sources += libangle_gl_egl_sources
  562. sources += libangle_gl_egl_dl_sources
  563. sources += libangle_gl_ozone_sources
  564. }
  565. }
  566. if (angle_enable_vulkan) {
  567. sources += libangle_vulkan_sources
  568. if (is_win) {
  569. sources += libangle_vulkan_win32_sources
  570. }
  571. if (is_linux) {
  572. sources += libangle_vulkan_xcb_sources
  573. }
  574. if (is_fuchsia) {
  575. sources += libangle_vulkan_fuchsia_sources
  576. deps += [
  577. "$angle_root/src/common/fuchsia_egl",
  578. "$angle_root/src/common/fuchsia_egl:backend",
  579. ]
  580. }
  581. if (is_android) {
  582. sources += libangle_vulkan_android_sources
  583. libs += [ "vulkan" ]
  584. }
  585. deps += [
  586. ":angle_vulkan",
  587. "${angle_glslang_dir}:glslang_default_resource_limits_sources",
  588. "${angle_glslang_dir}:glslang_sources",
  589. "${angle_spirv_tools_dir}:spvtools_val",
  590. ]
  591. public_deps += [ "$angle_root/third_party/vulkan-headers:vulkan_headers" ]
  592. # Include generated shaders.
  593. import("src/libANGLE/renderer/vulkan/vk_internal_shaders_autogen.gni")
  594. sources += angle_vulkan_internal_shaders
  595. }
  596. if (angle_enable_null) {
  597. sources += libangle_null_sources
  598. }
  599. if (is_mac) {
  600. sources += libangle_mac_sources
  601. }
  602. if (is_debug) {
  603. defines += [ "ANGLE_GENERATE_SHADER_DEBUG_INFO" ]
  604. }
  605. configs += [ ":debug_annotations_config" ]
  606. public_configs += [
  607. ":libANGLE_config",
  608. ":angle_backend_config",
  609. ]
  610. # Windows ARM64 is available since 10.0.16299 so no need to copy
  611. # d3dcompiler_47.dll because this file is available as inbox.
  612. if (is_win && target_cpu != "arm64") {
  613. data_deps = [
  614. ":copy_compiler_dll",
  615. ]
  616. }
  617. }
  618. angle_source_set("libANGLE_with_capture") {
  619. public_deps = [
  620. ":libANGLE",
  621. ]
  622. sources = libangle_capture_sources
  623. }
  624. config("shared_library_public_config") {
  625. if (is_mac && !is_component_build) {
  626. # Executable targets that depend on the shared libraries below need to have
  627. # the rpath setup in non-component build configurations.
  628. ldflags = [
  629. "-rpath",
  630. "@executable_path/",
  631. ]
  632. }
  633. }
  634. config("library_name_config") {
  635. defines = [
  636. "ANGLE_EGL_LIBRARY_NAME=\"libEGL${angle_libs_suffix}\"",
  637. "ANGLE_GLESV2_LIBRARY_NAME=\"libGLESv2${angle_libs_suffix}\"",
  638. ]
  639. }
  640. # This config controls export definitions on ANGLE API calls.
  641. config("angle_static") {
  642. defines = [
  643. "ANGLE_EXPORT=",
  644. "ANGLE_UTIL_EXPORT=",
  645. "EGLAPI=",
  646. "GL_APICALL=",
  647. "GL_API=",
  648. ]
  649. }
  650. template("angle_libGLESv2") {
  651. angle_shared_library(target_name) {
  652. sources = libglesv2_sources
  653. output_name = "${target_name}${angle_libs_suffix}"
  654. if (is_win) {
  655. sources += [ "src/libGLESv2/${target_name}_autogen.def" ]
  656. }
  657. configs += [
  658. ":angle_gl_visibility_config",
  659. ":debug_annotations_config",
  660. ":gl_prototypes",
  661. ]
  662. defines = [ "LIBGLESV2_IMPLEMENTATION" ] + invoker.defines
  663. deps = [
  664. ":includes",
  665. invoker.libANGLE,
  666. ]
  667. public_deps = [
  668. ":angle_version",
  669. ]
  670. }
  671. }
  672. angle_libGLESv2("libGLESv2") {
  673. libANGLE = ":libANGLE"
  674. defines = [ "ANGLE_CAPTURE_ENABLED=0" ]
  675. }
  676. angle_libGLESv2("libGLESv2_with_capture") {
  677. libANGLE = ":libANGLE_with_capture"
  678. defines = [ "ANGLE_CAPTURE_ENABLED=1" ]
  679. }
  680. if (is_win) {
  681. angle_shared_library("libGL") {
  682. sources = libgl_sources
  683. output_name = "openGL32"
  684. output_dir = "$root_out_dir/angle_libs"
  685. configs += [
  686. ":angle_gl_visibility_config",
  687. ":debug_annotations_config",
  688. ":gl_prototypes",
  689. ]
  690. defines = [
  691. "ANGLE_CAPTURE_ENABLED=0",
  692. "LIBGL_IMPLEMENTATION",
  693. ]
  694. deps = [
  695. ":includes",
  696. ":libANGLE",
  697. ]
  698. public_deps = [
  699. ":angle_version",
  700. ]
  701. }
  702. }
  703. angle_static_library("libGLESv2_static") {
  704. sources = libglesv2_sources
  705. configs += [ ":debug_annotations_config" ]
  706. public_configs += [ ":angle_static" ]
  707. deps = [
  708. ":includes",
  709. ]
  710. public_deps = [
  711. ":libANGLE",
  712. ]
  713. }
  714. angle_shared_library("libGLESv1_CM") {
  715. sources = libglesv1_cm_sources
  716. output_name = "libGLESv1_CM${angle_libs_suffix}"
  717. configs += [
  718. ":angle_gl_visibility_config",
  719. ":debug_annotations_config",
  720. ":gl_prototypes",
  721. ]
  722. defines = []
  723. deps = [
  724. ":includes",
  725. ":libGLESv2",
  726. ]
  727. }
  728. angle_static_library("libGLESv1_CM_static") {
  729. sources = libglesv1_cm_sources
  730. configs += [ ":debug_annotations_config" ]
  731. public_configs += [ ":angle_static" ]
  732. deps = [
  733. ":includes",
  734. ":libGLESv2_static",
  735. ]
  736. }
  737. config("libEGL_egl_loader_config") {
  738. defines = [ "ANGLE_USE_EGL_LOADER" ]
  739. }
  740. angle_source_set("libEGL_egl_loader") {
  741. sources = [
  742. "src/libEGL/egl_loader_autogen.cpp",
  743. "src/libEGL/egl_loader_autogen.h",
  744. ]
  745. public_configs += [
  746. ":libEGL_egl_loader_config",
  747. ":gl_prototypes",
  748. ]
  749. deps = [
  750. ":includes",
  751. ]
  752. }
  753. angle_shared_library("libEGL") {
  754. sources = libegl_sources
  755. output_name = "libEGL${angle_libs_suffix}"
  756. configs += [
  757. ":debug_annotations_config",
  758. ":library_name_config",
  759. ]
  760. defines = [ "LIBEGL_IMPLEMENTATION" ]
  761. if (is_win) {
  762. defines += [ "EGLAPI=" ]
  763. } else {
  764. defines += [ "EGLAPI=__attribute__((visibility(\"default\")))" ]
  765. }
  766. if (is_win) {
  767. sources += [ "src/libEGL/libEGL.def" ]
  768. }
  769. deps = [
  770. ":angle_system_utils",
  771. ":angle_version",
  772. ":libEGL_egl_loader",
  773. ]
  774. public_deps = [
  775. ":includes",
  776. ]
  777. data_deps = [
  778. ":libGLESv2",
  779. ]
  780. }
  781. angle_static_library("libEGL_static") {
  782. sources = libegl_sources
  783. configs += [
  784. ":debug_annotations_config",
  785. ":library_name_config",
  786. ]
  787. public_configs += [ ":angle_static" ]
  788. deps = [
  789. ":includes",
  790. ":libGLESv2_static",
  791. ]
  792. }
  793. import("util/util.gni")
  794. config("angle_util_loader_config") {
  795. defines = [ "ANGLE_USE_UTIL_LOADER" ]
  796. }
  797. angle_source_set("angle_util_loader_headers") {
  798. sources = [
  799. "util/egl_loader_autogen.h",
  800. "util/gles_loader_autogen.h",
  801. "util/util_export.h",
  802. ]
  803. if (is_win) {
  804. sources += [ "util/windows/wgl_loader_autogen.h" ]
  805. }
  806. public_deps = [
  807. ":includes",
  808. ]
  809. }
  810. angle_source_set("angle_util_loader") {
  811. defines = [ "LIBANGLE_UTIL_IMPLEMENTATION" ]
  812. sources = [
  813. "util/egl_loader_autogen.cpp",
  814. "util/gles_loader_autogen.cpp",
  815. ]
  816. if (is_win) {
  817. sources += [ "util/windows/wgl_loader_autogen.cpp" ]
  818. }
  819. deps = [
  820. ":angle_util_loader_headers",
  821. ]
  822. public_configs += [
  823. ":angle_util_config",
  824. ":angle_util_loader_config",
  825. ":no_gl_prototypes",
  826. ]
  827. }
  828. config("angle_util_config") {
  829. include_dirs = [ "." ]
  830. if (is_linux && use_x11) {
  831. libs = [ "X11" ]
  832. }
  833. }
  834. foreach(is_shared_library,
  835. [
  836. true,
  837. false,
  838. ]) {
  839. if (is_shared_library) {
  840. library_type = "angle_shared_library"
  841. library_name = "angle_util"
  842. dep_suffix = "${angle_libs_suffix}"
  843. } else {
  844. library_type = "angle_static_library"
  845. library_name = "angle_util_static"
  846. dep_suffix = "_static"
  847. }
  848. target(library_type, library_name) {
  849. sources = util_sources
  850. deps = [
  851. ":angle_common",
  852. ":angle_util_loader_headers",
  853. ]
  854. public_deps = []
  855. libs = []
  856. if (is_win) {
  857. sources += util_win_sources
  858. deps += [ ":angle_stack_walker" ]
  859. }
  860. if (is_linux) {
  861. sources += util_linux_sources
  862. libs += [
  863. "rt",
  864. "dl",
  865. ]
  866. }
  867. if (is_mac) {
  868. sources += util_osx_sources
  869. libs += [
  870. "AppKit.framework",
  871. "QuartzCore.framework",
  872. ]
  873. }
  874. if (use_x11) {
  875. sources += util_x11_sources
  876. }
  877. if (is_android) {
  878. # To prevent linux sources filtering on android
  879. set_sources_assignment_filter([])
  880. sources += util_android_sources
  881. libs += [
  882. "android",
  883. "log",
  884. ]
  885. }
  886. configs += [ ":debug_annotations_config" ]
  887. public_configs += [ ":angle_util_config" ]
  888. if (is_fuchsia) {
  889. sources += util_fuchsia_sources
  890. public_deps += [
  891. "$angle_root/src/common/fuchsia_egl",
  892. "//third_party/fuchsia-sdk/sdk:async_loop_cpp",
  893. "//third_party/fuchsia-sdk/sdk:fdio",
  894. "//third_party/fuchsia-sdk/sdk:images",
  895. "//third_party/fuchsia-sdk/sdk:scenic_cpp",
  896. "//third_party/fuchsia-sdk/sdk:ui_policy",
  897. "//third_party/fuchsia-sdk/sdk:ui_scenic",
  898. "//third_party/fuchsia-sdk/sdk:ui_views",
  899. ]
  900. } else if (use_ozone) {
  901. sources += util_ozone_sources
  902. }
  903. if (is_shared_library) {
  904. defines = [ "LIBANGLE_UTIL_IMPLEMENTATION" ]
  905. if (is_win) {
  906. sources += util_win_shared_sources
  907. }
  908. public_deps += [ ":angle_util_loader" ]
  909. if (is_mac && !is_component_build) {
  910. ldflags = [
  911. "-install_name",
  912. "@rpath/libangle_util.dylib",
  913. ]
  914. }
  915. } else {
  916. public_configs += [
  917. ":angle_static",
  918. ":gl_prototypes",
  919. ]
  920. }
  921. }
  922. }
  923. # Convenience targets for some of the samples so they can be built
  924. # with Chromium's toolchain.
  925. angle_executable("angle_shader_translator") {
  926. testonly = true
  927. sources = [
  928. "samples/shader_translator/shader_translator.cpp",
  929. ]
  930. deps = [
  931. ":translator",
  932. ]
  933. }
  934. config("angle_feature_support_config") {
  935. include_dirs = [
  936. "include",
  937. "src",
  938. ]
  939. defines = [ "LIBFEATURE_SUPPORT_IMPLEMENTATION" ]
  940. if (is_debug) {
  941. defines += [ "ANGLE_FEATURE_UTIL_LOG_VERBOSE" ]
  942. }
  943. }
  944. angle_shared_library("libfeature_support") {
  945. output_name = "libfeature_support${angle_libs_suffix}"
  946. if (is_android) {
  947. libs = [ "log" ]
  948. }
  949. public_configs += [
  950. ":angle_feature_support_config",
  951. "${angle_jsoncpp_dir}:jsoncpp_config",
  952. ]
  953. if (is_mac && !is_component_build) {
  954. ldflags = [
  955. "-install_name",
  956. "@rpath/${target_name}.dylib",
  957. ]
  958. }
  959. sources = [
  960. "src/feature_support_util/feature_support_util.cpp",
  961. "src/feature_support_util/feature_support_util.h",
  962. ]
  963. deps = [
  964. ":angle_gpu_info_util",
  965. "${angle_jsoncpp_dir}:jsoncpp",
  966. ]
  967. }
  968. if (!is_component_build && is_android && symbol_level != 0) {
  969. action_foreach("compressed_symbols") {
  970. sources = []
  971. foreach(_library, angle_libraries) {
  972. sources += [ "$root_out_dir/${_library}${angle_libs_suffix}.so" ]
  973. }
  974. if (angle_enable_vulkan_validation_layers) {
  975. foreach(_layer, vulkan_validation_layers) {
  976. sources += [ "$root_out_dir/lib${_layer}.so" ]
  977. }
  978. }
  979. script = rebase_path("${root_build_dir}/android/compress_symbols.py",
  980. root_build_dir)
  981. deps = []
  982. foreach(_library, angle_libraries) {
  983. deps += [ ":$_library" ]
  984. }
  985. if (angle_enable_vulkan_validation_layers) {
  986. foreach(_layer, vulkan_validation_layers) {
  987. deps +=
  988. [ "${angle_root}/third_party/vulkan-validation-layers:${_layer}" ]
  989. }
  990. }
  991. outputs = [
  992. "$root_out_dir/lib.compressed/{{source_file_part}}",
  993. ]
  994. android_nm = "${android_tool_prefix}nm"
  995. android_strip = "${android_tool_prefix}strip"
  996. args = [
  997. "--objcopy",
  998. rebase_path(android_objcopy, root_build_dir),
  999. "--nm",
  1000. rebase_path(android_nm, root_build_dir),
  1001. "--strip",
  1002. rebase_path(android_strip, root_build_dir),
  1003. "--unstrippedsofile",
  1004. "{{source_dir}}/lib.unstripped/{{source_file_part}}",
  1005. "--output",
  1006. "{{source_dir}}/lib.compressed/{{source_file_part}}",
  1007. ]
  1008. }
  1009. }
  1010. if (!is_component_build && is_android &&
  1011. current_toolchain == default_toolchain) {
  1012. # Package ANGLE libraries
  1013. angle_apk("angle_chromium_apk") {
  1014. package_name = "com.chromium.angle"
  1015. apk_name = "AngleLibraries"
  1016. }
  1017. group("angle_apks") {
  1018. deps = [
  1019. ":angle_chromium_apk",
  1020. ]
  1021. }
  1022. }