From 9f07dd89b7cd2de6ce341afd1aed3e6bd0122a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 14 Jan 2015 12:49:48 +0100 Subject: Python scripts added conf.py are files for configuration, all configuration is in global conf.py and others are just sourcing that kconfig_parser.py is executing kconfig_parser sat_solution.py is partly implemented, in state of this commit is not working properly. --- scripts/sat_solution.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 scripts/sat_solution.py (limited to 'scripts/sat_solution.py') diff --git a/scripts/sat_solution.py b/scripts/sat_solution.py new file mode 100755 index 0000000..1a44678 --- /dev/null +++ b/scripts/sat_solution.py @@ -0,0 +1,46 @@ +#!/bin/python3 +import os +import sys +import tempfile +import subprocess +from conf import conf + +if not os.path.isfile(conf.rules_file): + print("Error: Rules are not generated yet, or wrong build_folder.\nCheck existence of " + rules_file, file=sys.stderr) + sys.exit(1) + + +#w_file = tempfile.NamedTemporaryFile(delete=False) +w_file = open('bld', 'w') +# Join files to one single file +lines = set() +for ln in open(conf.rules_file, 'r'): + if ln not in lines: + lines.add(ln) +if os.path.isfile(conf.solved_file): + for ln in open(conf.solved_file, 'r'): + if ln not in lines: + lines.add(ln) +if os.path.isfile(conf.required_file): + for ln in open(conf.required_file, 'r'): + if ln not in lines: + lines.add(ln) + +with open(conf.symbol_map_file) as f: + for var_num, l in enumerate(f): + pass + var_num += 1 +lines_count = len(lines) + +first_line = "p cnf " + str(var_num) + " " + str(lines_count) +w_file.write(first_line + '\n') +for ln in lines: + w_file.write(ln) + +w_file.close() + +print("temp file: " + w_file.name) +print("Output: " + conf.solution_file) +subprocess.call(['minisat', w_file.name, conf.solution_file]) + +#os.remove(w_file.name) -- cgit v1.2.3