From b9ff681e3ed5efc0f8f76ce75d89b2214a6e68c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 6 May 2015 17:10:16 +0200 Subject: Separate initialisation Initialisation now can be executed without loop it self. --- scripts/boot.py | 16 ++++------------ scripts/confmk.py | 4 ++-- scripts/initialize.py | 42 ++++++++++++++++++++++++++++++++++++++++++ scripts/loop.py | 15 ++++----------- 4 files changed, 52 insertions(+), 25 deletions(-) mode change 100644 => 100755 scripts/initialize.py (limited to 'scripts') diff --git a/scripts/boot.py b/scripts/boot.py index c8c9bea..bff70d9 100644 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -5,24 +5,14 @@ import shutil import importlib import utils +import initialize from conf import conf from conf import sf from exceptions import MissingFile -def gen_nbscript(): - try: - os.remove(sf(conf.nbscript)) - except OSError: - pass - - with open(sf(conf.nbscript), 'w') as f: - f.write('# generated novaboot script. Please don\'t edit.\n') - f.write('load ' + sf(conf.linux_image) + ' console=ttyS0,115200\n') - f.write('load ' + sf(conf.initram) + '\n') - def boot(): if not os.path.isfile((conf.nbscript)): - gen_nbscript() + initialize.gen_nbscript() try: os.mkdir(sf(conf.output_folder)) except FileExistsError: @@ -41,6 +31,8 @@ def boot(): if line.startswith('lcp-output: '): output += line[12:] print(output) + + # TODO change data = bench.stdoutput(output) iteration = 0 diff --git a/scripts/confmk.py b/scripts/confmk.py index de9052e..952e674 100755 --- a/scripts/confmk.py +++ b/scripts/confmk.py @@ -1,4 +1,4 @@ -#!/bin/python3 +#!/bin/env python3 import os import sys from conf import conf @@ -18,7 +18,7 @@ def gen_confmk(): f.write("BUILDROOT_INITSCRIPT := " + conf.buildroot_initscript + "\n") f.write("BUILDROOT_DEF_CONFIG := " + conf.buildroot_def_config + "\n") f.write("\n") - f.write("NBSCRIPTS := " + conf.nbscript + "\n") + f.write("NBSCRIPT := " + conf.nbscript + "\n") ################################################################################# diff --git a/scripts/initialize.py b/scripts/initialize.py old mode 100644 new mode 100755 index 40d9eb5..314b293 --- a/scripts/initialize.py +++ b/scripts/initialize.py @@ -1,3 +1,4 @@ +#!/bin/env python3 import os import sys import subprocess @@ -7,6 +8,29 @@ import utils from conf import conf from conf import sf import exceptions +import loop + +def all(): + base() + parse_kconfig() + gen_requred() + gen_nbscript() + +def base(): + try: os.mkdir(conf.build_folder) + except FileExistsError: + pass + + if os.path.isfile(sf(conf.phase_file)): + print("Warning: file " + conf.phase_file + " already exists. Not overwritten.") + else: + loop.phase_set(1) + + if os.path.isfile(sf(conf.iteration_file)): + print("Warning: file " + conf.iteration_file + " already exists. Not overwritten.") + else: + loop.iteration_reset() + def parse_kconfig(): "Execute parse_kconfig in linux_sources directory." @@ -20,6 +44,7 @@ def parse_kconfig(): os.chdir(wd) + def gen_requred(): "Generates required depenpency from .config file in linux source tree." @@ -54,3 +79,20 @@ def gen_requred(): else: fconf.write(line); freq.write("-" + srmap["MODULES"] + "\n"); # force modules no + + +def gen_nbscript(): + if os.path.isfile(sf(conf.nbscript)): + print("Warning: file " + conf.nbscript + + " already exists. Generation skipped.") + return + + with open(sf(conf.nbscript), 'w') as f: + f.write('# generated novaboot script. Please don\'t edit.\n') + f.write('load ' + sf(conf.linux_image) + ' console=ttyS0,115200\n') + f.write('load ' + sf(conf.buildroot_initram) + '\n') + +################################################################################# + +if __name__ == '__main__': + all() diff --git a/scripts/loop.py b/scripts/loop.py index 21aabe8..dd5949a 100755 --- a/scripts/loop.py +++ b/scripts/loop.py @@ -1,4 +1,4 @@ -#!/bin/python3 +#!/bin/env python3 import os import sys import subprocess @@ -15,17 +15,9 @@ import exceptions def step(): phs = phase_get() - if phs == 0: - try: - os.mkdir(conf.build_folder) - except FileExistsError: - pass - phase_set(1) - elif phs == 1: + if phs == 0 or phs == 1: phase_message(1) - initialize.parse_kconfig() - initialize.gen_requred() - iteration_reset() + initialize.all() phase_set(2) elif phs == 2: phase_message(2) @@ -102,6 +94,7 @@ def phase_get(): return 0 def phase_set(phs): + # TODO global thr if thr.term: return -- cgit v1.2.3