BUILD.gn 46 KB

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