acrn-config: add "enable_commit" parameter for config tool
Config tool will generate files for board/scenaro/launch, some files are part of souce code for specify board. Git add/commit these files should be one optional of user experience. Add "--enable_commit" parameter to enable git add/commit. usage: --enable_commit: flag of whether to do git commit the config file changes to current git branch. Do commit with this flag and not do without the flag. Tracked-On: #3834 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
parent
780a53a175
commit
8eaee3b09b
|
@ -31,7 +31,7 @@ def main(args):
|
|||
config_srcs = []
|
||||
config_dirs = []
|
||||
|
||||
(err_dic, board_info_file, scenario_info_file) = board_cfg_lib.get_param(args)
|
||||
(err_dic, board_info_file, scenario_info_file, enable_commit) = board_cfg_lib.get_param(args)
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
|
@ -104,22 +104,29 @@ def main(args):
|
|||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
config_str = 'Config files'
|
||||
gen_str = 'generated'
|
||||
# move changes to patch, and apply to the source code
|
||||
err_dic = board_cfg_lib.gen_patch(config_srcs, board)
|
||||
if enable_commit:
|
||||
err_dic = board_cfg_lib.gen_patch(config_srcs, board)
|
||||
config_str = 'Config patch'
|
||||
gen_str = 'committed'
|
||||
|
||||
if board not in board_cfg_lib.BOARD_NAMES and not err_dic:
|
||||
print("Config patch for NEW board {} is committed successfully!".format(board))
|
||||
print("{} for NEW board {} is {} successfully!".format(config_str, board, gen_str))
|
||||
elif not err_dic:
|
||||
print("Config patch for {} is committed successfully!".format(board))
|
||||
print("{} for {} is {} successfully!".format(config_str, board, gen_str))
|
||||
else:
|
||||
print("Config patch for {} is failed".format(board))
|
||||
print("{} for {} is failed".format(config_str, board))
|
||||
|
||||
return err_dic
|
||||
|
||||
|
||||
def ui_entry_api(board_info,scenario_info):
|
||||
def ui_entry_api(board_info,scenario_info, enable_commit=False):
|
||||
|
||||
arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info]
|
||||
if enable_commit:
|
||||
arg_list.append('--enable_commit')
|
||||
|
||||
err_dic = board_cfg_lib.prepare()
|
||||
if err_dic:
|
||||
|
|
|
@ -81,11 +81,15 @@ def validate_launch_setting(board_info, scenario_info, launch_info):
|
|||
return (launch_cfg_lib.ERR_LIST, pt_sel, dm)
|
||||
|
||||
|
||||
def ui_entry_api(board_info, scenario_info, launch_info):
|
||||
def ui_entry_api(board_info, scenario_info, launch_info, enable_commit=False):
|
||||
|
||||
err_dic = {}
|
||||
|
||||
arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info, '--launch', launch_info, '--uosid', '0']
|
||||
|
||||
if enable_commit:
|
||||
arg_list.append('--enable_commit')
|
||||
|
||||
err_dic = launch_cfg_lib.prepare()
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
@ -139,7 +143,7 @@ def main(args):
|
|||
config_srcs = []
|
||||
|
||||
# get parameters
|
||||
(err_dic, board_info_file, scenario_info_file, launch_info_file, vm_th) = launch_cfg_lib.get_param(args)
|
||||
(err_dic, board_info_file, scenario_info_file, launch_info_file, vm_th, enable_commit) = launch_cfg_lib.get_param(args)
|
||||
if err_dic:
|
||||
return err_dic
|
||||
# vm_th =[0..post_vm_max]
|
||||
|
@ -208,12 +212,18 @@ def main(args):
|
|||
|
||||
commit_msg = "launch_uos_id{}.sh".format(launch_vm_count)
|
||||
|
||||
config_str = 'Config files'
|
||||
gen_str = 'generated'
|
||||
# move changes to patch, and apply to the source code
|
||||
err_dic = launch_cfg_lib.gen_patch(config_srcs, commit_msg)
|
||||
if enable_commit:
|
||||
err_dic = launch_cfg_lib.gen_patch(config_srcs, commit_msg)
|
||||
config_str = 'Config patch'
|
||||
gen_str = 'committed'
|
||||
|
||||
if not err_dic:
|
||||
print("Config patch for {} is committed successfully!".format(commit_msg))
|
||||
print("{} for {} is {} successfully!".format(config_str, commit_msg, gen_str))
|
||||
else:
|
||||
print("Config patch for {} is failed".format(commit_msg))
|
||||
print("{} for {} is failed".format(config_str, commit_msg))
|
||||
|
||||
return err_dic
|
||||
|
||||
|
|
|
@ -58,9 +58,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> [--enable_commit]")
|
||||
print('board_info_file : file name of the board info')
|
||||
print('scenario_info_file : file name of the scenario info')
|
||||
print('enable_commit: enable the flag that git add/commit the generate files to the code base. without --enable_commit will not commit this source code')
|
||||
|
||||
|
||||
def get_param(args):
|
||||
|
@ -71,34 +72,37 @@ def get_param(args):
|
|||
err_dic = {}
|
||||
board_info_file = False
|
||||
scenario_info_file = False
|
||||
enable_commit = 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, enable_commit)
|
||||
|
||||
args_list = args[1:]
|
||||
(optlist, args_list) = getopt.getopt(args_list, '', ['board=', 'scenario='])
|
||||
(optlist, args_list) = getopt.getopt(args_list, '', ['board=', 'scenario=', 'enable_commit'])
|
||||
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 == '--enable_commit':
|
||||
enable_commit = True
|
||||
|
||||
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, enable_commit)
|
||||
|
||||
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, enable_commit)
|
||||
|
||||
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, enable_commit)
|
||||
|
||||
return (err_dic, board_info_file, scenario_info_file)
|
||||
return (err_dic, board_info_file, scenario_info_file, enable_commit)
|
||||
|
||||
|
||||
def check_env():
|
||||
|
|
|
@ -80,11 +80,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> [--enable_commit]")
|
||||
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('enable_commit: enable the flag that git add/commit the generate files to the code base. without --enable_commit will not commit this source code')
|
||||
|
||||
|
||||
def get_param(args):
|
||||
|
@ -97,15 +98,24 @@ def get_param(args):
|
|||
board_info_file = False
|
||||
scenario_info_file = False
|
||||
launch_info_file = False
|
||||
enable_commit = False
|
||||
param_list = ['--board', '--scenario', '--launch', '--uosid', '--enable_commit']
|
||||
|
||||
if '--board' not in args or '--scenario' not in args or '--launch' not in args or '--uosid' 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))
|
||||
for arg_str in param_list:
|
||||
|
||||
if arg_str == '--enable_commit':
|
||||
continue
|
||||
|
||||
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), enable_commit)
|
||||
|
||||
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=', 'enable_commit'])
|
||||
for arg_k, arg_v in optlist:
|
||||
if arg_k == '--enable_commit':
|
||||
enable_commit = True
|
||||
if arg_k == '--board':
|
||||
board_info_file = arg_v
|
||||
if arg_k == '--scenario':
|
||||
|
@ -117,26 +127,26 @@ def get_param(args):
|
|||
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), enable_commit)
|
||||
|
||||
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), enable_commit)
|
||||
|
||||
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), enable_commit)
|
||||
|
||||
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), enable_commit)
|
||||
|
||||
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), enable_commit)
|
||||
|
||||
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), enable_commit)
|
||||
|
||||
|
||||
def get_scenario_uuid():
|
||||
|
|
|
@ -78,7 +78,7 @@ def main(args):
|
|||
err_dic = {}
|
||||
config_srcs = []
|
||||
|
||||
(err_dic, board_info_file, scenario_info_file) = scenario_cfg_lib.get_param(args)
|
||||
(err_dic, board_info_file, scenario_info_file, enable_commit) = scenario_cfg_lib.get_param(args)
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
|
@ -127,18 +127,28 @@ def main(args):
|
|||
with open(pci_config_c, 'w') as config:
|
||||
pci_dev_c.generate_file(config)
|
||||
|
||||
config_str = 'Config files'
|
||||
gen_str = 'generated'
|
||||
# move changes to patch, and apply to the source code
|
||||
err_dic = scenario_cfg_lib.gen_patch(config_srcs, scenario)
|
||||
if enable_commit:
|
||||
err_dic = scenario_cfg_lib.gen_patch(config_srcs, scenario)
|
||||
config_str = 'Config patch'
|
||||
gen_str = 'committed'
|
||||
|
||||
if not err_dic:
|
||||
print("Config patch for {} is committed successfully!".format(scenario))
|
||||
print("{} for {} is {} successfully!".format(config_str, scenario, gen_str))
|
||||
else:
|
||||
print("Config patch for {} is failed".format(scenario))
|
||||
print("{} for {} is failed".format(config_str, scenario))
|
||||
|
||||
return err_dic
|
||||
|
||||
|
||||
def ui_entry_api(board_info, scenario_info):
|
||||
def ui_entry_api(board_info, scenario_info, enable_commit=False):
|
||||
|
||||
arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info]
|
||||
if enable_commit:
|
||||
arg_list.append('--enable_commit')
|
||||
|
||||
err_dic = scenario_cfg_lib.prepare()
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
|
Loading…
Reference in New Issue