forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-codea.sh
More file actions
221 lines (202 loc) · 6.57 KB
/
build-codea.sh
File metadata and controls
221 lines (202 loc) · 6.57 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/bash
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
REPO_DIR="/root/CodeaStudioCode"
OUTPUT_DIR="/root/builds"
echo -e "${CYAN}"
echo "=============================================="
echo " CODEA STUDIO BUILD SYSTEM "
echo "=============================================="
echo -e "${NC}"
mkdir -p "$OUTPUT_DIR"
if [ ! -d "$REPO_DIR" ]; then
echo -e "${YELLOW}Cloning repository...${NC}"
git clone --depth 1 https://github.com/OxyHQ/CodeaStudioCode.git "$REPO_DIR"
fi
echo -e "${GREEN}What do you want to build?${NC}"
echo ""
echo " WINDOWS:"
echo " 1) Windows x64 - Portable"
echo " 2) Windows x64 - Installer (User)"
echo " 3) Windows x64 - Installer (System)"
echo " 4) Windows ARM64 - Portable"
echo " 5) Windows ARM64 - Installer (User)"
echo " 6) Windows ARM64 - Installer (System)"
echo ""
echo " LINUX:"
echo " 7) Linux x64 - Portable"
echo " 8) Linux x64 - DEB package"
echo " 9) Linux x64 - RPM package"
echo " 10) Linux ARM64 - Portable"
echo ""
echo " macOS:"
echo " 11) macOS x64 - App"
echo " 12) macOS ARM64 - App"
echo ""
echo " OTHER:"
echo " 13) Update repository (git pull)"
echo " 14) Install/reinstall dependencies"
echo " 15) Clean all builds"
echo " 0) Exit"
echo ""
read -p "Enter your choice [0-15]: " choice
setup_wine_wrapper() {
echo -e "${YELLOW}Setting up Wine wrapper for InnoSetup...${NC}"
if [ -f "$REPO_DIR/node_modules/innosetup/bin/ISCC.exe" ] && [ ! -f "$REPO_DIR/node_modules/innosetup/bin/ISCC.exe.real" ]; then
mv "$REPO_DIR/node_modules/innosetup/bin/ISCC.exe" "$REPO_DIR/node_modules/innosetup/bin/ISCC.exe.real"
fi
cat > /root/iscc_wrapper.py << 'PYWRAP'
#!/usr/bin/env python3
import sys, subprocess, os
args = []
for arg in sys.argv[1:]:
if arg.startswith('/') and os.path.exists(arg):
args.append('Z:' + arg.replace('/', chr(92)))
elif '=/' in arg and os.path.exists(arg.split('=', 1)[1]):
key, val = arg.split('=', 1)
args.append(key + '=Z:' + val.replace('/', chr(92)))
else:
args.append(arg)
cmd = ['wine', '/root/CodeaStudioCode/node_modules/innosetup/bin/ISCC.exe.real'] + args
sys.exit(subprocess.call(cmd))
PYWRAP
chmod +x /root/iscc_wrapper.py
cat > "$REPO_DIR/node_modules/innosetup/bin/ISCC.exe" << 'BASHWRAP'
#!/bin/bash
python3 /root/iscc_wrapper.py "$@"
BASHWRAP
chmod +x "$REPO_DIR/node_modules/innosetup/bin/ISCC.exe"
}
build_target() {
local target=$1
local desc=$2
cd "$REPO_DIR"
echo -e "${CYAN}Building $desc...${NC}"
npm run gulp $target
if [ $? -eq 0 ]; then
echo -e "${GREEN}Build successful!${NC}"
return 0
else
echo -e "${RED}Build failed!${NC}"
return 1
fi
}
copy_output() {
local src=$1
local dest=$2
if [ -f "$src" ]; then
cp "$src" "$OUTPUT_DIR/$dest"
echo -e "${GREEN}Output: $OUTPUT_DIR/$dest${NC}"
ls -lh "$OUTPUT_DIR/$dest"
elif [ -d "$src" ]; then
tar -czvf "$OUTPUT_DIR/$dest" -C "$(dirname $src)" "$(basename $src)" > /dev/null
echo -e "${GREEN}Output: $OUTPUT_DIR/$dest${NC}"
ls -lh "$OUTPUT_DIR/$dest"
fi
}
cd "$REPO_DIR"
case $choice in
1)
build_target "vscode-win32-x64" "Windows x64 Portable"
copy_output "/root/VSCode-win32-x64" "codea-win32-x64-portable.tar.gz"
;;
2)
build_target "vscode-win32-x64" "Windows x64"
npm run gulp vscode-win32-x64-inno-updater
setup_wine_wrapper
build_target "vscode-win32-x64-user-setup" "Windows x64 User Installer"
copy_output "$REPO_DIR/.build/win32-x64/user-setup/CodeaStudioSetup.exe" "CodeaStudioSetup-x64.exe"
;;
3)
build_target "vscode-win32-x64" "Windows x64"
npm run gulp vscode-win32-x64-inno-updater
setup_wine_wrapper
build_target "vscode-win32-x64-system-setup" "Windows x64 System Installer"
copy_output "$REPO_DIR/.build/win32-x64/system-setup/CodeaStudioSetup.exe" "CodeaStudioSetup-x64-system.exe"
;;
4)
build_target "vscode-win32-arm64" "Windows ARM64 Portable"
copy_output "/root/VSCode-win32-arm64" "codea-win32-arm64-portable.tar.gz"
;;
5)
build_target "vscode-win32-arm64" "Windows ARM64"
npm run gulp vscode-win32-arm64-inno-updater
setup_wine_wrapper
build_target "vscode-win32-arm64-user-setup" "Windows ARM64 User Installer"
copy_output "$REPO_DIR/.build/win32-arm64/user-setup/CodeaStudioSetup.exe" "CodeaStudioSetup-arm64.exe"
;;
6)
build_target "vscode-win32-arm64" "Windows ARM64"
npm run gulp vscode-win32-arm64-inno-updater
setup_wine_wrapper
build_target "vscode-win32-arm64-system-setup" "Windows ARM64 System Installer"
copy_output "$REPO_DIR/.build/win32-arm64/system-setup/CodeaStudioSetup.exe" "CodeaStudioSetup-arm64-system.exe"
;;
7)
build_target "vscode-linux-x64" "Linux x64 Portable"
copy_output "/root/VSCode-linux-x64" "codea-linux-x64.tar.gz"
;;
8)
build_target "vscode-linux-x64" "Linux x64"
build_target "vscode-linux-x64-build-deb" "Linux x64 DEB"
find "$REPO_DIR/.build" -name "*.deb" -exec cp {} "$OUTPUT_DIR/codea-linux-x64.deb" \;
ls -lh "$OUTPUT_DIR/codea-linux-x64.deb"
;;
9)
build_target "vscode-linux-x64" "Linux x64"
build_target "vscode-linux-x64-build-rpm" "Linux x64 RPM"
find "$REPO_DIR/.build" -name "*.rpm" -exec cp {} "$OUTPUT_DIR/codea-linux-x64.rpm" \;
ls -lh "$OUTPUT_DIR/codea-linux-x64.rpm"
;;
10)
build_target "vscode-linux-arm64" "Linux ARM64 Portable"
copy_output "/root/VSCode-linux-arm64" "codea-linux-arm64.tar.gz"
;;
11)
build_target "vscode-darwin-x64" "macOS x64"
copy_output "/root/VSCode-darwin-x64" "codea-darwin-x64.tar.gz"
;;
12)
build_target "vscode-darwin-arm64" "macOS ARM64"
copy_output "/root/VSCode-darwin-arm64" "codea-darwin-arm64.tar.gz"
;;
13)
echo -e "${YELLOW}Updating repository...${NC}"
cd "$REPO_DIR" && git pull
echo -e "${GREEN}Repository updated!${NC}"
;;
14)
echo -e "${YELLOW}Installing dependencies...${NC}"
cd "$REPO_DIR" && npm install --legacy-peer-deps
echo -e "${GREEN}Dependencies installed!${NC}"
;;
15)
echo -e "${YELLOW}Cleaning builds...${NC}"
rm -rf /root/VSCode-* "$REPO_DIR/.build" "$OUTPUT_DIR"/*
echo -e "${GREEN}Cleaned!${NC}"
;;
0)
echo "Goodbye!"
exit 0
;;
*)
echo -e "${RED}Invalid option!${NC}"
exit 1
;;
esac
echo ""
echo -e "${CYAN}==============================================${NC}"
echo -e "${GREEN}All builds available in: $OUTPUT_DIR${NC}"
IP=$(hostname -I | awk '{print $1}')
echo -e "${YELLOW}Download via: http://$IP:8080/${NC}"
echo -e "${CYAN}==============================================${NC}"
# Start HTTP server if not running
cd "$OUTPUT_DIR"
if ! pgrep -f "python3 -m http.server 8080" > /dev/null; then
nohup python3 -m http.server 8080 > /dev/null 2>&1 &
echo -e "${GREEN}HTTP server started on port 8080${NC}"
fi