summaryrefslogtreecommitdiff
path: root/utils/llvm-build
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-12-12 22:45:54 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-12-12 22:45:54 +0000
commitb0c594fd422417e1e290da166b566c7bee74644b (patch)
treec6b17c7e80638ee189e5fe72f1b8ff9ef22b8b38 /utils/llvm-build
parent54d8c7fc0359cf9a0b857d27ea6816ea6b050281 (diff)
downloadllvm-b0c594fd422417e1e290da166b566c7bee74644b.tar.gz
llvm-b0c594fd422417e1e290da166b566c7bee74644b.tar.bz2
llvm-b0c594fd422417e1e290da166b566c7bee74644b.tar.xz
LLVMBuild: Introduce a common section which currently has a list of the
subdirectories to traverse into. - Originally I wanted to avoid this and just autoscan, but this has one key flaw in that new subdirectories can not automatically trigger a rerun of the llvm-build tool. This is particularly a pain when switching back and forth between trees where one has added a subdirectory, as the dependencies will tend to be wrong. This will also eliminates FIXME implicitly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146436 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/llvm-build')
-rw-r--r--utils/llvm-build/llvmbuild/main.py46
1 files changed, 39 insertions, 7 deletions
diff --git a/utils/llvm-build/llvmbuild/main.py b/utils/llvm-build/llvmbuild/main.py
index 550c740303..279a10f5f1 100644
--- a/utils/llvm-build/llvmbuild/main.py
+++ b/utils/llvm-build/llvmbuild/main.py
@@ -214,14 +214,45 @@ class LLVMProjectInfo(object):
info_basedir[ci.subpath] = info_basedir.get(ci.subpath, []) + [ci]
+ # Compute the list of subdirectories to scan.
+ subpath_subdirs = {}
+ for ci in self.component_infos:
+ # Ignore root components.
+ if ci.subpath == '/':
+ continue
+
+ # Otherwise, append this subpath to the parent list.
+ parent_path = os.path.dirname(ci.subpath)
+ subpath_subdirs[parent_path] = parent_list = subpath_subdirs.get(
+ parent_path, set())
+ parent_list.add(os.path.basename(ci.subpath))
+
# Generate the build files.
for subpath, infos in info_basedir.items():
# Order the components by name to have a canonical ordering.
infos.sort(key = lambda ci: ci.name)
# Format the components into llvmbuild fragments.
- fragments = filter(None, [ci.get_llvmbuild_fragment()
- for ci in infos])
+ fragments = []
+
+ # Add the common fragments.
+ subdirectories = subpath_subdirs.get(subpath)
+ if subdirectories:
+ fragment = """\
+subdirectories = %s
+""" % (" ".join(sorted(subdirectories)),)
+ fragments.append(("common", fragment))
+
+ # Add the component fragments.
+ num_common_fragments = len(fragments)
+ for ci in infos:
+ fragment = ci.get_llvmbuild_fragment()
+ if fragment is None:
+ continue
+
+ name = "component_%d" % (len(fragments) - num_common_fragments)
+ fragments.append((name, fragment))
+
if not fragments:
continue
@@ -242,7 +273,7 @@ class LLVMProjectInfo(object):
if ln.startswith(';'):
comment_block += ln
elif ln.startswith('[') and ln.endswith(']\n'):
- comments_map[ln[:-1]] = comment_block
+ comments_map[ln[1:-2]] = comment_block
else:
comment_block = ""
f.close()
@@ -275,15 +306,16 @@ class LLVMProjectInfo(object):
;===------------------------------------------------------------------------===;
""" % header_string
- for i,fragment in enumerate(fragments):
- name = '[component_%d]' % i
+ # Write out each fragment.each component fragment.
+ for name,fragment in fragments:
comment = comments_map.get(name)
if comment is not None:
f.write(comment)
- print >>f, name
+ print >>f, "[%s]" % name
f.write(fragment)
- if fragment is not fragments[-1]:
+ if fragment is not fragments[-1][1]:
print >>f
+
f.close()
def write_library_table(self, output_path):