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))
|
ci.name, ci.subpath, existing.subpath))
|
||||||
self.component_info_map[ci.name] = ci
|
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:
|
if '$ROOT' in self.component_info_map:
|
||||||
fatal("project is not allowed to define $ROOT component")
|
fatal("project is not allowed to define $ROOT component")
|
||||||
self.component_info_map['$ROOT'] = componentinfo.GroupComponentInfo(
|
self.component_info_map['$ROOT'] = componentinfo.GroupComponentInfo(
|
||||||
'/', '$ROOT', None)
|
'/', '$ROOT', None)
|
||||||
|
self.component_infos.append(self.component_info_map['$ROOT'])
|
||||||
|
|
||||||
# Topologically order the component information according to their
|
# Topologically order the component information according to their
|
||||||
# component references.
|
# component references.
|
||||||
@ -80,11 +81,12 @@ class LLVMProjectInfo(object):
|
|||||||
components_to_visit.remove(ci)
|
components_to_visit.remove(ci)
|
||||||
|
|
||||||
# Validate the parent reference, which we treat specially.
|
# Validate the parent reference, which we treat specially.
|
||||||
parent = self.component_info_map.get(ci.parent)
|
if ci.parent is not None:
|
||||||
if parent is None:
|
parent = self.component_info_map.get(ci.parent)
|
||||||
fatal("component %r has invalid reference %r (via %r)" % (
|
if parent is None:
|
||||||
ci.name, ci.parent, 'parent'))
|
fatal("component %r has invalid reference %r (via %r)" % (
|
||||||
ci.set_parent_instance(parent)
|
ci.name, ci.parent, 'parent'))
|
||||||
|
ci.set_parent_instance(parent)
|
||||||
|
|
||||||
for relation,referent_name in ci.get_component_references():
|
for relation,referent_name in ci.get_component_references():
|
||||||
# Validate that the reference is ok.
|
# Validate that the reference is ok.
|
||||||
@ -113,12 +115,26 @@ class LLVMProjectInfo(object):
|
|||||||
while components_to_visit:
|
while components_to_visit:
|
||||||
visit_component_info(iter(components_to_visit).next(), [], set())
|
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():
|
def main():
|
||||||
from optparse import OptionParser, OptionGroup
|
from optparse import OptionParser, OptionGroup
|
||||||
parser = OptionParser("usage: %prog [options]")
|
parser = OptionParser("usage: %prog [options]")
|
||||||
parser.add_option("", "--source-root", dest="source_root", metavar="PATH",
|
parser.add_option("", "--source-root", dest="source_root", metavar="PATH",
|
||||||
help="Path to the LLVM source (inferred if not given)",
|
help="Path to the LLVM source (inferred if not given)",
|
||||||
action="store", default=None)
|
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(
|
parser.add_option(
|
||||||
"", "--llvmbuild-source-root", dest="llvmbuild_source_root",
|
"", "--llvmbuild-source-root", dest="llvmbuild_source_root",
|
||||||
help="If given, an alternate path to search for LLVMBuild.txt files",
|
help="If given, an alternate path to search for LLVMBuild.txt files",
|
||||||
@ -145,5 +161,9 @@ def main():
|
|||||||
project_info = LLVMProjectInfo.load_from_path(
|
project_info = LLVMProjectInfo.load_from_path(
|
||||||
source_root, llvmbuild_source_root)
|
source_root, llvmbuild_source_root)
|
||||||
|
|
||||||
|
# Print the component tree, if requested.
|
||||||
|
if opts.print_tree:
|
||||||
|
project_info.print_tree()
|
||||||
|
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user