mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CAS] swift dependency scanning using CAS for compiler caching (#66366)
Teach swift dependency scanner to use CAS to capture the full dependencies for a build and construct build commands with immutable inputs from CAS. This allows swift compilation caching using CAS.
This commit is contained in:
34
test/CAS/Inputs/SwiftDepsExtractor.py
Executable file
34
test/CAS/Inputs/SwiftDepsExtractor.py
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Usage: SwiftDepsExtractor.py file.json ModuleName Key
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
input_json = sys.argv[1]
|
||||
module_name = sys.argv[2]
|
||||
key = sys.argv[3]
|
||||
|
||||
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
|
||||
|
||||
if key in detail.keys():
|
||||
print(detail[key])
|
||||
break
|
||||
|
||||
print(detail['details'][mode][key])
|
||||
break
|
||||
Reference in New Issue
Block a user