[PATCH] D102860: [clang][deps] NFC: Remove the `module-deps-to-rsp.py` utility
Georgeta Igna via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 20 11:53:31 PDT 2021
georgi_igna created this revision.
georgi_igna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
This was upstreamed in https://reviews.llvm.org/D102495 and put into `clang/utils`.
Merge commit 'b99b18eb59ed' from apple/main into internal/main
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D102860
Files:
clang/test/ClangScanDeps/module-deps-to-rsp.py
Index: clang/test/ClangScanDeps/module-deps-to-rsp.py
===================================================================
--- clang/test/ClangScanDeps/module-deps-to-rsp.py
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/env python
-
-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 = dict()
- self.translation_units = str()
-
-def getModulePathArgs(modules, full_deps):
- cmd = []
- for md in modules:
- m = full_deps.modules[md['module-name'] + '-' + md['context-hash']]
- cmd += [u'-fmodule-map-file=' + m['clang-modulemap-file']]
- cmd += [u'-fmodule-file=' + md['module-name'] + '-' + md['context-hash'] + '.pcm']
- return cmd
-
-def getCommandLineForModule(module_name, full_deps):
- for m in full_deps.modules.values():
- if m['name'] == module_name:
- module = m
- break
- else:
- raise ModuleNotFoundError(module_name)
-
- cmd = m['command-line']
- cmd += getModulePathArgs(m['clang-module-deps'], full_deps)
- cmd += [u'-o', m['name'] + '-' + m['context-hash'] + '.pcm']
- cmd += [m['clang-modulemap-file']]
-
- return cmd
-
-def getCommandLineForTU(tu, full_deps):
- cmd = tu['command-line']
- cmd = [a for a in cmd if not (a.startswith('-fmodule-map-file=') or a.startswith('-fmodule-file='))]
- cmd += getModulePathArgs(tu['clang-module-deps'], full_deps)
- return cmd
-
-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 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)
- args = parser.parse_args()
-
- full_deps = parseFullDeps(json.load(open(args.full_deps_file, 'r')))
-
- try:
- if args.module_name:
- print(" ".join(getCommandLineForModule(args.module_name, full_deps)))
-
- elif args.tu_index != None:
- print(" ".join(getCommandLineForTU(full_deps.translation_units[args.tu_index], full_deps)))
- except:
- print("Unexpected error:", sys.exc_info()[0])
- raise
-
-if __name__ == '__main__':
- main()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102860.346814.patch
Type: text/x-patch
Size: 2663 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210520/9594742c/attachment.bin>
More information about the cfe-commits
mailing list