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