]> rtime.felk.cvut.cz Git - linux-conf-perf.git/blob - scripts/gen_fixed.py
Update dot_measure to remove errors reported by kconfig2sat
[linux-conf-perf.git] / scripts / gen_fixed.py
1 #!/usr/bin/env python3
2 import sys
3 import utils
4
5 from conf import conf
6
7 f_allconfig = open(sys.argv[1], 'r')
8 f_options = open(sys.argv[2], 'r')
9
10 f_measure = open(conf.measure_file, 'w')
11 f_fixed   = open(conf.fixed_file, 'w')
12
13 variable_options = set()
14 for line in f_options:
15         option = line.split('=')[0][7:] # Remove CONFIG_ (7 chars)
16         variable_options.add(option)
17
18 utils.build_symbol_map() # Ensure smap existence
19 srmap = {value:key for key, value in utils.smap.items()} # swap dictionary
20
21 for line in f_allconfig:
22         if (line[0] == '#') or (not '=' in line):
23                 continue
24         sym, val = line.rstrip().split('=')
25         sym = sym[7:] # Remove CONFIG_
26         if sym == "MODULES" and val == 'y':
27                 raise exceptions.ConfigurationError("Fixed kernel configuration must have MODULES disabled.")
28         if sym in variable_options:
29                 print(srmap[sym], file=f_measure)
30         else:
31                 print(srmap[sym] * (-1 if val == 'n' else +1), file=f_fixed)