]> rtime.felk.cvut.cz Git - linux-conf-perf.git/blob - scripts/utils.py
Chnage conf paths from absolute to relative
[linux-conf-perf.git] / scripts / utils.py
1 import os
2 import sys
3 from conf import conf
4 from conf import sf
5 from exceptions import MissingFile
6
7 def build_symbol_map():
8         """Generates global variable smap from symbol_map_file.
9         When file not exists, MissingFile exception is raised.
10         """
11         global smap
12         try:
13                 smap
14         except NameError:
15                 # Check if symbol_map_file exist
16                 if not os.path.isfile(sf(conf.symbol_map_file)):
17                         raise MissingFile(sf(conf.symbol_map_file), "Run parse_kconfig to generate it.")
18
19                 smap = dict()
20                 with open(sf(conf.symbol_map_file)) as f:
21                         for lnn in f:
22                                 w = lnn.rstrip().split(sep=':')
23                                 smap[w[0]] = w[1]
24                                 
25 def get_kernel_env():
26         env = dict(os.environ)
27         env['SRCARCH'] = conf.SRCARCH
28         env['ARCH'] = conf.ARCH
29         env['KERNELVERSION'] = 'KERNELVERSION' # hides error
30         return env