Beispiel #1
0
def main(args):
    """
    This is main function to start generate source code related with board
    :param args: it is a command line args for the script
    """
    err_dic = {}
    config_srcs = []
    config_dirs = []

    (err_dic, board_info_file, scenario_info_file,
     enable_commit) = board_cfg_lib.get_param(args)
    if err_dic:
        return err_dic

    board_cfg_lib.BOARD_INFO_FILE = board_info_file
    board_cfg_lib.SCENARIO_INFO_FILE = scenario_info_file
    board_cfg_lib.get_vm_count(scenario_info_file)

    # get board name
    (err_dic, board) = board_cfg_lib.get_board_name()
    if err_dic:
        return err_dic
    board_cfg_lib.BOARD_NAME = board

    # check if this is the scenario config which matched board info
    (err_dic, status) = board_cfg_lib.is_config_file_match()
    if not status:
        err_dic[
            'board config: Not match'] = "The board xml and scenario xml should be matched"
        return err_dic

    config_dirs.append(ACRN_CONFIG + board)
    if board not in board_cfg_lib.BOARD_NAMES:
        for config_dir in config_dirs:
            if not os.path.exists(config_dir):
                os.makedirs(config_dir)

    config_pci = config_dirs[0] + '/' + GEN_FILE[0]
    config_board = config_dirs[0] + '/' + GEN_FILE[1]
    config_platform = config_dirs[0] + '/' + board + GEN_FILE[2]
    config_misc_cfg = config_dirs[0] + '/' + GEN_FILE[3]
    config_ve820 = config_dirs[0] + '/' + GEN_FILE[4]
    config_board_kconfig = ACRN_CONFIG + board + GEN_FILE[5]

    config_srcs.append(config_pci)
    config_srcs.append(config_board)
    config_srcs.append(config_platform)
    config_srcs.append(config_misc_cfg)
    config_srcs.append(config_ve820)
    config_srcs.append(config_board_kconfig)

    # generate board.c
    with open(config_board, 'w+') as config:
        err_dic = board_c.generate_file(config)
        if err_dic:
            return err_dic

    # generate pci_devices.h
    with open(config_pci, 'w+') as config:
        pci_devices_h.generate_file(config)

    # generate acpi_platform.h
    with open(config_platform, 'w+') as config:
        acpi_platform_h.generate_file(config, ACRN_DEFAULT_PLATFORM)

    # generate acpi_platform.h
    with open(config_ve820, 'w+') as config:
        err_dic = ve820_c.generate_file(config)
        if err_dic:
            return err_dic

    # generate acpi_platform.h
    with open(config_misc_cfg, 'w+') as config:
        err_dic = misc_cfg_h.generate_file(config)
        if err_dic:
            return err_dic

    # generate new board_name.config
    if board not in board_cfg_lib.BOARD_NAMES:
        with open(config_board_kconfig, 'w+') as config:
            err_dic = new_board_kconfig.generate_file(config)
            if err_dic:
                return err_dic

    config_str = 'Config files'
    gen_str = 'generated'
    # move changes to patch, and apply to the source code
    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("{} for NEW board {} is {} successfully!".format(
            config_str, board, gen_str))
    elif not err_dic:
        print("{} for {} is {} successfully!".format(config_str, board,
                                                     gen_str))
    else:
        print("{} for {} is failed".format(config_str, board))

    return err_dic
def main(args):
    """
    This is main function to start generate source code related with board
    :param args: it is a command line args for the script
    """
    global ACRN_CONFIG_TARGET
    err_dic = {}

    (err_dic, board_info_file, scenario_info_file,
     output_folder) = board_cfg_lib.get_param(args)
    if err_dic:
        return err_dic

    if output_folder:
        ACRN_CONFIG_TARGET = os.path.abspath(output_folder) + '/'

    # check env
    err_dic = board_cfg_lib.prepare()
    if err_dic:
        return err_dic

    board_cfg_lib.BOARD_INFO_FILE = board_info_file
    board_cfg_lib.SCENARIO_INFO_FILE = scenario_info_file
    board_cfg_lib.get_vm_count(scenario_info_file)

    # get board name
    (err_dic, board) = board_cfg_lib.get_board_name()
    if err_dic:
        return err_dic
    board_cfg_lib.BOARD_NAME = board

    # check if this is the scenario config which matched board info
    (err_dic, status) = board_cfg_lib.is_config_file_match()
    if not status:
        err_dic[
            'board config: Not match'] = "The board xml and scenario xml should be matched"
        return err_dic

    board_dir = ACRN_CONFIG_TARGET + board + '/'
    board_cfg_lib.mkdir(board_dir)

    config_pci = board_dir + GEN_FILE[0]
    config_board = board_dir + GEN_FILE[1]
    config_acpi = board_dir + board + GEN_FILE[2]
    config_misc_cfg = board_dir + GEN_FILE[3]
    config_board_kconfig = ACRN_CONFIG_TARGET + board + GEN_FILE[4]

    # generate board.c
    with open(config_board, 'w+') as config:
        err_dic = board_c.generate_file(config)
        if err_dic:
            return err_dic

    # generate pci_devices.h
    with open(config_pci, 'w+') as config:
        pci_devices_h.generate_file(config)

    # generate ($board)_acpi_info.h
    with open(config_acpi, 'w+') as config:
        acpi_platform_h.generate_file(config, ACRN_DEFAULT_ACPI)

    # generate misc_cfg.h
    with open(config_misc_cfg, 'w+') as config:
        err_dic = misc_cfg_h.generate_file(config)
        if err_dic:
            return err_dic

    # generate ($board).config
    with open(config_board_kconfig, 'w+') as config:
        err_dic = new_board_kconfig.generate_file(config)
        if err_dic:
            return err_dic

    if not err_dic:
        print("Board configurations for {} is generated successfully.".format(
            board))
    else:
        print("Board configurations for {} is generated failed.".format(board))

    return err_dic