-
Notifications
You must be signed in to change notification settings - Fork 3
/
bootstrap.sh
executable file
·66 lines (57 loc) · 1.71 KB
/
bootstrap.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
#!/bin/bash
set -e
# Clean.
rm -rf ./build
rm -rf ./build-wasm
rm -rf ./src/wasi-sdk-*
# Clean barretenberg.
rm -rf ./barretenberg/cpp/build
rm -rf ./barretenberg/cpp/build-wasm
rm -rf ./barretenberg/cpp/src/wasi-sdk-*
# Install formatting git hook.
HOOKS_DIR=$(git rev-parse --git-path hooks)
echo "cd \$(git rev-parse --show-toplevel)/aztec-connect-cpp && ./format.sh staged" > $HOOKS_DIR/pre-commit
chmod +x $HOOKS_DIR/pre-commit
# Determine system.
if [[ "$OSTYPE" == "darwin"* ]]; then
OS=macos
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
OS=linux
else
echo "Unknown OS: $OSTYPE"
exit 1
fi
# Download ignition transcripts.
(cd ./barretenberg/cpp/srs_db && ./download_ignition.sh 3)
# Pick native toolchain file.
if [ "$OS" == "macos" ]; then
export BREW_PREFIX=$(brew --prefix)
# Ensure we have toolchain.
if [ ! "$?" -eq 0 ] || [ ! -f "$BREW_PREFIX/opt/llvm/bin/clang++" ]; then
echo "Default clang not sufficient. Install homebrew, and then: brew install llvm libomp clang-format"
exit 1
fi
ARCH=$(uname -m)
if [ "$ARCH" = "arm64" ]; then
TOOLCHAIN=arm-apple-clang
else
TOOLCHAIN=x86_64-apple-clang
fi
else
TOOLCHAIN=x86_64-linux-clang
fi
# Build native.
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=RelWithAssert -DTOOLCHAIN=$TOOLCHAIN ..
cmake --build . --parallel ${@/#/--target }
cd ..
# Install the webassembly toolchain.
WASI_VERSION=12
cd ./src
curl -s -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_VERSION/wasi-sdk-$WASI_VERSION.0-$OS.tar.gz | tar zxfv -
cd ..
# Build WASM.
mkdir -p build-wasm && cd build-wasm
cmake -DTOOLCHAIN=wasm-linux-clang ..
cmake --build . --parallel --target aztec-connect.wasm
cd ..