Skip to content

Commit c84307f

Browse files
author
Georges Aaron RANDRIANAINA
committed
feat(kernel_generator): support for many configs with --config
related to issue #2. Implementation for basic compilation: it does not support incremental compilation yet
1 parent 2de6e0e commit c84307f

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

kernel_generator.py

100755100644
+37-12
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,13 @@ def parser():
332332
parser.add_argument(
333333
"--tiny",
334334
action="store_true",
335-
help="Use Linux tiny configuration. Incompatible with --config "
335+
help="Use Linux tiny configuration. Incompatible with --configs "
336336
"argument."
337337
)
338338
parser.add_argument(
339-
"--config",
340-
help="Give a path to specific configuration file. Incompatible with "
339+
"--configs",
340+
nargs="+", # if --config, need to give at least one .config
341+
help="Give a path to specific configuration files. Incompatible with "
341342
"--tiny argument."
342343
)
343344
parser.add_argument(
@@ -366,7 +367,7 @@ def parser():
366367
"--unit_testing",
367368
action="store_true",
368369
help="Optional. Run the unit testing of the compilation script. Prevent"
369-
" any compilation to happen. Will disable --tiny, --config, "
370+
" any compilation to happen. Will disable --tiny, --configs, "
370371
"--linux_version, --silent, --fetch_kernel and incremental "
371372
"feature during runtime."
372373
)
@@ -399,9 +400,25 @@ def check_precondition_and_warning(args):
399400
# precondition
400401
if args.nbcontainer <= 0:
401402
raise ValueError("You can't run less than 1 container for compilation.")
403+
404+
# If we get more that 1 .config, the argument args.nbcontainer
405+
# will be ignored and the number of containers to create should be
406+
# as much as the number of given configuration files. Hence, the
407+
# following condition should be enough:
408+
# if args.nbcontainer is more than the default value
409+
# and we got more than one config file
410+
# | raise Warning("You do not need to set nbcontainer if you\
411+
# | give many configuration files")
412+
# +----
413+
# The default value for args.nbcontainer is 1. Even if the user
414+
# does not give this argument, it will be set to 1 automatically.
415+
if args.nbcontainer > 1 and len(args.configs) > 1:
416+
raise Warning(
417+
"You do not need to set nbcontainer if you give many configuration\
418+
files")
402419
if args.incremental < 0:
403420
raise ValueError("You can't use incremental with negative value.")
404-
if args.tiny and (args.config is not None):
421+
if args.tiny and (args.configs is not None):
405422
raise NotImplementedError(
406423
"You can't use tiny and config parameter at the same time."
407424
)
@@ -413,7 +430,7 @@ def check_precondition_and_warning(args):
413430
if args.unit_testing:
414431
args.incremental = 0
415432
args.tiny = None
416-
args.config = None
433+
args.configs = None
417434
args.silent = None
418435

419436
# not implemented yet
@@ -440,9 +457,10 @@ def check_precondition_and_warning(args):
440457
"out to date, or you could crash if you don't have the image.")
441458
if args.tiny:
442459
print("You are using tiny configuration.")
443-
if args.config is not None:
444-
print("You are using your specific configuration : {}".format(
445-
args.config))
460+
if args.configs is not None:
461+
print("You are using the following configuration(s):")
462+
for conf in args.configs:
463+
print("\t* {}".format(conf))
446464
if args.seed is not None:
447465
print("You are using your specific set of seed options")
448466
if args.unit_testing:
@@ -835,7 +853,14 @@ def compilation(image, args):
835853
:param args: parsed argument options
836854
:type args: `argparse.Namespace`_
837855
"""
838-
for i in range(args.nbcontainer):
856+
nbcontainer = args.nbcontainer
857+
nbconfigs = len(args.configs)
858+
# One does not care about nbcontainer as far as one gets more than
859+
# one configs.
860+
if nbconfigs > 1:
861+
nbcontainer = nbconfigs
862+
863+
for i in range(nbcontainer):
839864
if not args.silent:
840865
set_prompt_color("Light_Blue")
841866
print("\n=============== Docker number ", i, " ===============")
@@ -844,7 +869,7 @@ def compilation(image, args):
844869
image,
845870
args.incremental,
846871
args.tiny,
847-
args.config,
872+
args.configs[i],
848873
args.seed,
849874
args.silent,
850875
args.number_cpu,
@@ -855,7 +880,7 @@ def compilation(image, args):
855880
fetch_logs(container_id, args.logs, args.silent)
856881
delete_docker_container(container_id)
857882
if not args.silent:
858-
feedback_user(args.nbcontainer, args.incremental)
883+
feedback_user(nbcontainer, args.incremental)
859884

860885

861886
def run_unit_testing(image):

0 commit comments

Comments
 (0)