mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
swift-api-checker: allow users to specify the path of a swift-api-digester
This commit is contained in:
@@ -56,22 +56,27 @@ def prepare_module_list(platform, file):
|
||||
file.write(extra.read())
|
||||
|
||||
|
||||
def get_api_digester_path(tool_path):
|
||||
if tool_path:
|
||||
return tool_path
|
||||
return check_output(['xcrun', '--find', 'swift-api-digester'])
|
||||
|
||||
|
||||
class DumpConfig:
|
||||
def __init__(self, platform):
|
||||
def __init__(self, tool_path, platform):
|
||||
target_map = {
|
||||
'iphoneos': 'arm64-apple-ios10.0',
|
||||
'macosx': 'x86_64-apple-macosx10.11',
|
||||
'appletvos': 'arm64-apple-tvos10.0',
|
||||
'watchos': 'armv7k-apple-watchos3.0',
|
||||
}
|
||||
self.tool_path = get_api_digester_path(tool_path)
|
||||
self.platform = platform
|
||||
self.target = target_map[platform]
|
||||
self.sdk = get_sdk_path(platform)
|
||||
self.frameworks = [
|
||||
self.sdk + '/System/Library/Frameworks/',
|
||||
os.path.realpath(self.sdk + '/../../Library/Frameworks/')]
|
||||
self.tool_path = check_output(['xcrun', '--find',
|
||||
'swift-api-digester'])
|
||||
|
||||
def run(self, output, module, swift_ver, abi, verbose):
|
||||
cmd = [self.tool_path, '-o', output, '-sdk', self.sdk, '-target',
|
||||
@@ -95,9 +100,8 @@ class DumpConfig:
|
||||
|
||||
|
||||
class DiagnoseConfig:
|
||||
def __init__(self):
|
||||
self.tool_path = check_output(['xcrun', '--find',
|
||||
'swift-api-digester'])
|
||||
def __init__(self, tool_path):
|
||||
self.tool_path = get_api_digester_path(tool_path)
|
||||
|
||||
def run(self, abi, before, after, output, verbose):
|
||||
cmd = [self.tool_path, '-diagnose-sdk', '-input-paths', before,
|
||||
@@ -119,6 +123,12 @@ A convenient wrapper for swift-api-digester.
|
||||
''')
|
||||
|
||||
basic_group = parser.add_argument_group('Basic')
|
||||
|
||||
basic_group.add_argument('--tool-path', default=None, help='''
|
||||
the path to a swift-api-digester; if not specified, the script will
|
||||
use the one from the toolchain
|
||||
''')
|
||||
|
||||
basic_group.add_argument('--action', default='', help='''
|
||||
the action to perform for swift-api-digester
|
||||
''')
|
||||
@@ -165,7 +175,7 @@ A convenient wrapper for swift-api-digester.
|
||||
fatal_error("Need to specify --target")
|
||||
if not args.output:
|
||||
fatal_error("Need to specify --output")
|
||||
runner = DumpConfig(platform=args.target)
|
||||
runner = DumpConfig(tool_path=args.tool_path, platform=args.target)
|
||||
runner.run(output=args.output, module=args.module,
|
||||
swift_ver=args.swift_version, abi=args.abi, verbose=args.v)
|
||||
elif args.action == 'diagnose':
|
||||
@@ -173,7 +183,7 @@ A convenient wrapper for swift-api-digester.
|
||||
fatal_error("Need to specify --dump-before")
|
||||
if not args.dump_after:
|
||||
fatal_error("Need to specify --dump-after")
|
||||
runner = DiagnoseConfig()
|
||||
runner = DiagnoseConfig(tool_path=args.tool_path)
|
||||
runner.run(abi=args.abi, before=args.dump_before,
|
||||
after=args.dump_after, output=args.output, verbose=args.v)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user