BUILD.gn 46 KB

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