diff options
author | Daniel Dunbar <daniel@zuster.org> | 2011-11-10 00:49:58 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2011-11-10 00:49:58 +0000 |
commit | b4eaee7a4407a73d95b042b08523e9ace577e2a1 (patch) | |
tree | 4f3f0b31be23b39f3ec4a67b30c3137b620f589c /utils/llvm-build | |
parent | 6852b69e15c4b1078e23d6a5abd023ce48d4576a (diff) |
llvm-build: Split out the validation logic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144252 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/llvm-build')
-rw-r--r-- | utils/llvm-build/llvmbuild/main.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/utils/llvm-build/llvmbuild/main.py b/utils/llvm-build/llvmbuild/main.py index cc4617d9b9..e27acd2f32 100644 --- a/utils/llvm-build/llvmbuild/main.py +++ b/utils/llvm-build/llvmbuild/main.py @@ -83,12 +83,26 @@ class LLVMProjectInfo(object): def __init__(self, source_root, component_infos): # Store our simple ivars. self.source_root = source_root - self.component_infos = component_infos + self.component_infos = list(component_infos) + self.component_info_map = None + self.ordered_component_infos = None + + def validate_components(self): + """validate_components() -> None + + Validate that the project components are well-defined. Among other + things, this checks that: + - Components have valid references. + - Components references do not form cycles. + + We also construct the map from component names to info, and the + topological ordering of components. + """ # Create the component info map and validate that component names are # unique. self.component_info_map = {} - for ci in component_infos: + for ci in self.component_infos: existing = self.component_info_map.get(ci.name) if existing is not None: # We found a duplicate component name, report it and error out. @@ -157,7 +171,7 @@ class LLVMProjectInfo(object): # out easily. If we don't, we should special case the check. self.ordered_component_infos = [] - components_to_visit = set(component_infos) + components_to_visit = set(self.component_infos) while components_to_visit: visit_component_info(iter(components_to_visit).next(), [], set()) @@ -544,6 +558,9 @@ def main(): project_info = LLVMProjectInfo.load_from_path( source_root, llvmbuild_source_root) + # Validate the project component info. + project_info.validate_components() + # Print the component tree, if requested. if opts.print_tree: project_info.print_tree() |