]> rtime.felk.cvut.cz Git - linux-conf-perf.git/commitdiff
Reimplement gen_fixed and call it directly from Makefile
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 17 Oct 2015 20:57:15 +0000 (22:57 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 17 Oct 2015 20:57:15 +0000 (22:57 +0200)
Makefile
scripts/gen_fixed.py [new file with mode: 0755]
scripts/initialize.py

index 0000a333fff9e7bb4466c899b59dcb2ded02b517..d511ff1b76aa044bf1a8e02858748decc484a049 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,8 @@ HELPER_PROGRAMS = scripts/parse_kconfig/parse         \
 HELP+="all         - Builds basic programs and prints message about next steps.\n"
 .PHONY: all
 all:  $(HELPER_PROGRAMS) .stamp/initram_cyclictest
+       mkdir -p $(CONF_LOG_FOLDER)
+       mkdir -p $(CONF_BUILD_FOLDER)
 
 .PHONY: help
 help:
@@ -64,14 +66,19 @@ test: scripts/parse_kconfig/parse .stamp/initram_cyclictest
 
 HELP+="run         - Executes loop of kernel building, booting and benchmark execution.\n"
 .PHONY: run
-run: all $(CONF_BUILD_FOLDER)/rules
-       mkdir -p $(CONF_LOG_FOLDER)
+run: all $(CONF_BUILD_FOLDER)/rules $(CONF_BUILD_FOLDER)/fixed
+       ln -sf ../dot_measure $(CONF_BUILD_FOLDER)
        scripts/loop.py
 
-$(CONF_BUILD_FOLDER)/rules: .conf.mk $(CONF_LINUX_SOURCES)/Kconfig .target
-       mkdir -p $(dir $@)
+$(CONF_BUILD_FOLDER)/rules $(CONF_BUILD_FOLDER)/symbol_map: .conf.mk $(CONF_LINUX_SOURCES)/Kconfig
        scripts/parse_kconfig/parse -v --env .conf.mk $(CONF_LINUX_SOURCES)/Kconfig $(dir $@)
 
+$(CONF_BUILD_FOLDER)/allconfig: .conf.mk $(CONF_LINUX_SOURCES)/Kconfig $(CONF_LINUX_BUILD_FOLDER)/.config
+       scripts/allconfig/allconfig --env .conf.mk $(CONF_LINUX_SOURCES)/Kconfig $(CONF_LINUX_BUILD_FOLDER)/.config $@
+
+$(CONF_BUILD_FOLDER)/fixed $(CONF_BUILD_FOLDER)/measure: .conf.mk $(CONF_BUILD_FOLDER)/allconfig dot_measure
+       scripts/gen_fixed.py $(CONF_BUILD_FOLDER)/allconfig dot_measure
+
 .PHONY: evaluate
 evaluate:
        scripts/evaluate.py
diff --git a/scripts/gen_fixed.py b/scripts/gen_fixed.py
new file mode 100755 (executable)
index 0000000..0575f7d
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/env python3
+import sys
+import utils
+
+from conf import conf
+
+f_allconfig = open(sys.argv[1], 'r')
+f_options = open(sys.argv[2], 'r')
+
+f_measure = open(conf.measure_file, 'w')
+f_fixed   = open(conf.fixed_file, 'w')
+
+variable_options = set()
+for line in f_options:
+       option = line.split('=')[0][7:] # Remove CONFIG_ (7 chars)
+       variable_options.add(option)
+
+utils.build_symbol_map() # Ensure smap existence
+srmap = {value:key for key, value in utils.smap.items()} # swap dictionary
+
+for line in f_allconfig:
+       if (line[0] == '#') or (not '=' in line):
+               continue
+       sym, val = line.rstrip().split('=')
+       sym = sym[7:] # Remove CONFIG_
+       if sym == "MODULES" and val == 'y':
+               raise exceptions.ConfigurationError("Fixed kernel configuration must have MODULES disabled.")
+       if sym in variable_options:
+               print(srmap[sym], file=f_measure)
+       else:
+               print(srmap[sym] * (-1 if val == 'n' else +1), file=f_fixed)
index c399d0d57a62b6d4ed0bb0526cff4431eb51d91a..d08a62c3a84b259d319324b5a363f0164d9201b1 100755 (executable)
@@ -16,56 +16,9 @@ def all():
                utils.dirtycheck()
        except exceptions.DirtyRepository as e:
                print("Warning: " + str(e))
-       gen_fixed()
        checkmeasure()
        database.database() # check if database is initialized
 
-def __gen_allconfig_fixed__():
-       wd = os.getcwd()
-       os.chdir(sf(conf.linux_sources))
-       allconfig_cmd = [sf(conf.allconfig)]
-       allconfig_cmd += ['Kconfig', sf(conf.dot_config), sf(conf.dot_measure_file)]
-       allconfig_cmd += ['--inv']
-       utils.callsubprocess("allconfig_fixed", allconfig_cmd, False,
-                       env = utils.get_kernel_env())
-       os.chdir(wd)
-
-def gen_fixed():
-       "Generates fixed depenpency from dot_config file."
-       print('Generating required configuration...')
-
-       if not os.path.isfile(sf(conf.dot_config)):
-               raise exceptions.MissingFile(sf(conf.dot_config),
-                               'Generate fixed configuration. Use make dot_config.')
-
-       utils.build_symbol_map() # Ensure smap existence
-       srmap = {value:key for key, value in utils.smap.items()} # swap dictionary
-
-       shutil.copy(sf(conf.dot_config), sf(conf.dot_config_back_file))
-       __gen_allconfig_fixed__()
-
-       with open(sf(conf.dot_config), 'r') as f:
-               with open(sf(conf.fixed_file), 'w') as ffix:
-                       for line in f:
-                               if (line[0] == '#') or (not '=' in line):
-                                       continue
-                               indx = line.index('=')
-                               if (line[indx + 1] == 'y'):
-                                       if line[7:indx] == "MODULES": # exception if modules set
-                                               raise exceptions.ConfigurationError("Fixed kernel configuration must have MODULES disabled.")
-                                       ffix.write(str(srmap[line[7:indx]]) + "\n")
-                               elif (line[indx + 1] == 'n' or line[indx + 1] == 'm'):
-                                       ffix.write("-" + str(srmap[line[7:indx]]) + "\n")
-       with open(sf(conf.dot_measure_file), 'r') as f:
-               with open(sf(conf.measure_file), 'w') as fmes:
-                       for line in f:
-                               if (line[0] == '#') or (not '=' in line):
-                                       continue
-                               indx = line.index('=')
-                               if line[7:indx] == "MODULES":
-                                       raise exceptions.ConfigurationError("Can't measure configuraion option MODULES. Not supported.")
-                               fmes.write(str(srmap[line[7:indx]]) + "\n")
-
 def checkmeasure():
        if os.path.isfile(sf(conf.measurechecked_file)):
                print("Checking if all configurations can be measured skiped.")