sysroot.gni 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # Copyright (c) 2013 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. # This header file defines the "sysroot" variable which is the absolute path
  5. # of the sysroot. If no sysroot applies, the variable will be an empty string.
  6. import("//build/config/chrome_build.gni")
  7. declare_args() {
  8. # The path of the sysroot that is applied when compiling using the target
  9. # toolchain.
  10. target_sysroot = ""
  11. # The path to directory containing linux sysroot images.
  12. target_sysroot_dir = "//build/linux"
  13. # The path of the sysroot for the current toolchain. If empty, default
  14. # sysroot is used.
  15. sysroot = ""
  16. # Controls default is_linux sysroot. If set to true, and sysroot
  17. # is empty, default sysroot is calculated.
  18. use_sysroot = current_cpu == "x86" || current_cpu == "x64" ||
  19. current_cpu == "arm" || current_cpu == "arm64" ||
  20. current_cpu == "mipsel" || current_cpu == "mips64el" ||
  21. current_cpu == "riscv64"
  22. }
  23. if (sysroot == "") {
  24. if (current_os == target_os && current_cpu == target_cpu &&
  25. target_sysroot != "") {
  26. sysroot = target_sysroot
  27. } else if (is_android) {
  28. import("//build/config/android/config.gni")
  29. # Android uses unified headers, and thus a single compile time sysroot
  30. sysroot = "$android_toolchain_root/sysroot"
  31. } else if ((is_linux || is_chromeos) && use_sysroot) {
  32. # By default build against a sysroot image downloaded from Cloud Storage
  33. # during gclient runhooks.
  34. if (current_cpu == "x64") {
  35. sysroot = "$target_sysroot_dir/debian_bullseye_amd64-sysroot"
  36. } else if (current_cpu == "x86") {
  37. sysroot = "$target_sysroot_dir/debian_bullseye_i386-sysroot"
  38. } else if (current_cpu == "mipsel") {
  39. sysroot = "$target_sysroot_dir/debian_bullseye_mips-sysroot"
  40. } else if (current_cpu == "mips64el") {
  41. sysroot = "$target_sysroot_dir/debian_bullseye_mips64el-sysroot"
  42. } else if (current_cpu == "arm") {
  43. sysroot = "$target_sysroot_dir/debian_bullseye_arm-sysroot"
  44. } else if (current_cpu == "arm64") {
  45. sysroot = "$target_sysroot_dir/debian_bullseye_arm64-sysroot"
  46. } else if (current_cpu == "riscv64") {
  47. sysroot = "$target_sysroot_dir/debian_sid_riscv64-sysroot"
  48. } else {
  49. assert(false, "No linux sysroot for cpu: $target_cpu")
  50. }
  51. if (sysroot != "") {
  52. _script_arch = current_cpu
  53. if (_script_arch == "x86") {
  54. _script_arch = "i386"
  55. } else if (_script_arch == "x64") {
  56. _script_arch = "amd64"
  57. }
  58. assert(
  59. exec_script("//build/dir_exists.py",
  60. [ rebase_path(sysroot) ],
  61. "string") == "True",
  62. "Missing sysroot ($sysroot). To fix, run: build/linux/sysroot_scripts/install-sysroot.py --arch=$_script_arch")
  63. }
  64. } else if (is_mac) {
  65. import("//build/config/mac/mac_sdk.gni")
  66. sysroot = mac_sdk_path
  67. } else if (is_ios) {
  68. import("//build/config/ios/ios_sdk.gni")
  69. sysroot = ios_sdk_path
  70. } else if (is_fuchsia) {
  71. if (current_cpu == "arm64" || current_cpu == "x64") {
  72. sysroot = "//third_party/fuchsia-sdk/sdk/arch/$current_cpu/sysroot"
  73. }
  74. }
  75. }