BUILD.gn 46 KB

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