-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.fish
More file actions
executable file
·157 lines (139 loc) · 4.96 KB
/
bootstrap.fish
File metadata and controls
executable file
·157 lines (139 loc) · 4.96 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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/usr/bin/env fish
# Bootstrap script for R3BL Image Blur Android App development environment
# Run this once to set up all dependencies
# Works on both Linux and macOS
echo "=== R3BL Image Blur Bootstrap ==="
echo ""
# Detect OS
set -l os_type (uname -s)
echo "Detected OS: $os_type"
echo ""
# 1. Install JDK 21 (not just JRE - needed for compilation)
echo "Installing OpenJDK 21..."
if not command -q javac
if test "$os_type" = "Darwin"
if command -q brew
brew install openjdk@21
echo "✓ JDK 21 installed via Homebrew"
else
echo "✗ Please install Homebrew first: https://brew.sh"
exit 1
end
else
sudo apt install -y openjdk-21-jdk
echo "✓ JDK 21 installed"
end
else
echo "✓ JDK already installed ($(javac -version 2>&1))"
end
# 2. Install Android SDK (API 35 for Android 15)
echo ""
echo "Setting up Android SDK..."
# Set platform-specific paths and URLs
if test "$os_type" = "Darwin"
set -l ANDROID_HOME "$HOME/Library/Android/sdk"
set -l CMDLINE_TOOLS_URL "https://dl.google.com/android/repository/commandlinetools-mac-11076708_latest.zip"
else
set -l ANDROID_HOME "$HOME/Android/Sdk"
set -l CMDLINE_TOOLS_URL "https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip"
end
# Use global for ANDROID_HOME so it persists
if test "$os_type" = "Darwin"
set -g ANDROID_HOME "$HOME/Library/Android/sdk"
else
set -g ANDROID_HOME "$HOME/Android/Sdk"
end
if not test -d "$ANDROID_HOME/platforms/android-35"
# Create SDK directory
mkdir -p "$ANDROID_HOME/cmdline-tools"
# Download command line tools if not present
if not test -d "$ANDROID_HOME/cmdline-tools/latest"
echo "Downloading Android command line tools..."
set -l tmp_zip /tmp/cmdline-tools.zip
if test "$os_type" = "Darwin"
curl -L -o $tmp_zip "https://dl.google.com/android/repository/commandlinetools-mac-11076708_latest.zip"
else
curl -L -o $tmp_zip "https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip"
end
unzip -q $tmp_zip -d /tmp/cmdline-tools-tmp
mv /tmp/cmdline-tools-tmp/cmdline-tools "$ANDROID_HOME/cmdline-tools/latest"
rm -rf $tmp_zip /tmp/cmdline-tools-tmp
end
# Accept licenses and install SDK components
echo "Installing Android SDK platform 35 (Android 15)..."
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses >/dev/null 2>&1
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" "platforms;android-35" "build-tools;35.0.0" "platform-tools"
echo "✓ Android SDK installed"
else
echo "✓ Android SDK already installed"
end
# Set ANDROID_HOME for this session and create local.properties
set -gx ANDROID_HOME $ANDROID_HOME
set -gx PATH "$ANDROID_HOME/platform-tools" $PATH
echo "sdk.dir=$ANDROID_HOME" > local.properties
# 3. Install ADB for device communication and debugging
echo ""
echo "Installing ADB (via SDK platform-tools)..."
if test -f "$ANDROID_HOME/platform-tools/adb"
echo "✓ ADB available at $ANDROID_HOME/platform-tools/adb"
else if command -q adb
echo "✓ ADB already installed (system)"
else
if test "$os_type" = "Darwin"
brew install --cask android-platform-tools
echo "✓ ADB installed via Homebrew"
else
sudo apt install -y adb
echo "✓ ADB installed via apt"
end
end
# 4. Generate/update Gradle wrapper
echo ""
echo "Setting up Gradle wrapper..."
# Check if we need to install gradle to bootstrap the wrapper
if not test -f gradlew
echo "Installing Gradle to generate wrapper..."
if test "$os_type" = "Darwin"
brew install gradle
else
sudo apt install -y gradle
end
gradle wrapper --gradle-version 8.13
echo "✓ Gradle wrapper generated"
else
echo "✓ Gradle wrapper already exists"
end
# Ensure wrapper uses correct Gradle version
set -l wrapper_props gradle/wrapper/gradle-wrapper.properties
if test -f $wrapper_props
if not grep -q "gradle-8.13" $wrapper_props
echo "Updating Gradle wrapper to 8.13..."
if test "$os_type" = "Darwin"
sed -i '' 's/gradle-[0-9.]*-bin.zip/gradle-8.13-bin.zip/' $wrapper_props
else
sed -i 's/gradle-[0-9.]*-bin.zip/gradle-8.13-bin.zip/' $wrapper_props
end
echo "✓ Wrapper updated to Gradle 8.13"
else
echo "✓ Gradle wrapper already at 8.13"
end
end
# 5. Test the build
echo ""
echo "Testing build..."
./gradlew assembleDebug --quiet
if test $status -eq 0
echo "✓ Build successful!"
echo ""
echo "APK location: app/build/outputs/apk/debug/app-debug.apk"
else
echo "✗ Build failed. Check output above for errors."
exit 1
end
echo ""
echo "=== Bootstrap Complete ==="
echo ""
echo "Useful commands:"
echo " ./gradlew assembleDebug - Build debug APK"
echo " ./gradlew installDebug - Build and install to device"
echo " ./adb-log.fish - View filtered logcat output"