mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-08 12:19:06 +00:00
acrn-config: support '--out' option for board/scenario/launch config
Currently, config tool generate board files and scenario files in acrn-hypervisor directory, the origin souce code would be corrupted by the config tool. Config tool add '--out' option for user to give a path to store the generated files, without this option, tool will generate files in origin source code. Tracked-On: #4517 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
@@ -433,3 +433,8 @@ def undline_name(name):
|
||||
def round_up(addr, mem_align):
|
||||
"""Keep memory align"""
|
||||
return common.round_up(addr, mem_align)
|
||||
|
||||
|
||||
def mkdir(path):
|
||||
|
||||
common.mkdir(path)
|
||||
|
@@ -81,9 +81,10 @@ def print_if_red(msg, err=False):
|
||||
def usage(file_name):
|
||||
""" This is usage for how to use this tool """
|
||||
print("usage= {} [h] ".format(file_name), end="")
|
||||
print("--board <board_info_file> --scenario <scenario_info_file>")
|
||||
print("--board <board_info_file> --scenario <scenario_info_file> --out [output folder]")
|
||||
print('board_info_file : file name of the board info')
|
||||
print('scenario_info_file : file name of the scenario info')
|
||||
print('output folder : path to acrn-hypervisor_folder')
|
||||
|
||||
|
||||
def get_param(args):
|
||||
@@ -94,34 +95,37 @@ def get_param(args):
|
||||
err_dic = {}
|
||||
board_info_file = False
|
||||
scenario_info_file = False
|
||||
output_folder = False
|
||||
|
||||
if '--board' not in args or '--scenario' not in args:
|
||||
usage(args[0])
|
||||
err_dic['common error: get wrong parameter'] = "wrong usage"
|
||||
return (err_dic, board_info_file, scenario_info_file)
|
||||
return (err_dic, board_info_file, scenario_info_file, output_folder)
|
||||
|
||||
args_list = args[1:]
|
||||
(optlist, args_list) = getopt.getopt(args_list, '', ['board=', 'scenario='])
|
||||
(optlist, args_list) = getopt.getopt(args_list, '', ['board=', 'scenario=', 'out='])
|
||||
for arg_k, arg_v in optlist:
|
||||
if arg_k == '--board':
|
||||
board_info_file = arg_v
|
||||
if arg_k == '--scenario':
|
||||
scenario_info_file = arg_v
|
||||
if arg_k == '--out':
|
||||
output_folder = arg_v
|
||||
|
||||
if not board_info_file or not scenario_info_file:
|
||||
usage(args[0])
|
||||
err_dic['common error: get wrong parameter'] = "wrong usage"
|
||||
return (err_dic, board_info_file, scenario_info_file)
|
||||
return (err_dic, board_info_file, scenario_info_file, output_folder)
|
||||
|
||||
if not os.path.exists(board_info_file):
|
||||
err_dic['common error: get wrong parameter'] = "{} is not exist!".format(board_info_file)
|
||||
return (err_dic, board_info_file, scenario_info_file)
|
||||
return (err_dic, board_info_file, scenario_info_file, output_folder)
|
||||
|
||||
if not os.path.exists(scenario_info_file):
|
||||
err_dic['common error: get wrong parameter'] = "{} is not exist!".format(scenario_info_file)
|
||||
return (err_dic, board_info_file, scenario_info_file)
|
||||
return (err_dic, board_info_file, scenario_info_file, output_folder)
|
||||
|
||||
return (err_dic, board_info_file, scenario_info_file)
|
||||
return (err_dic, board_info_file, scenario_info_file, output_folder)
|
||||
|
||||
|
||||
def check_env():
|
||||
@@ -643,3 +647,12 @@ def get_vuart_info_id(config_file, idx):
|
||||
def round_up(addr, mem_align):
|
||||
"""Keep memory align"""
|
||||
return ((addr + (mem_align - 1)) & (~(mem_align - 1)))
|
||||
|
||||
|
||||
def mkdir(path):
|
||||
|
||||
if not os.path.exists(path):
|
||||
try:
|
||||
subprocess.check_call('mkdir -p {}'.format(path), shell=True, stdout=subprocess.PIPE)
|
||||
except subprocess.CalledProcessError:
|
||||
print_if_red("{} file create failed!".format(path), err=True)
|
||||
|
@@ -86,11 +86,12 @@ def print_red(msg, err=False):
|
||||
def usage(file_name):
|
||||
""" This is usage for how to use this tool """
|
||||
print("usage= {} [h]".format(file_name), end="")
|
||||
print("--board <board_info_file> --scenario <scenario_info_file> --launch <launch_info_file> --uosid <uosid id>")
|
||||
print("--board <board_info_file> --scenario <scenario_info_file> --launch <launch_info_file> --uosid <uosid id> --out [output folder]")
|
||||
print('board_info_file : file name of the board info')
|
||||
print('scenario_info_file : file name of the scenario info')
|
||||
print('launch_info_file : file name of the launch info')
|
||||
print('uosid : this is the relateive id for post launch vm in scenario info XML:[1..max post launch vm]')
|
||||
print('output folder : path to acrn-hypervisor_folder')
|
||||
|
||||
|
||||
def get_param(args):
|
||||
@@ -103,6 +104,7 @@ def get_param(args):
|
||||
board_info_file = False
|
||||
scenario_info_file = False
|
||||
launch_info_file = False
|
||||
output_folder = False
|
||||
param_list = ['--board', '--scenario', '--launch', '--uosid']
|
||||
|
||||
for arg_str in param_list:
|
||||
@@ -110,10 +112,10 @@ def get_param(args):
|
||||
if arg_str not in args:
|
||||
usage(args[0])
|
||||
err_dic['common error: get wrong parameter'] = "wrong usage"
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th))
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), output_folder)
|
||||
|
||||
args_list = args[1:]
|
||||
(optlist, args_list) = getopt.getopt(args_list, '', ['board=', 'scenario=', 'launch=', 'uosid='])
|
||||
(optlist, args_list) = getopt.getopt(args_list, '', ['board=', 'scenario=', 'launch=', 'uosid=', 'out='])
|
||||
for arg_k, arg_v in optlist:
|
||||
if arg_k == '--board':
|
||||
board_info_file = arg_v
|
||||
@@ -121,31 +123,33 @@ def get_param(args):
|
||||
scenario_info_file = arg_v
|
||||
if arg_k == '--launch':
|
||||
launch_info_file = arg_v
|
||||
if arg_k == '--out':
|
||||
output_folder = arg_v
|
||||
if '--uosid' in args:
|
||||
if arg_k == '--uosid':
|
||||
vm_th = arg_v
|
||||
if not vm_th.isnumeric():
|
||||
err_dic['common error: get wrong parameter'] = "--uosid should be a number"
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th))
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), output_folder)
|
||||
|
||||
if not board_info_file or not scenario_info_file or not launch_info_file:
|
||||
usage(args[0])
|
||||
err_dic['common error: get wrong parameter'] = "wrong usage"
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th))
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), output_folder)
|
||||
|
||||
if not os.path.exists(board_info_file):
|
||||
err_dic['common error: get wrong parameter'] = "{} is not exist!".format(board_info_file)
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th))
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), output_folder)
|
||||
|
||||
if not os.path.exists(scenario_info_file):
|
||||
err_dic['common error: get wrong parameter'] = "{} is not exist!".format(scenario_info_file)
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th))
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), output_folder)
|
||||
|
||||
if not os.path.exists(launch_info_file):
|
||||
err_dic['common error: get wrong parameter'] = "{} is not exist!".format(launch_info_file)
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th))
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), output_folder)
|
||||
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th))
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), output_folder)
|
||||
|
||||
|
||||
def get_post_num_list():
|
||||
@@ -692,3 +696,8 @@ def bdf_duplicate_check(bdf_dic):
|
||||
return
|
||||
else:
|
||||
bdf_used.append(dev_bdf)
|
||||
|
||||
|
||||
def mkdir(path):
|
||||
|
||||
common.mkdir(path)
|
||||
|
@@ -708,3 +708,8 @@ def get_first_post_vm():
|
||||
break
|
||||
|
||||
return (err_dic, i)
|
||||
|
||||
|
||||
def mkdir(path):
|
||||
|
||||
common.mkdir(path)
|
||||
|
Reference in New Issue
Block a user