BUILD.gn 46 KB

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