aboutsummaryrefslogtreecommitdiff
path: root/scripts/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/utils.py')
-rw-r--r--scripts/utils.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/utils.py b/scripts/utils.py
new file mode 100644
index 0000000..55ccb50
--- /dev/null
+++ b/scripts/utils.py
@@ -0,0 +1,29 @@
+import os
+import sys
+from conf import conf
+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(conf.symbol_map_file):
+ raise MissingFile(conf.symbol_map_file, "Run kconfig_parser to generate it.")
+
+ smap = dict()
+ with open(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