-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathrun-build.sh
executable file
·131 lines (116 loc) · 2.42 KB
/
run-build.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
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
123
124
125
126
127
128
129
130
131
#!/bin/bash
SCRIPTNAME="run-build.sh"
RECONFIG=FALSE
function HelpMsg()
{
echo "Usage: $SCRIPTNAME [Options]"
echo
echo "Configure EDK2 build environment, then kicks off build for Nintendo Switch."
echo
echo
echo "Options: "
echo " --help, -h, -? Print this help screen and exit."
echo
}
function SetWorkspace()
{
#
# If WORKSPACE is already set, then we can return right now
#
if [ -n "$WORKSPACE" ]
then
return 0
fi
#
# Check for BaseTools/BuildEnv before dirtying the user's environment.
#
if [ ! -f BaseTools/BuildEnv ] && [ -z "$EDK_TOOLS_PATH" ]
then
echo BaseTools not found in your tree, and EDK_TOOLS_PATH is not set.
echo Please point EDK_TOOLS_PATH at the directory that contains
echo the EDK2 BuildEnv script.
return 1
fi
#
# Set $WORKSPACE
#
export WORKSPACE=`pwd`
return 0
}
function SetupEnv()
{
if [ -n "$EDK_TOOLS_PATH" ]
then
. $EDK_TOOLS_PATH/BuildEnv
elif [ -f "$WORKSPACE/BaseTools/BuildEnv" ]
then
. $WORKSPACE/BaseTools/BuildEnv
elif [ -n "$PACKAGES_PATH" ]
then
PATH_LIST=$PACKAGES_PATH
PATH_LIST=${PATH_LIST//:/ }
for DIR in $PATH_LIST
do
if [ -f "$DIR/BaseTools/BuildEnv" ]
then
export EDK_TOOLS_PATH=$DIR/BaseTools
. $DIR/BaseTools/BuildEnv
break
fi
done
else
echo BaseTools not found in your tree, and EDK_TOOLS_PATH is not set.
echo Please check that WORKSPACE or PACKAGES_PATH is not set incorrectly
echo in your shell, or point EDK_TOOLS_PATH at the directory that contains
echo the EDK2 BuildEnv script.
return 1
fi
}
function FixPermission()
{
chmod +x NintendoSwitchPkg/Tools/*.ps1
chmod +x NintendoSwitchPkg/Tools/PsModules/*.psm1
chmod +x NintendoSwitchPkg/Tools/*.sh
}
function SourceEnv()
{
SetWorkspace &&
SetupEnv &&
FixPermission
}
function DevelopmentBuild()
{
./NintendoSwitchPkg/Tools/edk2-build.ps1
if [ ! $? -eq 0 ]; then
echo "[Builder] Build failed."
return $?
fi
}
I=$#
while [ $I -gt 0 ]
do
case "$1" in
-?|-h|--help|*)
HelpMsg
break
;;
esac
I=$(($I - 1))
done
if [ $I -gt 0 ]
then
return 1
else
echo "[Builder] Configure environment."
SourceEnv
if [ ! $? -eq 0 ]; then
echo "Unable to configure EDK2 environment."
return $?
fi
# Run build
DevelopmentBuild
if [ ! $? -eq 0 ]; then
echo "[Builder] Build failed."
return $?
fi
fi