aboutsummaryrefslogtreecommitdiff
path: root/scripts/utils.py
blob: 7f8e301872e31cf5dd28ce8ba7b485423db23df5 (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
import os
import sys
from conf import conf
from conf import sf
from exceptions import MissingFile

def build_symbol_map():
	"""Generates global variable smap from symbol_map_file.
	When file not exists, MissingFile exception is raised.
	"""
	global smap
	try:
		smap
	except NameError:
		# Check if symbol_map_file exist
		if not os.path.isfile(sf(conf.symbol_map_file)):
			raise MissingFile(sf(conf.symbol_map_file), "Run parse_kconfig to generate it.")

		smap = dict()
		with open(sf(conf.symbol_map_file)) as f:
			for lnn in f:
				w = lnn.rstrip().split(sep=':')
				smap[w[0]] = w[1]
				
def get_kernel_env():
	env = dict(os.environ)
	env['SRCARCH'] = conf.SRCARCH
	env['ARCH'] = conf.ARCH
	env['KERNELVERSION'] = 'KERNELVERSION' # hides error
	return env