BUILD.gn 43 KB

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