11 def build_symbol_map():
12 """Generates global variable smap from symbol_map_file.
13 When file not exists, MissingFile exception is raised.
19 # Check if symbol_map_file exist
20 if not os.path.isfile(sf(conf.symbol_map_file)):
21 raise exceptions.MissingFile(sf(conf.symbol_map_file),
22 "Run parse_kconfig to generate it.")
25 with open(sf(conf.symbol_map_file)) as f:
27 w = lnn.rstrip().split(sep=':')
28 smap[int(w[0])] = w[1]
32 """Generates global variable cmap from config_map_file and config_solved_file.
33 cmap is dictionary containing list ([configuration], bool solved)
34 cmap is rebuild every time this function is called.
38 if os.path.isfile(sf(conf.config_map_file)):
39 with open(sf(conf.config_map_file)) as f:
41 w = ln.rstrip().split(sep=':')
43 for vr in w[1].split(sep=" "):
45 cf.append(-1 * int(vf[1:]))
47 cmap[w[0]] = [w[1], False]
49 if os.path.isfile(sf(conf.config_solved_file)):
50 with open(sf(conf.config_solved_file)) as f:
53 cmap[ln.rstrip()][1] = True
58 def callsubprocess(process_name, process, show_output = True, regular = "",
60 sprc = subprocess.Popen(process, stdout = subprocess.PIPE, env = env)
63 with open(os.path.join(sf(conf.log_folder),
64 process_name + '-' + time.strftime("%y-%m-%d-%H-%M-%S") + ".log"),
66 f.write('::' + time.strftime("%y-%m-%d-%H-%M-%S-%f") + '::')
67 for linen in sprc.stdout:
68 line = linen.decode(sys.getdefaultencoding())
72 if re.search(regular, line):
77 raise exceptions.ProcessFailed(process, rtncode)
82 env = dict(os.environ)
83 env.update(conf.kernel_env)
88 """Hashes configuration using MD5 hash.
100 hsh = hashlib.md5(bytes(str, sys.getdefaultencoding()))
101 return hsh.hexdigest()
103 def config_strtoint(str, full):
104 """Reads list of configured symbols from string
108 for s in str.rstrip().split(sep=' '):
112 with open(sf(conf.variable_count_file)) as f:
114 count = int(f.readline())
115 for s in str.rstrip().split(sep=' '):
117 if abs(val) <= count:
127 def get_config_from_hash(hash):
128 with open(sf(conf.config_map_file), "r") as f:
130 w = line.rstrip().split(sep=':')
132 return config_strtoint(w[1], True)
135 def get_last_configuration():
138 with open(sf(conf.config_solved_file), "r") as f:
140 sline = line.rstrip()
143 except FileNotFoundError:
145 with open(sf(conf.config_map_file), "r") as f:
146 w = f.readline().split(sep=':')
148 except FileNotFoundError: