-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·149 lines (138 loc) · 4.58 KB
/
build.sh
File metadata and controls
executable file
·149 lines (138 loc) · 4.58 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
#!/bin/bash
set -e
echo "============================================"
echo " DKST RetroProxy - Build Script"
echo " (macOS / Ubuntu / Linux)"
echo "============================================"
echo ""
# Detect OS
OS="$(uname -s)"
case "${OS}" in
Darwin*) PLATFORM="macOS";;
Linux*) PLATFORM="Linux";;
*) PLATFORM="Unknown";;
esac
echo "Detected platform: $PLATFORM"
echo ""
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check Go
echo "[1/3] Checking Go installation..."
if ! command_exists go; then
echo " Go is not installed."
if [ "$PLATFORM" = "macOS" ]; then
echo " Installing Go via Homebrew..."
if ! command_exists brew; then
echo "[ERROR] Homebrew not found. Please install it first:"
echo " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
exit 1
fi
brew install go
elif [ "$PLATFORM" = "Linux" ]; then
echo " Installing Go..."
if command_exists apt-get; then
sudo apt-get update
sudo apt-get install -y golang-go
elif command_exists dnf; then
sudo dnf install -y golang
elif command_exists pacman; then
sudo pacman -S --noconfirm go
else
echo "[ERROR] Could not detect package manager. Please install Go manually:"
echo " https://go.dev/dl/"
exit 1
fi
fi
fi
GO_VERSION=$(go version | awk '{print $3}')
echo " Found Go $GO_VERSION"
# Check Node.js
echo "[2/3] Checking Node.js installation..."
if ! command_exists node; then
echo " Node.js is not installed."
if [ "$PLATFORM" = "macOS" ]; then
echo " Installing Node.js via Homebrew..."
brew install node
elif [ "$PLATFORM" = "Linux" ]; then
echo " Installing Node.js..."
if command_exists apt-get; then
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
elif command_exists dnf; then
sudo dnf install -y nodejs npm
elif command_exists pacman; then
sudo pacman -S --noconfirm nodejs npm
else
echo "[ERROR] Could not detect package manager. Please install Node.js manually:"
echo " https://nodejs.org/"
exit 1
fi
fi
fi
NODE_VERSION=$(node --version)
echo " Found Node.js $NODE_VERSION"
# Check Wails CLI
echo "[3/3] Checking Wails CLI installation..."
if ! command_exists wails; then
echo " Wails CLI not found. Installing..."
go install github.com/wailsapp/wails/v2/cmd/wails@latest
# Add Go bin to PATH for this session
export PATH="$PATH:$(go env GOPATH)/bin"
if ! command_exists wails; then
echo "[ERROR] Wails installed but not in PATH. Add this to your shell profile:"
echo " export PATH=\$PATH:\$(go env GOPATH)/bin"
exit 1
fi
echo " Wails CLI installed successfully."
else
echo " Found Wails CLI"
fi
# Check Wails dependencies (Linux only)
WEBKIT_VERSION=""
if [ "$PLATFORM" = "Linux" ]; then
echo ""
echo "Checking Linux dependencies for Wails..."
if command_exists apt-get; then
# Try 4.1 first (Ubuntu 22.04+), fallback to 4.0
if apt-cache show libwebkit2gtk-4.1-dev >/dev/null 2>&1; then
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev
WEBKIT_VERSION="4.1"
else
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev
WEBKIT_VERSION="4.0"
fi
elif command_exists dnf; then
sudo dnf install -y gtk3-devel webkit2gtk3-devel
elif command_exists pacman; then
sudo pacman -S --noconfirm gtk3 webkit2gtk
fi
fi
echo ""
echo "============================================"
echo " All dependencies satisfied. Building..."
echo "============================================"
echo ""
# Install frontend dependencies
echo "Installing frontend dependencies..."
cd frontend
npm install
cd ..
# Build the application
echo "Building application..."
if [ "$WEBKIT_VERSION" = "4.1" ]; then
echo " Using webkit2gtk-4.1 (Ubuntu 22.04+)"
wails build -tags webkit2_41
else
wails build
fi
echo ""
echo "============================================"
echo " Build completed successfully!"
if [ "$PLATFORM" = "macOS" ]; then
echo " Output: build/bin/RetroProxy.app"
else
echo " Output: build/bin/RetroProxy"
fi
echo "============================================"