Commit 2cdd0b37 authored by Erik Chen's avatar Erik Chen Committed by Commit Bot

Update find_sdk.py to print out the toolchain bin dir.

This allows build scripts to directly specify the required binaries, rather than
implicitly relying on xcrun to find the binaries.

Bug: 971452
Change-Id: I02862dc39fba7ec1c7534283b0b5a5bfd5f4bbd6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1648780Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Erik Chen <erikchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#667148}
parent 522a69ed
...@@ -45,7 +45,10 @@ declare_args() { ...@@ -45,7 +45,10 @@ declare_args() {
# iOS toolchains. # iOS toolchains.
_verify_sdk = is_chrome_branded && is_official_build && target_os != "ios" _verify_sdk = is_chrome_branded && is_official_build && target_os != "ios"
find_sdk_args = [ "--print_sdk_path" ] find_sdk_args = [
"--print_sdk_path",
"--print_bin_path",
]
if (!use_system_xcode) { if (!use_system_xcode) {
find_sdk_args += [ find_sdk_args += [
"--developer_dir", "--developer_dir",
...@@ -66,10 +69,11 @@ if (_verify_sdk) { ...@@ -66,10 +69,11 @@ if (_verify_sdk) {
# second line. # second line.
find_sdk_lines = find_sdk_lines =
exec_script("//build/mac/find_sdk.py", find_sdk_args, "list lines") exec_script("//build/mac/find_sdk.py", find_sdk_args, "list lines")
mac_sdk_version = find_sdk_lines[1] mac_sdk_version = find_sdk_lines[2]
if (mac_sdk_path == "") { if (mac_sdk_path == "") {
mac_sdk_path = find_sdk_lines[0] mac_sdk_path = find_sdk_lines[0]
} }
mac_bin_path = find_sdk_lines[1]
script_name = "//build/config/mac/sdk_info.py" script_name = "//build/config/mac/sdk_info.py"
sdk_info_args = [] sdk_info_args = []
......
...@@ -4,11 +4,23 @@ ...@@ -4,11 +4,23 @@
# found in the LICENSE file. # found in the LICENSE file.
"""Prints the lowest locally available SDK version greater than or equal to a """Prints the lowest locally available SDK version greater than or equal to a
given minimum sdk version to standard output. If --developer_dir is passed, then given minimum sdk version to standard output.
the script will use the Xcode toolchain located at DEVELOPER_DIR.
If --developer_dir is passed, then the script will use the Xcode toolchain
located at DEVELOPER_DIR.
If --print_sdk_path is passed, then the script will also print the SDK path.
If --print_bin_path is passed, then the script will also print the path to the
toolchain bin dir.
Usage: Usage:
python find_sdk.py [--developer_dir DEVELOPER_DIR] 10.6 # Ignores SDKs < 10.6 python find_sdk.py [--developer_dir DEVELOPER_DIR] [--print_sdk_path] \
[--print_bin_path] 10.6 # Ignores SDKs < 10.6
Sample Output:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/
10.14
""" """
from __future__ import print_function from __future__ import print_function
...@@ -44,6 +56,9 @@ def main(): ...@@ -44,6 +56,9 @@ def main():
parser.add_option("--print_sdk_path", parser.add_option("--print_sdk_path",
action="store_true", dest="print_sdk_path", default=False, action="store_true", dest="print_sdk_path", default=False,
help="Additionally print the path the SDK (appears first).") help="Additionally print the path the SDK (appears first).")
parser.add_option("--print_bin_path",
action="store_true", dest="print_bin_path", default=False,
help="Additionally print the path the toolchain bin dir.")
parser.add_option("--developer_dir", help='Path to Xcode.') parser.add_option("--developer_dir", help='Path to Xcode.')
options, args = parser.parse_args() options, args = parser.parse_args()
if len(args) != 1: if len(args) != 1:
...@@ -55,9 +70,7 @@ def main(): ...@@ -55,9 +70,7 @@ def main():
# This is important to avoid since we want to minimize dependencies on the # This is important to avoid since we want to minimize dependencies on the
# xcode toolchain. # xcode toolchain.
if options.developer_dir: if options.developer_dir:
sdk_dir = os.path.join( dev_dir = os.path.join(options.developer_dir, 'Contents/Developer')
options.developer_dir,
'Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs')
else: else:
job = subprocess.Popen(['xcode-select', '-print-path'], job = subprocess.Popen(['xcode-select', '-print-path'],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
...@@ -67,8 +80,9 @@ def main(): ...@@ -67,8 +80,9 @@ def main():
print(out, file=sys.stderr) print(out, file=sys.stderr)
print(err, file=sys.stderr) print(err, file=sys.stderr)
raise Exception('Error %d running xcode-select' % job.returncode) raise Exception('Error %d running xcode-select' % job.returncode)
sdk_dir = os.path.join( dev_dir = out.rstrip()
out.rstrip(), 'Platforms/MacOSX.platform/Developer/SDKs') sdk_dir = os.path.join(
dev_dir, 'Platforms/MacOSX.platform/Developer/SDKs')
# Xcode must be installed, its license agreement must be accepted, and its # Xcode must be installed, its license agreement must be accepted, and its
# command-line tools must be installed. Stand-alone installations (in # command-line tools must be installed. Stand-alone installations (in
...@@ -104,6 +118,10 @@ def main(): ...@@ -104,6 +118,10 @@ def main():
sdk_name = 'MacOSX' + best_sdk + '.sdk' sdk_name = 'MacOSX' + best_sdk + '.sdk'
print(os.path.join(sdk_dir, sdk_name)) print(os.path.join(sdk_dir, sdk_name))
if options.print_bin_path:
bin_path = 'Toolchains/XcodeDefault.xctoolchain/usr/bin/'
print(os.path.join(dev_dir, bin_path))
return best_sdk return best_sdk
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment