github.com/qjfoidnh/BaiduPCS-Go@v0.0.0-20231011165705-caa18a3765f3/build.sh (about) 1 #!/bin/sh 2 3 name="BaiduPCS-Go" 4 version=$1 5 6 if [ "$1" = "" ]; then 7 version=v3.7.1 8 fi 9 10 output="out" 11 12 old_golang() { 13 GOROOT=/usr/local/go 14 go=$GOROOT/bin/go 15 } 16 17 new_golang() { 18 GOROOT=/usr/local/go 19 go=$GOROOT/bin/go 20 } 21 22 Build() { 23 old_golang 24 goarm=$4 25 if [ "$4" = "" ]; then 26 goarm=7 27 fi 28 29 echo "Building $1..." 30 export GOOS=$2 GOARCH=$3 GO386=sse2 CGO_ENABLED=0 GOARM=$4 31 if [ $2 = "windows" ]; then 32 goversioninfo -o=resource_windows_386.syso 33 goversioninfo -64 -o=resource_windows_amd64.syso 34 $go build -ldflags "-X main.Version=$version -s -w" -o "$output/$1/$name.exe" 35 RicePack $1 $name.exe 36 else 37 $go build -ldflags "-X main.Version=$version -s -w" -o "$output/$1/$name" 38 RicePack $1 $name 39 fi 40 41 Pack $1 42 } 43 44 AndroidBuild() { 45 new_golang 46 echo "Building $1..." 47 export GOOS=$2 GOARCH=$3 GOARM=$4 CGO_ENABLED=1 48 go build -ldflags "-X main.Version=$version -s -w -linkmode=external -extldflags=-pie" -o "$output/$1/$name" 49 50 RicePack $1 $name 51 Pack $1 52 } 53 54 IOSBuild() { 55 old_golang 56 echo "Building $1..." 57 mkdir -p "$output/$1" 58 cd "$output/$1" 59 export CC=/usr/local/go/misc/ios/clangwrap.sh GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1 60 $go build -ldflags "-X main.Version=$version -s -w" -o "armv7" github.com/qjfoidnh/BaiduPCS-Go 61 jtool --sign --inplace --ent ../../entitlements.xml "armv7" 62 export GOARCH=arm64 63 $go build -ldflags "-X main.Version=$version -s -w" -o "arm64" github.com/qjfoidnh/BaiduPCS-Go 64 jtool --sign --inplace --ent ../../entitlements.xml "arm64" 65 lipo -create "armv7" "arm64" -output $name # merge 66 rm "armv7" "arm64" 67 cd ../.. 68 RicePack $1 $name 69 Pack $1 70 } 71 72 # zip 打包 73 Pack() { 74 cp README.md "$output/$1" 75 76 cd $output 77 zip -q -r "$1.zip" "$1" 78 79 # 删除 80 rm -rf "$1" 81 82 cd .. 83 } 84 85 # rice 打包静态资源 86 RicePack() { 87 return # 已取消web功能 88 rice -i github.com/qjfoidnh/BaiduPCS-Go/internal/pcsweb append --exec "$output/$1/$2" 89 } 90 91 touch ./vendor/golang.org/x/sys/windows/windows.s 92 93 # Android 94 #export NDK_INSTALL=$ANDROID_NDK_ROOT/bin 95 # CC=$NDK_INSTALL/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-gcc AndroidBuild $name-$version"-android-16-armv5" android arm 5 96 # CC=$NDK_INSTALL/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-gcc AndroidBuild $name-$version"-android-16-armv6" android arm 6 97 #CC=$NDK_INSTALL/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-gcc AndroidBuild $name-$version"-android-16-armv7" android arm 7 98 #CC=$NDK_INSTALL/aarch64-linux-android-4.9/bin/aarch64-linux-android-gcc AndroidBuild $name-$version"-android-21-arm64" android arm64 7 99 #CC=$NDK_INSTALL/i686-linux-android-4.9/bin/i686-linux-android-gcc AndroidBuild $name-$version"-android-16-386" android 386 7 100 #CC=$NDK_INSTALL/x86_64-linux-android-4.9/bin/x86_64-linux-android-gcc AndroidBuild $name-$version"-android-21-amd64" android amd64 7 101 102 # iOS 103 #IOSBuild $name-$version"-darwin-ios-arm" 104 105 # OS X / macOS 106 Build $name-$version"-darwin-osx-amd64" darwin amd64 107 Build $name-$version"-darwin-osx-arm64" darwin arm64 108 # Build $name-$version"-darwin-osx-386" darwin 386 109 110 # Windows 111 Build $name-$version"-windows-x86" windows 386 112 Build $name-$version"-windows-x64" windows amd64 113 Build $name-$version"-windows-arm" windows arm 114 115 # Linux 116 Build $name-$version"-linux-386" linux 386 117 Build $name-$version"-linux-amd64" linux amd64 118 #Build $name-$version"-linux-armv5" linux arm 5 119 Build $name-$version"-linux-arm" linux arm 120 Build $name-$version"-linux-arm64" linux arm64 121 GOMIPS=softfloat Build $name-$version"-linux-mips" linux mips 122 Build $name-$version"-linux-mips64" linux mips64 123 GOMIPS=softfloat Build $name-$version"-linux-mipsle" linux mipsle 124 Build $name-$version"-linux-mips64le" linux mips64le 125 # Build $name-$version"-linux-ppc64" linux ppc64 126 # Build $name-$version"-linux-ppc64le" linux ppc64le 127 # Build $name-$version"-linux-s390x" linux s390x 128 129 # Others 130 # Build $name-$version"-solaris-amd64" solaris amd64 131 Build $name-$version"-freebsd-386" freebsd 386 132 Build $name-$version"-freebsd-amd64" freebsd amd64 133 # Build $name-$version"-freebsd-arm" freebsd arm 134 # Build $name-$version"-netbsd-386" netbsd 386 135 # Build $name-$version"-netbsd-amd64" netbsd amd64 136 # Build $name-$version"-netbsd-arm" netbsd arm 137 # Build $name-$version"-openbsd-386" openbsd 386 138 # Build $name-$version"-openbsd-amd64" openbsd amd64 139 # Build $name-$version"-openbsd-arm" openbsd arm 140 # Build $name-$version"-plan9-386" plan9 386 141 # Build $name-$version"-plan9-amd64" plan9 amd64 142 # Build $name-$version"-plan9-arm" plan9 arm 143 # Build $name-$version"-nacl-386" nacl 386 144 # Build $name-$version"-nacl-amd64p32" nacl amd64p32 145 # Build $name-$version"-nacl-arm" nacl arm 146 # Build $name-$version"-dragonflybsd-amd64" dragonfly amd64