BUILD.gn 35 KB

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