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
This commit is contained in:
Daniel Dunbar 2011-11-10 00:49:51 +00:00
parent 1e5b24330b
commit c352caf168
15 changed files with 112 additions and 22 deletions

View File

@ -134,7 +134,7 @@ $ROOT of project trees for things which can be checked out separately. -->
</div> </div>
<!-- *********************************************************************** --> <!-- *********************************************************************** -->
<h2><a name="formatref">LLVMBuild Format Reference</a></h2> <h2><a name="formatreference">LLVMBuild Format Reference</a></h2>
<!-- *********************************************************************** --> <!-- *********************************************************************** -->
<div> <div>
@ -151,11 +151,12 @@ $ROOT of project trees for things which can be checked out separately. -->
<i>; Properties are declared using '=' and are contained in the previous section. <i>; Properties are declared using '=' and are contained in the previous section.
; ;
; We support simple scalar values and list values, where items are separated by ; We support simple string and boolean scalar values and list values, where
; spaces. There is no support for quoting, and so property values may not contain ; items are separated by spaces. There is no support for quoting, and so
; spaces.</i> ; property values may not contain spaces.</i>
property_name = property_value property_name = property_value
list_property_name = value_1 value_2 <em>...</em> value_n list_property_name = value_1 value_2 <em>...</em> value_n
boolean_property_name = 1 <em>(or 0)</em>
</pre> </pre>
</div> </div>
@ -281,6 +282,21 @@ required_libraries = Archive BitReader Core Support TransformUtils
</ul> </ul>
</li> </li>
<li><i>type = TargetGroup</i>
<p>TargetGroup components are an extension of LibraryGroups, specifically
for defining LLVM targets (which are handled specially in a few
places).</p>
<p>The name of the component should always be the name of the target.</p>
<p>Components with this type use the LibraryGroup properties in addition
to:</p>
<ul>
<li><i>has_jit</i> <b>[optional]</b> <b>[boolean]</b>
<p>Whether this target supports JIT compilation.</p></li>
</ul>
</li>
<li><i>type = Tool</i> <li><i>type = Tool</i>
<p>Tool components define standalone command line tools which should be <p>Tool components define standalone command line tools which should be
built from the source code in the component directory and linked.</p> built from the source code in the component directory and linked.</p>

View File

@ -16,10 +16,11 @@
;===------------------------------------------------------------------------===; ;===------------------------------------------------------------------------===;
[component_0] [component_0]
type = LibraryGroup type = TargetGroup
name = ARM name = ARM
parent = Target parent = Target
add_to_library_groups = all-targets add_to_library_groups = all-targets
has_jit = 1
[component_1] [component_1]
type = Library type = Library

View File

@ -16,7 +16,7 @@
;===------------------------------------------------------------------------===; ;===------------------------------------------------------------------------===;
[component_0] [component_0]
type = LibraryGroup type = TargetGroup
name = CBackend name = CBackend
parent = Target parent = Target
add_to_library_groups = all-targets add_to_library_groups = all-targets

View File

@ -16,7 +16,7 @@
;===------------------------------------------------------------------------===; ;===------------------------------------------------------------------------===;
[component_0] [component_0]
type = LibraryGroup type = TargetGroup
name = CellSPU name = CellSPU
parent = Target parent = Target
add_to_library_groups = all-targets add_to_library_groups = all-targets

View File

@ -16,7 +16,7 @@
;===------------------------------------------------------------------------===; ;===------------------------------------------------------------------------===;
[component_0] [component_0]
type = LibraryGroup type = TargetGroup
name = CppBackend name = CppBackend
parent = Target parent = Target
add_to_library_groups = all-targets add_to_library_groups = all-targets

View File

@ -16,7 +16,7 @@
;===------------------------------------------------------------------------===; ;===------------------------------------------------------------------------===;
[component_0] [component_0]
type = LibraryGroup type = TargetGroup
name = MBlaze name = MBlaze
parent = Target parent = Target
add_to_library_groups = all-targets add_to_library_groups = all-targets

View File

@ -16,7 +16,7 @@
;===------------------------------------------------------------------------===; ;===------------------------------------------------------------------------===;
[component_0] [component_0]
type = LibraryGroup type = TargetGroup
name = MSP430 name = MSP430
parent = Target parent = Target
add_to_library_groups = all-targets add_to_library_groups = all-targets

View File

