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