]> rtime.felk.cvut.cz Git - linux-conf-perf.git/blob - scripts/initialize.py
Implement requirement generation from kernel .config
[linux-conf-perf.git] / scripts / initialize.py
1 import os
2 import sys
3 import subprocess
4
5 import utils
6 from conf import conf
7 from exceptions import MissingFile
8
9 def kconfig_parser():
10         "Execute kconfig_parser in linux_sources directory and parsed output is placed to build_folder."
11         env = dict(os.environ)
12         env['SRCARCH'] = conf.SRCARCH
13         env['ARCH'] = conf.ARCH
14         env['KERNELVERSION'] = 'KERNELVERSION' # hides error
15         wd = os.getcwd()
16         os.chdir(conf.linux_sources)
17         if conf.kconfig_parser_output:
18                 subprocess.call([conf.kconfig_parser, conf.linux_kconfig_head, conf.build_folder, "-v", "-v"], env=env)
19         else:
20                 subprocess.call([conf.kconfig_parser, conf.linux_kconfig_head, conf.build_folder], env=env)
21
22         os.chdir(wd)
23
24 def gen_requred():
25         "Generates required depenpency from required file."
26         utils.build_symbol_map()
27         srmap = {value:key for key, value in utils.smap.items()}
28
29         try:
30                 os.remove(conf.required_file)
31                 os.remove(conf.dot_config_file)
32         except OSError:
33                 pass
34
35         with open(conf.linux_sources + '/.config', 'r') as f:
36                 with open(conf.required_file, 'w') as freq:
37                         with open(conf.dot_config_file, 'w') as fconf:
38                                 for line in f:
39                                         if (line[0] == '#') or (not '=' in line):
40                                                 continue
41                                         indx = line.index('=')
42                                         if (line[indx + 1] == 'y' or line[indx + 1] == 'm'):
43                                                 freq.write(srmap[line[7:indx]] + "\n")
44                                         elif (line[indx + 1] == 'n'):
45                                                 freq.write("-" + srmap[line[7:indx]] + "\n")
46                                         else:
47                                                 fconf.write(line);