BUILD.gn 35 KB

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