-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.sh
81 lines (70 loc) · 2.06 KB
/
compile.sh
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
#!/bin/bash
# Check if deno is installed
if ! command -v deno &> /dev/null
then
# Install deno
echo -e "\033[33mDeno is not installed. Installing...\033[0m"
curl -fsSL https://deno.land/x/install/install.sh | sh
fi
# If no parameters are passed, print the help message
if [ $# -eq 0 ]; then
echo "Usage: compile [windows|linux|macos|all]"
exit 1
else
platform=$1
fi
# Create a new directory for the build output if it doesn't exist
if [ ! -d "build" ]; then
mkdir "build"
fi
# Create vars
sourcedir="./src"
compileflags=""
# Compile the project
# Windows:
if [ "$platform" = "windows" ]; then
# remove the old build if it exists
if [ -d "./build/windows" ]; then
rm -rf "./build/windows"
fi
compileflags="x86_64-pc-windows-msvc"
fi
# Linux:
if [ "$platform" = "linux" ]; then
# remove the old build if it exists
if [ -d "./build/linux" ]; then
rm -rf "./build/linux"
fi
compileflags="x86_64-unknown-linux-gnu"
fi
# MacOS:
if [ "$platform" = "macos" ]; then
# remove the old build if it exists
if [ -d "./build/macos" ]; then
rm -rf "./build/macos"
fi
compileflags="x86_64-apple-darwin"
fi
# All:
if [ "$platform" = "all" ]; then
# remove the old builds if it exists
if [ -d "./build/windows" ]; then
rm -rf "./build/windows"
fi
if [ -d "./build/linux" ]; then
rm -rf "./build/linux"
fi
if [ -d "./build/macos" ]; then
rm -rf "./build/macos"
fi
deno compile --allow-all --target x86_64-pc-windows-msvc -o "./build/windows/demi.exe" "./$sourcedir/main.ts"
deno compile --allow-all --target x86_64-unknown-linux-gnu -o "./build/linux/demi" "./$sourcedir/main.ts"
deno compile --allow-all --target x86_64-apple-darwin -o "./build/macos/demi" "./$sourcedir/main.ts"
echo -e "\033[32mCompilation Complete!\033[0m"
exit
else
deno compile --allow-all --target $compileflags -o "./build/$platform/demi" "$sourcedir/main.ts"
# Print Completion Message in Green
echo -e "\033[32mCompilation Complete!\033[0m"
exit 0
fi