forked from Project-Silicium/Mu-Silicium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_active_devices.sh
executable file
·59 lines (53 loc) · 1.94 KB
/
build_active_devices.sh
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
#!/bin/bash
# Function to display Help Message
function _help(){
echo "Usage: ./build_active_devices.sh [-r <Build Mode>]"
echo
echo "Build Project Mu UEFI for active Devices"
echo
echo "Options:"
echo " --release <Build Mode>, -r <Build Mode>: Release mode for building, 'RELEASE' is the default or use 'DEBUG' alternatively."
echo " --help, -h: Shows this Help."
echo
echo "MainPage: https://github.com/Project-Silicium/Mu-Silicium"
exit 1
}
# Functions to display the Message Type (Error or Warning)
function _error(){ echo -e "\033[1;31m${@}\033[0m" >&2;exit 1; }
function _warn(){ echo -e "\033[0;33m${@}\033[0m" >&2; }
# Check if any args were given
OPTS="$(getopt -o hr: -l help,release: -n 'build_uefi.sh' -- "$@")"||exit 1
eval set -- "${OPTS}"
while true
do case "${1}" in
-h|--help) _help 0;shift;;
-r|--release) TARGET_BUILD_MODE="${2}";shift 2;;
--) shift;break;;
*) _help 1;;
esac
done
# Set Release Type of UEFI
case "${TARGET_BUILD_MODE}" in
DEBUG) _TARGET_BUILD_MODE=DEBUG;;
*) _TARGET_BUILD_MODE=RELEASE;;
esac
# Parse active devices from Status.md
DEVICES=$(awk '/**State: Active**/,/**Codename:/ {if ($0 ~ /**Codename:/) print substr($2, 1, length($2)-2)}' Status.md)
# Build UEFI for active Devices
for Device in $DEVICES; do
# Include Device Config if it exists
if [ -f "Resources/Configs/${Device}.conf" ]
then source "Resources/Configs/${Device}.conf"
else _error "\nDevice configuration not found from ${Device}!\nCheck if your .conf File is in the 'configs' Folder\n"
fi
# Check if the Device has Multiple Models
if [ ${TARGET_MULTIPLE_MODELS} == "TRUE" ]; then
# If device has it build device with models
for ((Model = 0; Model < $TARGET_NUMBER_OF_MODELS; Model++)); do
bash ./build_uefi.sh -d $Device -r $_TARGET_BUILD_MODE -m $Model || exit $?
done
else
# If device don't have it just run build script
bash ./build_uefi.sh -d $Device -r $_TARGET_BUILD_MODE || exit $?
fi
done