Skip to content

Commit 1e73dc2

Browse files
committed
fix: move option parsing in shell scripts to the beginning, where possible
1 parent 67a8d74 commit 1e73dc2

File tree

3 files changed

+114
-114
lines changed

3 files changed

+114
-114
lines changed

platforms/build-3ds.sh

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,44 @@
22

33
set -e
44

5+
## options: "smart, complete_rebuild"
6+
export COMPILE_TYPE="smart"
7+
8+
export BUILDTYPE="debug"
9+
10+
export RUN_IN_CI="false"
11+
12+
if [ "$#" -eq 0 ]; then
13+
# nothing
14+
echo "Using compile type '$COMPILE_TYPE'"
15+
elif [ "$#" -eq 1 ]; then
16+
COMPILE_TYPE="$1"
17+
elif [ "$#" -eq 2 ]; then
18+
COMPILE_TYPE="$1"
19+
BUILDTYPE="$2"
20+
elif [ "$#" -eq 3 ]; then
21+
COMPILE_TYPE="$1"
22+
BUILDTYPE="$2"
23+
24+
if [ -z "$3" ]; then
25+
RUN_IN_CI="false"
26+
else
27+
RUN_IN_CI="true"
28+
fi
29+
else
30+
echo "Too many arguments given, expected 1, 2 or 3"
31+
exit 1
32+
fi
33+
34+
if [ "$COMPILE_TYPE" == "smart" ]; then
35+
: # noop
36+
elif [ "$COMPILE_TYPE" == "complete_rebuild" ]; then
37+
: # noop
38+
else
39+
echo "Invalid COMPILE_TYPE, expected: 'smart' or 'complete_rebuild'"
40+
exit 1
41+
fi
42+
543
export DEVKITPRO="/opt/devkitpro"
644
export ARCH_DEVKIT_FOLDER="$DEVKITPRO/devkitARM"
745
export COMPILER_BIN="$ARCH_DEVKIT_FOLDER/bin"
@@ -214,44 +252,6 @@ fi
214252

215253
cd ..
216254

217-
## options: "smart, complete_rebuild"
218-
export COMPILE_TYPE="smart"
219-
220-
export BUILDTYPE="debug"
221-
222-
export RUN_IN_CI="false"
223-
224-
if [ "$#" -eq 0 ]; then
225-
# nothing
226-
echo "Using compile type '$COMPILE_TYPE'"
227-
elif [ "$#" -eq 1 ]; then
228-
COMPILE_TYPE="$1"
229-
elif [ "$#" -eq 2 ]; then
230-
COMPILE_TYPE="$1"
231-
BUILDTYPE="$2"
232-
elif [ "$#" -eq 3 ]; then
233-
COMPILE_TYPE="$1"
234-
BUILDTYPE="$2"
235-
236-
if [ -z "$3" ]; then
237-
RUN_IN_CI="false"
238-
else
239-
RUN_IN_CI="true"
240-
fi
241-
else
242-
echo "Too many arguments given, expected 1, 2 or 3"
243-
exit 1
244-
fi
245-
246-
if [ "$COMPILE_TYPE" == "smart" ]; then
247-
: # noop
248-
elif [ "$COMPILE_TYPE" == "complete_rebuild" ]; then
249-
: # noop
250-
else
251-
echo "Invalid COMPILE_TYPE, expected: 'smart' or 'complete_rebuild'"
252-
exit 1
253-
fi
254-
255255
if [ ! -d "$ROMFS" ]; then
256256

257257
mkdir -p "$ROMFS"

platforms/build-switch.sh

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,44 @@
22

33
set -e
44

5+
## options: "smart, complete_rebuild"
6+
export COMPILE_TYPE="smart"
7+
8+
export BUILDTYPE="debug"
9+
10+
export RUN_IN_CI="false"
11+
12+
if [ "$#" -eq 0 ]; then
13+
# nothing
14+
echo "Using compile type '$COMPILE_TYPE'"
15+
elif [ "$#" -eq 1 ]; then
16+
COMPILE_TYPE="$1"
17+
elif [ "$#" -eq 2 ]; then
18+
COMPILE_TYPE="$1"
19+
BUILDTYPE="$2"
20+
elif [ "$#" -eq 3 ]; then
21+
COMPILE_TYPE="$1"
22+
BUILDTYPE="$2"
23+
24+
if [ -z "$3" ]; then
25+
RUN_IN_CI="false"
26+
else
27+
RUN_IN_CI="true"
28+
fi
29+
else
30+
echo "Too many arguments given, expected 1, 2 or 3"
31+
exit 1
32+
fi
33+
34+
if [ "$COMPILE_TYPE" == "smart" ]; then
35+
: # noop
36+
elif [ "$COMPILE_TYPE" == "complete_rebuild" ]; then
37+
: # noop
38+
else
39+
echo "Invalid COMPILE_TYPE, expected: 'smart' or 'complete_rebuild'"
40+
exit 1
41+
fi
42+
543
export DEVKITPRO="/opt/devkitpro"
644
export ARCH_DEVKIT_FOLDER="$DEVKITPRO/devkitA64"
745
export COMPILER_BIN="$ARCH_DEVKIT_FOLDER/bin"
@@ -111,44 +149,6 @@ APP_ROMFS='$ROMFS'
111149
112150
EOF
113151

