mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
Clean and add gobin select
This commit is contained in:
73
build-all.sh
73
build-all.sh
@@ -1,40 +1,5 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# GoLang cross-compile snippet for Go 1.6+ based loosely on Dave Chaney's cross-compile script:
|
||||
# http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go
|
||||
#
|
||||
# To use:
|
||||
#
|
||||
# $ cd ~/path-to/my-awesome-project
|
||||
# $ go-build-all
|
||||
#
|
||||
# Features:
|
||||
#
|
||||
# * Cross-compiles to multiple machine types and architectures.
|
||||
# * Uses the current directory name as the output name...
|
||||
# * ...unless you supply an source file: $ go-build-all main.go
|
||||
# * Windows binaries are named .exe.
|
||||
# * ARM v5, v6, v7 and v8 (arm64) support
|
||||
#
|
||||
# ARM Support:
|
||||
#
|
||||
# You must read https://github.com/golang/go/wiki/GoArm for the specifics of running
|
||||
# Linux/BSD-style kernels and what kernel modules are needed for the target platform.
|
||||
# While not needed for cross-compilation of this script, you're users will need to ensure
|
||||
# the correct modules are included.
|
||||
#
|
||||
# Requirements:
|
||||
#
|
||||
# * GoLang 1.6+ (for mips and ppc), 1.5 for non-mips/ppc.
|
||||
# * CD to directory of the binary you are compiling. $PWD is used here.
|
||||
#
|
||||
# For 1.4 and earlier, see http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go
|
||||
#
|
||||
|
||||
# This PLATFORMS list is refreshed after every major Go release.
|
||||
# Though more platforms may be supported (freebsd/386), they have been removed
|
||||
# from the standard ports/downloads and therefore removed from this list.
|
||||
#
|
||||
PLATFORMS=""
|
||||
PLATFORMS="$PLATFORMS darwin/amd64" # amd64 only as of go1.5
|
||||
PLATFORMS="$PLATFORMS windows/amd64 windows/386" # arm compilation not available for Windows
|
||||
@@ -49,21 +14,6 @@ PLATFORMS="$PLATFORMS freebsd/amd64"
|
||||
# PLATFORMS="$PLATFORMS plan9/amd64 plan9/386" # as of go1.4
|
||||
# PLATFORMS="$PLATFORMS solaris/amd64" # as of go1.3
|
||||
|
||||
# ARMBUILDS lists the platforms that are currently supported. From this list
|
||||
# we generate the following architectures:
|
||||
#
|
||||
# ARM64 (aka ARMv8) <- only supported on linux and darwin builds (go1.6)
|
||||
# ARMv7
|
||||
# ARMv6
|
||||
# ARMv5
|
||||
#
|
||||
# Some words of caution from the master:
|
||||
#
|
||||
# @dfc: you'll have to use gomobile to build for darwin/arm64 [and others]
|
||||
# @dfc: that target expects that you're bulding for a mobile phone
|
||||
# @dfc: iphone 5 and below, ARMv7, iphone 3 and below ARMv6, iphone 5s and above arm64
|
||||
#
|
||||
# PLATFORMS_ARM="linux freebsd netbsd"
|
||||
PLATFORMS_ARM="linux"
|
||||
|
||||
##############################################################
|
||||
@@ -73,6 +23,9 @@ PLATFORMS_ARM="linux"
|
||||
type setopt >/dev/null 2>&1
|
||||
|
||||
export GOPATH="${PWD}"
|
||||
GOBIN="/usr/local/go_111/bin/go"
|
||||
|
||||
$GOBIN version
|
||||
|
||||
SCRIPT_NAME=$(basename "$0")
|
||||
FAILURES=""
|
||||
@@ -86,9 +39,9 @@ for PLATFORM in $PLATFORMS; do
|
||||
BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}"
|
||||
if [[ "${GOOS}" == "windows" ]]; then BIN_FILENAME="${BIN_FILENAME}.exe"; fi
|
||||
if [[ "${GOOS}" == "linux" ]]; then
|
||||
CMD="CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -o ${BIN_FILENAME} main"
|
||||
CMD="CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} ${GOBIN} build -o ${BIN_FILENAME} main"
|
||||
else
|
||||
CMD="GOOS=${GOOS} GOARCH=${GOARCH} go build -o ${BIN_FILENAME} main"
|
||||
CMD="GOOS=${GOOS} GOARCH=${GOARCH} ${GOBIN} build -o ${BIN_FILENAME} main"
|
||||
fi
|
||||
echo "${CMD}"
|
||||
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
|
||||
@@ -96,7 +49,7 @@ done
|
||||
|
||||
# ARM builds
|
||||
if [[ $PLATFORMS_ARM == *"linux"* ]]; then
|
||||
CMD="GOOS=linux GOARCH=arm64 go build -o ${OUTPUT}-linux-arm64 main"
|
||||
CMD="GOOS=linux GOARCH=arm64 ${GOBIN} build -o ${OUTPUT}-linux-arm64 main"
|
||||
echo "${CMD}"
|
||||
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
|
||||
fi
|
||||
@@ -106,7 +59,7 @@ for GOOS in $PLATFORMS_ARM; do
|
||||
# build for each ARM version
|
||||
for GOARM in 7 6 5; do
|
||||
BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}${GOARM}"
|
||||
CMD="GOARM=${GOARM} GOOS=${GOOS} GOARCH=${GOARCH} go build -o ${BIN_FILENAME} main"
|
||||
CMD="GOARM=${GOARM} GOOS=${GOOS} GOARCH=${GOARCH} ${GOBIN} build -o ${BIN_FILENAME} main"
|
||||
echo "${CMD}"
|
||||
eval "${CMD}" || FAILURES="${FAILURES} ${GOOS}/${GOARCH}${GOARM}"
|
||||
done
|
||||
@@ -123,6 +76,10 @@ export CGO_ENABLED=1
|
||||
export GOOS=android
|
||||
export LDFLAGS="-s -w"
|
||||
|
||||
# GOBIN="/usr/local/go_111/bin/go"
|
||||
|
||||
$GOBIN version
|
||||
|
||||
export NDK_TOOLCHAIN=$GOPATH/toolchains
|
||||
export CC=$NDK_TOOLCHAIN/bin/armv7a-linux-androideabi21-clang
|
||||
export CXX=$NDK_TOOLCHAIN/bin/armv7a-linux-androideabi21-clang++
|
||||
@@ -130,7 +87,7 @@ export GOARCH=arm
|
||||
export GOARM=7
|
||||
BIN_FILENAME="dist/TorrServer-${GOOS}-${GOARCH}${GOARM}"
|
||||
echo "Android ${BIN_FILENAME}"
|
||||
go build -ldflags="${LDFLAGS}" -o ${BIN_FILENAME} main
|
||||
${GOBIN} build -ldflags="${LDFLAGS}" -o ${BIN_FILENAME} main
|
||||
|
||||
export CC=$NDK_TOOLCHAIN/bin/aarch64-linux-android21-clang
|
||||
export CXX=$NDK_TOOLCHAIN/bin/aarch64-linux-android21-clang++
|
||||
@@ -138,7 +95,7 @@ export GOARCH=arm64
|
||||
export GOARM=""
|
||||
BIN_FILENAME="dist/TorrServer-${GOOS}-${GOARCH}${GOARM}"
|
||||
echo "Android ${BIN_FILENAME}"
|
||||
go build -ldflags="${LDFLAGS}" -o ${BIN_FILENAME} main
|
||||
${GOBIN} build -ldflags="${LDFLAGS}" -o ${BIN_FILENAME} main
|
||||
|
||||
export CC=$NDK_TOOLCHAIN/bin/i686-linux-android21-clang
|
||||
export CXX=$NDK_TOOLCHAIN/bin/i686-linux-android21-clang++
|
||||
@@ -146,7 +103,7 @@ export GOARCH=386
|
||||
export GOARM=""
|
||||
BIN_FILENAME="dist/TorrServer-${GOOS}-${GOARCH}${GOARM}"
|
||||
echo "Android ${BIN_FILENAME}"
|
||||
go build -ldflags="${LDFLAGS}" -o ${BIN_FILENAME} main
|
||||
${GOBIN} build -ldflags="${LDFLAGS}" -o ${BIN_FILENAME} main
|
||||
|
||||
export CC=$NDK_TOOLCHAIN/bin/x86_64-linux-android21-clang
|
||||
export CXX=$NDK_TOOLCHAIN/bin/x86_64-linux-android21-clang++
|
||||
@@ -154,6 +111,6 @@ export GOARCH=amd64
|
||||
export GOARM=""
|
||||
BIN_FILENAME="dist/TorrServer-${GOOS}-${GOARCH}${GOARM}"
|
||||
echo "Android ${BIN_FILENAME}"
|
||||
go build -ldflags="${LDFLAGS}" -o ${BIN_FILENAME} main
|
||||
${GOBIN} build -ldflags="${LDFLAGS}" -o ${BIN_FILENAME} main
|
||||
|
||||
# ./compile.sh
|
||||
|
||||
Reference in New Issue
Block a user