mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Redirecting file system can canonicalize the file path before forwarding the path to IncludeTreeFileSystem, which is a simplied FS that can only intepret the paths that has been seen by dep-scanner. Since all files that need redirecting already added to underlying FS via DepScan, there is no need for such layer when compiling using clang-include-tree. rdar://119727344
32 lines
787 B
Python
Executable File
32 lines
787 B
Python
Executable File
#!/usr/bin/env python3
|
|
#
|
|
# Usage: BuildCommandExtractor.py file.json ModuleName
|
|
|
|
import json
|
|
import sys
|
|
|
|
input_json = sys.argv[1]
|
|
module_name = sys.argv[2]
|
|
|
|
mode = 'swift'
|
|
|
|
if module_name.startswith('clang:'):
|
|
mode = 'clang'
|
|
module_name = module_name[6:]
|
|
elif module_name.startswith('swiftPrebuiltExternal:'):
|
|
mode = 'swiftPrebuiltExternal'
|
|
module_name = module_name[22:]
|
|
|
|
with open(input_json, 'r') as file:
|
|
deps = json.load(file)
|
|
module_names = deps['modules'][::2]
|
|
module_details = deps['modules'][1::2]
|
|
for name, detail in zip(module_names, module_details):
|
|
if name.get(mode, '') != module_name:
|
|
continue
|
|
|
|
cmd = detail['details'][mode]['commandLine']
|
|
for c in cmd:
|
|
print('"{}"'.format(c))
|
|
break
|