diff options
author | Karel Kočí <cynerd@email.cz> | 2015-05-06 21:18:38 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2015-05-06 21:18:38 +0200 |
commit | 86eb35073eaf733db725647eb7429da22d4d365a (patch) | |
tree | 5dff5d8e040624b546d78f545469027ab5198ae5 /scripts | |
parent | ff8c714ac90ba532030a5889ab9529c31a966238 (diff) | |
download | linux-conf-perf-86eb35073eaf733db725647eb7429da22d4d365a.tar.gz linux-conf-perf-86eb35073eaf733db725647eb7429da22d4d365a.tar.bz2 linux-conf-perf-86eb35073eaf733db725647eb7429da22d4d365a.zip |
Add generation of all solutions in initialization phase
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/exceptions.py | 6 | ||||
-rwxr-xr-x | scripts/initialize.py | 7 | ||||
-rw-r--r-- | scripts/solution.py | 18 |
3 files changed, 22 insertions, 9 deletions
diff --git a/scripts/exceptions.py b/scripts/exceptions.py index 5b55294..29aa1dc 100644 --- a/scripts/exceptions.py +++ b/scripts/exceptions.py @@ -25,3 +25,9 @@ class ConfigurationError(Exception): self.message = message; def __str__(self): return "Configuration error: " + message + +class SolutionGenerated(Exception): + def __init__(self): + pass + def __str__(self): + return "Solution already generated." diff --git a/scripts/initialize.py b/scripts/initialize.py index 94b6191..57654c6 100755 --- a/scripts/initialize.py +++ b/scripts/initialize.py @@ -9,15 +9,18 @@ from conf import conf from conf import sf import exceptions import loop +import solution def all(): base() + gen_nbscript() parse_kconfig() gen_requred() - gen_nbscript() + if conf.gen_all_solution_oninit: + solution.generate() def base(): - try: os.mkdir(conf.build_folder) + try: os.mkdir(sf(conf.build_folder)) except FileExistsError: pass diff --git a/scripts/solution.py b/scripts/solution.py index 60e9538..8e02324 100644 --- a/scripts/solution.py +++ b/scripts/solution.py @@ -6,7 +6,7 @@ import subprocess import utils from conf import conf from conf import sf -from exceptions import NoSolution +import exceptions def generate(): """Collect boolean equations from files: rules, solved and required @@ -14,7 +14,10 @@ def generate(): """ # Check if rules_file exist. If it was generated. if not os.path.isfile(sf(conf.rules_file)): - raise Exception("Rules file missing. Run parse_kconfig and check ecistence of " + rules_file) + raise exceptions.MissingFile(conf.rules_file,"Run parse_kconfig.") + + if sys.path.isfile(sf(conf.solution_file)) and conf.gen_all_solution_oninit: + raise exceptions.SolutionGenerated() w_file = tempfile.NamedTemporaryFile(delete=False) # Join files to one single temporary file @@ -47,13 +50,14 @@ def generate(): w_file.close() # Execute picosat + picosat_cmd = [conf.picosat, w_file.name] + picosat_cmd += ['-o', sf(conf.solution_file)] + if (conf.gen_all_solution_oninit): + picosat_cmd += ['--all'] if conf.picosat_output: - subprocess.call([conf.picosat, w_file.name, '-o', - sf(conf.solution_file)] + conf.picosat_args) + subprocess.call(picosat_cmd) else: - subprocess.call([conf.picosat, w_file.name, '-o', - sf(conf.solution_file)] + conf.picosat_args, - stdout=subprocess.DEVNULL) + subprocess.call(picosat_cmd, stdout=subprocess.DEVNULL) os.remove(w_file.name) |