build_board.py 4.4 KB

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