BUILD.gn 28 KB

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