|
2 | 2 | # Use of this source code is governed by a BSD-style license that can be |
3 | 3 | # found in the LICENSE file. |
4 | 4 |
|
| 5 | +import("//build/toolchain/rbe.gni") |
| 6 | + |
| 7 | +assert(host_os == "mac") |
| 8 | + |
| 9 | +# Common args across all Apple platforms. |
5 | 10 | declare_args() { |
6 | | - # Path to the Xcode toolchain (XcodeDefault.xctoolchain). |
7 | | - apple_host_toolchain_path = "" |
| 11 | + # The MACOSX_DEPLOYMENT_TARGET variable used when compiling. |
| 12 | + # Must be of the form x.x.x for Info.plist files. |
| 13 | + mac_deployment_target = "" |
| 14 | + |
| 15 | + # Path to the host Xcode toolchain (XcodeDefault.xctoolchain). |
| 16 | + mac_host_toolchain_path = "" |
| 17 | + |
| 18 | + # Path to the macOS platform. |
| 19 | + mac_platform_path = "" |
| 20 | + |
| 21 | + # Path to a specific version of the macOS SDK, not including a backslash at |
| 22 | + # the end. |
| 23 | + mac_sdk_path = "" |
| 24 | +} |
| 25 | + |
| 26 | +# Must be set above or by gn. |
| 27 | +assert(mac_deployment_target != "") |
| 28 | + |
| 29 | +if (is_ios) { |
| 30 | + # iOS-specific args. |
| 31 | + declare_args() { |
| 32 | + # Path to the iOS platform to use. |
| 33 | + # |
| 34 | + # When empty, this will use the default platform based on the value of |
| 35 | + # use_ios_simulator. |
| 36 | + ios_platform_path = "" |
| 37 | + |
| 38 | + # Path to the iOS SDK to use. |
| 39 | + # |
| 40 | + # When empty this will use the default SDK based on the value of |
| 41 | + # use_ios_simulator. |
| 42 | + ios_sdk_path = "" |
| 43 | + |
| 44 | + # Set to true when targeting a simulator build on iOS. False means that the |
| 45 | + # target is for running on the device. The default value is to use the |
| 46 | + # Simulator except when targeting GYP's Xcode builds (for compat with the |
| 47 | + # existing GYP build). |
| 48 | + use_ios_simulator = true |
| 49 | + |
| 50 | + # Alias for use_ios_simulator used by Skia. |
| 51 | + ios_use_simulator = true |
| 52 | + |
| 53 | + # Version of iOS that we're targeting. |
| 54 | + ios_deployment_target = "13.0" |
| 55 | + |
| 56 | + # The path to the iOS device platform. |
| 57 | + ios_device_platform_path = "" |
| 58 | + |
| 59 | + # The path to the iOS simulator platform. |
| 60 | + ios_simulator_platform_path = "" |
| 61 | + |
| 62 | + # The path to the iOS device SDK. |
| 63 | + ios_device_sdk_path = "" |
| 64 | + |
| 65 | + # The path to the iOS simulator SDK. |
| 66 | + ios_simulator_sdk_path = "" |
| 67 | + |
| 68 | + # The path to iOS SDK Swift libraries. |
| 69 | + ios_swift_lib_paths = [] |
| 70 | + |
| 71 | + # Version of iOS that we're targeting for tests. |
| 72 | + ios_testing_deployment_target = "13.0" |
| 73 | + } |
| 74 | + |
| 75 | + # Must be set above or by gn. |
| 76 | + assert(defined(use_ios_simulator)) |
| 77 | + assert(defined(ios_use_simulator)) |
| 78 | + assert(ios_deployment_target != "") |
| 79 | + assert(ios_testing_deployment_target != "") |
| 80 | +} |
| 81 | + |
| 82 | +# Run apple_sdk.gni to determine SDK paths if necessary. |
| 83 | +_need_apple_sdk_run = false |
| 84 | +if (mac_host_toolchain_path == "" || # |
| 85 | + mac_sdk_path == "" || # |
| 86 | + mac_platform_path == "") { |
| 87 | + _need_apple_sdk_run = true |
| 88 | +} |
| 89 | +if (is_ios) { |
| 90 | + if (use_ios_simulator && |
| 91 | + (ios_simulator_platform_path == "" || ios_simulator_sdk_path == "")) { |
| 92 | + _need_apple_sdk_run = true |
| 93 | + } |
| 94 | + if (!use_ios_simulator && |
| 95 | + (ios_device_platform_path == "" || ios_device_sdk_path == "")) { |
| 96 | + _need_apple_sdk_run = true |
| 97 | + } |
| 98 | +} |
| 99 | +if (_need_apple_sdk_run) { |
| 100 | + _args = [ "--print-paths" ] |
| 101 | + if (use_rbe && create_xcode_symlinks) { |
| 102 | + # RBE has a restriction that paths cannot come from outside the build root. |
| 103 | + _args += [ |
| 104 | + "--symlink", |
| 105 | + rebase_path("//flutter/prebuilts"), |
| 106 | + ] |
| 107 | + } |
| 108 | + _sdk_result = |
| 109 | + exec_script(rebase_path("//build/mac/apple_sdk.py"), _args, "scope") |
8 | 110 | } |
9 | 111 |
|
10 | | -if (apple_host_toolchain_path == "") { |
11 | | - # Outputs the SDK path on the first line, and the host toolchain path on the |
12 | | - # second. |
13 | | - _find_sdk_lines = |
14 | | - exec_script("//build/mac/find_sdk.py", ["--print_sdk_path", "1.0"], "list lines") |
| 112 | +# Set SDK paths. |
| 113 | +if (mac_host_toolchain_path == "") { |
| 114 | + mac_host_toolchain_path = _sdk_result.toolchain_path |
| 115 | +} |
| 116 | +assert(mac_host_toolchain_path != "") |
| 117 | + |
| 118 | +if (mac_sdk_path == "") { |
| 119 | + mac_sdk_path = _sdk_result.macosx_sdk_path |
| 120 | +} |
| 121 | +assert(mac_sdk_path != "") |
| 122 | + |
| 123 | +if (mac_platform_path == "") { |
| 124 | + mac_platform_path = _sdk_result.macosx_platform_path |
| 125 | +} |
| 126 | +assert(mac_platform_path != "") |
| 127 | + |
| 128 | +if (is_ios) { |
| 129 | + if (ios_platform_path == "" || ios_sdk_path == "") { |
| 130 | + if (use_ios_simulator) { |
| 131 | + if (ios_simulator_platform_path == "") { |
| 132 | + ios_simulator_platform_path = _sdk_result.iphonesimulator_platform_path |
| 133 | + } |
| 134 | + if (ios_simulator_sdk_path == "") { |
| 135 | + ios_simulator_sdk_path = _sdk_result.iphonesimulator_sdk_path |
| 136 | + } |
| 137 | + } else { |
| 138 | + if (ios_device_platform_path == "") { |
| 139 | + ios_device_platform_path = _sdk_result.iphoneos_platform_path |
| 140 | + } |
| 141 | + if (ios_device_sdk_path == "") { |
| 142 | + ios_device_sdk_path = _sdk_result.iphoneos_sdk_path |
| 143 | + } |
| 144 | + } |
| 145 | + |
| 146 | + if (use_ios_simulator) { |
| 147 | + assert(ios_simulator_platform_path != "") |
| 148 | + assert(ios_simulator_sdk_path != "") |
| 149 | + ios_platform_path = ios_simulator_platform_path |
| 150 | + ios_sdk_path = ios_simulator_sdk_path |
| 151 | + } else { |
| 152 | + assert(ios_device_platform_path != "") |
| 153 | + assert(ios_device_sdk_path != "") |
| 154 | + ios_platform_path = ios_device_platform_path |
| 155 | + ios_sdk_path = ios_device_sdk_path |
| 156 | + } |
| 157 | + } |
15 | 158 |
|
16 | | - apple_host_toolchain_path = _find_sdk_lines[1] |
| 159 | + if (ios_swift_lib_paths == []) { |
| 160 | + ios_swift_lib_paths += [ rebase_path("$ios_sdk_path/usr/lib/swift") ] |
| 161 | + if (use_ios_simulator) { |
| 162 | + ios_swift_lib_paths += [ rebase_path( |
| 163 | + "$mac_host_toolchain_path/usr/lib/swift/iphonesimulator") ] |
| 164 | + } else { |
| 165 | + ios_swift_lib_paths += |
| 166 | + [ rebase_path("$mac_host_toolchain_path/usr/lib/swift/iphoneos") ] |
| 167 | + } |
| 168 | + } |
17 | 169 | } |
0 commit comments