forked from dfinity/nns-dapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·58 lines (49 loc) · 2.21 KB
/
build.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
#!/usr/bin/env bash
#
# The frontend is built into public/. The dapp is bundled into a tarball,
# assets.tar.xz. This tarball is baked into the wasm binary output at build
# time by cargo, and finally the wasm binary is read by ic-wasm and
# optimized. This scripts outputs a single file, nns-dapp.wasm.
#
# frontend◄─────────── assets.tar.xz
# ▲
# │
# │
# cargo build
# ▲
# │ ic-wasm shrink
# │
# nns-dapp.wasm
# ▲
# │ gzip
# │
# nns-dapp.wasm.gz
set -euo pipefail
TOPLEVEL="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# If the WASM has been provided, there is no need to build it:
[[ "${NNS_DAPP_WASM:-}" == "" ]] || {
test -f "${NNS_DAPP_WASM}" || {
echo "File not found, or node is not a file: NNS_DAPP_WASM='${NNS_DAPP_WASM}'"
exit 1
} >&2
INSTALL_LOCATION="$(jq -r '.canisters["nns-dapp"].wasm' dfx.json)"
[[ "$(realpath "${NNS_DAPP_WASM}")" == "$(realpath "${INSTALL_LOCATION}")" ]] ||
cp "${NNS_DAPP_WASM}" "${INSTALL_LOCATION}"
echo "Skipping build as the WASM file has already been provided."
exit 0
}
# Need to know which deployment we are building for:
. "$TOPLEVEL/scripts/require-dfx-network.sh"
# Can we skip this here because build-frontend.sh now does it?
# Or do we need the exports for the backend as well?
# Assemble the configuration
./config.sh
set -x
###################
# frontend # (output: assets.tar.xz)
###################
"$TOPLEVEL/build-frontend.sh"
###############
# backend # (output: nns-dapp.wasm.gz)
###############
"$TOPLEVEL/build-backend.sh"