llvm.org GIT mirror llvm / e5609ab
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 Daniel Dunbar 8 years ago
3 changed file(s) with 40 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
146146 ; Comments start with a semi-colon.
147147
148148 ; Sections are declared using square brackets.
149 [component 0]
149 [component_0]
150150
151151 ; Properties are declared using '=' and are contained in the previous section.
152152 ;
159159
160160
161161
162

LLVMBuild files are expected to define a strict set of section and

162

LLVMBuild files are expected to define a strict set of sections and

163163 properties. An typical component description file for a library
164164 component would look typically look like the following example:

165165
175175

A full description of the exact sections and properties which are allowed

176176 follows.

177177
178

Each file may define exactly one common component, named "common". The

179 common component may define the following properties:

180
181
  • subdirectories [optional]
  • 182

    If given, a list of the names of the subdirectories from the current

    183 subpath to search for additional LLVMBuild files.

    184
    185
    178186

    Each file may define multiple components. Each component is described by a

    179187 section who name starts with "component". The remainder of the section name is
    180188 ignored, but each section name must be unique. Typically components are just
    181189 number in order for files with multiple components ("component_0",
    182190 "component_1", and so on).

    183191
    184

    Section names not matches this format are currently

    185 unused and are disallowed.

    192

    Section names not matches this format (or the "common" section) are

    193 currently unused and are disallowed.

    186194
    187195

    Every component is defined by the properties in the section. The exact list

    188196 of properties that are allowed depends on the component
    380380 parser = ConfigParser.RawConfigParser()
    381381 parser.read(path)
    382382
    383 # Extract the common section.
    384 if parser.has_section("common"):
    385 common = IniFormatParser(parser.items("common"))
    386 parser.remove_section("common")
    387 else:
    388 common = IniFormatParser({})
    389
    390 return common, _read_components_from_parser(parser, path, subpath)
    391
    392 def _read_components_from_parser(parser, path, subpath):
    383393 # We load each section which starts with 'component' as a distinct component
    384394 # description (so multiple components can be described in one file).
    385395 for section in parser.sections():
    6363 class LLVMProjectInfo(object):
    6464 @staticmethod
    6565 def load_infos_from_path(llvmbuild_source_root):
    66 # FIXME: Implement a simple subpath file list cache, so we don't restat
    67 # directories we have already traversed.
    68
    69 # First, discover all the LLVMBuild.txt files.
    70 #
    71 # FIXME: We would like to use followlinks=True here, but that isn't
    72 # compatible with Python 2.4. Instead, we will either have to special
    73 # case projects we would expect to possibly be linked to, or implement
    74 # our own walk that can follow links. For now, it doesn't matter since
    75 # we haven't picked up the LLVMBuild system in any other LLVM projects.
    76 for dirpath,dirnames,filenames in os.walk(llvmbuild_source_root):
    77 # If there is no LLVMBuild.txt file in a directory, we don't recurse
    78 # past it. This is a simple way to prune our search, although it
    79 # makes it easy for users to add LLVMBuild.txt files in places they
    80 # won't be seen.
    81 if 'LLVMBuild.txt' not in filenames:
    82 del dirnames[:]
    83 continue
    84
    85 # Otherwise, load the LLVMBuild file in this directory.
    86 assert dirpath.startswith(llvmbuild_source_root)
    87 subpath = '/' + dirpath[len(llvmbuild_source_root)+1:]
    88 llvmbuild_path = os.path.join(dirpath, 'LLVMBuild.txt')
    89 for info in componentinfo.load_from_path(llvmbuild_path, subpath):
    66 def recurse(subpath):
    67 # Load the LLVMBuild file.
    68 llvmbuild_path = os.path.join(llvmbuild_source_root + subpath,
    69 'LLVMBuild.txt')
    70 if not os.path.exists(llvmbuild_path):
    71 fatal("missing LLVMBuild.txt file at: %r" % (llvmbuild_path,))
    72
    73 # Parse the components from it.
    74 common,info_iter = componentinfo.load_from_path(llvmbuild_path,
    75 subpath)
    76 for info in info_iter:
    9077 yield info
    78
    79 # Recurse into the specified subdirectories.
    80 for subdir in common.get_list("subdirectories"):
    81 for item in recurse(os.path.join(subpath, subdir)):
    82 yield item
    83
    84 return recurse("/")
    9185
    9286 @staticmethod
    9387 def load_from_path(source_root, llvmbuild_source_root):