]> rtime.felk.cvut.cz Git - linux-conf-perf.git/blobdiff - scripts/initialize.py
Move directory creation from .py to Makefile
[linux-conf-perf.git] / scripts / initialize.py
index ee6c43d9d88fa1019aa7c7e5ed559808594cd811..1847a04174e136a66ef1e2c370dfc26ba2e23743 100755 (executable)
@@ -9,28 +9,17 @@ import database
 from conf import conf
 from conf import sf
 import exceptions
+import configurations
 
 def all():
-       base()
+       try:
+               utils.dirtycheck()
+       except exceptions.DirtyRepository as e:
+               print("Warning: " + str(e))
        parse_kconfig()
        gen_fixed()
-       # check if database is initialized
-       database.database()
-
-def base():
-       print('Initialize base...')
-       try:
-               os.mkdir(sf(conf.build_folder))
-       except FileExistsError:
-               pass
-       try:
-               os.mkdir(sf(conf.configurations_folder))
-       except FileExistsError:
-               pass
-       try:
-               os.mkdir(sf(conf.log_folder))
-       except FileExistsError:
-               pass
+       checkmeasure()
+       database.database() # check if database is initialized
 
 def parse_kconfig():
        "Execute parse_kconfig in linux_sources directory."
@@ -43,7 +32,7 @@ def parse_kconfig():
        wd = os.getcwd()
        os.chdir(sf(conf.linux_sources))
        parse_kconfig_cmd = [sf(conf.parse_kconfig)]
-       parse_kconfig_cmd += [sf(conf.linux_kconfig_head), sf(conf.build_folder)]
+       parse_kconfig_cmd += ['Kconfig', sf(conf.build_folder)]
        parse_kconfig_cmd += ['-v', '-v']
        utils.callsubprocess("parse_kconfig", parse_kconfig_cmd,
                        conf.parse_kconfig_output, env=utils.get_kernel_env())
@@ -96,6 +85,35 @@ def gen_fixed():
                                        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.")
+               print("  For new check remove file " + sf(conf.measurechecked_file))
+               return
+       print("Checking if all configurations can be measured...")
+       utils.build_symbol_map()
+       measure_list = set()
+       with open(sf(conf.variable_count_file)) as f:
+               var_num = f.readline().rstrip()
+               conf_num = f.readline().rstrip()
+       with open(sf(conf.measure_file), 'r') as fi:
+               for ln in fi:
+                       measure_list.add(int(ln))
+       for measure in measure_list:
+               tfile1 = configurations.__buildtempcnf__(var_num, (sf(conf.rules_file),
+                       sf(conf.fixed_file)), [str(measure)])
+               tfile2 = configurations.__buildtempcnf__(var_num, (sf(conf.rules_file),
+                       sf(conf.fixed_file)), [str(-1 * measure)])
+               try:
+                       configurations.__exec_sat__(tfile1, [], conf_num)
+               except exceptions.NoSolution:
+                       print("W: " + utils.smap[measure] + " won't be measured! Can't select.")
+               try:
+                       configurations.__exec_sat__(tfile2, [], conf_num)
+               except exceptions.NoSolution:
+                       print("W: " + utils.smap[measure] + " won't be measured! Can't unselect.")
+       with open(sf(conf.measurechecked_file), 'w') as f:
+               f.write("Remove this file if you wanna execute check if all configurations can be measured once again.\n")
 
 #################################################################################