BUILD.gn 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581
  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/electron_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("//ui/gl/features.gni")
  37. import("//v8/gni/v8.gni")
  38. import("build/rules.gni")
  39. assert(
  40. mac_deployment_target == "10.15",
  41. "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")
  42. }
  43. if (is_linux) {
  44. import("//build/config/linux/pkg_config.gni")
  45. import("//tools/generate_stubs/rules.gni")
  46. pkg_config("gio_unix") {
  47. packages = [ "gio-unix-2.0" ]
  48. }
  49. pkg_config("libnotify_config") {
  50. packages = [
  51. "glib-2.0",
  52. "gdk-pixbuf-2.0",
  53. ]
  54. }
  55. generate_library_loader("libnotify_loader") {
  56. name = "LibNotifyLoader"
  57. output_h = "libnotify_loader.h"
  58. output_cc = "libnotify_loader.cc"
  59. header = "<libnotify/notify.h>"
  60. config = ":libnotify_config"
  61. functions = [
  62. "notify_is_initted",
  63. "notify_init",
  64. "notify_get_server_caps",
  65. "notify_get_server_info",
  66. "notify_notification_new",
  67. "notify_notification_add_action",
  68. "notify_notification_set_image_from_pixbuf",
  69. "notify_notification_set_timeout",
  70. "notify_notification_set_urgency",
  71. "notify_notification_set_hint_string",
  72. "notify_notification_show",
  73. "notify_notification_close",
  74. ]
  75. }
  76. # Generates electron_gtk_stubs.h header which contains
  77. # stubs for extracting function ptrs from the gtk library.
  78. # Function signatures for which stubs are required should be
  79. # declared in electron_gtk.sigs, currently this file contains
  80. # signatures for the functions used with native file chooser
  81. # implementation. In future, this file can be extended to contain
  82. # gtk4 stubs to switch gtk version in runtime.
  83. generate_stubs("electron_gtk_stubs") {
  84. sigs = [
  85. "shell/browser/ui/electron_gdk_pixbuf.sigs",
  86. "shell/browser/ui/electron_gtk.sigs",
  87. ]
  88. extra_header = "shell/browser/ui/electron_gtk.fragment"
  89. output_name = "electron_gtk_stubs"
  90. public_deps = [ "//ui/gtk:gtk_config" ]
  91. logging_function = "LogNoop()"
  92. logging_include = "ui/gtk/log_noop.h"
  93. }
  94. }
  95. branding = read_file("shell/app/BRANDING.json", "json")
  96. electron_project_name = branding.project_name
  97. electron_product_name = branding.product_name
  98. electron_mac_bundle_id = branding.mac_bundle_id
  99. if (override_electron_version != "") {
  100. electron_version = override_electron_version
  101. } else {
  102. # When building from source code tarball there is no git tag available and
  103. # builders must explicitly pass override_electron_version in gn args.
  104. # This read_file call will assert if there is no git information, without it
  105. # gn will generate a malformed build configuration and ninja will get into
  106. # infinite loop.
  107. read_file(".git/packed-refs", "string")
  108. # Set electron version from git tag.
  109. electron_version = exec_script("script/get-git-version.py",
  110. [],
  111. "trim string",
  112. [
  113. ".git/packed-refs",
  114. ".git/HEAD",
  115. ])
  116. }
  117. if (is_mas_build) {
  118. assert(is_mac,
  119. "It doesn't make sense to build a MAS build on a non-mac platform")
  120. }
  121. if (enable_pdf_viewer) {
  122. assert(enable_pdf, "PDF viewer support requires enable_pdf=true")
  123. assert(enable_electron_extensions,
  124. "PDF viewer support requires enable_electron_extensions=true")
  125. }
  126. if (enable_electron_extensions) {
  127. assert(enable_extensions,
  128. "Chrome extension support requires enable_extensions=true")
  129. }
  130. config("branding") {
  131. defines = [
  132. "ELECTRON_PRODUCT_NAME=\"$electron_product_name\"",
  133. "ELECTRON_PROJECT_NAME=\"$electron_project_name\"",
  134. ]
  135. }
  136. config("electron_lib_config") {
  137. include_dirs = [ "." ]
  138. }
  139. # We generate the definitions twice here, once in //electron/electron.d.ts
  140. # and once in $target_gen_dir
  141. # The one in $target_gen_dir is used for the actual TSC build later one
  142. # and the one in //electron/electron.d.ts is used by your IDE (vscode)
  143. # for typescript prompting
  144. npm_action("build_electron_definitions") {
  145. script = "gn-typescript-definitions"
  146. args = [ rebase_path("$target_gen_dir/tsc/typings/electron.d.ts") ]
  147. inputs = auto_filenames.api_docs + [ "yarn.lock" ]
  148. outputs = [ "$target_gen_dir/tsc/typings/electron.d.ts" ]
  149. }
  150. webpack_build("electron_browser_bundle") {
  151. deps = [ ":build_electron_definitions" ]
  152. inputs = auto_filenames.browser_bundle_deps
  153. config_file = "//electron/build/webpack/webpack.config.browser.js"
  154. out_file = "$target_gen_dir/js2c/browser_init.js"
  155. }
  156. webpack_build("electron_renderer_bundle") {
  157. deps = [ ":build_electron_definitions" ]
  158. inputs = auto_filenames.renderer_bundle_deps
  159. config_file = "//electron/build/webpack/webpack.config.renderer.js"
  160. out_file = "$target_gen_dir/js2c/renderer_init.js"
  161. }
  162. webpack_build("electron_worker_bundle") {
  163. deps = [ ":build_electron_definitions" ]
  164. inputs = auto_filenames.worker_bundle_deps
  165. config_file = "//electron/build/webpack/webpack.config.worker.js"
  166. out_file = "$target_gen_dir/js2c/worker_init.js"
  167. }
  168. webpack_build("electron_sandboxed_renderer_bundle") {
  169. deps = [ ":build_electron_definitions" ]
  170. inputs = auto_filenames.sandbox_bundle_deps
  171. config_file = "//electron/build/webpack/webpack.config.sandboxed_renderer.js"
  172. out_file = "$target_gen_dir/js2c/sandbox_bundle.js"
  173. }
  174. webpack_build("electron_isolated_renderer_bundle") {
  175. deps = [ ":build_electron_definitions" ]
  176. inputs = auto_filenames.isolated_bundle_deps
  177. config_file = "//electron/build/webpack/webpack.config.isolated_renderer.js"
  178. out_file = "$target_gen_dir/js2c/isolated_bundle.js"
  179. }
  180. webpack_build("electron_node_bundle") {
  181. deps = [ ":build_electron_definitions" ]
  182. inputs = auto_filenames.node_bundle_deps
  183. config_file = "//electron/build/webpack/webpack.config.node.js"
  184. out_file = "$target_gen_dir/js2c/node_init.js"
  185. }
  186. webpack_build("electron_utility_bundle") {
  187. deps = [ ":build_electron_definitions" ]
  188. inputs = auto_filenames.utility_bundle_deps
  189. config_file = "//electron/build/webpack/webpack.config.utility.js"
  190. out_file = "$target_gen_dir/js2c/utility_init.js"
  191. }
  192. action("electron_js2c") {
  193. deps = [
  194. ":electron_browser_bundle",
  195. ":electron_isolated_renderer_bundle",
  196. ":electron_node_bundle",
  197. ":electron_renderer_bundle",
  198. ":electron_sandboxed_renderer_bundle",
  199. ":electron_utility_bundle",
  200. ":electron_worker_bundle",
  201. "//third_party/electron_node:node_js2c($electron_js2c_toolchain)",
  202. ]
  203. sources = [
  204. "$target_gen_dir/js2c/browser_init.js",
  205. "$target_gen_dir/js2c/isolated_bundle.js",
  206. "$target_gen_dir/js2c/node_init.js",
  207. "$target_gen_dir/js2c/renderer_init.js",
  208. "$target_gen_dir/js2c/sandbox_bundle.js",
  209. "$target_gen_dir/js2c/utility_init.js",
  210. "$target_gen_dir/js2c/worker_init.js",
  211. ]
  212. inputs = sources
  213. outputs = [ "$root_gen_dir/electron_natives.cc" ]
  214. script = "build/js2c.py"
  215. out_dir =
  216. get_label_info(":anything($electron_js2c_toolchain)", "root_out_dir")
  217. args = [
  218. rebase_path("$out_dir/node_js2c"),
  219. rebase_path("$root_gen_dir"),
  220. ] + rebase_path(outputs, root_gen_dir) +
  221. rebase_path(sources, root_gen_dir)
  222. }
  223. action("generate_config_gypi") {
  224. outputs = [ "$root_gen_dir/config.gypi" ]
  225. script = "script/generate-config-gypi.py"
  226. inputs = [ "//third_party/electron_node/configure.py" ]
  227. args = rebase_path(outputs) + [ target_cpu ]
  228. }
  229. target_gen_default_app_js = "$target_gen_dir/js/default_app"
  230. typescript_build("default_app_js") {
  231. deps = [ ":build_electron_definitions" ]
  232. sources = filenames.default_app_ts_sources
  233. output_gen_dir = target_gen_default_app_js
  234. output_dir_name = "default_app"
  235. tsconfig = "tsconfig.default_app.json"
  236. }
  237. copy("default_app_static") {
  238. sources = filenames.default_app_static_sources
  239. outputs = [ "$target_gen_default_app_js/{{source}}" ]
  240. }
  241. copy("default_app_octicon_deps") {
  242. sources = filenames.default_app_octicon_sources
  243. outputs = [ "$target_gen_default_app_js/electron/default_app/octicon/{{source_file_part}}" ]
  244. }
  245. asar("default_app_asar") {
  246. deps = [
  247. ":default_app_js",
  248. ":default_app_octicon_deps",
  249. ":default_app_static",
  250. ]
  251. root = "$target_gen_default_app_js/electron/default_app"
  252. sources = get_target_outputs(":default_app_js") +
  253. get_target_outputs(":default_app_static") +
  254. get_target_outputs(":default_app_octicon_deps")
  255. outputs = [ "$root_out_dir/resources/default_app.asar" ]
  256. }
  257. grit("resources") {
  258. source = "electron_resources.grd"
  259. outputs = [
  260. "grit/electron_resources.h",
  261. "electron_resources.pak",
  262. ]
  263. # Mojo manifest overlays are generated.
  264. grit_flags = [
  265. "-E",
  266. "target_gen_dir=" + rebase_path(target_gen_dir, root_build_dir),
  267. ]
  268. deps = [ ":copy_shell_devtools_discovery_page" ]
  269. output_dir = "$target_gen_dir"
  270. }
  271. copy("copy_shell_devtools_discovery_page") {
  272. sources = [ "//content/shell/resources/shell_devtools_discovery_page.html" ]
  273. outputs = [ "$target_gen_dir/shell_devtools_discovery_page.html" ]
  274. }
  275. npm_action("electron_version_args") {
  276. script = "generate-version-json"
  277. outputs = [ "$target_gen_dir/electron_version.args" ]
  278. args = rebase_path(outputs) + [ "$electron_version" ]
  279. inputs = [ "script/generate-version-json.js" ]
  280. }
  281. templated_file("electron_version_header") {
  282. deps = [ ":electron_version_args" ]
  283. template = "build/templates/electron_version.tmpl"
  284. output = "$target_gen_dir/electron_version.h"
  285. args_files = get_target_outputs(":electron_version_args")
  286. }
  287. templated_file("electron_win_rc") {
  288. deps = [ ":electron_version_args" ]
  289. template = "build/templates/electron_rc.tmpl"
  290. output = "$target_gen_dir/win-resources/electron.rc"
  291. args_files = get_target_outputs(":electron_version_args")
  292. }
  293. copy("electron_win_resource_files") {
  294. sources = [
  295. "shell/browser/resources/win/electron.ico",
  296. "shell/browser/resources/win/resource.h",
  297. ]
  298. outputs = [ "$target_gen_dir/win-resources/{{source_file_part}}" ]
  299. }
  300. templated_file("electron_version_file") {
  301. deps = [ ":electron_version_args" ]
  302. template = "build/templates/version_string.tmpl"
  303. output = "$root_build_dir/version"
  304. args_files = get_target_outputs(":electron_version_args")
  305. }
  306. group("electron_win32_resources") {
  307. public_deps = [
  308. ":electron_win_rc",
  309. ":electron_win_resource_files",
  310. ]
  311. }
  312. action("electron_fuses") {
  313. script = "build/fuses/build.py"
  314. inputs = [ "build/fuses/fuses.json5" ]
  315. outputs = [
  316. "$target_gen_dir/fuses.h",
  317. "$target_gen_dir/fuses.cc",
  318. ]
  319. args = rebase_path(outputs)
  320. }
  321. action("electron_generate_node_defines") {
  322. script = "build/generate_node_defines.py"
  323. inputs = [
  324. "//third_party/electron_node/src/tracing/trace_event_common.h",
  325. "//third_party/electron_node/src/tracing/trace_event.h",
  326. "//third_party/electron_node/src/util.h",
  327. ]
  328. outputs = [
  329. "$target_gen_dir/push_and_undef_node_defines.h",
  330. "$target_gen_dir/pop_node_defines.h",
  331. ]
  332. args = [ rebase_path(target_gen_dir) ] + rebase_path(inputs)
  333. }
  334. source_set("electron_lib") {
  335. configs += [
  336. "//v8:external_startup_data",
  337. "//third_party/electron_node:node_internals",
  338. ]
  339. public_configs = [
  340. ":branding",
  341. ":electron_lib_config",
  342. ]
  343. deps = [
  344. ":electron_fuses",
  345. ":electron_generate_node_defines",
  346. ":electron_js2c",
  347. ":electron_version_header",
  348. ":resources",
  349. "buildflags",
  350. "chromium_src:chrome",
  351. "chromium_src:chrome_spellchecker",
  352. "shell/common/api:mojo",
  353. "shell/services/node/public/mojom",
  354. "//base:base_static",
  355. "//base/allocator:buildflags",
  356. "//chrome:strings",
  357. "//chrome/app:command_ids",
  358. "//chrome/app/resources:platform_locale_settings",
  359. "//components/autofill/core/common:features",
  360. "//components/certificate_transparency",
  361. "//components/compose:buildflags",
  362. "//components/embedder_support:browser_util",
  363. "//components/language/core/browser",
  364. "//components/net_log",
  365. "//components/network_hints/browser",
  366. "//components/network_hints/common:mojo_bindings",
  367. "//components/network_hints/renderer",
  368. "//components/network_session_configurator/common",
  369. "//components/omnibox/browser:buildflags",
  370. "//components/os_crypt/async/browser",
  371. "//components/os_crypt/async/browser:key_provider_interface",
  372. "//components/os_crypt/sync",
  373. "//components/pref_registry",
  374. "//components/prefs",
  375. "//components/security_state/content",
  376. "//components/upload_list",
  377. "//components/user_prefs",
  378. "//components/viz/host",
  379. "//components/viz/service",
  380. "//components/webrtc",
  381. "//content/public/browser",
  382. "//content/public/child",
  383. "//content/public/gpu",
  384. "//content/public/renderer",
  385. "//content/public/utility",
  386. "//device/bluetooth",
  387. "//device/bluetooth/public/cpp",
  388. "//gin",
  389. "//media/capture/mojom:video_capture",
  390. "//media/mojo/mojom",
  391. "//net:extras",
  392. "//net:net_resources",
  393. "//printing/buildflags",
  394. "//services/device/public/cpp/bluetooth:bluetooth",
  395. "//services/device/public/cpp/geolocation",
  396. "//services/device/public/cpp/hid",
  397. "//services/device/public/mojom",
  398. "//services/proxy_resolver:lib",
  399. "//services/video_capture/public/mojom:constants",
  400. "//services/viz/privileged/mojom/compositing",
  401. "//services/viz/public/mojom",
  402. "//skia",
  403. "//third_party/blink/public:blink",
  404. "//third_party/blink/public:blink_devtools_inspector_resources",
  405. "//third_party/blink/public/platform/media",
  406. "//third_party/boringssl",
  407. "//third_party/electron_node:node_lib",
  408. "//third_party/inspector_protocol:crdtp",
  409. "//third_party/leveldatabase",
  410. "//third_party/libyuv",
  411. "//third_party/webrtc_overrides:webrtc_component",
  412. "//third_party/widevine/cdm:headers",
  413. "//third_party/zlib/google:zip",
  414. "//ui/base:ozone_buildflags",
  415. "//ui/base/idle",
  416. "//ui/compositor",
  417. "//ui/events:dom_keycode_converter",
  418. "//ui/gl",
  419. "//ui/native_theme",
  420. "//ui/shell_dialogs",
  421. "//ui/views",
  422. "//ui/views/controls/webview",
  423. "//v8",
  424. "//v8:v8_libplatform",
  425. ]
  426. public_deps = [
  427. "//base",
  428. "//base:i18n",
  429. "//content/public/app",
  430. ]
  431. include_dirs = [
  432. ".",
  433. "$target_gen_dir",
  434. # TODO(nornagon): replace usage of SchemeRegistry by an actually exported
  435. # API of blink, then remove this from the include_dirs.
  436. "//third_party/blink/renderer",
  437. ]
  438. defines = [ "V8_DEPRECATION_WARNINGS" ]
  439. libs = []
  440. if (is_linux) {
  441. defines += [ "GDK_DISABLE_DEPRECATION_WARNINGS" ]
  442. }
  443. if (!is_mas_build) {
  444. deps += [
  445. "//components/crash/core/app",
  446. "//components/crash/core/browser",
  447. ]
  448. }
  449. configs += [ "//electron/build/config:mas_build" ]
  450. sources = filenames.lib_sources
  451. if (is_win) {
  452. sources += filenames.lib_sources_win
  453. }
  454. if (is_mac) {
  455. sources += filenames.lib_sources_mac
  456. }
  457. if (is_posix) {
  458. sources += filenames.lib_sources_posix
  459. }
  460. if (is_linux) {
  461. sources += filenames.lib_sources_linux
  462. }
  463. if (!is_mac) {
  464. sources += filenames.lib_sources_views
  465. }
  466. if (is_component_build) {
  467. defines += [ "NODE_SHARED_MODE" ]
  468. }
  469. if (enable_fake_location_provider) {
  470. sources += [
  471. "shell/browser/fake_location_provider.cc",
  472. "shell/browser/fake_location_provider.h",
  473. ]
  474. }
  475. if (is_mac) {
  476. deps += [
  477. "//components/remote_cocoa/app_shim",
  478. "//components/remote_cocoa/browser",
  479. "//content/browser:mac_helpers",
  480. "//ui/accelerated_widget_mac",
  481. ]
  482. if (!is_mas_build) {
  483. deps += [ "//third_party/crashpad/crashpad/client" ]
  484. }
  485. frameworks = [
  486. "AuthenticationServices.framework",
  487. "AVFoundation.framework",
  488. "Carbon.framework",
  489. "LocalAuthentication.framework",
  490. "QuartzCore.framework",
  491. "Quartz.framework",
  492. "Security.framework",
  493. "SecurityInterface.framework",
  494. "ServiceManagement.framework",
  495. "StoreKit.framework",
  496. ]
  497. weak_frameworks = [ "QuickLookThumbnailing.framework" ]
  498. sources += [
  499. "shell/browser/ui/views/autofill_popup_view.cc",
  500. "shell/browser/ui/views/autofill_popup_view.h",
  501. ]
  502. if (is_mas_build) {
  503. sources += [ "shell/browser/api/electron_api_app_mas.mm" ]
  504. sources -= [ "shell/browser/auto_updater_mac.mm" ]
  505. sources -= [
  506. "shell/app/electron_crash_reporter_client.cc",
  507. "shell/app/electron_crash_reporter_client.h",
  508. "shell/common/crash_keys.cc",
  509. "shell/common/crash_keys.h",
  510. ]
  511. } else {
  512. frameworks += [
  513. "Squirrel.framework",
  514. "ReactiveObjC.framework",
  515. "Mantle.framework",
  516. ]
  517. deps += [
  518. "//third_party/squirrel.mac:reactiveobjc_framework+link",
  519. "//third_party/squirrel.mac:squirrel_framework+link",
  520. ]
  521. # ReactiveObjC which is used by Squirrel requires using __weak.
  522. cflags_objcc = [ "-fobjc-weak" ]
  523. }
  524. }
  525. if (is_linux) {
  526. libs = [ "xshmfence" ]
  527. deps += [
  528. ":electron_gtk_stubs",
  529. ":libnotify_loader",
  530. "//build/config/linux/gtk",
  531. "//components/crash/content/browser",
  532. "//dbus",
  533. "//device/bluetooth",
  534. "//third_party/crashpad/crashpad/client",
  535. "//ui/base/ime/linux",
  536. "//ui/events/devices/x11",
  537. "//ui/events/platform/x11",
  538. "//ui/gtk:gtk_config",
  539. "//ui/linux:linux_ui",
  540. "//ui/linux:linux_ui_factory",
  541. "//ui/wm",
  542. ]
  543. if (ozone_platform_x11) {
  544. sources += filenames.lib_sources_linux_x11
  545. public_deps += [
  546. "//ui/base/x",
  547. "//ui/ozone/platform/x11",
  548. ]
  549. }
  550. configs += [ ":gio_unix" ]
  551. defines += [
  552. # Disable warnings for g_settings_list_schemas.
  553. "GLIB_DISABLE_DEPRECATION_WARNINGS",
  554. ]
  555. sources += [
  556. "shell/browser/certificate_manager_model.cc",
  557. "shell/browser/certificate_manager_model.h",
  558. "shell/browser/ui/gtk_util.cc",
  559. "shell/browser/ui/gtk_util.h",
  560. ]
  561. }
  562. if (is_win) {
  563. libs += [ "dwmapi.lib" ]
  564. sources += [ "shell/common/asar/archive_win.cc" ]
  565. deps += [
  566. "//components/crash/core/app:crash_export_thunks",
  567. "//ui/native_theme:native_theme_browser",
  568. "//ui/wm",
  569. "//ui/wm/public",
  570. ]
  571. public_deps += [
  572. "//sandbox/win:sandbox",
  573. "//third_party/crashpad/crashpad/handler",
  574. ]
  575. }
  576. if (enable_plugins) {
  577. deps += [ "chromium_src:plugins" ]
  578. sources += [
  579. "shell/common/plugin_info.cc",
  580. "shell/common/plugin_info.h",
  581. "shell/renderer/electron_renderer_pepper_host_factory.cc",
  582. "shell/renderer/electron_renderer_pepper_host_factory.h",
  583. "shell/renderer/pepper_helper.cc",
  584. "shell/renderer/pepper_helper.h",
  585. ]
  586. }
  587. if (enable_ppapi) {
  588. deps += [
  589. "//ppapi/host",
  590. "//ppapi/proxy",
  591. "//ppapi/shared_impl",
  592. ]
  593. }
  594. if (enable_printing) {
  595. sources += [
  596. "shell/browser/printing/print_view_manager_electron.cc",
  597. "shell/browser/printing/print_view_manager_electron.h",
  598. "shell/browser/printing/printing_utils.cc",
  599. "shell/browser/printing/printing_utils.h",
  600. "shell/renderer/printing/print_render_frame_helper_delegate.cc",
  601. "shell/renderer/printing/print_render_frame_helper_delegate.h",
  602. ]
  603. deps += [
  604. "//chrome/services/printing/public/mojom",
  605. "//components/printing/common:mojo_interfaces",
  606. ]
  607. if (is_mac) {
  608. deps += [ "//chrome/services/mac_notifications/public/mojom" ]
  609. }
  610. }
  611. if (enable_electron_extensions) {
  612. sources += filenames.lib_sources_extensions
  613. deps += [
  614. "shell/browser/extensions/api:api_registration",
  615. "shell/common/extensions/api",
  616. "shell/common/extensions/api:extensions_features",
  617. "//chrome/browser/resources:component_extension_resources",
  618. "//components/guest_view/common:mojom",
  619. "//components/update_client:update_client",
  620. "//components/zoom",
  621. "//extensions/browser",
  622. "//extensions/browser/api:api_provider",
  623. "//extensions/browser/updater",
  624. "//extensions/common",
  625. "//extensions/common:core_api_provider",
  626. "//extensions/renderer",
  627. ]
  628. }
  629. if (enable_pdf) {
  630. # Printing depends on some //pdf code, so it needs to be built even if the
  631. # pdf viewer isn't enabled.
  632. deps += [
  633. "//pdf",
  634. "//pdf:features",
  635. ]
  636. }
  637. if (enable_pdf_viewer) {
  638. deps += [
  639. "//chrome/browser/resources/pdf:resources",
  640. "//components/pdf/browser",
  641. "//components/pdf/browser:interceptors",
  642. "//components/pdf/common:constants",
  643. "//components/pdf/common:util",
  644. "//components/pdf/renderer",
  645. "//pdf",
  646. ]
  647. sources += [
  648. "shell/browser/electron_pdf_document_helper_client.cc",
  649. "shell/browser/electron_pdf_document_helper_client.h",
  650. "shell/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.cc",
  651. "shell/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.h",
  652. ]
  653. }
  654. sources += get_target_outputs(":electron_fuses")
  655. if (allow_runtime_configurable_key_storage) {
  656. defines += [ "ALLOW_RUNTIME_CONFIGURABLE_KEY_STORAGE" ]
  657. }
  658. }
  659. electron_paks("packed_resources") {
  660. if (is_mac) {
  661. output_dir = "$root_gen_dir/electron_repack"
  662. copy_data_to_bundle = true
  663. } else {
  664. output_dir = root_out_dir
  665. }
  666. }
  667. if (is_mac) {
  668. electron_framework_name = "$electron_product_name Framework"
  669. electron_helper_name = "$electron_product_name Helper"
  670. electron_login_helper_name = "$electron_product_name Login Helper"
  671. electron_framework_version = "A"
  672. mac_xib_bundle_data("electron_xibs") {
  673. sources = [ "shell/common/resources/mac/MainMenu.xib" ]
  674. }
  675. bundle_data("electron_framework_resources") {
  676. public_deps = [ ":packed_resources" ]
  677. sources = []
  678. if (icu_use_data_file) {
  679. sources += [ "$root_out_dir/icudtl.dat" ]
  680. public_deps += [ "//third_party/icu:icudata" ]
  681. }
  682. if (v8_use_external_startup_data) {
  683. public_deps += [ "//v8" ]
  684. if (use_v8_context_snapshot) {
  685. sources += [ "$root_out_dir/$v8_context_snapshot_filename" ]
  686. public_deps += [ "//tools/v8_context_snapshot" ]
  687. } else {
  688. sources += [ "$root_out_dir/snapshot_blob.bin" ]
  689. }
  690. }
  691. outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
  692. }
  693. if (!is_component_build && is_component_ffmpeg) {
  694. bundle_data("electron_framework_libraries") {
  695. sources = []
  696. public_deps = []
  697. sources += [ "$root_out_dir/libffmpeg.dylib" ]
  698. public_deps += [ "//third_party/ffmpeg:ffmpeg" ]
  699. outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ]
  700. }
  701. } else {
  702. group("electron_framework_libraries") {
  703. }
  704. }
  705. if (use_egl) {
  706. # Add the ANGLE .dylibs in the Libraries directory of the Framework.
  707. bundle_data("electron_angle_binaries") {
  708. sources = [
  709. "$root_out_dir/egl_intermediates/libEGL.dylib",
  710. "$root_out_dir/egl_intermediates/libGLESv2.dylib",
  711. ]
  712. outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ]
  713. public_deps = [ "//ui/gl:angle_library_copy" ]
  714. }
  715. # Add the SwiftShader .dylibs in the Libraries directory of the Framework.
  716. bundle_data("electron_swiftshader_binaries") {
  717. sources = [
  718. "$root_out_dir/vk_intermediates/libvk_swiftshader.dylib",
  719. "$root_out_dir/vk_intermediates/vk_swiftshader_icd.json",
  720. ]
  721. outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ]
  722. public_deps = [ "//ui/gl:swiftshader_vk_library_copy" ]
  723. }
  724. }
  725. group("electron_angle_library") {
  726. if (use_egl) {
  727. deps = [ ":electron_angle_binaries" ]
  728. }
  729. }
  730. group("electron_swiftshader_library") {
  731. if (use_egl) {
  732. deps = [ ":electron_swiftshader_binaries" ]
  733. }
  734. }
  735. bundle_data("electron_crashpad_helper") {
  736. sources = [ "$root_out_dir/chrome_crashpad_handler" ]
  737. outputs = [ "{{bundle_contents_dir}}/Helpers/{{source_file_part}}" ]
  738. public_deps = [ "//components/crash/core/app:chrome_crashpad_handler" ]
  739. if (is_asan) {
  740. # crashpad_handler requires the ASan runtime at its @executable_path.
  741. sources += [ "$root_out_dir/libclang_rt.asan_osx_dynamic.dylib" ]
  742. public_deps += [ "//build/config/sanitizers:copy_sanitizer_runtime" ]
  743. }
  744. }
  745. mac_framework_bundle("electron_framework") {
  746. output_name = electron_framework_name
  747. framework_version = electron_framework_version
  748. framework_contents = [
  749. "Resources",
  750. "Libraries",
  751. ]
  752. if (!is_mas_build) {
  753. framework_contents += [ "Helpers" ]
  754. }
  755. public_deps = [
  756. ":electron_framework_libraries",
  757. ":electron_lib",
  758. ]
  759. deps = [
  760. ":electron_angle_library",
  761. ":electron_framework_libraries",
  762. ":electron_framework_resources",
  763. ":electron_swiftshader_library",
  764. ":electron_xibs",
  765. ]
  766. if (!is_mas_build) {
  767. deps += [ ":electron_crashpad_helper" ]
  768. }
  769. info_plist = "shell/common/resources/mac/Info.plist"
  770. extra_substitutions = [
  771. "ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.framework",
  772. "ELECTRON_VERSION=$electron_version",
  773. ]
  774. include_dirs = [ "." ]
  775. sources = filenames.framework_sources
  776. frameworks = [ "IOSurface.framework" ]
  777. ldflags = [
  778. "-Wl,-install_name,@rpath/$output_name.framework/$output_name",
  779. "-rpath",
  780. "@loader_path/Libraries",
  781. # Required for exporting all symbols of libuv.
  782. "-Wl,-force_load,obj/third_party/electron_node/deps/uv/libuv.a",
  783. ]
  784. if (is_component_build) {
  785. ldflags += [
  786. "-rpath",
  787. "@executable_path/../../../../../..",
  788. ]
  789. }
  790. # For component ffmpeg under non-component build, it is linked from
  791. # @loader_path. However the ffmpeg.dylib is moved to a different place
  792. # when generating app bundle, and we should change to link from @rpath.
  793. if (is_component_ffmpeg && !is_component_build) {
  794. ldflags += [ "-Wcrl,installnametool,-change,@loader_path/libffmpeg.dylib,@rpath/libffmpeg.dylib" ]
  795. }
  796. }
  797. template("electron_helper_app") {
  798. mac_app_bundle(target_name) {
  799. assert(defined(invoker.helper_name_suffix))
  800. output_name = electron_helper_name + invoker.helper_name_suffix
  801. deps = [ ":electron_framework+link" ]
  802. if (!is_mas_build) {
  803. deps += [ "//sandbox/mac:seatbelt" ]
  804. }
  805. defines = [ "HELPER_EXECUTABLE" ]
  806. configs += [ "//electron/build/config:mas_build" ]
  807. sources = [
  808. "shell/app/electron_main_mac.cc",
  809. "shell/app/uv_stdio_fix.cc",
  810. "shell/app/uv_stdio_fix.h",
  811. "shell/common/electron_constants.cc",
  812. ]
  813. include_dirs = [ "." ]
  814. info_plist = "shell/renderer/resources/mac/Info.plist"
  815. extra_substitutions =
  816. [ "ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.helper" ]
  817. ldflags = [
  818. "-rpath",
  819. "@executable_path/../../..",
  820. ]
  821. if (is_component_build) {
  822. ldflags += [
  823. "-rpath",
  824. "@executable_path/../../../../../..",
  825. ]
  826. }
  827. }
  828. }
  829. foreach(helper_params, content_mac_helpers) {
  830. _helper_target = helper_params[0]
  831. _helper_bundle_id = helper_params[1]
  832. _helper_suffix = helper_params[2]
  833. electron_helper_app("electron_helper_app_${_helper_target}") {
  834. helper_name_suffix = _helper_suffix
  835. }
  836. }
  837. template("stripped_framework") {
  838. action(target_name) {
  839. assert(defined(invoker.framework))
  840. script = "//electron/build/strip_framework.py"
  841. forward_variables_from(invoker, [ "deps" ])
  842. inputs = [ "$root_out_dir/" + invoker.framework ]
  843. outputs = [ "$target_out_dir/stripped_frameworks/" + invoker.framework ]
  844. args = rebase_path(inputs) + rebase_path(outputs)
  845. }
  846. }
  847. stripped_framework("stripped_mantle_framework") {
  848. framework = "Mantle.framework"
  849. deps = [ "//third_party/squirrel.mac:mantle_framework" ]
  850. }
  851. stripped_framework("stripped_reactiveobjc_framework") {
  852. framework = "ReactiveObjC.framework"
  853. deps = [ "//third_party/squirrel.mac:reactiveobjc_framework" ]
  854. }
  855. stripped_framework("stripped_squirrel_framework") {
  856. framework = "Squirrel.framework"
  857. deps = [ "//third_party/squirrel.mac:squirrel_framework" ]
  858. }
  859. bundle_data("electron_app_framework_bundle_data") {
  860. sources = [ "$root_out_dir/$electron_framework_name.framework" ]
  861. if (!is_mas_build) {
  862. sources += get_target_outputs(":stripped_mantle_framework") +
  863. get_target_outputs(":stripped_reactiveobjc_framework") +
  864. get_target_outputs(":stripped_squirrel_framework")
  865. }
  866. outputs = [ "{{bundle_contents_dir}}/Frameworks/{{source_file_part}}" ]
  867. public_deps = [
  868. ":electron_framework+link",
  869. ":stripped_mantle_framework",
  870. ":stripped_reactiveobjc_framework",
  871. ":stripped_squirrel_framework",
  872. ]
  873. foreach(helper_params, content_mac_helpers) {
  874. sources +=
  875. [ "$root_out_dir/${electron_helper_name}${helper_params[2]}.app" ]
  876. public_deps += [ ":electron_helper_app_${helper_params[0]}" ]
  877. }
  878. }
  879. mac_app_bundle("electron_login_helper") {
  880. output_name = electron_login_helper_name
  881. sources = filenames.login_helper_sources
  882. include_dirs = [ "." ]
  883. frameworks = [ "AppKit.framework" ]
  884. info_plist = "shell/app/resources/mac/loginhelper-Info.plist"
  885. extra_substitutions =
  886. [ "ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.loginhelper" ]
  887. }
  888. bundle_data("electron_login_helper_app") {
  889. public_deps = [ ":electron_login_helper" ]
  890. sources = [ "$root_out_dir/$electron_login_helper_name.app" ]
  891. outputs =
  892. [ "{{bundle_contents_dir}}/Library/LoginItems/{{source_file_part}}" ]
  893. }
  894. action("electron_app_lproj_dirs") {
  895. outputs = []
  896. foreach(locale, locales_as_apple_outputs) {
  897. outputs += [ "$target_gen_dir/app_infoplist_strings/$locale.lproj" ]
  898. }
  899. script = "build/mac/make_locale_dirs.py"
  900. args = rebase_path(outputs)
  901. }
  902. foreach(locale, locales_as_apple_outputs) {
  903. bundle_data("electron_app_strings_${locale}_bundle_data") {
  904. sources = [ "$target_gen_dir/app_infoplist_strings/$locale.lproj" ]
  905. outputs = [ "{{bundle_resources_dir}}/$locale.lproj" ]
  906. public_deps = [ ":electron_app_lproj_dirs" ]
  907. }
  908. }
  909. group("electron_app_strings_bundle_data") {
  910. public_deps = []
  911. foreach(locale, locales_as_apple_outputs) {
  912. public_deps += [ ":electron_app_strings_${locale}_bundle_data" ]
  913. }
  914. }
  915. bundle_data("electron_app_resources") {
  916. public_deps = [
  917. ":default_app_asar",
  918. ":electron_app_strings_bundle_data",
  919. ]
  920. sources = [
  921. "$root_out_dir/resources/default_app.asar",
  922. "shell/browser/resources/mac/electron.icns",
  923. ]
  924. outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
  925. }
  926. asar_hashed_info_plist("electron_app_plist") {
  927. keys = [ "DEFAULT_APP_ASAR_HEADER_SHA" ]
  928. hash_targets = [ ":default_app_asar_header_hash" ]
  929. plist_file = "shell/browser/resources/mac/Info.plist"
  930. }
  931. mac_app_bundle("electron_app") {
  932. output_name = electron_product_name
  933. sources = [
  934. "shell/app/electron_main_mac.cc",
  935. "shell/app/uv_stdio_fix.cc",
  936. "shell/app/uv_stdio_fix.h",
  937. ]
  938. include_dirs = [ "." ]
  939. deps = [
  940. ":electron_app_framework_bundle_data",
  941. ":electron_app_plist",
  942. ":electron_app_resources",
  943. ":electron_fuses",
  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. configs += [ "//electron/build/config:mas_build" ]
  959. }
  960. if (enable_dsyms) {
  961. extract_symbols("electron_framework_syms") {
  962. binary = "$root_out_dir/$electron_framework_name.framework/Versions/$electron_framework_version/$electron_framework_name"
  963. symbol_dir = "$root_out_dir/breakpad_symbols"
  964. dsym_file = "$root_out_dir/$electron_framework_name.dSYM/Contents/Resources/DWARF/$electron_framework_name"
  965. deps = [ ":electron_framework" ]
  966. }
  967. foreach(helper_params, content_mac_helpers) {
  968. _helper_target = helper_params[0]
  969. _helper_bundle_id = helper_params[1]
  970. _helper_suffix = helper_params[2]
  971. extract_symbols("electron_helper_syms_${_helper_target}") {
  972. binary = "$root_out_dir/$electron_helper_name${_helper_suffix}.app/Contents/MacOS/$electron_helper_name${_helper_suffix}"
  973. symbol_dir = "$root_out_dir/breakpad_symbols"
  974. dsym_file = "$root_out_dir/$electron_helper_name${_helper_suffix}.dSYM/Contents/Resources/DWARF/$electron_helper_name${_helper_suffix}"
  975. deps = [ ":electron_helper_app_${_helper_target}" ]
  976. }
  977. }
  978. extract_symbols("electron_app_syms") {
  979. binary = "$root_out_dir/$electron_product_name.app/Contents/MacOS/$electron_product_name"
  980. symbol_dir = "$root_out_dir/breakpad_symbols"
  981. dsym_file = "$root_out_dir/$electron_product_name.dSYM/Contents/Resources/DWARF/$electron_product_name"
  982. deps = [ ":electron_app" ]
  983. }
  984. extract_symbols("egl_syms") {
  985. binary = "$root_out_dir/libEGL.dylib"
  986. symbol_dir = "$root_out_dir/breakpad_symbols"
  987. dsym_file = "$root_out_dir/libEGL.dylib.dSYM/Contents/Resources/DWARF/libEGL.dylib"
  988. deps = [ "//third_party/angle:libEGL" ]
  989. }
  990. extract_symbols("gles_syms") {
  991. binary = "$root_out_dir/libGLESv2.dylib"
  992. symbol_dir = "$root_out_dir/breakpad_symbols"
  993. dsym_file = "$root_out_dir/libGLESv2.dylib.dSYM/Contents/Resources/DWARF/libGLESv2.dylib"
  994. deps = [ "//third_party/angle:libGLESv2" ]
  995. }
  996. extract_symbols("crashpad_handler_syms") {
  997. binary = "$root_out_dir/chrome_crashpad_handler"
  998. symbol_dir = "$root_out_dir/breakpad_symbols"
  999. dsym_file = "$root_out_dir/chrome_crashpad_handler.dSYM/Contents/Resources/DWARF/chrome_crashpad_handler"
  1000. deps = [ "//components/crash/core/app:chrome_crashpad_handler" ]
  1001. }
  1002. group("electron_symbols") {
  1003. deps = [
  1004. ":egl_syms",
  1005. ":electron_app_syms",
  1006. ":electron_framework_syms",
  1007. ":gles_syms",
  1008. ]
  1009. if (!is_mas_build) {
  1010. deps += [ ":crashpad_handler_syms" ]
  1011. }
  1012. foreach(helper_params, content_mac_helpers) {
  1013. _helper_target = helper_params[0]
  1014. deps += [ ":electron_helper_syms_${_helper_target}" ]
  1015. }
  1016. }
  1017. } else {
  1018. group("electron_symbols") {
  1019. }
  1020. }
  1021. } else {
  1022. windows_manifest("electron_app_manifest") {
  1023. sources = [
  1024. "shell/browser/resources/win/disable_window_filtering.manifest",
  1025. "shell/browser/resources/win/dpi_aware.manifest",
  1026. as_invoker_manifest,
  1027. common_controls_manifest,
  1028. default_compatibility_manifest,
  1029. ]
  1030. }
  1031. executable("electron_app") {
  1032. output_name = electron_project_name
  1033. if (is_win) {
  1034. sources = [ "shell/app/electron_main_win.cc" ]
  1035. } else if (is_linux) {
  1036. sources = [
  1037. "shell/app/electron_main_linux.cc",
  1038. "shell/app/uv_stdio_fix.cc",
  1039. "shell/app/uv_stdio_fix.h",
  1040. ]
  1041. }
  1042. include_dirs = [ "." ]
  1043. deps = [
  1044. ":default_app_asar",
  1045. ":electron_app_manifest",
  1046. ":electron_lib",
  1047. ":electron_win32_resources",
  1048. ":packed_resources",
  1049. "//components/crash/core/app",
  1050. "//content:sandbox_helper_win",
  1051. "//electron/buildflags",
  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 = []
  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_files = read_file("$node_dir/filenames.json", "json")
  1317. node_headers_dir = "$root_gen_dir/node_headers"
  1318. header_group_index = 0
  1319. header_groups = []
  1320. foreach(header_group, node_files.headers) {
  1321. copy("node_headers_${header_group_index}") {
  1322. sources = rebase_path(header_group.files, ".", node_dir)
  1323. outputs =
  1324. [ "$node_headers_dir/${header_group.dest_dir}/{{source_file_part}}" ]
  1325. }
  1326. header_groups += [ ":node_headers_${header_group_index}" ]
  1327. header_group_index += 1
  1328. }
  1329. copy("zlib_headers") {
  1330. sources = [
  1331. "$node_dir/deps/zlib/zconf.h",
  1332. "$node_dir/deps/zlib/zlib.h",
  1333. ]
  1334. outputs = [ "$node_headers_dir/include/node/{{source_file_part}}" ]
  1335. }
  1336. copy("node_gypi_headers") {
  1337. deps = [ ":generate_config_gypi" ]
  1338. sources = [
  1339. "$node_dir/common.gypi",
  1340. "$root_gen_dir/config.gypi",
  1341. ]
  1342. outputs = [ "$node_headers_dir/include/node/{{source_file_part}}" ]
  1343. }
  1344. action("node_version_header") {
  1345. inputs = [ "$node_dir/src/node_version.h" ]
  1346. outputs = [ "$node_headers_dir/include/node/node_version.h" ]
  1347. script = "script/generate_node_version_header.py"
  1348. args = rebase_path(inputs) + rebase_path(outputs)
  1349. if (node_module_version != "") {
  1350. args += [ "$node_module_version" ]
  1351. }
  1352. }
  1353. action("tar_node_headers") {
  1354. deps = [ ":copy_node_headers" ]
  1355. outputs = [ "$root_gen_dir/node_headers.tar.gz" ]
  1356. script = "script/tar.py"
  1357. args = [
  1358. rebase_path("$root_gen_dir/node_headers"),
  1359. rebase_path(outputs[0]),
  1360. ]
  1361. }
  1362. group("copy_node_headers") {
  1363. public_deps = header_groups + [
  1364. ":node_gypi_headers",
  1365. ":node_version_header",
  1366. ":zlib_headers",
  1367. ]
  1368. }
  1369. group("node_headers") {
  1370. public_deps = [ ":tar_node_headers" ]
  1371. }