Skip to content

Commit

Permalink
add windows cross-build tool chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarak Ben Youssef committed Feb 21, 2024
1 parent 93cba0c commit fd673c6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
# build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
goos: [ linux, windows ]
goos: [ windows ]
goarch: [ amd64, arm64 ]
exclude:
- goarch: arm64
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ generate: install-tools
.PHONY: install-cross-build-tools
install-cross-build-tools:
if [ "$(UNAME)" = "Debian" ] ; then \
apt-get update && apt-get -y install apt-utils gcc-aarch64-linux-gnu ; \
apt-get update && apt-get -y install apt-utils gcc-aarch64-linux-gnu gcc-mingw-w64-x86-64 ; \
elif [ "$(UNAME)" = "Linux" ] ; then \
apt-get update && apt-get -y install apt-utils gcc-aarch64-linux-gnu ; \
apt-get update && apt-get -y install apt-utils gcc-aarch64-linux-gnu gcc-mingw-w64-x86-64 ; \
else \
echo "this target only works on Debian or Linux, host runs on" $(UNAME) ; \
fi
Expand Down
27 changes: 22 additions & 5 deletions pre_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,34 @@
# Exit as soon as any command fails
set -e

# INPUT_GOARCH is a variable set by the wangyoucao577 action
# 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 [ "${INPUT_GOARCH}" = "arm64" ]; then
C_COMP="aarch64-linux-gnu-gcc"
elif [ "${INPUT_GOARCH}" = "amd64" ]; then
C_COMP="x86_64-linux-gnu-gcc"
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="gcc-mingw-w64-x86-64"
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__"\"

0 comments on commit fd673c6

Please sign in to comment.