mac_sdk.gni 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # Copyright 2014 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/chrome_build.gni")
  5. import("//build/config/gclient_args.gni")
  6. import("//build/config/mac/mac_sdk_overrides.gni")
  7. import("//build/toolchain/goma.gni")
  8. import("//build/toolchain/rbe.gni")
  9. import("//build/toolchain/toolchain.gni")
  10. assert(current_os == "mac" || current_toolchain == default_toolchain)
  11. declare_args() {
  12. # The `MACOSX_DEPLOYMENT_TARGET` variable used when compiling. This partially
  13. # controls the minimum supported version of macOS for Chromium by
  14. # affecting the symbol availability rules. This may differ from
  15. # `mac_min_system_version` when dropping support for older macOSes but where
  16. # additional code changes are required to be compliant with the availability
  17. # rules.
  18. mac_deployment_target = "10.13"
  19. # The value of the `LSMinimumSystemVersion` in `Info.plist` files. This
  20. # partially controls the minimum supported version of macOS for Chromium by
  21. # affecting the `Info.plist`. This may differ from `mac_deployment_target`
  22. # when dropping support for older macOSes. This must be greater than or equal
  23. # to the `mac_deployment_target` version.
  24. mac_min_system_version = "10.13"
  25. # Path to a specific version of the Mac SDK, not including a slash at the end.
  26. # If empty, the path to the lowest version greater than or equal to
  27. # `mac_sdk_min` is used.
  28. mac_sdk_path = ""
  29. # The SDK name as accepted by `xcodebuild`.
  30. mac_sdk_name = "macosx"
  31. # The SDK version used when making official builds. This is a single exact
  32. # version, not a minimum. If this version isn't available official builds
  33. # will fail.
  34. mac_sdk_official_version = "12.3"
  35. # Production builds should use hermetic Xcode. If you want to do production
  36. # builds with system Xcode to test new SDKs, set this.
  37. # Don't set this on any bots.
  38. mac_allow_system_xcode_for_official_builds_for_testing = false
  39. }
  40. # Check that the version of macOS SDK used is the one requested when building
  41. # a version of Chrome shipped to the users. Disable the check if building for
  42. # iOS as the version macOS SDK used is not relevant for the tool build for the
  43. # host (they are not shipped) --- this is required as Chrome on iOS is usually
  44. # build with the latest version of Xcode that may not ship with the version of
  45. # the macOS SDK used to build Chrome on mac.
  46. # TODO(crbug.com/635745): the check for target_os should be replaced by a
  47. # check that current_toolchain is default_toolchain, and the file should
  48. # assert that current_os is "mac" once this file is no longer included by
  49. # iOS toolchains.
  50. if (is_chrome_branded && is_official_build && target_os != "ios") {
  51. assert(!use_system_xcode ||
  52. mac_allow_system_xcode_for_official_builds_for_testing,
  53. "official branded builds should use hermetic xcode")
  54. }
  55. # The path to the hermetic install of Xcode. Only relevant when
  56. # use_system_xcode = false.
  57. if (!use_system_xcode) {
  58. _hermetic_xcode_path = "//build/mac_files/xcode_binaries"
  59. }
  60. script_name = "//build/config/apple/sdk_info.py"
  61. sdk_info_args = []
  62. if (!use_system_xcode) {
  63. sdk_info_args += [
  64. "--developer_dir",
  65. rebase_path(_hermetic_xcode_path, "", root_build_dir),
  66. ]
  67. }
  68. # Goma RBE requires paths relative to source directory. When using system
  69. # Xcode, this is done by creating symbolic links in root_build_dir.
  70. if (use_system_xcode && (use_goma || use_remoteexec)) {
  71. sdk_info_args += [
  72. "--get_sdk_info",
  73. "--create_symlink_at",
  74. "sdk/xcode_links",
  75. "--root_build_dir",
  76. root_build_dir,
  77. ]
  78. }
  79. sdk_info_args += [ mac_sdk_name ]
  80. _mac_sdk_result = exec_script(script_name, sdk_info_args, "scope")
  81. xcode_version = _mac_sdk_result.xcode_version
  82. xcode_build = _mac_sdk_result.xcode_build
  83. if (mac_sdk_path == "" && use_system_xcode && (use_goma || use_remoteexec)) {
  84. mac_sdk_path = _mac_sdk_result.sdk_path
  85. }
  86. if (use_system_xcode) {
  87. # The tool will print the SDK path on the first line, and the version on the
  88. # second line.
  89. find_sdk_args = [
  90. "--print_sdk_path",
  91. "--print_bin_path",
  92. mac_sdk_min,
  93. ]
  94. find_sdk_lines =
  95. exec_script("//build/mac/find_sdk.py", find_sdk_args, "list lines")
  96. mac_sdk_version = find_sdk_lines[2]
  97. if (mac_sdk_path == "") {
  98. mac_sdk_path = find_sdk_lines[0]
  99. mac_bin_path = find_sdk_lines[1]
  100. } else {
  101. mac_bin_path = find_sdk_lines[1]
  102. }
  103. } else {
  104. mac_sdk_version = mac_sdk_official_version
  105. _dev = _hermetic_xcode_path + "/Contents/Developer"
  106. _sdk = "MacOSX${mac_sdk_version}.sdk"
  107. mac_sdk_path = _dev + "/Platforms/MacOSX.platform/Developer/SDKs/$_sdk"
  108. mac_bin_path = _dev + "/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
  109. # If we're using hermetic Xcode, then we want the paths to be relative so that
  110. # generated ninja files are independent of the directory location.
  111. # TODO(thakis): Do this at the uses of this variable instead.
  112. mac_bin_path = rebase_path(mac_bin_path, root_build_dir)
  113. }