Files
swift-mirror/test/CAS/Inputs/GenerateExplicitModuleMap.py
Steven Wu 52671e1a6a [Caching] Improve swift caching related tests
Improve caching related tests to make them faster and test the situation
closer to what actually happens during explicit module build. Most
noticable changes are:
* Avoid swift stdlib dependency during the tests to save time
* Use dependency scanner output to construct test cases
* Update old test cases that try to simulate caching from file system
  inputs to using only CAS inputs.
2024-01-28 22:06:59 -08:00

37 lines
1.0 KiB
Python
Executable File

#!/usr/bin/env python3
#
# Usage: GenerateExplicitModuleMap.py file.json
import json
import sys
input_json = sys.argv[1]
modules = []
with open(input_json, 'r') as file:
deps = json.load(file)
main_module_name = deps['mainModuleName']
module_names = deps['modules'][::2]
module_details = deps['modules'][1::2]
# add all modules other than the main module into the module map.
for name, detail in zip(module_names, module_details):
kind, name = list(name.items())[0]
if name == main_module_name:
continue
module = {}
module["moduleName"] = name
module["isFramework"] = False
if kind == "clang":
module["clangModulePath"] = name + ".pcm"
module["clangModuleCacheKey"] = detail['details'][kind]["moduleCacheKey"]
else:
module["modulePath"] = name + ".swiftmdoule"
module["moduleCacheKey"] = detail['details'][kind]["moduleCacheKey"]
modules.append(module)
json.dump(modules, sys.stdout, indent=2)