@ -16,10 +16,11 @@
;===------------------------------------------------------------------------===; ;===------------------------------------------------------------------------===;
[component_0] [component_0]
type = LibraryGroup type = TargetGroup
name = Mips name = Mips
parent = Target parent = Target
add_to_library_groups = all-targets add_to_library_groups = all-targets
has_jit = 1
[component_1] [component_1]
type = Library type = Library

View File

@ -16,7 +16,7 @@
;===------------------------------------------------------------------------===; ;===------------------------------------------------------------------------===;
[component_0] [component_0]
type = LibraryGroup type = TargetGroup
name = PTX name = PTX
parent = Target parent = Target
add_to_library_groups = all-targets add_to_library_groups = all-targets

View File

@ -16,10 +16,11 @@
;===------------------------------------------------------------------------===; ;===------------------------------------------------------------------------===;
[component_0] [component_0]
type = LibraryGroup type = TargetGroup
name = PowerPC name = PowerPC
parent = Target parent = Target
add_to_library_groups = all-targets add_to_library_groups = all-targets
has_jit = 1
[component_1] [component_1]
type = Library type = Library

View File

@ -16,7 +16,7 @@
;===------------------------------------------------------------------------===; ;===------------------------------------------------------------------------===;
[component_0] [component_0]
type = LibraryGroup type = TargetGroup
name = Sparc name = Sparc
parent = Target parent = Target
add_to_library_groups = all-targets add_to_library_groups = all-targets

View File

@ -16,10 +16,11 @@
;===------------------------------------------------------------------------===; ;===------------------------------------------------------------------------===;
[component_0] [component_0]
type = LibraryGroup type = TargetGroup
name = X86 name = X86
parent = Target parent = Target
add_to_library_groups = all-targets add_to_library_groups = all-targets
has_jit = 1
[component_1] [component_1]
type = Library type = Library

View File

@ -16,7 +16,7 @@
;===------------------------------------------------------------------------===; ;===------------------------------------------------------------------------===;
[component_0] [component_0]
type = LibraryGroup type = TargetGroup
name = XCore name = XCore
parent = Target parent = Target
add_to_library_groups = all-targets add_to_library_groups = all-targets

View File

@ -188,6 +188,60 @@ class LibraryGroupComponentInfo(ComponentInfo):
def get_llvmconfig_component_name(self): def get_llvmconfig_component_name(self):
return self.name.lower() 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): class ToolComponentInfo(ComponentInfo):
type_name = 'Tool' type_name = 'Tool'
@ -255,11 +309,27 @@ class IniFormatParser(dict):
raise ParseError("missing value for required string: %r" % key) raise ParseError("missing value for required string: %r" % key)
return value 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( _component_type_map = dict(
(t.type_name, t) (t.type_name, t)
for t in (GroupComponentInfo, for t in (GroupComponentInfo,
LibraryComponentInfo, LibraryGroupComponentInfo, LibraryComponentInfo, LibraryGroupComponentInfo,
ToolComponentInfo, BuildToolComponentInfo)) ToolComponentInfo, BuildToolComponentInfo,
TargetGroupComponentInfo))
def load_from_path(path, subpath): def load_from_path(path, subpath):
# Load the LLVMBuild.txt file as an .ini format file. # Load the LLVMBuild.txt file as an .ini format file.
parser = ConfigParser.RawConfigParser() parser = ConfigParser.RawConfigParser()

View File

@ -242,8 +242,8 @@ class LLVMProjectInfo(object):
# dependencies for added library groups. # dependencies for added library groups.
entries = {} entries = {}
for c in self.ordered_component_infos: for c in self.ordered_component_infos:
# Only Library and LibraryGroup components are in the table. # Only certain components are in the table.
if c.type_name not in ('Library', 'LibraryGroup'): if c.type_name not in ('Library', 'LibraryGroup', 'TargetGroup'):
continue continue
# Compute the llvm-config "component name". For historical reasons, # Compute the llvm-config "component name". For historical reasons,
@ -251,10 +251,10 @@ class LLVMProjectInfo(object):
llvmconfig_component_name = c.get_llvmconfig_component_name() llvmconfig_component_name = c.get_llvmconfig_component_name()
# Get the library name, or None for LibraryGroups. # Get the library name, or None for LibraryGroups.
if c.type_name == 'LibraryGroup': if c.type_name == 'Library':
library_name = None
else:
library_name = c.get_library_name() library_name = c.get_library_name()
else:
library_name = None
# Get the component names of all the required libraries. # Get the component names of all the required libraries.
required_llvmconfig_component_names = [ required_llvmconfig_component_names = [