BUILD.gn 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570
  1. import("//build/config/locales.gni")
  2. import("//build/config/ui.gni")
  3. import("//build/config/win/manifest.gni")
  4. import("//components/os_crypt/sync/features.gni")
  5. import("//components/spellcheck/spellcheck_build_features.gni")
  6. import("//content/public/app/mac_helpers.gni")
  7. import("//extensions/buildflags/buildflags.gni")
  8. import("//pdf/features.gni")
  9. import("//ppapi/buildflags/buildflags.gni")
  10. import("//printing/buildflags/buildflags.gni")
  11. import("//testing/test.gni")
  12. import("//third_party/ffmpeg/ffmpeg_options.gni")
  13. import("//tools/generate_library_loader/generate_library_loader.gni")
  14. import("//tools/grit/grit_rule.gni")
  15. import("//tools/grit/repack.gni")
  16. import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
  17. import("//v8/gni/snapshot_toolchain.gni")
  18. import("build/asar.gni")
  19. import("build/extract_symbols.gni")
  20. import("build/npm.gni")
  21. import("build/templated_file.gni")
  22. import("build/tsc.gni")
  23. import("build/webpack/webpack.gni")
  24. import("buildflags/buildflags.gni")
  25. import("electron_paks.gni")
  26. import("filenames.auto.gni")
  27. import("filenames.gni")
  28. import("filenames.hunspell.gni")
  29. import("filenames.libcxx.gni")
  30. import("filenames.libcxxabi.gni")
  31. if (is_mac) {
  32. import("//build/config/mac/rules.gni")
  33. import("//third_party/icu/config.gni")
  34. import("//ui/gl/features.gni")
  35. import("//v8/gni/v8.gni")
  36. import("build/rules.gni")
  37. assert(
  38. mac_deployment_target == "10.13",
  39. "Chromium has updated the mac_deployment_target, please update this assert, update the supported versions documentation (docs/tutorial/support.md) and flag this as a breaking change")
  40. }
  41. if (is_linux) {
  42. import("//build/config/linux/pkg_config.gni")
  43. import("//tools/generate_stubs/rules.gni")
  44. pkg_config("gio_unix") {
  45. packages = [ "gio-unix-2.0" ]
  46. }
  47. pkg_config("libnotify_config") {
  48. packages = [
  49. "glib-2.0",
  50. "gdk-pixbuf-2.0",
  51. ]
  52. }
  53. generate_library_loader("libnotify_loader") {
  54. name = "LibNotifyLoader"
  55. output_h = "libnotify_loader.h"
  56. output_cc = "libnotify_loader.cc"
  57. header = "<libnotify/notify.h>"
  58. config = ":libnotify_config"
  59. functions = [
  60. "notify_is_initted",
  61. "notify_init",
  62. "notify_get_server_caps",
  63. "notify_get_server_info",
  64. "notify_notification_new",
  65. "notify_notification_add_action",
  66. "notify_notification_set_image_from_pixbuf",
  67. "notify_notification_set_timeout",
  68. "notify_notification_set_urgency",
  69. "notify_notification_set_hint_string",
  70. "notify_notification_show",
  71. "notify_notification_close",
  72. ]
  73. }
  74. # Generates electron_gtk_stubs.h header which contains
  75. # stubs for extracting function ptrs from the gtk library.
  76. # Function signatures for which stubs are required should be
  77. # declared in electron_gtk.sigs, currently this file contains
  78. # signatures for the functions used with native file chooser
  79. # implementation. In future, this file can be extended to contain
  80. # gtk4 stubs to switch gtk version in runtime.
  81. generate_stubs("electron_gtk_stubs") {
  82. sigs = [
  83. "shell/browser/ui/electron_gdk_pixbuf.sigs",
  84. "shell/browser/ui/electron_gtk.sigs",
  85. ]
  86. extra_header = "shell/browser/ui/electron_gtk.fragment"
  87. output_name = "electron_gtk_stubs"
  88. public_deps = [ "//ui/gtk:gtk_config" ]
  89. logging_function = "LogNoop()"
  90. logging_include = "ui/gtk/log_noop.h"
  91. }
  92. }
  93. declare_args() {
  94. use_prebuilt_v8_context_snapshot = false
  95. }
  96. branding = read_file("shell/app/BRANDING.json", "json")
  97. electron_project_name = branding.project_name
  98. electron_product_name = branding.product_name
  99. electron_mac_bundle_id = branding.mac_bundle_id
  100. electron_version = exec_script("script/print-version.py",
  101. [],
  102. "trim string",
  103. [
  104. ".git/packed-refs",
  105. ".git/HEAD",
  106. "script/lib/get-version.js",
  107. ])
  108. if (is_mas_build) {
  109. assert(is_mac,
  110. "It doesn't make sense to build a MAS build on a non-mac platform")
  111. }
  112. if (enable_pdf_viewer) {
  113. assert(enable_pdf, "PDF viewer support requires enable_pdf=true")
  114. assert(enable_electron_extensions,
  115. "PDF viewer support requires enable_electron_extensions=true")
  116. }
  117. if (enable_electron_extensions) {
  118. assert(enable_extensions,
  119. "Chrome extension support requires enable_extensions=true")
  120. }
  121. config("branding") {
  122. defines = [
  123. "ELECTRON_PRODUCT_NAME=\"$electron_product_name\"",
  124. "ELECTRON_PROJECT_NAME=\"$electron_project_name\"",
  125. ]
  126. }
  127. config("electron_lib_config") {
  128. include_dirs = [ "." ]
  129. }
  130. # We generate the definitions twice here, once in //electron/electron.d.ts
  131. # and once in $target_gen_dir
  132. # The one in $target_gen_dir is used for the actual TSC build later one
  133. # and the one in //electron/electron.d.ts is used by your IDE (vscode)
  134. # for typescript prompting
  135. npm_action("build_electron_definitions") {
  136. script = "gn-typescript-definitions"
  137. args = [ rebase_path("$target_gen_dir/tsc/typings/electron.d.ts") ]
  138. inputs = auto_filenames.api_docs + [ "yarn.lock" ]
  139. outputs = [ "$target_gen_dir/tsc/typings/electron.d.ts" ]
  140. }
  141. webpack_build("electron_asar_bundle") {
  142. deps = [ ":build_electron_definitions" ]
  143. inputs = auto_filenames.asar_bundle_deps
  144. config_file = "//electron/build/webpack/webpack.config.asar.js"
  145. out_file = "$target_gen_dir/js2c/asar_bundle.js"
  146. }
  147. webpack_build("electron_browser_bundle") {
  148. deps = [ ":build_electron_definitions" ]
  149. inputs = auto_filenames.browser_bundle_deps
  150. config_file = "//electron/build/webpack/webpack.config.browser.js"
  151. out_file = "$target_gen_dir/js2c/browser_init.js"
  152. }
  153. webpack_build("electron_renderer_bundle") {
  154. deps = [ ":build_electron_definitions" ]
  155. inputs = auto_filenames.renderer_bundle_deps
  156. config_file = "//electron/build/webpack/webpack.config.renderer.js"
  157. out_file = "$target_gen_dir/js2c/renderer_init.js"
  158. }
  159. webpack_build("electron_worker_bundle") {
  160. deps = [ ":build_electron_definitions" ]
  161. inputs = auto_filenames.worker_bundle_deps
  162. config_file = "//electron/build/webpack/webpack.config.worker.js"
  163. out_file = "$target_gen_dir/js2c/worker_init.js"
  164. }
  165. webpack_build("electron_sandboxed_renderer_bundle") {
  166. deps = [ ":build_electron_definitions" ]
  167. inputs = auto_filenames.sandbox_bundle_deps
  168. config_file = "//electron/build/webpack/webpack.config.sandboxed_renderer.js"
  169. out_file = "$target_gen_dir/js2c/sandbox_bundle.js"
  170. }
  171. webpack_build("electron_isolated_renderer_bundle") {
  172. deps = [ ":build_electron_definitions" ]
  173. inputs = auto_filenames.isolated_bundle_deps
  174. config_file = "//electron/build/webpack/webpack.config.isolated_renderer.js"
  175. out_file = "$target_gen_dir/js2c/isolated_bundle.js"
  176. }
  177. webpack_build("electron_utility_bundle") {
  178. deps = [ ":build_electron_definitions" ]
  179. inputs = auto_filenames.utility_bundle_deps
  180. config_file = "//electron/build/webpack/webpack.config.utility.js"
  181. out_file = "$target_gen_dir/js2c/utility_init.js"
  182. }
  183. action("electron_js2c") {
  184. deps = [
  185. ":electron_asar_bundle",
  186. ":electron_browser_bundle",
  187. ":electron_isolated_renderer_bundle",
  188. ":electron_renderer_bundle",
  189. ":electron_sandboxed_renderer_bundle",
  190. ":electron_utility_bundle",
  191. ":electron_worker_bundle",
  192. ]
  193. sources = [
  194. "$target_gen_dir/js2c/asar_bundle.js",
  195. "$target_gen_dir/js2c/browser_init.js",
  196. "$target_gen_dir/js2c/isolated_bundle.js",
  197. "$target_gen_dir/js2c/renderer_init.js",
  198. "$target_gen_dir/js2c/sandbox_bundle.js",
  199. "$target_gen_dir/js2c/utility_init.js",
  200. "$target_gen_dir/js2c/worker_init.js",
  201. ]
  202. inputs = sources + [ "//third_party/electron_node/tools/js2c.py" ]
  203. outputs = [ "$root_gen_dir/electron_natives.cc" ]
  204. script = "build/js2c.py"
  205. args = [ rebase_path("//third_party/electron_node") ] +
  206. rebase_path(outputs, root_build_dir) +
  207. rebase_path(sources, root_build_dir)
  208. }
  209. action("generate_config_gypi") {
  210. outputs = [ "$root_gen_dir/config.gypi" ]
  211. script = "script/generate-config-gypi.py"
  212. inputs = [ "//third_party/electron_node/configure.py" ]
  213. args = rebase_path(outputs) + [ target_cpu ]
  214. }
  215. target_gen_default_app_js = "$target_gen_dir/js/default_app"
  216. typescript_build("default_app_js") {
  217. deps = [ ":build_electron_definitions" ]
  218. sources = filenames.default_app_ts_sources
  219. output_gen_dir = target_gen_default_app_js
  220. output_dir_name = "default_app"
  221. tsconfig = "tsconfig.default_app.json"
  222. }
  223. copy("default_app_static") {
  224. sources = filenames.default_app_static_sources
  225. outputs = [ "$target_gen_default_app_js/{{source}}" ]
  226. }
  227. copy("default_app_octicon_deps") {
  228. sources = filenames.default_app_octicon_sources
  229. outputs = [ "$target_gen_default_app_js/electron/default_app/octicon/{{source_file_part}}" ]
  230. }
  231. asar("default_app_asar") {
  232. deps = [
  233. ":default_app_js",
  234. ":default_app_octicon_deps",
  235. ":default_app_static",
  236. ]
  237. root = "$target_gen_default_app_js/electron/default_app"
  238. sources = get_target_outputs(":default_app_js") +
  239. get_target_outputs(":default_app_static") +
  240. get_target_outputs(":default_app_octicon_deps")
  241. outputs = [ "$root_out_dir/resources/default_app.asar" ]
  242. }
  243. grit("resources") {
  244. source = "electron_resources.grd"
  245. outputs = [
  246. "grit/electron_resources.h",
  247. "electron_resources.pak",
  248. ]
  249. # Mojo manifest overlays are generated.
  250. grit_flags = [
  251. "-E",
  252. "target_gen_dir=" + rebase_path(target_gen_dir, root_build_dir),
  253. ]
  254. deps = [ ":copy_shell_devtools_discovery_page" ]
  255. output_dir = "$target_gen_dir"
  256. }
  257. copy("copy_shell_devtools_discovery_page") {
  258. sources = [ "//content/shell/resources/shell_devtools_discovery_page.html" ]
  259. outputs = [ "$target_gen_dir/shell_devtools_discovery_page.html" ]
  260. }
  261. npm_action("electron_version_args") {
  262. script = "generate-version-json"
  263. outputs = [ "$target_gen_dir/electron_version.args" ]
  264. args = rebase_path(outputs) + [ "$electron_version" ]
  265. inputs = [ "script/generate-version-json.js" ]
  266. }
  267. templated_file("electron_version_header") {
  268. deps = [ ":electron_version_args" ]
  269. template = "build/templates/electron_version.tmpl"
  270. output = "$target_gen_dir/electron_version.h"
  271. args_files = get_target_outputs(":electron_version_args")
  272. }
  273. templated_file("electron_win_rc") {
  274. deps = [ ":electron_version_args" ]
  275. template = "build/templates/electron_rc.tmpl"
  276. output = "$target_gen_dir/win-resources/electron.rc"
  277. args_files = get_target_outputs(":electron_version_args")
  278. }
  279. copy("electron_win_resource_files") {
  280. sources = [
  281. "shell/browser/resources/win/electron.ico",
  282. "shell/browser/resources/win/resource.h",
  283. ]
  284. outputs = [ "$target_gen_dir/win-resources/{{source_file_part}}" ]
  285. }
  286. templated_file("electron_version_file") {
  287. deps = [ ":electron_version_args" ]
  288. template = "build/templates/version_string.tmpl"
  289. output = "$root_build_dir/version"
  290. args_files = get_target_outputs(":electron_version_args")
  291. }
  292. group("electron_win32_resources") {
  293. public_deps = [
  294. ":electron_win_rc",
  295. ":electron_win_resource_files",
  296. ]
  297. }
  298. action("electron_fuses") {
  299. script = "build/fuses/build.py"
  300. inputs = [ "build/fuses/fuses.json5" ]
  301. outputs = [
  302. "$target_gen_dir/fuses.h",
  303. "$target_gen_dir/fuses.cc",
  304. ]
  305. args = rebase_path(outputs)
  306. }
  307. action("electron_generate_node_defines") {
  308. script = "build/generate_node_defines.py"
  309. inputs = [
  310. "//third_party/electron_node/src/tracing/trace_event_common.h",
  311. "//third_party/electron_node/src/tracing/trace_event.h",
  312. "//third_party/electron_node/src/util.h",
  313. ]
  314. outputs = [
  315. "$target_gen_dir/push_and_undef_node_defines.h",
  316. "$target_gen_dir/pop_node_defines.h",
  317. ]
  318. args = [ rebase_path(target_gen_dir) ] + rebase_path(inputs)
  319. }
  320. source_set("electron_lib") {
  321. configs += [ "//v8:external_startup_data" ]
  322. configs += [ "//third_party/electron_node:node_internals" ]
  323. public_configs = [
  324. ":branding",
  325. ":electron_lib_config",
  326. ]
  327. deps = [
  328. ":electron_fuses",
  329. ":electron_generate_node_defines",
  330. ":electron_js2c",
  331. ":electron_version_header",
  332. ":resources",
  333. "buildflags",
  334. "chromium_src:chrome",
  335. "chromium_src:chrome_spellchecker",
  336. "shell/common/api:mojo",
  337. "shell/services/node/public/mojom",
  338. "//base:base_static",
  339. "//base/allocator:buildflags",
  340. "//chrome:strings",
  341. "//chrome/app:command_ids",
  342. "//chrome/app/resources:platform_locale_settings",
  343. "//components/autofill/core/common:features",
  344. "//components/certificate_transparency",
  345. "//components/embedder_support:browser_util",
  346. "//components/language/core/browser",
  347. "//components/net_log",
  348. "//components/network_hints/browser",
  349. "//components/network_hints/common:mojo_bindings",
  350. "//components/network_hints/renderer",
  351. "//components/network_session_configurator/common",
  352. "//components/omnibox/browser:buildflags",
  353. "//components/os_crypt/sync",
  354. "//components/pref_registry",
  355. "//components/prefs",
  356. "//components/security_state/content",
  357. "//components/upload_list",
  358. "//components/user_prefs",
  359. "//components/viz/host",
  360. "//components/viz/service",
  361. "//components/webrtc",
  362. "//content/public/browser",
  363. "//content/public/child",
  364. "//content/public/gpu",
  365. "//content/public/renderer",
  366. "//content/public/utility",
  367. "//device/bluetooth",
  368. "//device/bluetooth/public/cpp",
  369. "//gin",
  370. "//media/capture/mojom:video_capture",
  371. "//media/mojo/mojom",
  372. "//net:extras",
  373. "//net:net_resources",
  374. "//printing/buildflags",
  375. "//services/device/public/cpp/geolocation",
  376. "//services/device/public/cpp/hid",
  377. "//services/device/public/mojom",
  378. "//services/proxy_resolver:lib",
  379. "//services/video_capture/public/mojom:constants",
  380. "//services/viz/privileged/mojom/compositing",
  381. "//skia",
  382. "//third_party/blink/public:blink",
  383. "//third_party/blink/public:blink_devtools_inspector_resources",
  384. "//third_party/blink/public/platform/media",
  385. "//third_party/boringssl",
  386. "//third_party/electron_node:node_lib",
  387. "//third_party/inspector_protocol:crdtp",
  388. "//third_party/leveldatabase",
  389. "//third_party/libyuv",
  390. "//third_party/webrtc_overrides:webrtc_component",
  391. "//third_party/widevine/cdm:headers",
  392. "//third_party/zlib/google:zip",
  393. "//ui/base/idle",
  394. "//ui/events:dom_keycode_converter",
  395. "//ui/gl",
  396. "//ui/native_theme",
  397. "//ui/shell_dialogs",
  398. "//ui/views",
  399. "//v8",
  400. "//v8:v8_libplatform",
  401. ]
  402. public_deps = [
  403. "//base",
  404. "//base:i18n",
  405. "//content/public/app",
  406. ]
  407. include_dirs = [
  408. ".",
  409. "$target_gen_dir",
  410. # TODO(nornagon): replace usage of SchemeRegistry by an actually exported
  411. # API of blink, then remove this from the include_dirs.
  412. "//third_party/blink/renderer",
  413. ]
  414. defines = [ "V8_DEPRECATION_WARNINGS" ]
  415. libs = []
  416. if (is_linux) {
  417. defines += [ "GDK_DISABLE_DEPRECATION_WARNINGS" ]
  418. }
  419. if (!is_mas_build) {
  420. deps += [
  421. "//components/crash/core/app",
  422. "//components/crash/core/browser",
  423. ]
  424. }
  425. configs += [ "//electron/build/config:mas_build" ]
  426. sources = filenames.lib_sources
  427. if (is_win) {
  428. sources += filenames.lib_sources_win
  429. }
  430. if (is_mac) {
  431. sources += filenames.lib_sources_mac
  432. }
  433. if (is_posix) {
  434. sources += filenames.lib_sources_posix
  435. }
  436. if (is_linux) {
  437. sources += filenames.lib_sources_linux
  438. }
  439. if (!is_mac) {
  440. sources += filenames.lib_sources_views
  441. }
  442. if (is_component_build) {
  443. defines += [ "NODE_SHARED_MODE" ]
  444. }
  445. if (enable_fake_location_provider) {
  446. sources += [
  447. "shell/browser/fake_location_provider.cc",
  448. "shell/browser/fake_location_provider.h",
  449. ]
  450. }
  451. if (is_mac) {
  452. deps += [
  453. "//components/remote_cocoa/app_shim",
  454. "//components/remote_cocoa/browser",
  455. "//content/browser:mac_helpers",
  456. "//ui/accelerated_widget_mac",
  457. ]
  458. if (!is_mas_build) {
  459. deps += [ "//third_party/crashpad/crashpad/client" ]
  460. }
  461. frameworks = [
  462. "AVFoundation.framework",
  463. "Carbon.framework",
  464. "LocalAuthentication.framework",
  465. "QuartzCore.framework",
  466. "Quartz.framework",
  467. "Security.framework",
  468. "SecurityInterface.framework",
  469. "ServiceManagement.framework",
  470. "StoreKit.framework",
  471. ]
  472. weak_frameworks = [ "QuickLookThumbnailing.framework" ]
  473. sources += [
  474. "shell/browser/ui/views/autofill_popup_view.cc",
  475. "shell/browser/ui/views/autofill_popup_view.h",
  476. ]
  477. if (is_mas_build) {
  478. sources += [ "shell/browser/api/electron_api_app_mas.mm" ]
  479. sources -= [ "shell/browser/auto_updater_mac.mm" ]
  480. sources -= [
  481. "shell/app/electron_crash_reporter_client.cc",
  482. "shell/app/electron_crash_reporter_client.h",
  483. "shell/common/crash_keys.cc",
  484. "shell/common/crash_keys.h",
  485. ]
  486. } else {
  487. frameworks += [
  488. "Squirrel.framework",
  489. "ReactiveObjC.framework",
  490. "Mantle.framework",
  491. ]
  492. deps += [
  493. "//third_party/squirrel.mac:reactiveobjc_framework+link",
  494. "//third_party/squirrel.mac:squirrel_framework+link",
  495. ]
  496. # ReactiveObjC which is used by Squirrel requires using __weak.
  497. cflags_objcc = [ "-fobjc-weak" ]
  498. }
  499. }
  500. if (is_linux) {
  501. libs = [ "xshmfence" ]
  502. deps += [
  503. ":electron_gtk_stubs",
  504. ":libnotify_loader",
  505. "//build/config/linux/gtk",
  506. "//components/crash/content/browser",
  507. "//dbus",
  508. "//device/bluetooth",
  509. "//third_party/crashpad/crashpad/client",
  510. "//ui/base/ime/linux",
  511. "//ui/events/devices/x11",
  512. "//ui/events/platform/x11",
  513. "//ui/gtk:gtk_config",
  514. "//ui/linux:linux_ui",
  515. "//ui/linux:linux_ui_factory",
  516. "//ui/views/controls/webview",
  517. "//ui/wm",
  518. ]
  519. if (ozone_platform_x11) {
  520. sources += filenames.lib_sources_linux_x11
  521. public_deps += [
  522. "//ui/base/x",
  523. "//ui/ozone/platform/x11",
  524. ]
  525. }
  526. configs += [ ":gio_unix" ]
  527. defines += [
  528. # Disable warnings for g_settings_list_schemas.
  529. "GLIB_DISABLE_DEPRECATION_WARNINGS",
  530. ]
  531. sources += [
  532. "shell/browser/certificate_manager_model.cc",
  533. "shell/browser/certificate_manager_model.h",
  534. "shell/browser/ui/gtk_util.cc",
  535. "shell/browser/ui/gtk_util.h",
  536. ]
  537. }
  538. if (is_win) {
  539. libs += [ "dwmapi.lib" ]
  540. deps += [
  541. "//components/crash/core/app:crash_export_thunks",
  542. "//ui/native_theme:native_theme_browser",
  543. "//ui/views/controls/webview",
  544. "//ui/wm",
  545. "//ui/wm/public",
  546. ]
  547. public_deps += [
  548. "//sandbox/win:sandbox",
  549. "//third_party/crashpad/crashpad/handler",
  550. ]
  551. }
  552. if (enable_plugins) {
  553. deps += [ "chromium_src:plugins" ]
  554. sources += [
  555. "shell/common/plugin_info.cc",
  556. "shell/common/plugin_info.h",
  557. "shell/renderer/electron_renderer_pepper_host_factory.cc",
  558. "shell/renderer/electron_renderer_pepper_host_factory.h",
  559. "shell/renderer/pepper_helper.cc",
  560. "shell/renderer/pepper_helper.h",
  561. ]
  562. }
  563. if (enable_ppapi) {
  564. deps += [
  565. "//ppapi/host",
  566. "//ppapi/proxy",
  567. "//ppapi/shared_impl",
  568. ]
  569. }
  570. if (enable_run_as_node) {
  571. sources += [
  572. "shell/app/node_main.cc",
  573. "shell/app/node_main.h",
  574. ]
  575. }
  576. if (enable_osr) {
  577. sources += [
  578. "shell/browser/osr/osr_host_display_client.cc",
  579. "shell/browser/osr/osr_host_display_client.h",
  580. "shell/browser/osr/osr_render_widget_host_view.cc",
  581. "shell/browser/osr/osr_render_widget_host_view.h",
  582. "shell/browser/osr/osr_video_consumer.cc",
  583. "shell/browser/osr/osr_video_consumer.h",
  584. "shell/browser/osr/osr_view_proxy.cc",
  585. "shell/browser/osr/osr_view_proxy.h",
  586. "shell/browser/osr/osr_web_contents_view.cc",
  587. "shell/browser/osr/osr_web_contents_view.h",
  588. ]
  589. if (is_mac) {
  590. sources += [
  591. "shell/browser/osr/osr_host_display_client_mac.mm",
  592. "shell/browser/osr/osr_web_contents_view_mac.mm",
  593. ]
  594. }
  595. deps += [
  596. "//components/viz/service",
  597. "//services/viz/public/mojom",
  598. "//ui/compositor",
  599. ]
  600. }
  601. if (enable_desktop_capturer) {
  602. sources += [
  603. "shell/browser/api/electron_api_desktop_capturer.cc",
  604. "shell/browser/api/electron_api_desktop_capturer.h",
  605. ]
  606. }
  607. if (enable_views_api) {
  608. sources += [
  609. "shell/browser/api/views/electron_api_image_view.cc",
  610. "shell/browser/api/views/electron_api_image_view.h",
  611. ]
  612. }
  613. if (enable_printing) {
  614. sources += [
  615. "shell/browser/printing/print_view_manager_electron.cc",
  616. "shell/browser/printing/print_view_manager_electron.h",
  617. "shell/renderer/printing/print_render_frame_helper_delegate.cc",
  618. "shell/renderer/printing/print_render_frame_helper_delegate.h",
  619. ]
  620. deps += [
  621. "//chrome/services/printing/public/mojom",
  622. "//components/printing/common:mojo_interfaces",
  623. ]
  624. if (is_mac) {
  625. deps += [ "//chrome/services/mac_notifications/public/mojom" ]
  626. }
  627. }
  628. if (enable_electron_extensions) {
  629. sources += filenames.lib_sources_extensions
  630. deps += [
  631. "shell/browser/extensions/api:api_registration",
  632. "shell/common/extensions/api",
  633. "shell/common/extensions/api:extensions_features",
  634. "//chrome/browser/resources:component_extension_resources",
  635. "//components/update_client:update_client",
  636. "//components/zoom",
  637. "//extensions/browser",
  638. "//extensions/browser/api:api_provider",
  639. "//extensions/browser/updater",
  640. "//extensions/common",
  641. "//extensions/common:core_api_provider",
  642. "//extensions/renderer",
  643. ]
  644. }
  645. if (enable_pdf) {
  646. # Printing depends on some //pdf code, so it needs to be built even if the
  647. # pdf viewer isn't enabled.
  648. deps += [
  649. "//pdf",
  650. "//pdf:features",
  651. ]
  652. }
  653. if (enable_pdf_viewer) {
  654. deps += [
  655. "//chrome/browser/resources/pdf:resources",
  656. "//components/pdf/browser",
  657. "//components/pdf/browser:interceptors",
  658. "//components/pdf/common",
  659. "//components/pdf/renderer",
  660. "//pdf",
  661. ]
  662. sources += [
  663. "shell/browser/electron_pdf_web_contents_helper_client.cc",
  664. "shell/browser/electron_pdf_web_contents_helper_client.h",
  665. "shell/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.cc",
  666. "shell/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.h",
  667. ]
  668. }
  669. sources += get_target_outputs(":electron_fuses")
  670. if (allow_runtime_configurable_key_storage) {
  671. defines += [ "ALLOW_RUNTIME_CONFIGURABLE_KEY_STORAGE" ]
  672. }
  673. }
  674. electron_paks("packed_resources") {
  675. if (is_mac) {
  676. output_dir = "$root_gen_dir/electron_repack"
  677. copy_data_to_bundle = true
  678. } else {
  679. output_dir = root_out_dir
  680. }
  681. }
  682. if (is_mac) {
  683. electron_framework_name = "$electron_product_name Framework"
  684. electron_helper_name = "$electron_product_name Helper"
  685. electron_login_helper_name = "$electron_product_name Login Helper"
  686. electron_framework_version = "A"
  687. mac_xib_bundle_data("electron_xibs") {
  688. sources = [ "shell/common/resources/mac/MainMenu.xib" ]
  689. }
  690. action("fake_v8_context_snapshot_generator") {
  691. script = "build/fake_v8_context_snapshot_generator.py"
  692. args = [
  693. rebase_path("$root_out_dir/$v8_context_snapshot_filename"),
  694. rebase_path("$root_out_dir/fake/$v8_context_snapshot_filename"),
  695. ]
  696. outputs = [ "$root_out_dir/fake/$v8_context_snapshot_filename" ]
  697. }
  698. bundle_data("electron_framework_resources") {
  699. public_deps = [ ":packed_resources" ]
  700. sources = []
  701. if (icu_use_data_file) {
  702. sources += [ "$root_out_dir/icudtl.dat" ]
  703. public_deps += [ "//third_party/icu:icudata" ]
  704. }
  705. if (v8_use_external_startup_data) {
  706. public_deps += [ "//v8" ]
  707. if (use_v8_context_snapshot) {
  708. if (use_prebuilt_v8_context_snapshot) {
  709. sources += [ "$root_out_dir/fake/$v8_context_snapshot_filename" ]
  710. public_deps += [ ":fake_v8_context_snapshot_generator" ]
  711. } else {
  712. sources += [ "$root_out_dir/$v8_context_snapshot_filename" ]
  713. public_deps += [ "//tools/v8_context_snapshot" ]
  714. }
  715. } else {
  716. sources += [ "$root_out_dir/snapshot_blob.bin" ]
  717. }
  718. }
  719. outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
  720. }
  721. if (!is_component_build && is_component_ffmpeg) {
  722. bundle_data("electron_framework_libraries") {
  723. sources = []
  724. public_deps = []
  725. sources += [ "$root_out_dir/libffmpeg.dylib" ]
  726. public_deps += [ "//third_party/ffmpeg:ffmpeg" ]
  727. outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ]
  728. }
  729. } else {
  730. group("electron_framework_libraries") {
  731. }
  732. }
  733. if (use_egl) {
  734. # Add the ANGLE .dylibs in the Libraries directory of the Framework.
  735. bundle_data("electron_angle_binaries") {
  736. sources = [
  737. "$root_out_dir/egl_intermediates/libEGL.dylib",
  738. "$root_out_dir/egl_intermediates/libGLESv2.dylib",
  739. ]
  740. outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ]
  741. public_deps = [ "//ui/gl:angle_library_copy" ]
  742. }
  743. # Add the SwiftShader .dylibs in the Libraries directory of the Framework.
  744. bundle_data("electron_swiftshader_binaries") {
  745. sources = [
  746. "$root_out_dir/vk_intermediates/libvk_swiftshader.dylib",
  747. "$root_out_dir/vk_intermediates/vk_swiftshader_icd.json",
  748. ]
  749. outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ]
  750. public_deps = [ "//ui/gl:swiftshader_vk_library_copy" ]
  751. }
  752. }
  753. group("electron_angle_library") {
  754. if (use_egl) {
  755. deps = [ ":electron_angle_binaries" ]
  756. }
  757. }
  758. group("electron_swiftshader_library") {
  759. if (use_egl) {
  760. deps = [ ":electron_swiftshader_binaries" ]
  761. }
  762. }
  763. bundle_data("electron_crashpad_helper") {
  764. sources = [ "$root_out_dir/chrome_crashpad_handler" ]
  765. outputs = [ "{{bundle_contents_dir}}/Helpers/{{source_file_part}}" ]
  766. public_deps = [ "//components/crash/core/app:chrome_crashpad_handler" ]
  767. if (is_asan) {
  768. # crashpad_handler requires the ASan runtime at its @executable_path.
  769. sources += [ "$root_out_dir/libclang_rt.asan_osx_dynamic.dylib" ]
  770. public_deps += [ "//build/config/sanitizers:copy_asan_runtime" ]
  771. }
  772. }
  773. mac_framework_bundle("electron_framework") {
  774. output_name = electron_framework_name
  775. framework_version = electron_framework_version
  776. framework_contents = [
  777. "Resources",
  778. "Libraries",
  779. ]
  780. if (!is_mas_build) {
  781. framework_contents += [ "Helpers" ]
  782. }
  783. public_deps = [
  784. ":electron_framework_libraries",
  785. ":electron_lib",
  786. ]
  787. deps = [
  788. ":electron_angle_library",
  789. ":electron_framework_libraries",
  790. ":electron_framework_resources",
  791. ":electron_swiftshader_library",
  792. ":electron_xibs",
  793. ]
  794. if (!is_mas_build) {
  795. deps += [ ":electron_crashpad_helper" ]
  796. }
  797. info_plist = "shell/common/resources/mac/Info.plist"
  798. extra_substitutions = [
  799. "ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.framework",
  800. "ELECTRON_VERSION=$electron_version",
  801. ]
  802. include_dirs = [ "." ]
  803. sources = filenames.framework_sources
  804. frameworks = []
  805. if (enable_osr) {
  806. frameworks += [ "IOSurface.framework" ]
  807. }
  808. ldflags = [
  809. "-Wl,-install_name,@rpath/$output_name.framework/$output_name",
  810. "-rpath",
  811. "@loader_path/Libraries",
  812. # Required for exporting all symbols of libuv.
  813. "-Wl,-force_load,obj/third_party/electron_node/deps/uv/libuv.a",
  814. ]
  815. if (is_component_build) {
  816. ldflags += [
  817. "-rpath",
  818. "@executable_path/../../../../../..",
  819. ]
  820. }
  821. # For component ffmpeg under non-component build, it is linked from
  822. # @loader_path. However the ffmpeg.dylib is moved to a different place
  823. # when generating app bundle, and we should change to link from @rpath.
  824. if (is_component_ffmpeg && !is_component_build) {
  825. ldflags += [ "-Wcrl,installnametool,-change,@loader_path/libffmpeg.dylib,@rpath/libffmpeg.dylib" ]
  826. }
  827. }
  828. template("electron_helper_app") {
  829. mac_app_bundle(target_name) {
  830. assert(defined(invoker.helper_name_suffix))
  831. output_name = electron_helper_name + invoker.helper_name_suffix
  832. deps = [
  833. ":electron_framework+link",
  834. "//base/allocator:early_zone_registration_mac",
  835. ]
  836. if (!is_mas_build) {
  837. deps += [ "//sandbox/mac:seatbelt" ]
  838. }
  839. defines = [ "HELPER_EXECUTABLE" ]
  840. extra_configs = [ "//electron/build/config:mas_build" ]
  841. sources = [
  842. "shell/app/electron_main_mac.cc",
  843. "shell/app/uv_stdio_fix.cc",
  844. "shell/app/uv_stdio_fix.h",
  845. "shell/common/electron_constants.cc",
  846. ]
  847. include_dirs = [ "." ]
  848. info_plist = "shell/renderer/resources/mac/Info.plist"
  849. extra_substitutions =
  850. [ "ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.helper" ]
  851. ldflags = [
  852. "-rpath",
  853. "@executable_path/../../..",
  854. ]
  855. if (is_component_build) {
  856. ldflags += [
  857. "-rpath",
  858. "@executable_path/../../../../../..",
  859. ]
  860. }
  861. }
  862. }
  863. foreach(helper_params, content_mac_helpers) {
  864. _helper_target = helper_params[0]
  865. _helper_bundle_id = helper_params[1]
  866. _helper_suffix = helper_params[2]
  867. electron_helper_app("electron_helper_app_${_helper_target}") {
  868. helper_name_suffix = _helper_suffix
  869. }
  870. }
  871. template("stripped_framework") {
  872. action(target_name) {
  873. assert(defined(invoker.framework))
  874. script = "//electron/build/strip_framework.py"
  875. forward_variables_from(invoker, [ "deps" ])
  876. inputs = [ "$root_out_dir/" + invoker.framework ]
  877. outputs = [ "$target_out_dir/stripped_frameworks/" + invoker.framework ]
  878. args = rebase_path(inputs) + rebase_path(outputs)
  879. }
  880. }
  881. stripped_framework("stripped_mantle_framework") {
  882. framework = "Mantle.framework"
  883. deps = [ "//third_party/squirrel.mac:mantle_framework" ]
  884. }
  885. stripped_framework("stripped_reactiveobjc_framework") {
  886. framework = "ReactiveObjC.framework"
  887. deps = [ "//third_party/squirrel.mac:reactiveobjc_framework" ]
  888. }
  889. stripped_framework("stripped_squirrel_framework") {
  890. framework = "Squirrel.framework"
  891. deps = [ "//third_party/squirrel.mac:squirrel_framework" ]
  892. }
  893. bundle_data("electron_app_framework_bundle_data") {
  894. sources = [ "$root_out_dir/$electron_framework_name.framework" ]
  895. if (!is_mas_build) {
  896. sources += get_target_outputs(":stripped_mantle_framework") +
  897. get_target_outputs(":stripped_reactiveobjc_framework") +
  898. get_target_outputs(":stripped_squirrel_framework")
  899. }
  900. outputs = [ "{{bundle_contents_dir}}/Frameworks/{{source_file_part}}" ]
  901. public_deps = [
  902. ":electron_framework+link",
  903. ":stripped_mantle_framework",
  904. ":stripped_reactiveobjc_framework",
  905. ":stripped_squirrel_framework",
  906. ]
  907. foreach(helper_params, content_mac_helpers) {
  908. sources +=
  909. [ "$root_out_dir/${electron_helper_name}${helper_params[2]}.app" ]
  910. public_deps += [ ":electron_helper_app_${helper_params[0]}" ]
  911. }
  912. }
  913. mac_app_bundle("electron_login_helper") {
  914. output_name = electron_login_helper_name
  915. sources = filenames.login_helper_sources
  916. include_dirs = [ "." ]
  917. frameworks = [ "AppKit.framework" ]
  918. info_plist = "shell/app/resources/mac/loginhelper-Info.plist"
  919. extra_substitutions =
  920. [ "ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.loginhelper" ]
  921. }
  922. bundle_data("electron_login_helper_app") {
  923. public_deps = [ ":electron_login_helper" ]
  924. sources = [ "$root_out_dir/$electron_login_helper_name.app" ]
  925. outputs =
  926. [ "{{bundle_contents_dir}}/Library/LoginItems/{{source_file_part}}" ]
  927. }
  928. action("electron_app_lproj_dirs") {
  929. outputs = []
  930. foreach(locale, locales_as_apple_outputs) {
  931. outputs += [ "$target_gen_dir/app_infoplist_strings/$locale.lproj" ]
  932. }
  933. script = "build/mac/make_locale_dirs.py"
  934. args = rebase_path(outputs)
  935. }
  936. foreach(locale, locales_as_apple_outputs) {
  937. bundle_data("electron_app_strings_${locale}_bundle_data") {
  938. sources = [ "$target_gen_dir/app_infoplist_strings/$locale.lproj" ]
  939. outputs = [ "{{bundle_resources_dir}}/$locale.lproj" ]
  940. public_deps = [ ":electron_app_lproj_dirs" ]
  941. }
  942. }
  943. group("electron_app_strings_bundle_data") {
  944. public_deps = []
  945. foreach(locale, locales_as_apple_outputs) {
  946. public_deps += [ ":electron_app_strings_${locale}_bundle_data" ]
  947. }
  948. }
  949. bundle_data("electron_app_resources") {
  950. public_deps = [
  951. ":default_app_asar",
  952. ":electron_app_strings_bundle_data",
  953. ]
  954. sources = [
  955. "$root_out_dir/resources/default_app.asar",
  956. "shell/browser/resources/mac/electron.icns",
  957. ]
  958. outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
  959. }
  960. asar_hashed_info_plist("electron_app_plist") {
  961. keys = [ "DEFAULT_APP_ASAR_HEADER_SHA" ]
  962. hash_targets = [ ":default_app_asar_header_hash" ]
  963. plist_file = "shell/browser/resources/mac/Info.plist"
  964. }
  965. mac_app_bundle("electron_app") {
  966. output_name = electron_product_name
  967. sources = [
  968. "shell/app/electron_main_mac.cc",
  969. "shell/app/uv_stdio_fix.cc",
  970. "shell/app/uv_stdio_fix.h",
  971. ]
  972. include_dirs = [ "." ]
  973. deps = [
  974. ":electron_app_framework_bundle_data",
  975. ":electron_app_plist",
  976. ":electron_app_resources",
  977. ":electron_fuses",
  978. "//base/allocator:early_zone_registration_mac",
  979. "//electron/buildflags",
  980. ]
  981. if (is_mas_build) {
  982. deps += [ ":electron_login_helper_app" ]
  983. }
  984. info_plist_target = ":electron_app_plist"
  985. extra_substitutions = [
  986. "ELECTRON_BUNDLE_ID=$electron_mac_bundle_id",
  987. "ELECTRON_VERSION=$electron_version",
  988. ]
  989. ldflags = [
  990. "-rpath",
  991. "@executable_path/../Frameworks",
  992. ]
  993. extra_configs = [ "//electron/build/config:mas_build" ]
  994. }
  995. if (enable_dsyms) {
  996. extract_symbols("electron_framework_syms") {
  997. binary = "$root_out_dir/$electron_framework_name.framework/Versions/$electron_framework_version/$electron_framework_name"
  998. symbol_dir = "$root_out_dir/breakpad_symbols"
  999. dsym_file = "$root_out_dir/$electron_framework_name.dSYM/Contents/Resources/DWARF/$electron_framework_name"
  1000. deps = [ ":electron_framework" ]
  1001. }
  1002. foreach(helper_params, content_mac_helpers) {
  1003. _helper_target = helper_params[0]
  1004. _helper_bundle_id = helper_params[1]
  1005. _helper_suffix = helper_params[2]
  1006. extract_symbols("electron_helper_syms_${_helper_target}") {
  1007. binary = "$root_out_dir/$electron_helper_name${_helper_suffix}.app/Contents/MacOS/$electron_helper_name${_helper_suffix}"
  1008. symbol_dir = "$root_out_dir/breakpad_symbols"
  1009. dsym_file = "$root_out_dir/$electron_helper_name${_helper_suffix}.dSYM/Contents/Resources/DWARF/$electron_helper_name${_helper_suffix}"
  1010. deps = [ ":electron_helper_app_${_helper_target}" ]
  1011. }
  1012. }
  1013. extract_symbols("electron_app_syms") {
  1014. binary = "$root_out_dir/$electron_product_name.app/Contents/MacOS/$electron_product_name"
  1015. symbol_dir = "$root_out_dir/breakpad_symbols"
  1016. dsym_file = "$root_out_dir/$electron_product_name.dSYM/Contents/Resources/DWARF/$electron_product_name"
  1017. deps = [ ":electron_app" ]
  1018. }
  1019. extract_symbols("egl_syms") {
  1020. binary = "$root_out_dir/libEGL.dylib"
  1021. symbol_dir = "$root_out_dir/breakpad_symbols"
  1022. dsym_file = "$root_out_dir/libEGL.dylib.dSYM/Contents/Resources/DWARF/libEGL.dylib"
  1023. deps = [ "//third_party/angle:libEGL" ]
  1024. }
  1025. extract_symbols("gles_syms") {
  1026. binary = "$root_out_dir/libGLESv2.dylib"
  1027. symbol_dir = "$root_out_dir/breakpad_symbols"
  1028. dsym_file = "$root_out_dir/libGLESv2.dylib.dSYM/Contents/Resources/DWARF/libGLESv2.dylib"
  1029. deps = [ "//third_party/angle:libGLESv2" ]
  1030. }
  1031. extract_symbols("crashpad_handler_syms") {
  1032. binary = "$root_out_dir/chrome_crashpad_handler"
  1033. symbol_dir = "$root_out_dir/breakpad_symbols"
  1034. dsym_file = "$root_out_dir/chrome_crashpad_handler.dSYM/Contents/Resources/DWARF/chrome_crashpad_handler"
  1035. deps = [ "//components/crash/core/app:chrome_crashpad_handler" ]
  1036. }
  1037. group("electron_symbols") {
  1038. deps = [
  1039. ":egl_syms",
  1040. ":electron_app_syms",
  1041. ":electron_framework_syms",
  1042. ":gles_syms",
  1043. ]
  1044. if (!is_mas_build) {
  1045. deps += [ ":crashpad_handler_syms" ]
  1046. }
  1047. foreach(helper_params, content_mac_helpers) {
  1048. _helper_target = helper_params[0]
  1049. deps += [ ":electron_helper_syms_${_helper_target}" ]
  1050. }
  1051. }
  1052. } else {
  1053. group("electron_symbols") {
  1054. }
  1055. }
  1056. } else {
  1057. windows_manifest("electron_app_manifest") {
  1058. sources = [
  1059. "shell/browser/resources/win/disable_window_filtering.manifest",
  1060. "shell/browser/resources/win/dpi_aware.manifest",
  1061. as_invoker_manifest,
  1062. common_controls_manifest,
  1063. default_compatibility_manifest,
  1064. ]
  1065. }
  1066. executable("electron_app") {
  1067. output_name = electron_project_name
  1068. if (is_win) {
  1069. sources = [ "shell/app/electron_main_win.cc" ]
  1070. } else if (is_linux) {
  1071. sources = [
  1072. "shell/app/electron_main_linux.cc",
  1073. "shell/app/uv_stdio_fix.cc",
  1074. "shell/app/uv_stdio_fix.h",
  1075. ]
  1076. }
  1077. include_dirs = [ "." ]
  1078. deps = [
  1079. ":default_app_asar",
  1080. ":electron_app_manifest",
  1081. ":electron_lib",
  1082. ":electron_win32_resources",
  1083. ":packed_resources",
  1084. "//components/crash/core/app",
  1085. "//content:sandbox_helper_win",
  1086. "//electron/buildflags",
  1087. "//ui/strings",
  1088. ]
  1089. data = []
  1090. data_deps = []
  1091. data += [ "$root_out_dir/resources.pak" ]
  1092. data += [ "$root_out_dir/chrome_100_percent.pak" ]
  1093. if (enable_hidpi) {
  1094. data += [ "$root_out_dir/chrome_200_percent.pak" ]
  1095. }
  1096. foreach(locale, platform_pak_locales) {
  1097. data += [ "$root_out_dir/locales/$locale.pak" ]
  1098. }
  1099. if (!is_mac) {
  1100. data += [ "$root_out_dir/resources/default_app.asar" ]
  1101. }
  1102. if (use_v8_context_snapshot) {
  1103. public_deps = [ "//tools/v8_context_snapshot:v8_context_snapshot" ]
  1104. }
  1105. if (is_linux) {
  1106. data_deps += [ "//components/crash/core/app:chrome_crashpad_handler" ]
  1107. }
  1108. if (is_win) {
  1109. sources += [
  1110. "$target_gen_dir/win-resources/electron.rc",
  1111. "shell/browser/resources/win/resource.h",
  1112. ]
  1113. deps += [
  1114. "//chrome/app:exit_code_watcher",
  1115. "//components/crash/core/app:run_as_crashpad_handler",
  1116. ]
  1117. ldflags = []
  1118. libs = [
  1119. "comctl32.lib",
  1120. "uiautomationcore.lib",
  1121. "wtsapi32.lib",
  1122. ]
  1123. configs -= [ "//build/config/win:console" ]
  1124. configs += [
  1125. "//build/config/win:windowed",
  1126. "//build/config/win:delayloads",
  1127. ]
  1128. if (current_cpu == "x86") {
  1129. # Set the initial stack size to 0.5MiB, instead of the 1.5MiB needed by
  1130. # Chrome's main thread. This saves significant memory on threads (like
  1131. # those in the Windows thread pool, and others) whose stack size we can
  1132. # only control through this setting. Because Chrome's main thread needs
  1133. # a minimum 1.5 MiB stack, the main thread (in 32-bit builds only) uses
  1134. # fibers to switch to a 1.5 MiB stack before running any other code.
  1135. ldflags += [ "/STACK:0x80000" ]
  1136. } else {
  1137. # Increase the initial stack size. The default is 1MB, this is 8MB.
  1138. ldflags += [ "/STACK:0x800000" ]
  1139. }
  1140. # This is to support renaming of electron.exe. node-gyp has hard-coded
  1141. # executable names which it will recognise as node. This module definition
  1142. # file claims that the electron executable is in fact named "node.exe",
  1143. # which is one of the executable names that node-gyp recognizes.
  1144. # See https://github.com/nodejs/node-gyp/commit/52ceec3a6d15de3a8f385f43dbe5ecf5456ad07a
  1145. ldflags += [ "/DEF:" + rebase_path("build/electron.def", root_build_dir) ]
  1146. inputs = [
  1147. "shell/browser/resources/win/electron.ico",
  1148. "build/electron.def",
  1149. ]
  1150. }
  1151. if (is_linux) {
  1152. ldflags = [
  1153. "-pie",
  1154. # Required for exporting all symbols of libuv.
  1155. "-Wl,--whole-archive",
  1156. "obj/third_party/electron_node/deps/uv/libuv.a",
  1157. "-Wl,--no-whole-archive",
  1158. ]
  1159. if (!is_component_build && is_component_ffmpeg) {
  1160. configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
  1161. }
  1162. if (is_linux) {
  1163. deps += [ "//sandbox/linux:chrome_sandbox" ]
  1164. }
  1165. }
  1166. }
  1167. if (is_official_build) {
  1168. if (is_linux) {
  1169. _target_executable_suffix = ""
  1170. _target_shared_library_suffix = ".so"
  1171. } else if (is_win) {
  1172. _target_executable_suffix = ".exe"
  1173. _target_shared_library_suffix = ".dll"
  1174. }
  1175. extract_symbols("electron_app_symbols") {
  1176. binary = "$root_out_dir/$electron_project_name$_target_executable_suffix"
  1177. symbol_dir = "$root_out_dir/breakpad_symbols"
  1178. deps = [ ":electron_app" ]
  1179. }
  1180. extract_symbols("egl_symbols") {
  1181. binary = "$root_out_dir/libEGL$_target_shared_library_suffix"
  1182. symbol_dir = "$root_out_dir/breakpad_symbols"
  1183. deps = [ "//third_party/angle:libEGL" ]
  1184. }
  1185. extract_symbols("gles_symbols") {
  1186. binary = "$root_out_dir/libGLESv2$_target_shared_library_suffix"
  1187. symbol_dir = "$root_out_dir/breakpad_symbols"
  1188. deps = [ "//third_party/angle:libGLESv2" ]
  1189. }
  1190. group("electron_symbols") {
  1191. deps = [
  1192. ":egl_symbols",
  1193. ":electron_app_symbols",
  1194. ":gles_symbols",
  1195. ]
  1196. }
  1197. }
  1198. }
  1199. test("shell_browser_ui_unittests") {
  1200. sources = [
  1201. "//electron/shell/browser/ui/accelerator_util_unittests.cc",
  1202. "//electron/shell/browser/ui/run_all_unittests.cc",
  1203. ]
  1204. configs += [ ":electron_lib_config" ]
  1205. deps = [
  1206. ":electron_lib",
  1207. "//base",
  1208. "//base/test:test_support",
  1209. "//testing/gmock",
  1210. "//testing/gtest",
  1211. "//ui/base",
  1212. "//ui/strings",
  1213. ]
  1214. }
  1215. template("dist_zip") {
  1216. _runtime_deps_target = "${target_name}__deps"
  1217. _runtime_deps_file =
  1218. "$root_out_dir/gen.runtime/" + get_label_info(target_name, "dir") + "/" +
  1219. get_label_info(target_name, "name") + ".runtime_deps"
  1220. group(_runtime_deps_target) {
  1221. forward_variables_from(invoker,
  1222. [
  1223. "deps",
  1224. "data_deps",
  1225. "data",
  1226. "testonly",
  1227. ])
  1228. write_runtime_deps = _runtime_deps_file
  1229. }
  1230. action(target_name) {
  1231. script = "//electron/build/zip.py"
  1232. deps = [ ":$_runtime_deps_target" ]
  1233. forward_variables_from(invoker,
  1234. [
  1235. "outputs",
  1236. "testonly",
  1237. ])
  1238. flatten = false
  1239. flatten_relative_to = false
  1240. if (defined(invoker.flatten)) {
  1241. flatten = invoker.flatten
  1242. if (defined(invoker.flatten_relative_to)) {
  1243. flatten_relative_to = invoker.flatten_relative_to
  1244. }
  1245. }
  1246. args = rebase_path(outputs + [ _runtime_deps_file ], root_build_dir) + [
  1247. target_cpu,
  1248. target_os,
  1249. "$flatten",
  1250. "$flatten_relative_to",
  1251. ]
  1252. }
  1253. }
  1254. copy("electron_license") {
  1255. sources = [ "LICENSE" ]
  1256. outputs = [ "$root_build_dir/{{source_file_part}}" ]
  1257. }
  1258. copy("chromium_licenses") {
  1259. deps = [ "//components/resources:about_credits" ]
  1260. sources = [ "$root_gen_dir/components/resources/about_credits.html" ]
  1261. outputs = [ "$root_build_dir/LICENSES.chromium.html" ]
  1262. }
  1263. group("licenses") {
  1264. data_deps = [
  1265. ":chromium_licenses",
  1266. ":electron_license",
  1267. ]
  1268. }
  1269. dist_zip("electron_dist_zip") {
  1270. data_deps = [
  1271. ":electron_app",
  1272. ":electron_version_file",
  1273. ":licenses",
  1274. ]
  1275. if (is_linux) {
  1276. data_deps += [ "//sandbox/linux:chrome_sandbox" ]
  1277. }
  1278. deps = data_deps
  1279. outputs = [ "$root_build_dir/dist.zip" ]
  1280. }
  1281. dist_zip("electron_ffmpeg_zip") {
  1282. data_deps = [ "//third_party/ffmpeg" ]
  1283. deps = data_deps
  1284. outputs = [ "$root_build_dir/ffmpeg.zip" ]
  1285. }
  1286. electron_chromedriver_deps = [
  1287. ":licenses",
  1288. "//chrome/test/chromedriver:chromedriver_server",
  1289. "//electron/buildflags",
  1290. ]
  1291. group("electron_chromedriver") {
  1292. testonly = true
  1293. public_deps = electron_chromedriver_deps
  1294. }
  1295. dist_zip("electron_chromedriver_zip") {
  1296. testonly = true
  1297. data_deps = electron_chromedriver_deps
  1298. deps = data_deps
  1299. outputs = [ "$root_build_dir/chromedriver.zip" ]
  1300. }
  1301. mksnapshot_deps = [
  1302. ":licenses",
  1303. "//v8:mksnapshot($v8_snapshot_toolchain)",
  1304. ]
  1305. if (use_v8_context_snapshot) {
  1306. mksnapshot_deps += [ "//tools/v8_context_snapshot:v8_context_snapshot_generator($v8_snapshot_toolchain)" ]
  1307. }
  1308. group("electron_mksnapshot") {
  1309. public_deps = mksnapshot_deps
  1310. }
  1311. dist_zip("electron_mksnapshot_zip") {
  1312. data_deps = mksnapshot_deps
  1313. deps = data_deps
  1314. outputs = [ "$root_build_dir/mksnapshot.zip" ]
  1315. }
  1316. copy("hunspell_dictionaries") {
  1317. sources = hunspell_dictionaries + hunspell_licenses
  1318. outputs = [ "$target_gen_dir/electron_hunspell/{{source_file_part}}" ]
  1319. }
  1320. dist_zip("hunspell_dictionaries_zip") {
  1321. data_deps = [ ":hunspell_dictionaries" ]
  1322. deps = data_deps
  1323. flatten = true
  1324. outputs = [ "$root_build_dir/hunspell_dictionaries.zip" ]
  1325. }
  1326. copy("libcxx_headers") {
  1327. sources = libcxx_headers + libcxx_licenses +
  1328. [ "//buildtools/third_party/libc++/__config_site" ]
  1329. outputs = [ "$target_gen_dir/electron_libcxx_include/{{source_root_relative_dir}}/{{source_file_part}}" ]
  1330. }
  1331. dist_zip("libcxx_headers_zip") {
  1332. data_deps = [ ":libcxx_headers" ]
  1333. deps = data_deps
  1334. flatten = true
  1335. flatten_relative_to = rebase_path(
  1336. "$target_gen_dir/electron_libcxx_include/buildtools/third_party/libc++/trunk",
  1337. "$root_out_dir")
  1338. outputs = [ "$root_build_dir/libcxx_headers.zip" ]
  1339. }
  1340. copy("libcxxabi_headers") {
  1341. sources = libcxxabi_headers + libcxxabi_licenses
  1342. outputs = [ "$target_gen_dir/electron_libcxxabi_include/{{source_root_relative_dir}}/{{source_file_part}}" ]
  1343. }
  1344. dist_zip("libcxxabi_headers_zip") {
  1345. data_deps = [ ":libcxxabi_headers" ]
  1346. deps = data_deps
  1347. flatten = true
  1348. flatten_relative_to = rebase_path(
  1349. "$target_gen_dir/electron_libcxxabi_include/buildtools/third_party/libc++abi/trunk",
  1350. "$root_out_dir")
  1351. outputs = [ "$root_build_dir/libcxxabi_headers.zip" ]
  1352. }
  1353. action("libcxx_objects_zip") {
  1354. deps = [ "//buildtools/third_party/libc++" ]
  1355. script = "build/zip_libcxx.py"
  1356. outputs = [ "$root_build_dir/libcxx_objects.zip" ]
  1357. args = rebase_path(outputs)
  1358. }
  1359. group("electron") {
  1360. public_deps = [ ":electron_app" ]
  1361. }