af7cc913a58e67ad6c09538061c56c13ddefcb88
[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', _os.getcwd())
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
21 class Board(object):
22         def __init__(self, name, arch, gcc_march, gcc_mcpu='', gcc_mfpu='', gcc_options='', gnu_host='', flash_erase_size='65536', flash_pad_size='0'):
23                 self.name = name
24                 self.arch = arch
25                 self.gcc_march = gcc_march
26                 self.gcc_mcpu = gcc_mcpu
27                 self.gcc_mfpu = gcc_mfpu
28                 self.gcc_options = gcc_options
29                 self.gnu_host = gnu_host
30                 self.flash_erase_size = flash_erase_size
31                 self.flash_pad_size = flash_pad_size
32
33                 boards[name] = self
34
35 class _Repository(object):
36         def __init__(self, name, path):
37                 self.name = name
38                 self.path = path
39                 self.active_url = None
40                 self.active_hash = None
41
42 class Component(object):
43         from_platform = False
44
45         def __init__(self, name, tag='master', tags={}, flags=[]):
46                 self.name = name
47
48                 self.repo = _Repository(
49                         'repo/%s' % name, _os.path.join(top_dir, 'src', name))
50                 self.meta = _Repository(
51                         'meta/%s' % name, _os.path.join(top_dir, 'src', name, 'meta'))
52
53                 self.tags = {}
54                 self.tags.update(tags)
55                 self.tags[None] = tag
56
57                 self.flags = flags
58
59                 self.__active_tag = None
60                 self.active_packages = None
61                 self.active_depends = None
62                 self.active_state = None
63
64                 components[name] = self
65
66         def get_active_tag(self):
67                 global board
68
69                 if self.__active_tag is None:
70                         tag = self.tags.get(board)
71                         if not tag:
72                                 tag = self.tags.get(None)
73                         self.__active_tag = tag
74
75                 return self.__active_tag
76
77 class PlatformProvidedComponent(Component):
78         """A Component that is provided by the platform.
79            The sources will not be built during install."""
80
81         from_platform = True