forked from Acode-Foundation/Acode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
99 lines (84 loc) · 2.12 KB
/
build.sh
File metadata and controls
99 lines (84 loc) · 2.12 KB
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
#!/bin/bash
# Default values
app="paid"
mode="d"
fdroidFlag=""
packageType="apk" # New default: apk or aar
webpackmode="development"
cordovamode=""
# Check all arguments for specific values
for arg in "$@"; do
case "$arg" in
"free"|"paid")
app="$arg"
;;
"p"|"prod"|"d"|"dev")
mode="$arg"
;;
"fdroid")
fdroidFlag="fdroid"
;;
"apk"|"bundle")
packageType="$arg"
;;
*)
echo "Warning: Unknown argument '$arg' ignored"
;;
esac
done
root=$(npm prefix)
if [ -n "$TMPDIR" ] && [ -r "$TMPDIR" ] && [ -w "$TMPDIR" ]; then
tmpdir="$TMPDIR"
elif [ -r "/tmp" ] && [ -w "/tmp" ]; then
tmpdir="/tmp"
else
echo "Warning: No usable temporary directory found (TMPDIR or /tmp not accessible). Skipping fdroid.bool file." >&2
tmpdir=""
fi
if [ "$fdroidFlag" = "fdroid" ]; then
if [ -n "$tmpdir" ]; then
echo "true" > "$tmpdir/fdroid.bool"
fi
# Remove only if installed
if [ -d "plugins/com.foxdebug.acode.rk.exec.proot" ]; then
cordova plugin remove com.foxdebug.acode.rk.exec.proot
fi
else
if [ -n "$tmpdir" ]; then
echo "false" > "$tmpdir/fdroid.bool"
fi
# Add only if the src exists and not already installed
if [ -d "src/plugins/proot" ] && [ ! -d "plugins/com.foxdebug.acode.rk.exec.proot" ]; then
cordova plugin add src/plugins/proot/
fi
fi
# Normalize mode values
if [ "$mode" = "p" ] || [ "$mode" = "prod" ]
then
mode="p"
webpackmode="production"
cordovamode="--release"
fi
# Set build target based on packageType
if [ "$packageType" = "bundle" ]; then
echo "Building AAR library file..."
else
echo "Building APK file..."
fi
RED=''
NC=''
script1="node ./utils/config.js $mode $app"
script2="node ./utils/esbuild.js --mode $webpackmode"
# script3="node ./utils/loadStyles.js"
echo "type : $packageType"
script4="cordova build android $cordovamode -- --packageType=$packageType"
eval "
echo \"${RED}$script1${NC}\";
$script1;
echo \"${RED}$script2${NC}\";
$script2&&
# echo \"${RED}$script3${NC}\";
# $script3;
echo \"${RED}$script4${NC}\";
$script4;
"