BUILD.gn 46 KB

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