17 except exceptions.DirtyRepository as e:
18 print("Warning: " + str(e))
22 database.database() # check if database is initialized
25 "Execute parse_kconfig in linux_sources directory."
26 if os.path.isfile(sf(conf.symbol_map_file)) and \
27 os.path.isfile(sf(conf.rules_file)) and \
28 os.path.isfile(sf(conf.variable_count_file)):
29 print('Warning: parse_kconfig not executed. Files already exists.')
31 print('Executing parse_kconfig...')
33 os.chdir(sf(conf.linux_sources))
34 parse_kconfig_cmd = [sf(conf.parse_kconfig)]
35 parse_kconfig_cmd += ['Kconfig', sf(conf.build_folder)]
36 parse_kconfig_cmd += ['-v', '-v']
37 utils.callsubprocess("parse_kconfig", parse_kconfig_cmd,
38 conf.parse_kconfig_output, env=utils.get_kernel_env())
42 def __gen_allconfig_fixed__():
44 os.chdir(sf(conf.linux_sources))
45 allconfig_cmd = [sf(conf.allconfig)]
46 allconfig_cmd += ['Kconfig', sf(conf.dot_config), sf(conf.dot_measure_file)]
47 allconfig_cmd += ['--inv']
48 utils.callsubprocess("allconfig_fixed", allconfig_cmd, False,
49 env = utils.get_kernel_env())
53 "Generates fixed depenpency from dot_config file."
54 print('Generating required configuration...')
56 if not os.path.isfile(sf(conf.dot_config)):
57 raise exceptions.MissingFile(sf(conf.dot_config),
58 'Generate fixed configuration. Use make dot_config.')
60 utils.build_symbol_map() # Ensure smap existence
61 srmap = {value:key for key, value in utils.smap.items()} # swap dictionary
63 shutil.copy(sf(conf.dot_config), sf(conf.dot_config_back_file))
64 __gen_allconfig_fixed__()
66 with open(sf(conf.dot_config), 'r') as f:
67 with open(sf(conf.fixed_file), 'w') as ffix:
69 if (line[0] == '#') or (not '=' in line):
71 indx = line.index('=')
72 if (line[indx + 1] == 'y'):
73 if line[7:indx] == "MODULES": # exception if modules set
74 raise exceptions.ConfigurationError("Fixed kernel configuration must have MODULES disabled.")
75 ffix.write(str(srmap[line[7:indx]]) + "\n")
76 elif (line[indx + 1] == 'n' or line[indx + 1] == 'm'):
77 ffix.write("-" + str(srmap[line[7:indx]]) + "\n")
78 with open(sf(conf.dot_measure_file), 'r') as f:
79 with open(sf(conf.measure_file), 'w') as fmes:
81 if (line[0] == '#') or (not '=' in line):
83 indx = line.index('=')
84 if line[7:indx] == "MODULES":
85 raise exceptions.ConfigurationError("Can't measure configuraion option MODULES. Not supported.")
86 fmes.write(str(srmap[line[7:indx]]) + "\n")
89 if os.path.isfile(sf(conf.measurechecked_file)):
90 print("Checking if all configurations can be measured skiped.")
91 print(" For new check remove file " + sf(conf.measurechecked_file))
93 print("Checking if all configurations can be measured...")
94 utils.build_symbol_map()
96 with open(sf(conf.variable_count_file)) as f:
97 var_num = f.readline().rstrip()
98 conf_num = f.readline().rstrip()
99 with open(sf(conf.measure_file), 'r') as fi:
101 measure_list.add(int(ln))
102 for measure in measure_list:
103 tfile1 = configurations.__buildtempcnf__(var_num, (sf(conf.rules_file),
104 sf(conf.fixed_file)), [str(measure)])
105 tfile2 = configurations.__buildtempcnf__(var_num, (sf(conf.rules_file),
106 sf(conf.fixed_file)), [str(-1 * measure)])
108 configurations.__exec_sat__(tfile1, [], conf_num)
109 except exceptions.NoSolution:
110 print("W: " + utils.smap[measure] + " won't be measured! Can't select.")
112 configurations.__exec_sat__(tfile2, [], conf_num)
113 except exceptions.NoSolution:
114 print("W: " + utils.smap[measure] + " won't be measured! Can't unselect.")
115 with open(sf(conf.measurechecked_file), 'w') as f:
116 f.write("Remove this file if you wanna execute check if all configurations can be measured once again.\n")
118 #################################################################################
120 if __name__ == '__main__':