BUILD.gn 26 KB

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