Component.get_tag() -> Repository.get_commit()
[matrix.git] / matrix / config.py
1 # Copyright (C) 2007-2008 Movial Oy
2 # Authors: Timo Savola <tsavola@movial.fi>
3 #          Kalle Vahlman <kalle.vahlman@movial.fi>
4
5 import os as _os
6
7 top_dir = _os.environ.get('MATRIX_TOPDIR', '')
8 cache_dir = _os.path.join(top_dir, 'build-cache')
9 global_cache_dir = '/usr/share/matrix/build-cache'
10 script_dir = None
11
12 boards = {}
13 board = None
14 components = {}
15 roots = []
16 flags = []
17 libc = 'glibc'
18 verbose = False
19 debug = False
20 force = False
21
22 class Board(object):
23         def __init__(self, name, arch, gcc_march, gcc_mcpu='', gcc_mfpu='', gcc_options='', gnu_host='', flash_erase_size='65536', flash_pad_size='0'):
24                 self.name = name
25                 self.arch = arch
26                 self.gcc_march = gcc_march
27                 self.gcc_mcpu = gcc_mcpu
28                 self.gcc_mfpu = gcc_mfpu
29                 self.gcc_options = gcc_options
30                 self.gnu_host = gnu_host
31                 self.flash_erase_size = flash_erase_size
32                 self.flash_pad_size = flash_pad_size
33
34                 boards[name] = self
35
36 class _Repository(object):
37         def __init__(self, component, name, path):
38                 self.component = component
39                 self.name = name
40                 self.path = path
41                 self.active_url = None
42                 self.active_hash = None
43
44         def get_commit(self):
45                 commits = self.component.commits
46                 return commits.get(board) or commits.get(None)
47
48 class Component(object):
49         from_platform = False
50
51         def __init__(self, name, tag='master', tags={}, flags=[]):
52                 self.name = name
53
54                 self.repo = _Repository(self, 'repo/%s' % name,
55                         _os.path.join(top_dir, 'src', name))
56                 self.meta = _Repository(self, 'meta/%s' % name,
57                         _os.path.join(top_dir, 'src', name, 'meta'))
58
59                 self.commits = {}
60                 self.commits.update(tags)
61                 self.commits[None] = tag
62
63                 self.flags = flags
64
65                 self.active_packages = None
66                 self.active_depends = None
67                 self.active_state = None
68
69                 components[name] = self
70
71         def __cmp__(self, other):
72                 return cmp(self.name, other.name)
73
74 class PlatformProvidedComponent(Component):
75         """A Component that is provided by the platform.
76            The sources will not be built during install."""
77
78         from_platform = True