-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzig.sh
75 lines (50 loc) · 1.64 KB
/
zig.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
#!/usr/bin/env bash
set -euo pipefail
if [[ $(uname) == "Darwin" ]]; then
parent_dir=$(
dirname "$(realpath ${BASH_SOURCE[0]})"
)
# find the node_modules directory and cd to it
if [[ $parent_dir == *"node_modules"* ]]; then
while [[ ! -d "$parent_dir/node_modules" ]]; do
if [[ "$parent_dir" == "/" ]]; then
echo "Could not find node_modules directory"
exit 1
fi
parent_dir=$(dirname "$parent_dir")
done
fi
if [[ $(uname -m) == "arm64" ]]; then
$parent_dir/node_modules/@oven/zig-darwin-arm64/zig "$@"
else
$parent_dir/node_modules/@oven/zig-darwin-x64/zig "$@"
fi
elif [[ $(uname) == "Linux" ]]; then
parent_dir=$(
dirname "$(realpath ${BASH_SOURCE[0]})"
)
# find the node_modules directory and cd to it
if [[ $parent_dir == *"node_modules"* ]]; then
while [[ ! -d "$parent_dir/node_modules" ]]; do
if [[ "$parent_dir" == "/" ]]; then
echo "Could not find node_modules directory"
exit 1
fi
parent_dir=$(dirname "$parent_dir")
done
fi
if [[ $(uname -m) == "aarch64" ]]; then
$parent_dir/node_modules/@oven/zig-linux-arm64/zig "$@"
else
$parent_dir/node_modules/@oven/zig-linux-x64/zig "$@"
fi
elif [[ $(uname) == "Windows" ]]; then
if [[ $(uname -m) == "x86_64" ]]; then
$parent_dir/node_modules/@oven/zig-win32-x64/zig.exe "$@"
else
$parent_dir/node_modules/@oven/zig-win32-x86/zig.exe "$@"
fi
else
echo "Unsupported platform"
exit 1
fi