Files
TheRock/compiler/amd-llvm/clang/utils/module-deps-to-rsp.py
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

89 lines
2.3 KiB
Python
Executable File

#!/usr/bin/env python3
# Converts clang-scan-deps output into response files.
#
# Usage:
#
# clang-scan-deps -compilation-database compile_commands.json ... > deps.json
# module-deps-to-rsp.py deps.json --module-name=ModuleName > module_name.cc1.rsp
# module-deps-to-rsp.py deps.json --tu-index=0 > tu.rsp
# clang @module_name.cc1.rsp
# clang @tu.rsp
import argparse
import json
import sys
class ModuleNotFoundError(Exception):
def __init__(self, module_name):
self.module_name = module_name
class FullDeps:
def __init__(self):
self.modules = {}
self.translation_units = []
def findModule(module_name, full_deps):
for m in full_deps.modules.values():
if m["name"] == module_name:
return m
raise ModuleNotFoundError(module_name)
def parseFullDeps(json):
ret = FullDeps()
for m in json["modules"]:
ret.modules[m["name"] + "-" + m["context-hash"]] = m
ret.translation_units = json["translation-units"]
return ret
def quote(str):
return '"' + str.replace("\\", "\\\\") + '"'
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"full_deps_file", help="Path to the full dependencies json file", type=str
)
action = parser.add_mutually_exclusive_group(required=True)
action.add_argument(
"--module-name", help="The name of the module to get arguments for", type=str
)
action.add_argument(
"--tu-index",
help="The index of the translation unit to get arguments for",
type=int,
)
parser.add_argument(
"--tu-cmd-index",
help="The index of the command within the translation unit (default=0)",
type=int,
default=0,
)
args = parser.parse_args()
full_deps = parseFullDeps(json.load(open(args.full_deps_file, "r")))
try:
cmd = []
if args.module_name:
cmd = findModule(args.module_name, full_deps)["command-line"]
elif args.tu_index is not None:
tu = full_deps.translation_units[args.tu_index]
cmd = tu["commands"][args.tu_cmd_index]["command-line"]
print(" ".join(map(quote, cmd)))
except:
print("Unexpected error:", sys.exc_info()[0])
raise
if __name__ == "__main__":
main()