mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
llvm-build: Add --print-tree command line option.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143625 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
86c119a507
commit
00b4b4f5cb
@ -54,11 +54,12 @@ class LLVMProjectInfo(object):
|
||||
ci.name, ci.subpath, existing.subpath))
|
||||
self.component_info_map[ci.name] = ci
|
||||
|
||||
# Add the root component, which does not go in any list.
|
||||
# Add the root component.
|
||||
if '$ROOT' in self.component_info_map:
|
||||
fatal("project is not allowed to define $ROOT component")
|
||||
self.component_info_map['$ROOT'] = componentinfo.GroupComponentInfo(
|
||||
'/', '$ROOT', None)
|
||||
self.component_infos.append(self.component_info_map['$ROOT'])
|
||||
|
||||
# Topologically order the component information according to their
|
||||
# component references.
|
||||
@ -80,6 +81,7 @@ class LLVMProjectInfo(object):
|
||||
components_to_visit.remove(ci)
|
||||
|
||||
# Validate the parent reference, which we treat specially.
|
||||
if ci.parent is not None:
|
||||
parent = self.component_info_map.get(ci.parent)
|
||||
if parent is None:
|
||||
fatal("component %r has invalid reference %r (via %r)" % (
|
||||
@ -113,12 +115,26 @@ class LLVMProjectInfo(object):
|
||||
while components_to_visit:
|
||||
visit_component_info(iter(components_to_visit).next(), [], set())
|
||||
|
||||
# Canonicalize children lists.
|
||||
for c in self.ordered_component_infos:
|
||||
c.children.sort(key = lambda c: c.name)
|
||||
|
||||
def print_tree(self):
|
||||
def visit(node, depth = 0):
|
||||
print '%s%-40s (%s)' % (' '*depth, node.name, node.type_name)
|
||||
for c in node.children:
|
||||
visit(c, depth + 1)
|
||||
visit(self.component_info_map['$ROOT'])
|
||||
|
||||
def main():
|
||||
from optparse import OptionParser, OptionGroup
|
||||
parser = OptionParser("usage: %prog [options]")
|
||||
parser.add_option("", "--source-root", dest="source_root", metavar="PATH",
|
||||
help="Path to the LLVM source (inferred if not given)",
|
||||
action="store", default=None)
|
||||
parser.add_option("", "--print-tree", dest="print_tree",
|
||||
help="Print out the project component tree [%default]",
|
||||
action="store_true", default=False)
|
||||
parser.add_option(
|
||||
"", "--llvmbuild-source-root", dest="llvmbuild_source_root",
|
||||
help="If given, an alternate path to search for LLVMBuild.txt files",
|
||||
@ -145,5 +161,9 @@ def main():
|
||||
project_info = LLVMProjectInfo.load_from_path(
|
||||
source_root, llvmbuild_source_root)
|
||||
|
||||
# Print the component tree, if requested.
|
||||
if opts.print_tree:
|
||||
project_info.print_tree()
|
||||
|
||||
if __name__=='__main__':
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user