aboutsummaryrefslogtreecommitdiff
path: root/scripts/solution.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/solution.py')
-rw-r--r--scripts/solution.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/scripts/solution.py b/scripts/solution.py
index 21e1cea..3fddb6b 100644
--- a/scripts/solution.py
+++ b/scripts/solution.py
@@ -5,6 +5,7 @@ import subprocess
import utils
from conf import conf
+from conf import sf
from exceptions import NoSolution
def generate():
@@ -18,29 +19,29 @@ def generate():
solution_file
"""
# Check if rules_file exist. If it was generated.
- if not os.path.isfile(conf.rules_file):
+ if not os.path.isfile(sf(conf.rules_file)):
raise Exception("Rules file missing. Run parse_kconfig and check ecistence of " + rules_file)
w_file = tempfile.NamedTemporaryFile(delete=False)
# Join files to one single temporary file
lines = set()
- with open(conf.rules_file, 'r') as f:
- for lnn in open(conf.rules_file, 'r'):
+ with open(sf(conf.rules_file), 'r') as f:
+ for lnn in open(sf(conf.rules_file), 'r'):
ln = lnn.rstrip()
if ln not in lines:
lines.add(ln)
- if os.path.isfile(conf.solved_file):
- for lnn in open(conf.solved_file, 'r'):
+ if os.path.isfile(sf(conf.solved_file)):
+ for lnn in open(sf(conf.solved_file), 'r'):
ln = lnn.rstrip()
if ln not in lines:
lines.add(ln)
- if os.path.isfile(conf.required_file):
- for lnn in open(conf.required_file, 'r'):
+ if os.path.isfile(sf(conf.required_file)):
+ for lnn in open((conf.required_file), 'r'):
ln = lnn.rstrip()
if ln not in lines:
lines.add(ln)
- with open(conf.symbol_map_file) as f:
+ with open(sf(conf.symbol_map_file)) as f:
for var_num, l in enumerate(f):
pass
var_num += 1
@@ -55,9 +56,9 @@ def generate():
# Execute minisat
if conf.minisat_output:
- subprocess.call(['minisat', w_file.name, conf.solution_file])
+ subprocess.call(['minisat', w_file.name, sf(conf.solution_file)])
else:
- subprocess.call(['minisat', w_file.name, conf.solution_file], stdout=subprocess.DEVNULL)
+ subprocess.call(['minisat', w_file.name, sf(conf.solution_file)], stdout=subprocess.DEVNULL)
os.remove(w_file.name)
@@ -65,20 +66,22 @@ def apply():
"""Apply generated solution to kernel source.
"""
# Check if solution_file exist
- if not os.path.isfile(conf.solution_file):
- raise Exception("Solution file is missing. Run sat_solution and check existence of " + conf.solution_file)
+ if not os.path.isfile(sf(conf.solution_file)):
+ raise Exception("Solution file is missing. Run sat_solution and check existence of " + sf(conf.solution_file))
utils.build_symbol_map() # Ensure smap existence
# Read solution if satisfiable
- with open(conf.solution_file, 'r') as f:
+ with open(sf(conf.solution_file), 'r') as f:
if not f.readline().rstrip() == 'SAT':
raise NoSolution()
solut = f.readline().split()
solut.remove('0') # Remove 0 at the end
+
+
# Write negotation solution to solver_file
- with open(conf.solved_file, 'a') as f:
+ with open(sf(conf.solved_file), 'a') as f:
for txt in solut:
if txt[0] == '-':
ntx = ""
@@ -89,7 +92,7 @@ def apply():
f.write("\n")
# Write solution to .config file in linux source folder
- with open(conf.linux_sources + '/.config', 'w') as f:
+ with open(sf(conf.linux_dot_config), 'w') as f:
for txt in solut:
if txt[0] == '-':
nt = True