forked from AztecProtocol/aztec-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·78 lines (65 loc) · 2.48 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
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Usage:
# Bootstraps the repo. End to end tests should be runnable after a bootstrap:
# ./bootstrap.sh
# Run a second time to perform a "light bootstrap", rebuilds code that's changed:
# ./bootstrap.sh
# Force a clean of the repo before performing a full bootstrap, erases untracked files, be careful!
# ./bootstrap.sh clean
set -eu
export CMD=${1:-}
cd "$(dirname "$0")"
# Bump this number to force a full bootstrap.
VERSION=1
# Remove all untracked files and directories.
if [ -n "$CMD" ]; then
if [ "$CMD" = "clean" ]; then
echo "WARNING: This will erase *all* untracked files, including hooks and submodules."
echo -n "Continue? [y/n] "
read user_input
if [ "$user_input" != "y" ] && [ "$user_input" != "Y" ]; then
exit 1
fi
rm -f .bootstrapped
rm -rf .git/hooks/*
rm -rf .git/modules/*
git clean -fd
for SUBMODULE in $(git config --file .gitmodules --get-regexp path | awk '{print $2}'); do
rm -rf $SUBMODULE
done
else
echo "Unknown command: $CLEAN"
exit 1
fi
fi
if [ ! -f ~/.nvm/nvm.sh ]; then
echo "Nvm not found at ~/.nvm"
exit 1
fi
# Install pre-commit git hooks.
HOOKS_DIR=$(git rev-parse --git-path hooks)
echo "(cd barretenberg/cpp && ./format.sh staged)" > $HOOKS_DIR/pre-commit
echo "(cd circuits/cpp && ./format.sh staged)" >> $HOOKS_DIR/pre-commit
# TODO: Call cci_gen to ensure .circleci/config.yml is up-to-date!
chmod +x $HOOKS_DIR/pre-commit
git submodule update --init --recursive
# Lightweight bootstrap. Run `./bootstrap.sh clean` to bypass.
# TODO: We shouldn't do this here. We should call each projects bootstrap script and it should decide between light/heavy.
if [[ -f .bootstrapped && $(cat .bootstrapped) -eq "$VERSION" ]]; then
echo -e '\033[1mRebuild L1 contracts...\033[0m'
(cd l1-contracts && .foundry/bin/forge build)
echo -e '\n\033[1mUpdate npm deps...\033[0m'
(cd yarn-project && yarn install)
echo -e '\n\033[1mRebuild Noir contracts...\033[0m'
(cd yarn-project/noir-contracts && yarn noir:build:all 2> /dev/null)
echo -e '\n\033[1mRebuild barretenberg wasm...\033[0m'
(cd barretenberg/cpp && cmake --build --preset default && cmake --build --preset wasm && cmake --build --preset wasm-threads)
echo -e '\n\033[1mRebuild circuits wasm...\033[0m'
(cd circuits/cpp && cmake --build --preset wasm -j --target aztec3-circuits.wasm)
else
# Heavy bootstrap.
barretenberg/cpp/bootstrap.sh
circuits/cpp/bootstrap.sh
yarn-project/bootstrap.sh
echo $VERSION > .bootstrapped
fi