From 1ad844cee99d5d7b737b62f56eb5ccdc806f433d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 17 Jul 2015 11:50:04 +0200 Subject: Remove possibility of generating next solution in loop. Only possibility now is generating all solutions on initialisation. Remove solution generating phase. --- conf.py | 7 +----- scripts/initialize.py | 9 ++++--- scripts/loop.py | 65 +++++++++++++++++++++------------------------------ scripts/solution.py | 14 ++--------- 4 files changed, 34 insertions(+), 61 deletions(-) diff --git a/conf.py b/conf.py index 206f723..e5a4059 100644 --- a/conf.py +++ b/conf.py @@ -5,10 +5,6 @@ import os # This defines environment variable for linux kernel. # Change this to change target architecture ARCH = 'x86' -# gen_all_solutions_oninit -# If True, all solutions are generated at initalization. -# If False, every loop is generated one solution. -gen_all_solution_oninit = True # If True, all solutions are generated at initialization. # kernle_env # Enviroment variables for Linux @@ -33,7 +29,7 @@ boot_command = ['scripts/novaboot/novaboot', nbscript] + novaboot_args # picosat_args # Arguments passed to PicoSAT. -picosat_args = [] +picosat_args = ['--all'] ## Programs output show/hide # These options hides output of launched programs from terminal. @@ -74,7 +70,6 @@ rules_file = build_folder + 'rules' # Also defined in parse_kconfig variable_count_file = build_folder + 'variable_count' # Also defined in parse_kconfig config_map_file = build_folder + 'config_map' config_solved_file = build_folder + 'config_solved' -solved_file = build_folder + 'solved' required_file = build_folder + 'required' dot_config_fragment_file = build_folder + 'dot_config_fragment' dot_config_back_file = build_folder + 'dot_config_back' diff --git a/scripts/initialize.py b/scripts/initialize.py index da54aee..2c2ca59 100755 --- a/scripts/initialize.py +++ b/scripts/initialize.py @@ -17,11 +17,10 @@ def all(): base() parse_kconfig() gen_requred() - if conf.gen_all_solution_oninit: - try: - solution.generate() - except exceptions.NoSolution: - pass + try: + solution.generate() + except exceptions.NoSolution: + pass def base(): print('Initialize base...') diff --git a/scripts/loop.py b/scripts/loop.py index 0fd3639..712b054 100755 --- a/scripts/loop.py +++ b/scripts/loop.py @@ -23,16 +23,7 @@ def step(): phase_message(2) phase_set(3) elif phs == 3: - if not conf.gen_all_solution_oninit: - phase_message(3) - solution.generate() - iteration_inc() - phase_set(4) - elif phs == 4: - phase_message(4) - phase_set(5) - elif phs == 5: - phase_message(5) + phase_message(3) try: solution.apply() except exceptions.NoApplicableSolution: @@ -42,54 +33,52 @@ def step(): pass print('\nAll done.') exit(0) - phase_set(6) - elif phs == 6: - phase_message(6) - phase_set(7) - elif phs == 7: - phase_message(7) + phase_set(4) + elif phs == 4: + phase_message(4) + phase_set(5) + elif phs == 5: + phase_message(5) try: kernel.config() except exceptions.ConfigurationError: if not conf.ignore_misconfig: print("Configuration mismatch. Exiting.") sys.exit(-2) - phase_set(8) - elif phs == 8: - phase_message(8) + phase_set(6) + elif phs == 6: + phase_message(6) if conf.only_config: phase_set(3) else: - phase_set(9) + phase_set(7) + elif phs == 7: + phase_message(7) + kernel.make() + phase_set(8) + elif phs == 8: + phase_message(8) + phase_set(9) elif phs == 9: phase_message(9) - kernel.make() + boot.boot() phase_set(10) elif phs == 10: phase_message(10) - phase_set(11) - elif phs == 11: - phase_message(11) - boot.boot() - phase_set(12) - elif phs == 12: - phase_message(12) phase_set(3) # Phase # phases = ("Not Initialized", #0 "Initializing", #1 "Initialized", #2 - "Solution generating", #3 - "Solution generated", #4 - "Solution applying", #5 - "Solution applied", #6 - "Kernel configuration", #7 - "Kernel configured", #8 - "Kernel build", #9 - "Kernel built", #10 - "System boot", #11 - "Benchmark successful" #12 + "Solution applying", #3 + "Solution applied", #4 + "Kernel configuration", #5 + "Kernel configured", #6 + "Kernel build", #7 + "Kernel built", #8 + "System boot", #9 + "Benchmark successful" #10 ) def phase_get(): diff --git a/scripts/solution.py b/scripts/solution.py index 930297b..722aaaf 100644 --- a/scripts/solution.py +++ b/scripts/solution.py @@ -17,7 +17,7 @@ def generate(): if not os.path.isfile(sf(conf.rules_file)): raise exceptions.MissingFile(conf.rules_file,"Run parse_kconfig.") - if os.path.isfile(sf(conf.solution_file)) and conf.gen_all_solution_oninit: + if os.path.isfile(sf(conf.solution_file)): raise exceptions.SolutionGenerated() w_file = tempfile.NamedTemporaryFile(delete=False) @@ -28,11 +28,6 @@ def generate(): ln = lnn.rstrip() if ln not in lines: lines.add(ln) - 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(sf(conf.required_file)): for lnn in open(sf(conf.required_file), 'r'): ln = lnn.rstrip() @@ -57,8 +52,7 @@ def generate(): pass picosat_cmd = [sf(conf.picosat), w_file.name] - if (conf.gen_all_solution_oninit): - picosat_cmd += ['--all'] + picosat_cmd += conf.picosat_args satprc = subprocess.Popen(picosat_cmd, stdout = subprocess.PIPE) with open(os.path.join(sf(conf.log_folder), "picosat.log"), 'a') as f: @@ -77,10 +71,6 @@ def generate(): for sl in solut: fm.write(str(sl) + ' ') fm.write('\n') - with open(sf(conf.solved_file), 'a') as fs: - for sl in solut: - fs.write(str(-1 * sl) + ' ') - fs.write('\n') except ValueError: pass solut = [] -- cgit v1.2.3