BUILD.gn 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. # Copyright 2015 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. import("//build/config/c++/c++.gni")
  5. import("//build/config/chrome_build.gni")
  6. import("//build/config/chromeos/ui_mode.gni")
  7. import("//build/config/features.gni")
  8. import("//build/config/sanitizers/sanitizers.gni")
  9. import("//build/config/sysroot.gni")
  10. import("//build/linux/strip_binary.gni")
  11. import("//build/util/lastchange.gni")
  12. import("//build/util/process_version.gni")
  13. import("//chrome/version.gni")
  14. import("//components/nacl/features.gni")
  15. import("//components/optimization_guide/features.gni")
  16. import("//third_party/angle/gni/angle.gni")
  17. import("//third_party/widevine/cdm/widevine.gni")
  18. import("//ui/gl/features.gni")
  19. import("//ui/qt/qt.gni")
  20. if (bundle_widevine_cdm) {
  21. import("//media/cdm/library_cdm/cdm_paths.gni")
  22. }
  23. declare_args() {
  24. # Enables checks that ensure the packages are installable on all supported
  25. # distributions.
  26. enable_distro_version_check = true
  27. # Enable building snap packages
  28. enable_snap_package = false
  29. }
  30. assert(is_linux || is_chromeos)
  31. packaging_files_executables = [
  32. "$root_out_dir/chrome",
  33. "$root_out_dir/chrome_crashpad_handler",
  34. "$root_out_dir/chrome_management_service",
  35. "$root_out_dir/chrome_sandbox",
  36. ]
  37. packaging_files_shlibs = []
  38. # TODO(https://crbug.com/1299021): Implement building these NaCl targets as
  39. # ARM32 when Chrome is built for ARM64 (for Linux/Chrome OS).
  40. if (target_cpu == "arm64") {
  41. enable_nacl = false
  42. }
  43. if (enable_nacl) {
  44. packaging_files_executables += [
  45. "$root_out_dir/nacl_helper",
  46. "$root_out_dir/nacl_helper_bootstrap",
  47. ]
  48. if (current_cpu == "x86") {
  49. packaging_files_executables += [ "$root_out_dir/nacl_irt_x86_32.nexe" ]
  50. } else if (current_cpu == "x64") {
  51. packaging_files_executables += [ "$root_out_dir/nacl_irt_x86_64.nexe" ]
  52. } else if (current_cpu == "arm") {
  53. packaging_files_executables += [ "$root_out_dir/nacl_irt_arm.nexe" ]
  54. } else if (current_cpu == "mipsel") {
  55. packaging_files_executables += [ "$root_out_dir/nacl_irt_mips32.nexe" ]
  56. }
  57. }
  58. if (bundle_widevine_cdm) {
  59. packaging_files_shlibs +=
  60. [ "$root_out_dir/$widevine_cdm_path/libwidevinecdm.so" ]
  61. }
  62. if (use_egl) {
  63. packaging_files_shlibs += [
  64. "$root_out_dir/libEGL.so",
  65. "$root_out_dir/libGLESv2.so",
  66. ]
  67. if (angle_shared_libvulkan && !is_chromeos) {
  68. packaging_files_shlibs += [ "$root_out_dir/libvulkan.so.1" ]
  69. }
  70. }
  71. if (enable_swiftshader) {
  72. packaging_files_shlibs += [ "$root_out_dir/libvk_swiftshader.so" ]
  73. }
  74. if (build_with_internal_optimization_guide) {
  75. packaging_files_shlibs +=
  76. [ "$root_out_dir/liboptimization_guide_internal.so" ]
  77. }
  78. packaging_files_binaries = packaging_files_executables + packaging_files_shlibs
  79. # TODO(mmoss) Any convenient way to get all the relevant build files?
  80. # (e.g. all locales, resources, etc.)
  81. packaging_files = packaging_files_binaries + [
  82. "$root_out_dir/vk_swiftshader_icd.json",
  83. "$root_out_dir/xdg-mime",
  84. "$root_out_dir/xdg-settings",
  85. "$root_out_dir/locales/en-US.pak",
  86. "$root_out_dir/MEIPreload/manifest.json",
  87. "$root_out_dir/MEIPreload/preloaded_data.pb",
  88. ]
  89. if (use_qt) {
  90. # Even though this is a shared library, add it to `packaging_files` instead of
  91. # `packaging_files_shlibs` to skip the dependency check. This is intentional
  92. # to prevent a hard dependency on QT for the package.
  93. packaging_files += [ "$root_out_dir/libqt5_shim.so" ]
  94. }
  95. action_foreach("calculate_deb_dependencies") {
  96. deps = [ ":installer_deps" ]
  97. script = "debian/calculate_package_deps.py"
  98. sources = packaging_files_binaries
  99. inputs = [
  100. "debian/deb_version.py",
  101. "debian/dist_package_versions.json",
  102. "debian/package_version_interval.py",
  103. "//third_party/dpkg-shlibdeps/dpkg-shlibdeps.pl",
  104. ]
  105. outputs = [ "$root_out_dir/deb_{{source_name_part}}.deps" ]
  106. args = [
  107. "{{source}}",
  108. rebase_path(sysroot, root_build_dir),
  109. target_cpu,
  110. "deb_{{source_name_part}}.deps",
  111. ]
  112. if ((is_linux || is_chromeos_lacros) && target_cpu == "x64" &&
  113. enable_distro_version_check) {
  114. args += [ "--distro-check" ]
  115. }
  116. }
  117. action("merge_deb_dependencies") {
  118. deps = [ ":calculate_deb_dependencies" ]
  119. script = "debian/merge_package_versions.py"
  120. additional_deps = "debian/additional_deps"
  121. inputs = [
  122. additional_deps,
  123. "debian/deb_version.py",
  124. "debian/package_version_interval.py",
  125. ]
  126. outputs = [ "$root_out_dir/deb_common.deps" ]
  127. args = [
  128. "deb_common.deps",
  129. rebase_path(additional_deps, root_build_dir),
  130. ]
  131. args += rebase_path(get_target_outputs(":calculate_deb_dependencies"),
  132. root_build_dir)
  133. }
  134. action_foreach("calculate_rpm_dependencies") {
  135. deps = [ ":installer_deps" ]
  136. script = "rpm/calculate_package_deps.py"
  137. sources = packaging_files_binaries
  138. inputs = [ "rpm/dist_package_provides.json" ]
  139. outputs = [ "$root_out_dir/rpm_{{source_name_part}}.deps" ]
  140. args = [
  141. "{{source}}",
  142. "rpm_{{source_name_part}}.deps",
  143. ]
  144. args += rebase_path(packaging_files_shlibs, root_build_dir)
  145. if ((is_linux || is_chromeos_lacros) && target_cpu == "x64" &&
  146. enable_distro_version_check) {
  147. args += [ "--distro-check" ]
  148. }
  149. }
  150. action("merge_rpm_dependencies") {
  151. deps = [ ":calculate_rpm_dependencies" ]
  152. script = "rpm/merge_package_deps.py"
  153. additional_deps = "rpm/additional_deps"
  154. inputs = [ additional_deps ]
  155. outputs = [ "$root_out_dir/rpm_common.deps" ]
  156. args = [
  157. "rpm_common.deps",
  158. rebase_path(additional_deps, root_build_dir),
  159. ]
  160. args += rebase_path(get_target_outputs(":calculate_rpm_dependencies"),
  161. root_build_dir)
  162. }
  163. strip_binary("strip_chrome_binary") {
  164. binary_input = "$root_out_dir/chrome"
  165. deps = [ "//chrome" ]
  166. }
  167. strip_binary("strip_chrome_crashpad_handler") {
  168. binary_input = "$root_out_dir/chrome_crashpad_handler"
  169. deps = [ "//components/crash/core/app:chrome_crashpad_handler" ]
  170. }
  171. strip_binary("strip_chrome_management_service") {
  172. binary_input = "$root_out_dir/chrome_management_service"
  173. deps = [ "//chrome/browser/enterprise/connectors/device_trust/key_management/installer/management_service:chrome_management_service" ]
  174. }
  175. strip_binary("strip_chrome_sandbox") {
  176. binary_input = "$root_out_dir/chrome_sandbox"
  177. deps = [ "//sandbox/linux:chrome_sandbox" ]
  178. }
  179. strip_binary("strip_libEGL_shlib") {
  180. binary_input = "$root_out_dir/libEGL.so"
  181. deps = [ "//third_party/angle:libEGL" ]
  182. }
  183. strip_binary("strip_libGLESv2_shlib") {
  184. binary_input = "$root_out_dir/libGLESv2.so"
  185. deps = [ "//third_party/angle:libGLESv2" ]
  186. }
  187. strip_binary("strip_libvulkan_shlib") {
  188. binary_input = "$root_out_dir/libvulkan.so.1"
  189. deps = [ "//third_party/vulkan-deps/vulkan-loader/src:libvulkan" ]
  190. }
  191. strip_binary("strip_libvk_swiftshader.shlib") {
  192. binary_input = "$root_out_dir/libvk_swiftshader.so"
  193. deps = [ "//third_party/swiftshader/src/Vulkan:swiftshader_libvulkan" ]
  194. }
  195. if (enable_nacl) {
  196. strip_binary("strip_nacl_helper") {
  197. binary_input = "$root_out_dir/nacl_helper"
  198. deps = [ "//components/nacl/loader:nacl_helper" ]
  199. }
  200. strip_binary("strip_nacl_helper_bootstrap") {
  201. binary_input = "$root_out_dir/nacl_helper_bootstrap"
  202. deps = [ "//native_client/src/trusted/service_runtime/linux:bootstrap" ]
  203. }
  204. }
  205. if (build_with_internal_optimization_guide) {
  206. strip_binary("strip_optimization_guide") {
  207. binary_input = "$root_out_dir/liboptimization_guide_internal.so"
  208. deps = [
  209. "//components/optimization_guide/internal:optimization_guide_internal",
  210. ]
  211. }
  212. }
  213. if (use_qt) {
  214. strip_binary("strip_qt5_shim") {
  215. binary_input = "$root_out_dir/libqt5_shim.so"
  216. deps = [ "//ui/qt:qt5_shim" ]
  217. }
  218. }
  219. # This target builds all "normal" Linux installers. You must set
  220. # is_component_build=false before building this target.
  221. group("linux") {
  222. deps = [
  223. ":beta",
  224. ":stable",
  225. ":unstable",
  226. ]
  227. }
  228. branding_dir = "//chrome/app/theme/$branding_path_component"
  229. branding_dir_100 =
  230. "//chrome/app/theme/default_100_percent/$branding_path_component"
  231. copy("common_packaging_files") {
  232. visibility = [ ":*" ]
  233. sources = [
  234. "//chrome/app/resources/manpage.1.in",
  235. "common/apt.include",
  236. "common/default-app-block.template",
  237. "common/default-app.template",
  238. "common/desktop.template",
  239. "common/installer.include",
  240. "common/postinst.include",
  241. "common/prerm.include",
  242. "common/repo.cron",
  243. "common/repo_variables.include",
  244. "common/rpm.include",
  245. "common/rpmrepo.cron",
  246. "common/symlinks.include",
  247. "common/variables.include",
  248. "common/wrapper",
  249. ]
  250. if (is_chrome_branded) {
  251. sources += [
  252. "common/google-chrome/google-chrome.appdata.xml.template",
  253. "common/google-chrome/google-chrome.info",
  254. ]
  255. } else {
  256. sources += [
  257. "common/chromium-browser/chromium-browser.appdata.xml",
  258. "common/chromium-browser/chromium-browser.info",
  259. ]
  260. }
  261. sources += [ "//buildtools/third_party/eu-strip/bin/eu-strip" ]
  262. outputs = [ "$root_out_dir/installer/common/{{source_file_part}}" ]
  263. }
  264. copy("deb_packaging_files") {
  265. visibility = [ ":*" ]
  266. sources = [
  267. "debian/build.sh",
  268. "debian/changelog.template",
  269. "debian/control.template",
  270. "debian/debian.menu",
  271. "debian/manual_recommends",
  272. "debian/postinst",
  273. "debian/postrm",
  274. "debian/prerm",
  275. ]
  276. outputs = [ "$root_out_dir/installer/debian/{{source_file_part}}" ]
  277. }
  278. copy("theme_files") {
  279. visibility = [ ":*" ]
  280. sources = [
  281. "$branding_dir/BRANDING",
  282. "$branding_dir/linux/product_logo_128.png",
  283. "$branding_dir/linux/product_logo_24.png",
  284. "$branding_dir/linux/product_logo_256.png",
  285. "$branding_dir/linux/product_logo_32.xpm",
  286. "$branding_dir/linux/product_logo_48.png",
  287. "$branding_dir/linux/product_logo_64.png",
  288. "$branding_dir_100/linux/product_logo_16.png",
  289. "$branding_dir_100/linux/product_logo_32.png",
  290. ]
  291. if (is_chrome_branded) {
  292. sources += [
  293. "$branding_dir/linux/product_logo_128_beta.png",
  294. "$branding_dir/linux/product_logo_128_dev.png",
  295. "$branding_dir/linux/product_logo_24_beta.png",
  296. "$branding_dir/linux/product_logo_24_dev.png",
  297. "$branding_dir/linux/product_logo_256_beta.png",
  298. "$branding_dir/linux/product_logo_256_dev.png",
  299. "$branding_dir/linux/product_logo_32_beta.xpm",
  300. "$branding_dir/linux/product_logo_32_dev.xpm",
  301. "$branding_dir/linux/product_logo_48_beta.png",
  302. "$branding_dir/linux/product_logo_48_dev.png",
  303. "$branding_dir/linux/product_logo_64_beta.png",
  304. "$branding_dir/linux/product_logo_64_dev.png",
  305. "$branding_dir_100/linux/product_logo_16_beta.png",
  306. "$branding_dir_100/linux/product_logo_16_dev.png",
  307. "$branding_dir_100/linux/product_logo_32_beta.png",
  308. "$branding_dir_100/linux/product_logo_32_dev.png",
  309. ]
  310. }
  311. outputs = [ "$root_out_dir/installer/theme/{{source_file_part}}" ]
  312. }
  313. if (!is_chromeos_ash) {
  314. copy("rpm_packaging_files") {
  315. visibility = [ ":*" ]
  316. sources = [
  317. "rpm/build.sh",
  318. "rpm/chrome.spec.template",
  319. ]
  320. outputs = [ "$root_out_dir/installer/rpm/{{source_file_part}}" ]
  321. }
  322. }
  323. process_version("save_build_info") {
  324. # Just output the default version info variables (no template).
  325. process_only = true
  326. sources = [
  327. "//chrome/VERSION",
  328. branding_file_path,
  329. lastchange_file,
  330. ]
  331. output = "$root_out_dir/installer/version.txt"
  332. }
  333. # Dependencies for all Linux installer targets.
  334. group("installer_deps") {
  335. # Though many of these things appear in data_deps further down the
  336. # dependency chain, they must appear here as public_deps so that they can
  337. # be listed as inputs to the actions that depend on ":installer_deps"
  338. # and are guaranteed to have been built before those actions run.
  339. public_deps = [
  340. ":common_packaging_files",
  341. ":deb_packaging_files",
  342. ":save_build_info",
  343. ":strip_chrome_binary",
  344. ":strip_chrome_crashpad_handler",
  345. ":strip_chrome_management_service",
  346. ":strip_chrome_sandbox",
  347. ":theme_files",
  348. "//chrome",
  349. "//chrome:packed_resources",
  350. "//chrome/browser/enterprise/connectors/device_trust/key_management/installer/management_service:chrome_management_service",
  351. "//chrome/browser/resources/media/mei_preload:component",
  352. "//components/crash/core/app:chrome_crashpad_handler",
  353. "//sandbox/linux:chrome_sandbox",
  354. ]
  355. if (enable_nacl) {
  356. public_deps += [
  357. ":strip_nacl_helper",
  358. ":strip_nacl_helper_bootstrap",
  359. "//components/nacl/loader:nacl_helper",
  360. # These are data_deps of nacl_helper, but that is not enough,
  361. # as explained above.
  362. "//native_client/src/trusted/service_runtime/linux:bootstrap",
  363. "//ppapi/native_client:irt",
  364. ]
  365. }
  366. if (bundle_widevine_cdm) {
  367. public_deps += [ "//third_party/widevine/cdm" ]
  368. }
  369. if (use_egl) {
  370. public_deps += [
  371. ":strip_libEGL_shlib",
  372. ":strip_libGLESv2_shlib",
  373. "//third_party/angle:libEGL",
  374. "//third_party/angle:libGLESv2",
  375. ]
  376. if (angle_shared_libvulkan && !is_chromeos) {
  377. public_deps += [
  378. ":strip_libvulkan_shlib",
  379. "//third_party/vulkan-deps/vulkan-loader/src:libvulkan",
  380. ]
  381. }
  382. }
  383. if (enable_swiftshader) {
  384. public_deps += [
  385. ":strip_libvk_swiftshader.shlib",
  386. "//third_party/swiftshader/src/Vulkan:icd_file",
  387. "//third_party/swiftshader/src/Vulkan:swiftshader_libvulkan",
  388. ]
  389. }
  390. if (!is_chromeos_ash) {
  391. public_deps += [ ":rpm_packaging_files" ]
  392. }
  393. if (build_with_internal_optimization_guide) {
  394. public_deps += [
  395. ":strip_optimization_guide",
  396. "//components/optimization_guide/internal:optimization_guide_internal",
  397. ]
  398. }
  399. if (use_qt) {
  400. public_deps += [
  401. ":strip_qt5_shim",
  402. "//ui/qt:qt5_shim",
  403. ]
  404. }
  405. }
  406. # Creates .deb and .rpm (RPM for non-ChromeOS only) installer packages.
  407. #
  408. # channel:
  409. # Name of the channel.
  410. template("linux_package") {
  411. assert(defined(invoker.channel))
  412. channel = invoker.channel
  413. if (is_chrome_branded) {
  414. package = "google-chrome"
  415. } else {
  416. package = "chromium-browser"
  417. }
  418. deb_target_name = "${target_name}_deb"
  419. action(deb_target_name) {
  420. visibility = [ ":*" ]
  421. script = "//build/gn_run_binary.py"
  422. if (current_cpu == "x86") {
  423. deb_arch = "i386"
  424. } else if (current_cpu == "x64") {
  425. deb_arch = "amd64"
  426. } else if (current_cpu == "arm") {
  427. deb_arch = "armhf"
  428. } else if (current_cpu == "arm64") {
  429. deb_arch = "arm64"
  430. } else if (current_cpu == "mipsel") {
  431. deb_arch = "mipsel"
  432. } else if (current_cpu == "mips64el") {
  433. deb_arch = "mips64el"
  434. } else if (current_cpu == "riscv64") {
  435. deb_arch = "riscv64"
  436. } else {
  437. assert(false, "Linux installer not configured for this architecture.")
  438. }
  439. inputs = packaging_files
  440. outputs = [ "$root_out_dir/${package}-${channel}_${chrome_version_full}-1_${deb_arch}.deb" ]
  441. args = [
  442. rebase_path("$root_out_dir/installer/debian/build.sh", root_build_dir),
  443. "-a",
  444. deb_arch,
  445. "-c",
  446. invoker.channel,
  447. "-d",
  448. branding_path_component,
  449. "-o",
  450. rebase_path(root_out_dir, root_build_dir),
  451. "-s",
  452. rebase_path(sysroot, root_build_dir),
  453. "-t",
  454. target_os,
  455. ]
  456. if (is_official_build) {
  457. args += [ "-f" ]
  458. }
  459. deps = [
  460. ":installer_deps",
  461. ":merge_deb_dependencies",
  462. ]
  463. }
  464. if (!is_chromeos_ash) {
  465. rpm_target_name = "${target_name}_rpm"
  466. action(rpm_target_name) {
  467. visibility = [ ":*" ]
  468. script = "//build/gn_run_binary.py"
  469. if (current_cpu == "x86") {
  470. rpm_arch = "i386"
  471. } else if (current_cpu == "x64") {
  472. rpm_arch = "x86_64"
  473. } else if (current_cpu == "arm") {
  474. rpm_arch = "armhf"
  475. } else if (current_cpu == "arm64") {
  476. rpm_arch = "aarch64"
  477. } else if (current_cpu == "mipsel") {
  478. rpm_arch = "mipsel"
  479. } else if (current_cpu == "mips64el") {
  480. rpm_arch = "mips64el"
  481. } else if (current_cpu == "riscv64") {
  482. rpm_arch = "riscv64"
  483. } else {
  484. assert(false, "Linux installer not configured for this architecture.")
  485. }
  486. inputs = packaging_files
  487. outputs = [ "$root_out_dir/${package}-${channel}-${chrome_version_full}-1.${rpm_arch}.rpm" ]
  488. args = [
  489. rebase_path("$root_out_dir/installer/rpm/build.sh", root_build_dir),
  490. "-a",
  491. rpm_arch,
  492. "-c",
  493. invoker.channel,
  494. "-d",
  495. branding_path_component,
  496. "-o",
  497. rebase_path(root_out_dir, root_build_dir),
  498. "-t",
  499. target_os,
  500. ]
  501. if (is_official_build) {
  502. args += [ "-f" ]
  503. }
  504. deps = [
  505. ":installer_deps",
  506. ":merge_rpm_dependencies",
  507. ]
  508. }
  509. if (enable_snap_package) {
  510. snap_target_name = "${target_name}_snap"
  511. action(snap_target_name) {
  512. visibility = [ ":*" ]
  513. deps = [
  514. ":installer_deps",
  515. ":save_build_info",
  516. ]
  517. script = "//build/gn_run_binary.py"
  518. sources = [
  519. "snap/chrome.launcher.in",
  520. "snap/snapcraft.yaml.in",
  521. ]
  522. if (!is_chrome_branded) {
  523. package = "chromium"
  524. }
  525. if (current_cpu == "x86") {
  526. snap_arch = "i386"
  527. } else if (current_cpu == "x64") {
  528. snap_arch = "amd64"
  529. } else if (current_cpu == "arm") {
  530. snap_arch = "armhf"
  531. } else if (current_cpu == "arm64") {
  532. snap_arch = "arm64"
  533. } else if (current_cpu == "riscv64") {
  534. snap_arch = "riscv64"
  535. } else {
  536. assert(false, "Linux installer not configured for this architecture.")
  537. }
  538. args = [
  539. rebase_path("snap/build.sh", root_build_dir),
  540. package,
  541. channel,
  542. chrome_version_full,
  543. snap_arch,
  544. target_os,
  545. ]
  546. outputs = [ "$root_out_dir/${package}-${channel}_${chrome_version_full}_${snap_arch}.snap" ]
  547. }
  548. }
  549. }
  550. group(target_name) {
  551. deps = [ ":$deb_target_name" ]
  552. if (!is_chromeos_ash) {
  553. deps += [ ":$rpm_target_name" ]
  554. if (enable_snap_package) {
  555. deps += [ ":$snap_target_name" ]
  556. }
  557. }
  558. }
  559. }
  560. # Standard packages.
  561. linux_package("stable") {
  562. channel = "stable"
  563. }
  564. linux_package("beta") {
  565. channel = "beta"
  566. }
  567. linux_package("unstable") {
  568. channel = "unstable"
  569. }