forked from onflow/flow-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre_build.sh
36 lines (29 loc) · 995 Bytes
/
pre_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
#!/bin/sh
# Exit as soon as any command fails
set -e
# INPUT_GOARCH and INPUT_GOOS are set by the wangyoucao577 action:
# https://github.com/wangyoucao577/go-release-action/blob/v1.40/action.yml#L109
# it represents the target arch and target os
export GOOS=${INPUT_GOOS}
export GOARCH=${INPUT_GOARCH}
C_COMP=""
if [ "${GOOS}" = "linux" ]; then
if [ "${GOARCH}" = "arm64" ]; then
C_COMP="aarch64-linux-gnu-gcc"
elif [ "${GOARCH}" = "amd64" ]; then
C_COMP="x86_64-linux-gnu-gcc"
fi
elif [ "${GOOS}" = "windows" ]; then
if [ "${GOARCH}" = "amd64" ]; then
C_COMP="x86_64-w64-mingw32-gcc"
else
{ echo "arm64 on windows isn't supported"; exit 1; }
fi
fi
export GO111MODULE=on
# enable CGO because it is requiired by the onflow/crypto package
export CGO_ENABLED=1
# set the correct C compiler
export CC=${C_COMP}
# this flag disables non-portable code that requires specific CPU features.
export CGO_FLAGS=\""-O2 -D__BLST_PORTABLE__"\"