BUILD.gn 29 KB

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