61 parser = OptionParser()
67 help=
"return the sdk argument and warn if it doesn't exist")
74 help=
"user-specified SDK path; bypasses verification")
78 dest=
"print_sdk_path",
80 help=
"Additionally print the path the SDK (appears first).")
82 "--create_symlink_at",
84 dest=
"create_symlink_at",
86 "Create symlink to SDK at given location and return symlink path as SDK "
87 "info instead of the original location.")
88 (options, args) = parser.parse_args()
89 min_sdk_version = args[0]
91 job = subprocess.Popen([
'xcode-select',
'-print-path'],
92 stdout=subprocess.PIPE,
93 stderr=subprocess.STDOUT,
94 universal_newlines=
True)
95 out, err = job.communicate()
96 if job.returncode != 0:
97 print(out, file=sys.stderr)
98 print(err, file=sys.stderr)
99 raise Exception(
'Error %d running xcode-select' % job.returncode)
100 sdk_dir = os.path.join(out.rstrip(),
101 'Platforms/MacOSX.platform/Developer/SDKs')
102 if not os.path.isdir(sdk_dir):
104 'Install Xcode, launch it, accept the license ' +
105 'agreement, and run `sudo xcode-select -s /path/to/Xcode.app` ' +
108 re.findall(
'^MacOSX(\d+\.\d+)\.sdk$', s)
for s
in os.listdir(sdk_dir)
110 sdks = [s[0]
for s
in sdks
if s]
116 raise Exception(
'No %s+ SDK found' % min_sdk_version)
117 best_sdk = sorted(sdks, key=parse_version)[0]
119 if options.verify
and best_sdk != min_sdk_version
and not options.sdk_path:
123This build requires the %s SDK, but it was not found on your system.
125Either install it, or explicitly set mac_sdk in your GYP_DEFINES.
128''' % min_sdk_version,
130 return min_sdk_version
132 if options.print_sdk_path:
133 sdk_path = subprocess.check_output(
134 [
'xcodebuild',
'-version',
'-sdk',
'macosx' + best_sdk,
'Path'],
135 universal_newlines=
True).strip()
136 if options.create_symlink_at: