BUILD.gn 28 KB

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