-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathinstall_deps.sh
More file actions
93 lines (76 loc) · 2.2 KB
/
Copy pathinstall_deps.sh
File metadata and controls
93 lines (76 loc) · 2.2 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
#!/bin/bash
# Detect operating system and architecture
detect_platform() {
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$OS" in
linux)
case "$ARCH" in
x86_64) echo "linux-amd64" ;;
*) echo "unsupported" ;;
esac
;;
darwin)
case "$ARCH" in
x86_64) echo "mac-amd64" ;;
arm64) echo "mac-arm64" ;;
*) echo "unsupported" ;;
esac
;;
*)
echo "unsupported"
;;
esac
}
# Check if current directory is YASA-Engine root
check_directory() {
if [ ! -f "package.json" ]; then
echo "[ERROR] This script must be run from the root directory of the YASA-Engine repository."
echo "Please navigate to the YASA-Engine directory and try again."
exit 1
fi
}
# Download binary files
download_binaries() {
PLATFORM=$1
echo "[INFO] Downloading latest release binaries for platform: $PLATFORM..."
# Create target directories
mkdir -p deps/uast4go deps/uast4py
# Define binaries and target paths
BINARIES=("uast4go-$PLATFORM" "uast4py-$PLATFORM")
TARGET_PATHS=("deps/uast4go/uast4go" "deps/uast4py/uast4py")
for i in "${!BINARIES[@]}"; do
BINARY=${BINARIES[$i]}
TARGET=${TARGET_PATHS[$i]}
DOWNLOAD_URL="https://github.com/antgroup/YASA-UAST/releases/latest/download/${BINARY}"
echo "[INFO] Downloading $BINARY to $TARGET..."
# Download the binary
curl -L -f -o "$TARGET" "$DOWNLOAD_URL" || {
echo "[ERROR] Failed to download $BINARY";
exit 1;
}
# Make the binary executable
chmod +x "$TARGET"
done
}
# Main build process
main() {
echo "[INFO] Starting YASA-Engine build process..."
# Check if in the correct directory
check_directory
# Detect platform
PLATFORM=$(detect_platform)
if [ "$PLATFORM" = "unsupported" ]; then
echo "[ERROR] Unsupported platform: $(uname -s)-$(uname -m)"
exit 1
fi
echo "[INFO] Detected platform: $PLATFORM"
# Install dependencies
echo "[INFO] Installing dependencies..."
npm install || { echo "[ERROR] npm install failed"; exit 1; }
# Download binary files
echo "[INFO] Downloading required binaries..."
download_binaries "$PLATFORM"
echo "[INFO] Build completed successfully."
}
main "$@"