17 # check if database is initialized
21 print('Initialize base...')
23 os.mkdir(sf(conf.build_folder))
24 except FileExistsError:
27 os.mkdir(sf(conf.configurations_folder))
28 except FileExistsError:
31 os.mkdir(sf(conf.log_folder))
32 except FileExistsError:
36 "Execute parse_kconfig in linux_sources directory."
37 if os.path.isfile(sf(conf.symbol_map_file)) and \
38 os.path.isfile(sf(conf.rules_file)) and \
39 os.path.isfile(sf(conf.variable_count_file)):
40 print('Warning: parse_kconfig not executed. Files already exists.')
42 print('Executing parse_kconfig...')
44 os.chdir(sf(conf.linux_sources))
45 parse_kconfig_cmd = [sf(conf.parse_kconfig)]
46 parse_kconfig_cmd += [sf(conf.linux_kconfig_head), sf(conf.build_folder)]
47 parse_kconfig_cmd += ['-v', '-v']
48 utils.callsubprocess("parse_kconfig", parse_kconfig_cmd,
49 conf.parse_kconfig_output, env=utils.get_kernel_env())
53 def __gen_allconfig_fixed__():
55 os.chdir(sf(conf.linux_sources))
56 allconfig_cmd = [sf(conf.allconfig)]
57 allconfig_cmd += ['Kconfig', sf(conf.dot_config), sf(conf.dot_measure_file)]
58 allconfig_cmd += ['--inv']
59 utils.callsubprocess("allconfig_fixed", allconfig_cmd, False,
60 env = utils.get_kernel_env())
64 "Generates fixed depenpency from dot_config file."
65 print('Generating required configuration...')
67 if not os.path.isfile(sf(conf.dot_config)):
68 raise exceptions.MissingFile(sf(conf.dot_config),
69 'Generate fixed configuration. Use make dot_config.')
71 utils.build_symbol_map() # Ensure smap existence
72 srmap = {value:key for key, value in utils.smap.items()} # swap dictionary
74 shutil.copy(sf(conf.dot_config), sf(conf.dot_config_back_file))
75 __gen_allconfig_fixed__()
77 with open(sf(conf.dot_config), 'r') as f:
78 with open(sf(conf.fixed_file), 'w') as ffix:
80 if (line[0] == '#') or (not '=' in line):
82 indx = line.index('=')
83 if (line[indx + 1] == 'y'):
84 if line[7:indx] == "MODULES": # exception if modules set
85 raise exceptions.ConfigurationError("Fixed kernel configuration must have MODULES disabled.")
86 ffix.write(str(srmap[line[7:indx]]) + "\n")
87 elif (line[indx + 1] == 'n' or line[indx + 1] == 'm'):
88 ffix.write("-" + str(srmap[line[7:indx]]) + "\n")
89 with open(sf(conf.dot_measure_file), 'r') as f:
90 with open(sf(conf.measure_file), 'w') as fmes:
92 if (line[0] == '#') or (not '=' in line):
94 indx = line.index('=')
95 if line[7:indx] == "MODULES":
96 raise exceptions.ConfigurationError("Can't measure configuraion option MODULES. Not supported.")
97 fmes.write(str(srmap[line[7:indx]]) + "\n")
100 #################################################################################
102 if __name__ == '__main__':