github.com/yggdrasil-network/yggdrasil-go@v0.5.6/contrib/mobile/build (about)

     1  #!/bin/sh
     2  
     3  set -ef
     4  
     5  [ ! -d contrib/mobile ] && (echo "Must run ./contrib/mobile/build [-i] [-a] from the repository top level folder"; exit 1)
     6  
     7  PKGSRC=${PKGSRC:-github.com/yggdrasil-network/yggdrasil-go/src/version}
     8  PKGNAME=${PKGNAME:-$(sh contrib/semver/name.sh)}
     9  PKGVER=${PKGVER:-$(sh contrib/semver/version.sh --bare)}
    10  
    11  LDFLAGS="-X $PKGSRC.buildName=$PKGNAME -X $PKGSRC.buildVersion=$PKGVER"
    12  ARGS="-v"
    13  
    14  while getopts "aitc:l:d" option
    15  do
    16    case "$option"
    17    in
    18    i) IOS=true;;
    19    a) ANDROID=true;;
    20    t) TABLES=true;;
    21    c) GCFLAGS="$GCFLAGS $OPTARG";;
    22    l) LDFLAGS="$LDFLAGS $OPTARG";;
    23    d) ARGS="$ARGS -tags debug" DEBUG=true;;
    24    esac
    25  done
    26  
    27  if [ -z $TABLES ] && [ -z $DEBUG ]; then
    28    LDFLAGS="$LDFLAGS -s -w"
    29  fi
    30  
    31  if [ ! $IOS ] && [ ! $ANDROID ]; then 
    32    echo "Must specify -a (Android), -i (iOS) or both"
    33    exit 1
    34  fi
    35  
    36  if [ $IOS ]; then
    37    echo "Building framework for iOS"
    38    go get golang.org/x/mobile/bind
    39    gomobile bind \
    40      -target ios,macos -tags mobile -o Yggdrasil.xcframework \
    41      -ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" \
    42      ./contrib/mobile ./src/config;
    43  fi
    44  
    45  if [ $ANDROID ]; then
    46    echo "Building aar for Android"
    47    go get golang.org/x/mobile/bind
    48    gomobile bind \
    49      -target android -tags mobile -o yggdrasil.aar \
    50      -ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" \
    51      ./contrib/mobile ./src/config;
    52  fi