Files
swift-mirror/test/CAS/Inputs/GenerateExplicitModuleMap.py
Steven Wu ef99096e43 [Test] Fix a typo in the test util python script
Fix the typo in GenerateExplicitModuleMap.py where the modulePath is
mis-spelled. Use the module path from the dependency output json file
directly instead, which means the script can be used to generate
non-caching build module map as well since the module path actually
matters for those builds.
2025-01-08 11:22:00 -08:00

41 lines
1.2 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"] = detail["modulePath"]
if "moduleCacheKey" in detail["details"][kind]:
module["clangModuleCacheKey"] = detail["details"][kind][
"moduleCacheKey"
]
else:
module["modulePath"] = detail["modulePath"]
if "moduleCacheKey" in detail["details"][kind]:
module["moduleCacheKey"] = detail["details"][kind]["moduleCacheKey"]
modules.append(module)
json.dump(modules, sys.stdout, indent=2)