114-
## options: "smart, complete_rebuild"
115-
export COMPILE_TYPE="smart"
116-
117-
export BUILDTYPE="debug"
118-
119-
export RUN_IN_CI="false"
120-
121-
if [ "$#" -eq 0 ]; then
122-
# nothing
123-
echo "Using compile type '$COMPILE_TYPE'"
124-
elif [ "$#" -eq 1 ]; then
125-
COMPILE_TYPE="$1"
126-
elif [ "$#" -eq 2 ]; then
127-
COMPILE_TYPE="$1"
128-
BUILDTYPE="$2"
129-
elif [ "$#" -eq 3 ]; then
130-
COMPILE_TYPE="$1"
131-
BUILDTYPE="$2"
132-
133-
if [ -z "$3" ]; then
134-
RUN_IN_CI="false"
135-
else
136-
RUN_IN_CI="true"
137-
fi
138-
else
139-
echo "Too many arguments given, expected 1, 2 or 3"
140-
exit 1
141-
fi
142-
143-
if [ "$COMPILE_TYPE" == "smart" ]; then
144-
: # noop
145-
elif [ "$COMPILE_TYPE" == "complete_rebuild" ]; then
146-
: # noop
147-
else
148-
echo "Invalid COMPILE_TYPE, expected: 'smart' or 'complete_rebuild'"
149-
exit 1
150-
fi
151-
152152
if [ ! -d "$ROMFS" ]; then
153153

154154
mkdir -p "$ROMFS"

platforms/build-web.sh

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,44 @@
22

33
set -e
44

5+
## options: "smart, complete_rebuild"
6+
export COMPILE_TYPE="smart"
7+
8+
export BUILDTYPE="debug"
9+
10+
export RUN_IN_CI="false"
11+
12+
if [ "$#" -eq 0 ]; then
13+
# nothing
14+
echo "Using compile type '$COMPILE_TYPE'"
15+
elif [ "$#" -eq 1 ]; then
16+
COMPILE_TYPE="$1"
17+
elif [ "$#" -eq 2 ]; then
18+
COMPILE_TYPE="$1"
19+
BUILDTYPE="$2"
20+
elif [ "$#" -eq 3 ]; then
21+
COMPILE_TYPE="$1"
22+
BUILDTYPE="$2"
23+
24+
if [ -z "$3" ]; then
25+
RUN_IN_CI="false"
26+
else
27+
RUN_IN_CI="true"
28+
fi
29+
else
30+
echo "Too many arguments given, expected 1, 2 or 3"
31+
exit 1
32+
fi
33+
34+
if [ "$COMPILE_TYPE" == "smart" ]; then
35+
: # noop
36+
elif [ "$COMPILE_TYPE" == "complete_rebuild" ]; then
37+
: # noop
38+
else
39+
echo "Invalid COMPILE_TYPE, expected: 'smart' or 'complete_rebuild'"
40+
exit 1
41+
fi
42+
543
if [ ! -d "toolchains" ]; then
644
mkdir -p toolchains
745
fi
@@ -112,44 +150,6 @@ APP_ROMFS='$ROMFS/assets/'
112150
113151
EOF
114152

115-
## options: "smart, complete_rebuild"
116-
export COMPILE_TYPE="smart"
117-
118-
export BUILDTYPE="debug"
119-
120-
export RUN_IN_CI="false"
121-
122-
if [ "$#" -eq 0 ]; then
123-
# nothing
124-
echo "Using compile type '$COMPILE_TYPE'"
125-
elif [ "$#" -eq 1 ]; then
126-
COMPILE_TYPE="$1"
127-
elif [ "$#" -eq 2 ]; then
128-
COMPILE_TYPE="$1"
129-
BUILDTYPE="$2"
130-
elif [ "$#" -eq 3 ]; then
131-
COMPILE_TYPE="$1"
132-
BUILDTYPE="$2"
133-
134-
if [ -z "$3" ]; then
135-
RUN_IN_CI="false"
136-
else
137-
RUN_IN_CI="true"
138-
fi
139-
else
140-
echo "Too many arguments given, expected 1, 2 or 3"
141-
exit 1
142-
fi
143-
144-
if [ "$COMPILE_TYPE" == "smart" ]; then
145-
: # noop
146-
elif [ "$COMPILE_TYPE" == "complete_rebuild" ]; then
147-
: # noop
148-
else
149-
echo "Invalid COMPILE_TYPE, expected: 'smart' or 'complete_rebuild'"
150-
exit 1
151-
fi
152-
153153
if [ ! -d "$ROMFS" ]; then
154154

155155
mkdir -p "$ROMFS"

0 commit comments

Comments
 (0)