use MATRIX_SCRIPTDIR in scripts
[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 Component(object):
36         import git
37
38         from_platform = False
39
40         def __init__(self, name, tag='matrix', tags={}, flags=[]):
41                 self.name = name
42
43                 self.tags = {}
44                 self.tags.update(tags)
45                 self.tags[None] = tag
46
47                 self.flags = flags
48
49                 self.active_url = None
50                 self.__active_tag = None
51                 self.active_packages = None
52                 self.active_depends = None
53                 self.__active_hash = None
54                 self.active_state = None
55
56                 components[name] = self
57
58         def get_active_tag(self):
59                 global board
60
61                 if self.__active_tag is None:
62                         tag = self.tags.get(board)
63                         if not tag:
64                                 tag = self.tags.get(None)
65                         self.__active_tag = tag
66
67                 return self.__active_tag
68
69         def get_active_hash(self):
70                 if self.__active_hash is None:
71                         self.__active_hash \
72                             = self.git.rev_parse(self.name, 'HEAD')
73
74                 return self.__active_hash
75
76 class PlatformProvidedComponent(Component):
77         """A Component that is provided by the platform.
78            The sources will not be built during install."""
79
80         from_platform = True