BUILD.gn 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. # Copyright 2014-2015 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 the use_x11 variable
  5. import("//build/config/dcheck_always_on.gni")
  6. import("//build/config/linux/pkg_config.gni")
  7. import("//build/config/ui.gni")
  8. import("//third_party/angle/build/angle_common.gni")
  9. import("//ui/ozone/ozone.gni")
  10. if (ozone_platform_gbm) {
  11. pkg_config("libdrm") {
  12. packages = [ "libdrm" ]
  13. }
  14. }
  15. angle_git_is_present = exec_script("src/commit_id.py",
  16. [
  17. "check",
  18. rebase_path(".", root_build_dir),
  19. ],
  20. "value")
  21. angle_use_commit_id = angle_git_is_present == 1
  22. gles_gypi = exec_script("//build/gypi_to_gn.py",
  23. [ rebase_path("src/libGLESv2.gypi") ],
  24. "scope",
  25. [ "src/libGLESv2.gypi" ])
  26. compiler_gypi = exec_script("//build/gypi_to_gn.py",
  27. [ rebase_path("src/compiler.gypi") ],
  28. "scope",
  29. [ "src/compiler.gypi" ])
  30. # This config is exported to dependent targets (and also applied to internal
  31. # ones).
  32. config("external_config") {
  33. include_dirs = [ "include" ]
  34. }
  35. # This config is applied to internal Angle targets (not pushed to dependents).
  36. config("internal_config") {
  37. include_dirs = [
  38. "include",
  39. "src",
  40. ]
  41. }
  42. config("extra_warnings") {
  43. # Enable more default warnings on Windows.
  44. if (is_win) {
  45. cflags = [
  46. "/we4244", # Conversion: possible loss of data.
  47. "/we4456", # Variable shadowing.
  48. ]
  49. }
  50. }
  51. if (is_win) {
  52. copy("copy_compiler_dll") {
  53. sources = [
  54. "$windows_sdk_path/Redist/D3D/$target_cpu/d3dcompiler_47.dll",
  55. ]
  56. outputs = [
  57. "$root_out_dir/d3dcompiler_47.dll",
  58. ]
  59. }
  60. }
  61. angle_undefine_configs = [ "//build/config/compiler:default_include_dirs" ]
  62. component("translator") {
  63. sources = [
  64. "src/compiler/translator/ShaderLang.cpp",
  65. "src/compiler/translator/ShaderVars.cpp",
  66. ]
  67. defines = [ "ANGLE_TRANSLATOR_IMPLEMENTATION" ]
  68. configs -= angle_undefine_configs
  69. configs += [ ":internal_config" ]
  70. public_deps = [
  71. ":translator_lib",
  72. ]
  73. }
  74. # Holds the shared includes so we only need to list them once.
  75. source_set("includes") {
  76. sources = [
  77. "include/EGL/egl.h",
  78. "include/EGL/eglext.h",
  79. "include/EGL/eglplatform.h",
  80. "include/GLES2/gl2.h",
  81. "include/GLES2/gl2ext.h",
  82. "include/GLES2/gl2platform.h",
  83. "include/GLES3/gl3.h",
  84. "include/GLES3/gl31.h",
  85. "include/GLES3/gl32.h",
  86. "include/GLES3/gl3platform.h",
  87. "include/GLSLANG/ShaderLang.h",
  88. "include/KHR/khrplatform.h",
  89. ]
  90. }
  91. static_library("preprocessor") {
  92. sources = rebase_path(compiler_gypi.angle_preprocessor_sources, ".", "src")
  93. configs -= angle_undefine_configs
  94. configs += [ ":internal_config" ]
  95. }
  96. config("translator_static_config") {
  97. defines = [ "ANGLE_TRANSLATOR_STATIC" ]
  98. }
  99. config("debug_annotations_config") {
  100. if (is_debug) {
  101. defines = [ "ANGLE_ENABLE_DEBUG_ANNOTATIONS" ]
  102. }
  103. }
  104. config("angle_release_asserts_config") {
  105. if (dcheck_always_on) {
  106. defines = [ "ANGLE_ENABLE_RELEASE_ASSERTS" ]
  107. }
  108. }
  109. config("angle_common_config") {
  110. include_dirs = [ "src/common/third_party/numerics" ]
  111. }
  112. static_library("angle_common") {
  113. sources = rebase_path(gles_gypi.libangle_common_sources, ".", "src")
  114. configs -= angle_undefine_configs
  115. configs += [
  116. ":angle_common_config",
  117. ":debug_annotations_config",
  118. ":extra_warnings",
  119. ":internal_config",
  120. ]
  121. public_deps = [
  122. ":commit_id",
  123. ]
  124. public_configs = [
  125. ":angle_release_asserts_config",
  126. ":angle_common_config",
  127. ]
  128. }
  129. config("angle_image_util_config") {
  130. include_dirs = [
  131. "include",
  132. "src",
  133. ]
  134. }
  135. static_library("angle_image_util") {
  136. sources = rebase_path(gles_gypi.libangle_image_util_sources, ".", "src")
  137. configs -= angle_undefine_configs
  138. configs += [ ":internal_config" ]
  139. public_configs = [ ":angle_image_util_config" ]
  140. public_deps = [
  141. ":angle_common",
  142. ]
  143. }
  144. static_library("translator_lib") {
  145. sources = rebase_path(compiler_gypi.angle_translator_lib_sources, ".", "src")
  146. defines = []
  147. if (angle_enable_essl) {
  148. sources +=
  149. rebase_path(compiler_gypi.angle_translator_lib_essl_sources, ".", "src")
  150. defines += [ "ANGLE_ENABLE_ESSL" ]
  151. }
  152. if (angle_enable_glsl) {
  153. sources +=
  154. rebase_path(compiler_gypi.angle_translator_lib_glsl_sources, ".", "src")
  155. defines += [ "ANGLE_ENABLE_GLSL" ]
  156. }
  157. if (angle_enable_hlsl) {
  158. sources +=
  159. rebase_path(compiler_gypi.angle_translator_lib_hlsl_sources, ".", "src")
  160. defines += [ "ANGLE_ENABLE_HLSL" ]
  161. }
  162. configs -= angle_undefine_configs
  163. configs += [
  164. ":internal_config",
  165. ":translator_static_config",
  166. ]
  167. public_configs = [ ":external_config" ]
  168. deps = [
  169. ":includes",
  170. ":preprocessor",
  171. ]
  172. public_deps = [
  173. ":angle_common",
  174. ]
  175. if (is_win) {
  176. # Necessary to suppress some system header xtree warnigns in Release.
  177. # For some reason this warning doesn't get triggered in Chromium
  178. cflags = [ "/wd4718" ]
  179. }
  180. }
  181. static_library("translator_static") {
  182. sources = [
  183. "src/compiler/translator/ShaderLang.cpp",
  184. "src/compiler/translator/ShaderVars.cpp",
  185. ]
  186. if (angle_enable_hlsl) {
  187. defines = [ "ANGLE_ENABLE_HLSL" ]
  188. }
  189. configs -= angle_undefine_configs
  190. configs += [ ":internal_config" ]
  191. public_configs = [ ":translator_static_config" ]
  192. public_deps = [
  193. ":translator_lib",
  194. ]
  195. }
  196. config("commit_id_config") {
  197. include_dirs = [ "$root_gen_dir/angle" ]
  198. }
  199. commit_id_output_file = "$root_gen_dir/angle/id/commit.h"
  200. if (angle_use_commit_id) {
  201. action("commit_id") {
  202. script = "src/commit_id.py"
  203. outputs = [
  204. commit_id_output_file,
  205. ]
  206. args = [
  207. "gen",
  208. rebase_path(".", root_build_dir),
  209. rebase_path(commit_id_output_file, root_build_dir),
  210. ]
  211. public_configs = [ ":commit_id_config" ]
  212. }
  213. } else {
  214. copy("commit_id") {
  215. sources = [
  216. "src/commit.h",
  217. ]
  218. outputs = [
  219. commit_id_output_file,
  220. ]
  221. public_configs = [ ":commit_id_config" ]
  222. }
  223. }
  224. config("libANGLE_config") {
  225. cflags = []
  226. defines = []
  227. if (angle_enable_d3d9) {
  228. defines += [ "ANGLE_ENABLE_D3D9" ]
  229. }
  230. if (angle_enable_d3d11) {
  231. defines += [ "ANGLE_ENABLE_D3D11" ]
  232. }
  233. if (angle_enable_gl) {
  234. defines += [ "ANGLE_ENABLE_OPENGL" ]
  235. if (use_x11) {
  236. defines += [ "ANGLE_USE_X11" ]
  237. }
  238. }
  239. if (angle_enable_vulkan) {
  240. defines += [ "ANGLE_ENABLE_VULKAN" ]
  241. }
  242. defines += [
  243. "GL_GLEXT_PROTOTYPES",
  244. "EGL_EGLEXT_PROTOTYPES",
  245. ]
  246. if (is_win) {
  247. defines += [
  248. "GL_APICALL=",
  249. "EGLAPI=",
  250. ]
  251. } else {
  252. defines += [
  253. "GL_APICALL=__attribute__((visibility(\"default\")))",
  254. "EGLAPI=__attribute__((visibility(\"default\")))",
  255. ]
  256. }
  257. if (is_win) {
  258. cflags += [ "/wd4530" ] # C++ exception handler used, but unwind semantics are not enabled.
  259. }
  260. }
  261. static_library("libANGLE") {
  262. sources = rebase_path(gles_gypi.libangle_sources, ".", "src")
  263. include_dirs = []
  264. libs = []
  265. defines = [ "LIBANGLE_IMPLEMENTATION" ]
  266. public_deps = [
  267. ":angle_common",
  268. ]
  269. deps = [
  270. ":angle_image_util",
  271. ":commit_id",
  272. ":includes",
  273. ":translator_static",
  274. ]
  275. # Shared D3D sources.
  276. if (angle_enable_d3d9 || angle_enable_d3d11) {
  277. sources += rebase_path(gles_gypi.libangle_d3d_shared_sources, ".", "src")
  278. defines += [ "ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ " + "\"d3dcompiler_47.dll\", \"d3dcompiler_46.dll\", \"d3dcompiler_43.dll\" }" ]
  279. }
  280. if (angle_enable_d3d9) {
  281. sources += rebase_path(gles_gypi.libangle_d3d9_sources, ".", "src")
  282. libs += [ "d3d9.lib" ]
  283. }
  284. if (angle_enable_d3d11) {
  285. sources += rebase_path(gles_gypi.libangle_d3d11_sources, ".", "src")
  286. sources += rebase_path(gles_gypi.libangle_d3d11_win32_sources, ".", "src")
  287. libs += [ "dxguid.lib" ]
  288. }
  289. if (angle_enable_gl) {
  290. sources += rebase_path(gles_gypi.libangle_gl_sources, ".", "src")
  291. include_dirs += [ "src/third_party/khronos" ]
  292. if (is_win) {
  293. sources += rebase_path(gles_gypi.libangle_gl_wgl_sources, ".", "src")
  294. }
  295. if (use_x11) {
  296. sources += rebase_path(gles_gypi.libangle_gl_glx_sources, ".", "src")
  297. deps += [ "src/third_party/libXNVCtrl:libXNVCtrl" ]
  298. libs += [
  299. "X11",
  300. "Xi",
  301. "Xext",
  302. ]
  303. }
  304. if (is_mac) {
  305. sources += rebase_path(gles_gypi.libangle_gl_cgl_sources, ".", "src")
  306. libs += [
  307. "Cocoa.framework",
  308. "IOSurface.framework",
  309. "OpenGL.framework",
  310. "QuartzCore.framework",
  311. ]
  312. }
  313. if (is_android) {
  314. sources += rebase_path(gles_gypi.libangle_gl_egl_sources, ".", "src")
  315. sources += rebase_path(gles_gypi.libangle_gl_egl_dl_sources, ".", "src")
  316. sources +=
  317. rebase_path(gles_gypi.libangle_gl_egl_android_sources, ".", "src")
  318. libs += [
  319. "android",
  320. "log",
  321. ]
  322. }
  323. if (ozone_platform_gbm) {
  324. configs += [ ":libdrm" ]
  325. defines += [ "ANGLE_USE_OZONE" ]
  326. deps += [ "//third_party/minigbm" ]
  327. sources += rebase_path(gles_gypi.libangle_gl_egl_sources, ".", "src")
  328. sources += rebase_path(gles_gypi.libangle_gl_egl_dl_sources, ".", "src")
  329. sources += rebase_path(gles_gypi.libangle_gl_ozone_sources, ".", "src")
  330. }
  331. }
  332. if (angle_enable_vulkan) {
  333. sources += rebase_path(gles_gypi.libangle_vulkan_sources, ".", "src")
  334. }
  335. if (is_debug) {
  336. defines += [ "ANGLE_GENERATE_SHADER_DEBUG_INFO" ]
  337. }
  338. configs -= angle_undefine_configs
  339. configs += [
  340. ":commit_id_config",
  341. ":debug_annotations_config",
  342. ":extra_warnings",
  343. ":libANGLE_config",
  344. ":internal_config",
  345. ]
  346. if (is_win) {
  347. data_deps = [
  348. ":copy_compiler_dll",
  349. ]
  350. }
  351. }
  352. config("shared_library_public_config") {
  353. if (is_mac && !is_component_build) {
  354. # Executable targets that depend on the shared libraries below need to have
  355. # the rpath setup in non-component build configurations.
  356. ldflags = [
  357. "-rpath",
  358. "@executable_path/",
  359. ]
  360. }
  361. }
  362. shared_library("libGLESv2") {
  363. sources = rebase_path(gles_gypi.libglesv2_sources, ".", "src")
  364. if (is_win) {
  365. ldflags =
  366. [ "/DEF:" + rebase_path("src/libGLESv2/libGLESv2.def", root_build_dir) ]
  367. }
  368. if (is_mac && !is_component_build) {
  369. ldflags = [
  370. "-install_name",
  371. "@rpath/${target_name}.dylib",
  372. ]
  373. public_configs = [ ":shared_library_public_config" ]
  374. }
  375. configs -= angle_undefine_configs
  376. configs += [
  377. ":internal_config",
  378. ":commit_id_config",
  379. ":debug_annotations_config",
  380. ":libANGLE_config",
  381. ]
  382. defines = [ "LIBGLESV2_IMPLEMENTATION" ]
  383. deps = [
  384. ":includes",
  385. ":libANGLE",
  386. ]
  387. }
  388. shared_library("libEGL") {
  389. sources = rebase_path(gles_gypi.libegl_sources, ".", "src")
  390. if (is_win) {
  391. ldflags = [ "/DEF:" + rebase_path("src/libEGL/libEGL.def", root_build_dir) ]
  392. }
  393. if (is_mac && !is_component_build) {
  394. ldflags = [
  395. "-install_name",
  396. "@rpath/${target_name}.dylib",
  397. ]
  398. public_configs = [ ":shared_library_public_config" ]
  399. }
  400. configs -= angle_undefine_configs
  401. configs += [
  402. ":commit_id_config",
  403. ":debug_annotations_config",
  404. ":extra_warnings",
  405. ":internal_config",
  406. ":libANGLE_config",
  407. ]
  408. defines = [ "LIBEGL_IMPLEMENTATION" ]
  409. deps = [
  410. ":includes",
  411. ":libGLESv2",
  412. ]
  413. }
  414. util_gypi = exec_script("//build/gypi_to_gn.py",
  415. [ rebase_path("util/util.gyp") ],
  416. "scope",
  417. [ "util/util.gyp" ])
  418. config("angle_util_config") {
  419. include_dirs = [ "util" ]
  420. if (is_linux && use_x11) {
  421. libs = [ "X11" ]
  422. }
  423. }
  424. static_library("angle_util") {
  425. sources = rebase_path(util_gypi.util_sources, ".", "util")
  426. if (is_win) {
  427. sources += rebase_path(util_gypi.util_win32_sources, ".", "util")
  428. }
  429. if (is_linux) {
  430. sources += rebase_path(util_gypi.util_linux_sources, ".", "util")
  431. libs = [
  432. "rt",
  433. "dl",
  434. ]
  435. }
  436. if (is_mac) {
  437. sources += rebase_path(util_gypi.util_osx_sources, ".", "util")
  438. }
  439. if (use_x11) {
  440. sources += rebase_path(util_gypi.util_x11_sources, ".", "util")
  441. }
  442. if (is_android) {
  443. # To prevent linux sources filtering on android
  444. set_sources_assignment_filter([])
  445. sources += rebase_path(util_gypi.util_linux_sources, ".", "util")
  446. sources += rebase_path(util_gypi.util_android_sources, ".", "util")
  447. libs = [
  448. "android",
  449. "log",
  450. ]
  451. }
  452. if (use_ozone) {
  453. sources += rebase_path(util_gypi.util_ozone_sources, ".", "util")
  454. }
  455. defines = [
  456. "GL_GLEXT_PROTOTYPES",
  457. "EGL_EGLEXT_PROTOTYPES",
  458. ]
  459. configs += [
  460. ":debug_annotations_config",
  461. ":extra_warnings",
  462. ]
  463. public_configs = [
  464. ":angle_util_config",
  465. ":internal_config",
  466. ]
  467. deps = [
  468. ":angle_common",
  469. ":libEGL",
  470. ":libGLESv2",
  471. ]
  472. }