mirror of https://github.com/ventoy/Ventoy.git
Refactor EDK2 build script for improved clarity and efficiency
Refactor EDK2 build script for improved clarity and efficiency - Implement a case statement for setting architecture and postfix based on the input argument, enhancing readability and scalability. - Add a directory change check to exit the script if the `cd` command to the EDK2 source directory fails, improving robustness. - Consolidate file removal commands into a single line for each set of related files, simplifying the script structure. - Streamline the build commands with a conditional segment specifically for the AARCH64 architecture, making the script more concise. - Enhance the success check logic by verifying the existence of all expected output files before declaring success.
This commit is contained in:
parent
757cacf274
commit
f668360d59
|
@ -1,23 +1,28 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
# Set architecture based on input argument
|
||||||
EDKARCH=X64
|
case "$1" in
|
||||||
postfix=x64
|
"ia32")
|
||||||
elif [ "$1" = "ia32" ]; then
|
EDKARCH=IA32
|
||||||
EDKARCH=IA32
|
postfix=ia32
|
||||||
postfix=ia32
|
;;
|
||||||
shift
|
"aa64")
|
||||||
elif [ "$1" = "aa64" ]; then
|
EDKARCH=AARCH64
|
||||||
EDKARCH=AARCH64
|
postfix=aa64
|
||||||
postfix=aa64
|
;;
|
||||||
shift
|
*)
|
||||||
fi
|
EDKARCH=X64
|
||||||
|
postfix=x64
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
cd edk2-edk2-stable201911
|
cd edk2-edk2-stable201911 || exit 1
|
||||||
|
|
||||||
|
# Clean up configuration and cache files
|
||||||
rm -rf ./Conf/.cache
|
rm -rf ./Conf/.cache
|
||||||
rm -f ./Conf/.AutoGenIdFile.txt
|
rm -f ./Conf/.AutoGenIdFile.txt
|
||||||
|
|
||||||
|
# Define paths for EFI files
|
||||||
VTEFI_PATH=Build/MdeModule/RELEASE_GCC48/$EDKARCH/MdeModulePkg/Application/Ventoy/Ventoy/OUTPUT/Ventoy.efi
|
VTEFI_PATH=Build/MdeModule/RELEASE_GCC48/$EDKARCH/MdeModulePkg/Application/Ventoy/Ventoy/OUTPUT/Ventoy.efi
|
||||||
DST_PATH=../../INSTALL/ventoy/ventoy_${postfix}.efi
|
DST_PATH=../../INSTALL/ventoy/ventoy_${postfix}.efi
|
||||||
|
|
||||||
|
@ -27,17 +32,15 @@ DST_PATH2=../../INSTALL/ventoy/vtoyutil_${postfix}.efi
|
||||||
VTEFI_PATH3=Build/MdeModule/RELEASE_GCC48/$EDKARCH/MdeModulePkg/Application/VDiskChain/VDiskChain/OUTPUT/VDiskChain.efi
|
VTEFI_PATH3=Build/MdeModule/RELEASE_GCC48/$EDKARCH/MdeModulePkg/Application/VDiskChain/VDiskChain/OUTPUT/VDiskChain.efi
|
||||||
DST_PATH3=../../VDiskChain/Tool/vdiskchain_${postfix}.efi
|
DST_PATH3=../../VDiskChain/Tool/vdiskchain_${postfix}.efi
|
||||||
|
|
||||||
|
# Remove old EFI files
|
||||||
rm -f $VTEFI_PATH
|
rm -f $VTEFI_PATH $DST_PATH $VTEFI_PATH2 $DST_PATH2 $VTEFI_PATH3
|
||||||
rm -f $DST_PATH
|
|
||||||
rm -f $VTEFI_PATH2
|
|
||||||
rm -f $DST_PATH2
|
|
||||||
rm -f $VTEFI_PATH3
|
|
||||||
[ -d ../../VDiskChain ] && rm -f $DST_PATH3
|
[ -d ../../VDiskChain ] && rm -f $DST_PATH3
|
||||||
|
|
||||||
|
# Setup build environment
|
||||||
unset WORKSPACE
|
unset WORKSPACE
|
||||||
source ./edksetup.sh
|
source ./edksetup.sh
|
||||||
|
|
||||||
|
# Build based on architecture
|
||||||
if [ "$EDKARCH" = "AARCH64" ]; then
|
if [ "$EDKARCH" = "AARCH64" ]; then
|
||||||
GCC48_AARCH64_PREFIX=aarch64-linux-gnu- \
|
GCC48_AARCH64_PREFIX=aarch64-linux-gnu- \
|
||||||
build -p MdeModulePkg/MdeModulePkg.dsc -a $EDKARCH -b RELEASE -t GCC48
|
build -p MdeModulePkg/MdeModulePkg.dsc -a $EDKARCH -b RELEASE -t GCC48
|
||||||
|
@ -45,6 +48,7 @@ else
|
||||||
build -p MdeModulePkg/MdeModulePkg.dsc -a $EDKARCH -b RELEASE -t GCC48
|
build -p MdeModulePkg/MdeModulePkg.dsc -a $EDKARCH -b RELEASE -t GCC48
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if build was successful and copy files
|
||||||
if [ -e $VTEFI_PATH ] && [ -e $VTEFI_PATH2 ] && [ -e $VTEFI_PATH3 ]; then
|
if [ -e $VTEFI_PATH ] && [ -e $VTEFI_PATH2 ] && [ -e $VTEFI_PATH3 ]; then
|
||||||
echo -e '\n\n====================== SUCCESS ========================\n\n'
|
echo -e '\n\n====================== SUCCESS ========================\n\n'
|
||||||
cp -a $VTEFI_PATH $DST_PATH
|
cp -a $VTEFI_PATH $DST_PATH
|
||||||
|
@ -56,4 +60,3 @@ else
|
||||||
cd ..
|
cd ..
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue