-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathbuild-wsl.sh
More file actions
89 lines (76 loc) · 2.33 KB
/
build-wsl.sh
File metadata and controls
89 lines (76 loc) · 2.33 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
#!/bin/bash
set -euo pipefail
ABI="${1:-armv8}"
BUILD_TYPE="${2:-debug}"
if [ ! -f "gradlew" ]; then
echo "Error: gradlew not found. Are you in the project root?" >&2
exit 1
fi
chmod +x gradlew
chmod +x native/build-native.sh
if ! command -v node >/dev/null 2>&1; then
echo "Error: Node.js is not installed in WSL." >&2
echo "Please install Node.js in WSL using one of the following methods:" >&2
echo "" >&2
echo "Option 1: Install via nvm (recommended):" >&2
echo " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash" >&2
echo " source ~/.bashrc" >&2
echo " nvm install --lts" >&2
echo "" >&2
echo "Option 2: Install via apt:" >&2
echo " curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -" >&2
echo " sudo apt-get install -y nodejs" >&2
echo "" >&2
exit 1
fi
if ! command -v npm >/dev/null 2>&1; then
echo "Error: npm is not installed in WSL." >&2
echo "Please install npm (it should come with Node.js)." >&2
exit 1
fi
if ! command -v gcc >/dev/null 2>&1 && ! command -v clang >/dev/null 2>&1; then
echo "Error: No C compiler found in WSL. Required for Rust build scripts." >&2
echo "Please install build-essential:" >&2
echo " sudo apt-get update" >&2
echo " sudo apt-get install -y build-essential" >&2
exit 1
fi
case "$ABI" in
armv8|arm64)
FLAVOR="armv8"
;;
armv7|arm32)
FLAVOR="armv7"
;;
all)
FLAVOR="all"
;;
core)
FLAVOR="core"
;;
*)
echo "Error: Unknown ABI '$ABI'. Valid options: armv8, armv7, all, core" >&2
exit 1
;;
esac
case "$BUILD_TYPE" in
debug|Debug|DEBUG)
BUILD_TYPE="Debug"
;;
release|Release|RELEASE)
BUILD_TYPE="Release"
;;
*)
echo "Error: Unknown build type '$BUILD_TYPE'. Valid options: debug, release" >&2
exit 1
;;
esac
TASK="assemble${FLAVOR^}${BUILD_TYPE^}"
echo "Building $FLAVOR $BUILD_TYPE..."
echo "Clearing configuration cache..."
./gradlew --stop 2>/dev/null || true
rm -rf .gradle/configuration-cache 2>/dev/null || true
echo "Running: ./gradlew --configuration-cache $TASK"
./gradlew --configuration-cache "$TASK"
echo "Build completed successfully!"
echo "APK location: app/build/outputs/apk/$FLAVOR/$BUILD_TYPE/"