mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-12-27 10:17:47 +00:00
d6fd305f12
The `github.com/wlynxg/anet` library depends on the `//go:linkname` linker feature [1]. However, since Go 1.23.0, the usage of `//go:linkname` has been restricted [2]. And now it's necessary to explicitly specify `-checklinkname=0` linker flag to use it. [1] https://github.com/wlynxg/anet/blob/main/README.md#how-to-build-with-go-1230-or-later [2] https://tip.golang.org/doc/go1.23#linker Resolves: #1165
63 lines
1.6 KiB
Bash
Executable File
63 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -ef
|
|
|
|
[ ! -d contrib/mobile ] && (echo "Must run ./contrib/mobile/build [-i] [-a] from the repository top level folder"; exit 1)
|
|
|
|
PKGSRC=${PKGSRC:-github.com/yggdrasil-network/yggdrasil-go/src/version}
|
|
PKGNAME=${PKGNAME:-$(sh contrib/semver/name.sh)}
|
|
PKGVER=${PKGVER:-$(sh contrib/semver/version.sh --bare)}
|
|
GOVER=$(go version | { read _ _ version _; echo ${version#go}; })
|
|
|
|
LDFLAGS="-X $PKGSRC.buildName=$PKGNAME -X $PKGSRC.buildVersion=$PKGVER"
|
|
ARGS="-v"
|
|
|
|
while getopts "aitc:l:d" option
|
|
do
|
|
case "$option"
|
|
in
|
|
i) IOS=true;;
|
|
a) ANDROID=true;;
|
|
t) TABLES=true;;
|
|
c) GCFLAGS="$GCFLAGS $OPTARG";;
|
|
l) LDFLAGS="$LDFLAGS $OPTARG";;
|
|
d) ARGS="$ARGS -tags debug" DEBUG=true;;
|
|
esac
|
|
done
|
|
|
|
if [ -z $TABLES ] && [ -z $DEBUG ]; then
|
|
LDFLAGS="$LDFLAGS -s -w"
|
|
fi
|
|
|
|
if [ ! $IOS ] && [ ! $ANDROID ]; then
|
|
echo "Must specify -a (Android), -i (iOS) or both"
|
|
exit 1
|
|
fi
|
|
|
|
ver_le() {
|
|
printf "$1\n$2\n" | sort -VC
|
|
}
|
|
|
|
if [ $ANDROID ] && ver_le 1.23.0 $GOVER ; then
|
|
# github.com/wlynxg/anet library relies on //go:linkname
|
|
LDFLAGS="$LDFLAGS -checklinkname=0"
|
|
fi
|
|
|
|
if [ $IOS ]; then
|
|
echo "Building framework for iOS"
|
|
go get golang.org/x/mobile/bind
|
|
gomobile bind \
|
|
-target ios,macos -tags mobile -o Yggdrasil.xcframework \
|
|
-ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" \
|
|
./contrib/mobile ./src/config;
|
|
fi
|
|
|
|
if [ $ANDROID ]; then
|
|
echo "Building aar for Android"
|
|
go get golang.org/x/mobile/bind
|
|
gomobile bind \
|
|
-target android -tags mobile -o yggdrasil.aar \
|
|
-ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" \
|
|
./contrib/mobile ./src/config;
|
|
fi
|