nekoray_Mahdi-zarei/script/build_go.sh
Mahdi 2dde7dbb2e
Migrate to protorpc (#598)
* refactor: migrate from grpc to protorpc

* fix

* fix

* fix

* cleanup

* Update mainwindow_grpc.cpp

* Update RPC.cpp

* fix

---------

Co-authored-by: parhelia512 <0011d3@gmail.com>
2025-08-02 03:19:32 -07:00

47 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
set -e
source script/env_deploy.sh
[ "$GOOS" == "windows" ] && [ "$GOARCH" == "amd64" ] && DEST=$DEPLOYMENT/windows64 || true
[ "$GOOS" == "windows" ] && [ "$GOARCH" == "386" ] && DEST=$DEPLOYMENT/windows32 || true
[ "$GOOS" == "windows" ] && [ "$GOARCH" == "arm64" ] && DEST=$DEPLOYMENT/windows-arm64 || true
[ "$GOOS" == "linux" ] && [ "$GOARCH" == "amd64" ] && DEST=$DEPLOYMENT/linux-amd64 || true
[ "$GOOS" == "linux" ] && [ "$GOARCH" == "arm64" ] && DEST=$DEPLOYMENT/linux-arm64 || true
[ "$GOOS" == "darwin" ] && [ "$GOARCH" == "amd64" ] && DEST=$DEPLOYMENT/macos-amd64 || true
[ "$GOOS" == "darwin" ] && [ "$GOARCH" == "arm64" ] && DEST=$DEPLOYMENT/macos-arm64 || true
if [[ "$GOOS" == "windowslegacy" ]]; then
GOOS="windows"
GOCMD="$PWD/go/bin/go"
if [[ $GOARCH == 'amd64' ]]; then
DEST=$DEPLOYMENT/windowslegacy64
else
DEST=$DEPLOYMENT/windows32
fi
else
GOCMD="go"
fi
if [ -z $DEST ]; then
echo "Please set GOOS GOARCH"
exit 1
fi
rm -rf $DEST
mkdir -p $DEST
export CGO_ENABLED=0
#### Go: updater ####
pushd core/updater
[ "$GOOS" == "darwin" ] || $GOCMD build -o $DEST -trimpath -ldflags "-w -s"
popd
#### Go: core ####
pushd core/server
pushd gen
protoc -I . --go_out=. --protorpc_out=. libcore.proto
popd
VERSION_SINGBOX=$(go list -m -f '{{.Version}}' github.com/sagernet/sing-box)
$GOCMD build -v -o $DEST -trimpath -ldflags "-w -s -X 'github.com/sagernet/sing-box/constant.Version=${VERSION_SINGBOX}'" -tags "with_clash_api,with_gvisor,with_quic,with_wireguard,with_utls,with_ech,with_dhcp"
popd