BUILD.gn 45 KB

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