Files
swift-mirror/test/CAS/Inputs/BuildCommandExtractor.py
Steven Wu ead742b8f1 [CAS] Do not create redirect file system when using clang-include-tree
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
2023-12-20 12:30:14 -08:00

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