reorganized component and repository code into separate modules
[matrix.git] / matrix / config.py
index ba8cd1f..b146ba2 100644 (file)
@@ -3,6 +3,7 @@
 #          Kalle Vahlman <kalle.vahlman@movial.fi>
 
 import os as _os
+import components as _components
 
 top_dir = _os.environ.get('MATRIX_TOPDIR', '')
 cache_dir = _os.path.join(top_dir, 'build-cache')
@@ -33,46 +34,12 @@ class Board(object):
 
                boards[name] = self
 
-class _Repository(object):
-       def __init__(self, component, name, path):
-               self.component = component
-               self.name = name
-               self.path = path
-               self.active_url = None
-               self.active_hash = None
-
-       def get_commit(self):
-               commits = self.component.commits
-               return commits.get(board) or commits.get(None)
-
-class Component(object):
-       from_platform = False
-
-       def __init__(self, name, tag='master', tags={}, flags=[]):
-               self.name = name
-
-               self.repo = _Repository(self, 'repo/%s' % name,
-                       _os.path.join(top_dir, 'src', name))
-               self.meta = _Repository(self, 'meta/%s' % name,
-                       _os.path.join(top_dir, 'src', name, 'meta'))
-
-               self.commits = {}
-               self.commits.update(tags)
-               self.commits[None] = tag
-
-               self.flags = flags
-
-               self.active_packages = None
-               self.active_depends = None
-               self.active_state = None
-
-               components[name] = self
-
-       def __cmp__(self, other):
-               return cmp(self.name, other.name)
-
-class PlatformProvidedComponent(Component):
-       """A Component that is provided by the platform.
-          The sources will not be built during install."""
+def Component(*args, **kwargs):
+       c = _components.Component(*args, **kwargs)
+       components[c.name] = c
+       return c
 
-       from_platform = True
+def PlatformProvidedComponent(*args, **kwargs):
+       c = _components.PlatformProvidedComponent(*args, **kwargs)
+       components[c.name] = c
+       return c