diff options
author | Daniel Dunbar <daniel@zuster.org> | 2011-12-12 22:45:59 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2011-12-12 22:45:59 +0000 |
commit | e5609abccbd329ef4b07270c8b71a5b59cfe8bce (patch) | |
tree | db1a8da69f79db4c5cafff00b7c2e80a4218916d /utils/llvm-build | |
parent | b0c594fd422417e1e290da166b566c7bee74644b (diff) | |
download | external_llvm-e5609abccbd329ef4b07270c8b71a5b59cfe8bce.zip external_llvm-e5609abccbd329ef4b07270c8b71a5b59cfe8bce.tar.gz external_llvm-e5609abccbd329ef4b07270c8b71a5b59cfe8bce.tar.bz2 |
llvm-build: Switch to using the common subdirectory list instead of
autodiscovery.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146437 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/llvm-build')
-rw-r--r-- | utils/llvm-build/llvmbuild/componentinfo.py | 10 | ||||
-rw-r--r-- | utils/llvm-build/llvmbuild/main.py | 40 |
2 files changed, 27 insertions, 23 deletions
diff --git a/utils/llvm-build/llvmbuild/componentinfo.py b/utils/llvm-build/llvmbuild/componentinfo.py index 8526461..230ae21 100644 --- a/utils/llvm-build/llvmbuild/componentinfo.py +++ b/utils/llvm-build/llvmbuild/componentinfo.py @@ -381,6 +381,16 @@ def load_from_path(path, subpath): parser = ConfigParser.RawConfigParser() parser.read(path) + # Extract the common section. + if parser.has_section("common"): + common = IniFormatParser(parser.items("common")) + parser.remove_section("common") + else: + common = IniFormatParser({}) + + return common, _read_components_from_parser(parser, path, subpath) + +def _read_components_from_parser(parser, path, subpath): # We load each section which starts with 'component' as a distinct component # description (so multiple components can be described in one file). for section in parser.sections(): diff --git a/utils/llvm-build/llvmbuild/main.py b/utils/llvm-build/llvmbuild/main.py index 279a10f..2d7db04 100644 --- a/utils/llvm-build/llvmbuild/main.py +++ b/utils/llvm-build/llvmbuild/main.py @@ -64,31 +64,25 @@ def make_install_dir(path): class LLVMProjectInfo(object): @staticmethod def load_infos_from_path(llvmbuild_source_root): - # FIXME: Implement a simple subpath file list cache, so we don't restat - # directories we have already traversed. + def recurse(subpath): + # Load the LLVMBuild file. + llvmbuild_path = os.path.join(llvmbuild_source_root + subpath, + 'LLVMBuild.txt') + if not os.path.exists(llvmbuild_path): + fatal("missing LLVMBuild.txt file at: %r" % (llvmbuild_path,)) + + # Parse the components from it. + common,info_iter = componentinfo.load_from_path(llvmbuild_path, + subpath) + for info in info_iter: + yield info - # First, discover all the LLVMBuild.txt files. - # - # FIXME: We would like to use followlinks=True here, but that isn't - # compatible with Python 2.4. Instead, we will either have to special - # case projects we would expect to possibly be linked to, or implement - # our own walk that can follow links. For now, it doesn't matter since - # we haven't picked up the LLVMBuild system in any other LLVM projects. - for dirpath,dirnames,filenames in os.walk(llvmbuild_source_root): - # If there is no LLVMBuild.txt file in a directory, we don't recurse - # past it. This is a simple way to prune our search, although it - # makes it easy for users to add LLVMBuild.txt files in places they - # won't be seen. - if 'LLVMBuild.txt' not in filenames: - del dirnames[:] - continue + # Recurse into the specified subdirectories. + for subdir in common.get_list("subdirectories"): + for item in recurse(os.path.join(subpath, subdir)): + yield item - # Otherwise, load the LLVMBuild file in this directory. - assert dirpath.startswith(llvmbuild_source_root) - subpath = '/' + dirpath[len(llvmbuild_source_root)+1:] - llvmbuild_path = os.path.join(dirpath, 'LLVMBuild.txt') - for info in componentinfo.load_from_path(llvmbuild_path, subpath): - yield info + return recurse("/") @staticmethod def load_from_path(source_root, llvmbuild_source_root): |