aboutsummaryrefslogtreecommitdiff
path: root/scripts/initialize.py
blob: 87a98b46962fea47b4e883a059615db13f01c325 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import sys
import subprocess

import utils
from conf import conf
from exceptions import MissingFile

def kconfig_parser():
	"Execute kconfig_parser in linux_sources directory and parsed output is placed to build_folder."
	env = dict(os.environ)
	env['SRCARCH'] = conf.SRCARCH
	env['ARCH'] = conf.ARCH
	env['KERNELVERSION'] = 'KERNELVERSION' # hides error
	wd = os.getcwd()
	os.chdir(conf.linux_sources)
	if conf.kconfig_parser_output:
		subprocess.call([conf.kconfig_parser, conf.linux_kconfig_head, conf.build_folder, "-v", "-v"], env=env)
	else:
		subprocess.call([conf.kconfig_parser, conf.linux_kconfig_head, conf.build_folder], env=env)

	os.chdir(wd)

def gen_requred():
	"Generates required depenpency from required file."
	utils.build_symbol_map()
	srmap = {value:key for key, value in utils.smap.items()}
	
	if not os.path.isfile(conf.required):
		raise MissingFile(conf.required, None)

	try:
		os.remove(conf.required_file)
	except OSError:
		pass

	with open(conf.required_file, 'w') as fout:
		with open(conf.required, 'r') as f:
			for line in f:
				for word in line.rstrip().split():
					if word[0] == '-':
						fout.write('-')
						word = word[1:]
					fout.write(srmap[word] + " ")
				fout.write("\n")