hc
2024-03-22 a0752693d998599af469473b8dc239ef973a012f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# @ build_board.py
# Extensions for building CooperCityRvp using build_bios.py
#
# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
 
"""
This module serves as a sample implementation of the build extension
scripts
"""
 
import os
import sys
 
def pre_build_ex(config, functions):
    """Additional Pre BIOS build function
 
    :param config: The environment variables to be used in the build process
    :type config: Dictionary
    :param functions: A dictionary of function pointers
    :type functions: Dictionary
    :returns: nothing
    """
    print("pre_build_ex")
    config["BUILD_DIR_PATH"] = os.path.join(config["WORKSPACE"],
                                            'Build',
                                            config["PLATFORM_BOARD_PACKAGE"],
                                            "{}_{}".format(
                                                config["TARGET"],
                                                config["TOOL_CHAIN_TAG"]))
    # set BUILD_DIR path
    config["BUILD_DIR"] = os.path.join('Build',
                                       config["PLATFORM_BOARD_PACKAGE"],
                                       "{}_{}".format(
                                           config["TARGET"],
                                           config["TOOL_CHAIN_TAG"]))
    config["BUILD_X64"] = os.path.join(config["BUILD_DIR_PATH"], 'X64')
    config["BUILD_IA32"] = os.path.join(config["BUILD_DIR_PATH"], 'IA32')
 
    if not os.path.isdir(config["BUILD_DIR_PATH"]):
        try:
            os.makedirs(config["BUILD_DIR_PATH"])
        except OSError:
            print("Error while creating Build folder")
            sys.exit(1)
 
    #@todo: Replace this with PcdFspModeSelection
    if config.get("API_MODE_FSP_WRAPPER_BUILD", "FALSE") == "TRUE":
        config["EXT_BUILD_FLAGS"] += " -D FSP_MODE=0"
    else:
        config["EXT_BUILD_FLAGS"] += " -D FSP_MODE=1"
    return None
 
def _merge_files(files, ofile):
    with open(ofile, 'wb') as of:
        for x in files:
            if not os.path.exists(x):
                return
 
            with open(x, 'rb') as f:
                of.write(f.read())
 
def build_ex(config, functions):
    """Additional BIOS build function
 
    :param config: The environment variables to be used in the build process
    :type config: Dictionary
    :param functions: A dictionary of function pointers
    :type functions: Dictionary
    :returns: config dictionary
    :rtype: Dictionary
    """
    print("build_ex")
    fv_path = os.path.join(config["BUILD_DIR_PATH"], "FV")
    binary_fd = os.path.join(fv_path, "BINARY.fd")
    main_fd = os.path.join(fv_path, "MAIN.fd")
    secpei_fd = os.path.join(fv_path, "SECPEI.fd")
    board_fd = config["BOARD"].upper()
    final_fd = os.path.join(fv_path, "{}.fd".format(board_fd))
    _merge_files((binary_fd, main_fd, secpei_fd), final_fd)
    return None
 
 
def post_build_ex(config, functions):
    """Additional Post BIOS build function
 
    :param config: The environment variables to be used in the post
        build process
    :type config: Dictionary
    :param functions: A dictionary of function pointers
    :type functions: Dictionary
    :returns: config dictionary
    :rtype: Dictionary
    """
    print("post_build_ex")
    fv_path = os.path.join(config["BUILD_DIR_PATH"], "FV")
    board_fd = config["BOARD"].upper()
    final_fd = os.path.join(fv_path, "{}.fd".format(board_fd))
    final_ifwi = os.path.join(fv_path, "{}.bin".format(board_fd))
 
    ifwi_ingredients_path = os.path.join(config["WORKSPACE_PLATFORM_BIN"], "Ifwi", config["BOARD"])
    flash_descriptor = os.path.join(ifwi_ingredients_path, "FlashDescriptor.bin")
    intel_me = os.path.join(ifwi_ingredients_path, "Me.bin")
    _merge_files((flash_descriptor, intel_me, final_fd), final_ifwi)
    if os.path.isfile(final_fd):
        print("IFWI image can be found at {}".format(final_ifwi))
    return None
 
 
def clean_ex(config, functions):
    """Additional clean function
 
    :param config: The environment variables to be used in the build process
    :type config: Dictionary
    :param functions: A dictionary of function pointers
    :type functions: Dictionary
    :returns: config dictionary
    :rtype: Dictionary
    """
    print("clean_ex")
    return None