-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-function.sh
executable file
·70 lines (61 loc) · 2.25 KB
/
build-function.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
#!/bin/sh
kernel="$(uname)"
arch="$(uname -m)"
linker="x86_64-linux-gnu-gcc"
rustflags=""
case $kernel in
Linux)
echo "OS: Linux\nArch: ${arch}\nLinker: ${linker}"
sudo apt install build-essential -y
sudo apt install musl-tools -y
if [ "${arch}" = "aarch64" ]; then
export CC_x86_64_unknown_linux_musl=${linker}
sudo apt install gcc-x86-64-linux-gnu -y
fi
;;
Darwin)
if [ "${arch}" = "x86_64" ]; then
if [ "$(sysctl -n sysctl.proc_translated)" = "1" ]; then
linker="x86_64-linux-musl-gcc"
echo "OS: Mac M1 using Rosetta\nArch: ${arch}\nLinker: ${linker}"
echo "Mac M1 using Rosetta currently WiP... Exiting"
exit 1
# pretty sure this should work akin to normal x86_64, but not sure
# brew install FiloSottile/musl-cross/musl-cross
# ln -s /usr/local/bin/${linker} /usr/local/bin/musl-gcc
else
linker="x86_64-linux-musl-gcc"
echo "OS: Mac Intel\nArch: ${arch}\nLinker: ${linker}"
brew install FiloSottile/musl-cross/musl-cross
ln -s /usr/local/bin/${linker} /usr/local/bin/musl-gcc
fi
elif [ "${arch}" = "arm64" ]; then
linker="x86_64-unknown-linux-gnu-gcc"
echo "OS: Mac M1\nArch: ${arch}\nLinker: ${linker}"
brew tap messense/macos-cross-toolchains
brew install x86_64-unknown-linux-gnu
export CC_x86_64_unknown_linux_musl=${linker}
fi
;;
*)
echo "Unknown System: ${kernel} ${arch}"
echo "Exiting..."
exit 1
;;
esac
echo "Adding rustup target"
rustup target add x86_64-unknown-linux-musl
echo "Creating .cargo/config"
mkdir -p .cargo
echo "[target.x86_64-unknown-linux-musl]\nlinker = \"${linker}\"${rustflags}" > .cargo/config
echo "Creating resources/.cargo/config"
mkdir -p ./resources/.cargo
cp -r .cargo ./resources
echo "Building Project"
cd resources
cargo build --release --target x86_64-unknown-linux-musl
(cd target/x86_64-unknown-linux-musl/release && mkdir -p lambda && cp bootstrap lambda/)
echo "NPM Install"
npm install
echo "NPM Run Build"
npm run build