build_board.py 4.6 KB

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