summaryrefslogtreecommitdiff
path: root/utils/llvm-build
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-11-10 00:49:51 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-11-10 00:49:51 +0000
commitc352caf168094c83f05a8010ca14c2e643dbf618 (patch)
tree5493f3b1c5171f126086d932df15539b37f77ef3 /utils/llvm-build
parent1e5b24330b11fb2631c7bc2892ba6364309fe385 (diff)
downloadllvm-c352caf168094c83f05a8010ca14c2e643dbf618.tar.gz
llvm-c352caf168094c83f05a8010ca14c2e643dbf618.tar.bz2
llvm-c352caf168094c83f05a8010ca14c2e643dbf618.tar.xz
llvm-build: Add an explicit component type to represent targets.
- Gives us a place to hang target specific metadata (like whether the target has a JIT). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144250 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/llvm-build')
-rw-r--r--utils/llvm-build/llvmbuild/componentinfo.py72
-rw-r--r--utils/llvm-build/llvmbuild/main.py10
2 files changed, 76 insertions, 6 deletions
diff --git a/utils/llvm-build/llvmbuild/componentinfo.py b/utils/llvm-build/llvmbuild/componentinfo.py
index fb455710b6..00b8ac52a9 100644
--- a/utils/llvm-build/llvmbuild/componentinfo.py
+++ b/utils/llvm-build/llvmbuild/componentinfo.py
@@ -188,6 +188,60 @@ class LibraryGroupComponentInfo(ComponentInfo):
def get_llvmconfig_component_name(self):
return self.name.lower()
+class TargetGroupComponentInfo(ComponentInfo):
+ type_name = 'TargetGroup'
+
+ @staticmethod
+ def parse(subpath, items):
+ kwargs = ComponentInfo.parse_items(items, has_dependencies = False)
+ kwargs['required_libraries'] = items.get_list('required_libraries')
+ kwargs['add_to_library_groups'] = items.get_list(
+ 'add_to_library_groups')
+ kwargs['has_jit'] = items.get_optional_bool('has_jit', False)
+ return TargetGroupComponentInfo(subpath, **kwargs)
+
+ def __init__(self, subpath, name, parent, required_libraries = [],
+ add_to_library_groups = [], has_jit = False):
+ ComponentInfo.__init__(self, subpath, name, [], parent)
+
+ # The names of the library components which are required when linking
+ # with this component.
+ self.required_libraries = list(required_libraries)
+
+ # The names of the library group components this component should be
+ # considered part of.
+ self.add_to_library_groups = list(add_to_library_groups)
+
+ # Whether or not this target supports the JIT.
+ self.has_jit = bool(has_jit)
+
+ def get_component_references(self):
+ for r in ComponentInfo.get_component_references(self):
+ yield r
+ for r in self.required_libraries:
+ yield ('required library', r)
+ for r in self.add_to_library_groups:
+ yield ('library group', r)
+
+ def get_llvmbuild_fragment(self):
+ result = StringIO.StringIO()
+ print >>result, 'type = %s' % self.type_name
+ print >>result, 'name = %s' % self.name
+ print >>result, 'parent = %s' % self.parent
+ if self.required_libraries:
+ print >>result, 'required_libraries = %s' % ' '.join(
+ self.required_libraries)
+ if self.add_to_library_groups:
+ print >>result, 'add_to_library_groups = %s' % ' '.join(
+ self.add_to_library_groups)
+ if self.has_jit:
+ print >>result, 'has_jit = %s' % ' '.join(
+ int(self.has_jit))
+ return result.getvalue()
+
+ def get_llvmconfig_component_name(self):
+ return self.name.lower()
+
class ToolComponentInfo(ComponentInfo):
type_name = 'Tool'
@@ -255,11 +309,27 @@ class IniFormatParser(dict):
raise ParseError("missing value for required string: %r" % key)
return value
+ def get_optional_bool(self, key, default = None):
+ value = self.get_optional_string(key)
+ if not value:
+ return default
+ if value not in ('0', '1'):
+ raise ParseError("invalid value(%r) for boolean property: %r" % (
+ value, key))
+ return bool(int(value))
+
+ def get_bool(self, key):
+ value = self.get_optional_bool(key)
+ if value is None:
+ raise ParseError("missing value for required boolean: %r" % key)
+ return value
+
_component_type_map = dict(
(t.type_name, t)
for t in (GroupComponentInfo,
LibraryComponentInfo, LibraryGroupComponentInfo,
- ToolComponentInfo, BuildToolComponentInfo))
+ ToolComponentInfo, BuildToolComponentInfo,
+ TargetGroupComponentInfo))
def load_from_path(path, subpath):
# Load the LLVMBuild.txt file as an .ini format file.
parser = ConfigParser.RawConfigParser()
diff --git a/utils/llvm-build/llvmbuild/main.py b/utils/llvm-build/llvmbuild/main.py
index 2a9ef5d907..cc4617d9b9 100644
--- a/utils/llvm-build/llvmbuild/main.py
+++ b/utils/llvm-build/llvmbuild/main.py
@@ -242,8 +242,8 @@ class LLVMProjectInfo(object):
# dependencies for added library groups.
entries = {}
for c in self.ordered_component_infos:
- # Only Library and LibraryGroup components are in the table.
- if c.type_name not in ('Library', 'LibraryGroup'):
+ # Only certain components are in the table.
+ if c.type_name not in ('Library', 'LibraryGroup', 'TargetGroup'):
continue
# Compute the llvm-config "component name". For historical reasons,
@@ -251,10 +251,10 @@ class LLVMProjectInfo(object):
llvmconfig_component_name = c.get_llvmconfig_component_name()
# Get the library name, or None for LibraryGroups.
- if c.type_name == 'LibraryGroup':
- library_name = None
- else:
+ if c.type_name == 'Library':
library_name = c.get_library_name()
+ else:
+ library_name = None
# Get the component names of all the required libraries.
required_llvmconfig_component_names = [