xref: /llvm-project/llvm/utils/gn/build/write_library_dependencies.py (revision b71edfaa4ec3c998aadb35255ce2f60bba2940b0)
1#!/usr/bin/env python3
2
3import argparse
4import os
5import re
6import sys
7
8
9# FIXME: This should get outputs from gn.
10OUTPUT = """struct AvailableComponent {
11    /// The name of the component.
12    const char *Name;
13
14    /// The name of the library for this component (or NULL).
15    const char *Library;
16
17    /// Whether the component is installed.
18    bool IsInstalled;
19
20    /// The list of libraries required when linking this component.
21    const char *RequiredLibraries[84];
22  } AvailableComponents[84] = {
23  { "aggressiveinstcombine", "LLVMAggressiveInstCombine", true, {"analysis", "core", "support", "transformutils"} },
24{ "all", nullptr, true, {"demangle", "support", "tablegen", "core", "fuzzmutate", "filecheck", "interfacestub", "irreader", "codegen", "selectiondag", "asmprinter", "mirparser", "globalisel", "binaryformat", "bitreader", "bitwriter", "bitstreamreader", "dwarflinker", "extensions", "frontendopenmp", "transformutils", "instrumentation", "aggressiveinstcombine", "instcombine", "scalaropts", "ipo", "vectorize", "objcarcopts", "coroutines", "cfguard", "linker", "analysis", "lto", "mc", "mcparser", "mcdisassembler", "mca", "object", "objectyaml", "option", "remarks", "debuginfodwarf", "debuginfogsym", "debuginfomsf", "debuginfocodeview", "debuginfopdb", "symbolize", "executionengine", "interpreter", "jitlink", "mcjit", "orcjit", "orcshared", "orctargetprocess", "runtimedyld", "target", "asmparser", "lineeditor", "profiledata", "coverage", "passes", "textapi", "dlltooldriver", "libdriver", "xray", "windowsmanifest"} },
25{ "all-targets", nullptr, true, {} },
26{ "analysis", "LLVMAnalysis", true, {"binaryformat", "core", "object", "profiledata", "support"} },
27{ "asmparser", "LLVMAsmParser", true, {"binaryformat", "core", "support"} },
28{ "asmprinter", "LLVMAsmPrinter", true, {"analysis", "binaryformat", "codegen", "core", "debuginfocodeview", "debuginfodwarf", "debuginfomsf", "mc", "mcparser", "remarks", "support", "target"} },
29{ "binaryformat", "LLVMBinaryFormat", true, {"support"} },
30{ "bitreader", "LLVMBitReader", true, {"bitstreamreader", "core", "support"} },
31{ "bitstreamreader", "LLVMBitstreamReader", true, {"support"} },
32{ "bitwriter", "LLVMBitWriter", true, {"analysis", "core", "mc", "object", "support"} },
33{ "cfguard", "LLVMCFGuard", true, {"core", "support"} },
34{ "codegen", "LLVMCodeGen", true, {"analysis", "bitreader", "bitwriter", "core", "mc", "profiledata", "scalaropts", "support", "target", "transformutils"} },
35{ "core", "LLVMCore", true, {"binaryformat", "remarks", "support"} },
36{ "coroutines", "LLVMCoroutines", true, {"analysis", "core", "ipo", "scalaropts", "support", "transformutils"} },
37{ "coverage", "LLVMCoverage", true, {"core", "object", "profiledata", "support"} },
38{ "debuginfocodeview", "LLVMDebugInfoCodeView", true, {"support", "debuginfomsf"} },
39{ "debuginfodwarf", "LLVMDebugInfoDWARF", true, {"binaryformat", "object", "mc", "support"} },
40{ "debuginfogsym", "LLVMDebugInfoGSYM", true, {"mc", "object", "support", "debuginfodwarf"} },
41{ "debuginfomsf", "LLVMDebugInfoMSF", true, {"support"} },
42{ "debuginfopdb", "LLVMDebugInfoPDB", true, {"binaryformat", "object", "support", "debuginfocodeview", "debuginfomsf"} },
43{ "demangle", "LLVMDemangle", true, {} },
44{ "dlltooldriver", "LLVMDlltoolDriver", true, {"object", "option", "support"} },
45{ "dwarflinker", "LLVMDWARFLinker", true, {"debuginfodwarf", "asmprinter", "codegen", "mc", "object", "support"} },
46{ "engine", nullptr, true, {"interpreter"} },
47{ "executionengine", "LLVMExecutionEngine", true, {"core", "mc", "object", "runtimedyld", "support", "target"} },
48{ "extensions", "LLVMExtensions", true, {"support"} },
49{ "filecheck", "LLVMFileCheck", true, {} },
50{ "frontendopenmp", "LLVMFrontendOpenMP", true, {"core", "support", "transformutils"} },
51{ "fuzzmutate", "LLVMFuzzMutate", true, {"analysis", "bitreader", "bitwriter", "core", "scalaropts", "support", "target"} },
52{ "globalisel", "LLVMGlobalISel", true, {"analysis", "codegen", "core", "mc", "selectiondag", "support", "target", "transformutils"} },
53{ "instcombine", "LLVMInstCombine", true, {"analysis", "core", "support", "transformutils"} },
54{ "instrumentation", "LLVMInstrumentation", true, {"analysis", "core", "mc", "support", "transformutils", "profiledata"} },
55{ "interfacestub", "LLVMInterfaceStub", true, {"object", "support"} },
56{ "interpreter", "LLVMInterpreter", true, {"codegen", "core", "executionengine", "support"} },
57{ "ipo", "LLVMipo", true, {"aggressiveinstcombine", "analysis", "bitreader", "bitwriter", "core", "frontendopenmp", "instcombine", "irreader", "linker", "object", "profiledata", "scalaropts", "support", "transformutils", "vectorize", "instrumentation"} },
58{ "irreader", "LLVMIRReader", true, {"asmparser", "bitreader", "core", "support"} },
59{ "jitlink", "LLVMJITLink", true, {"binaryformat", "object", "orctargetprocess", "support"} },
60{ "libdriver", "LLVMLibDriver", true, {"binaryformat", "bitreader", "object", "option", "support", "binaryformat", "bitreader", "object", "option", "support"} },
61{ "lineeditor", "LLVMLineEditor", true, {"support"} },
62{ "linker", "LLVMLinker", true, {"core", "support", "transformutils"} },
63{ "lto", "LLVMLTO", true, {"aggressiveinstcombine", "analysis", "binaryformat", "bitreader", "bitwriter", "codegen", "core", "extensions", "ipo", "instcombine", "linker", "mc", "objcarcopts", "object", "passes", "remarks", "scalaropts", "support", "target", "transformutils"} },
64{ "mc", "LLVMMC", true, {"support", "binaryformat", "debuginfocodeview"} },
65{ "mca", "LLVMMCA", true, {"mc", "support"} },
66{ "mcdisassembler", "LLVMMCDisassembler", true, {"mc", "support"} },
67{ "mcjit", "LLVMMCJIT", true, {"core", "executionengine", "object", "runtimedyld", "support", "target"} },
68{ "mcparser", "LLVMMCParser", true, {"mc", "support"} },
69{ "mirparser", "LLVMMIRParser", true, {"asmparser", "binaryformat", "codegen", "core", "mc", "support", "target"} },
70{ "native", nullptr, true, {} },
71{ "nativecodegen", nullptr, true, {} },
72{ "objcarcopts", "LLVMObjCARCOpts", true, {"analysis", "core", "support", "transformutils"} },
73{ "object", "LLVMObject", true, {"bitreader", "core", "mc", "binaryformat", "mcparser", "support", "textapi"} },
74{ "objectyaml", "LLVMObjectYAML", true, {"binaryformat", "object", "support", "debuginfocodeview", "mc"} },
75{ "option", "LLVMOption", true, {"support"} },
76{ "orcjit", "LLVMOrcJIT", true, {"core", "executionengine", "jitlink", "object", "orcshared", "orctargetprocess", "mc", "passes", "runtimedyld", "support", "target", "transformutils"} },
77{ "orcshared", "LLVMOrcShared", true, {"support"} },
78{ "orctargetprocess", "LLVMOrcTargetProcess", true, {"orcshared", "support"} },
79{ "passes", "LLVMPasses", true, {"aggressiveinstcombine", "analysis", "core", "coroutines", "ipo", "instcombine", "objcarcopts", "scalaropts", "support", "target", "transformutils", "vectorize", "instrumentation"} },
80{ "profiledata", "LLVMProfileData", true, {"core", "support", "demangle"} },
81{ "remarks", "LLVMRemarks", true, {"bitstreamreader", "support"} },
82{ "runtimedyld", "LLVMRuntimeDyld", true, {"core", "mc", "object", "support"} },
83{ "scalaropts", "LLVMScalarOpts", true, {"aggressiveinstcombine", "analysis", "core", "instcombine", "support", "transformutils"} },
84{ "selectiondag", "LLVMSelectionDAG", true, {"analysis", "codegen", "core", "mc", "support", "target", "transformutils"} },
85{ "support", "LLVMSupport", true, {"demangle"} },
86{ "symbolize", "LLVMSymbolize", true, {"debuginfodwarf", "debuginfopdb", "object", "support", "demangle"} },
87{ "tablegen", "LLVMTableGen", true, {"support"} },
88{ "target", "LLVMTarget", true, {"analysis", "core", "mc", "support"} },
89{ "textapi", "LLVMTextAPI", true, {"support", "binaryformat"} },
90{ "transformutils", "LLVMTransformUtils", true, {"analysis", "core", "support"} },
91{ "vectorize", "LLVMVectorize", true, {"analysis", "core", "support", "transformutils"} },
92{ "windowsmanifest", "LLVMWindowsManifest", true, {"support"} },
93{ "xray", "LLVMXRay", true, {"support", "object"} },
94};
95"""
96
97
98def main():
99    parser = argparse.ArgumentParser()
100    parser.add_argument("-o", "--output", required=True, help="output file")
101    args = parser.parse_args()
102
103    with open(args.output, "w") as f:
104        f.write(OUTPUT)
105
106
107if __name__ == "__main__":
108    sys.exit(main())
109