BUILD.gn 46 KB

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