Skip to content

Commit

Permalink
add lib build script
Browse files Browse the repository at this point in the history
  • Loading branch information
matteriot committed Aug 26, 2023
1 parent 4ec847e commit b5c4a9e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/gateway-go
/*.log
/cn-hk.yaml
/build/
Empty file added lib/build.sh
Empty file.
4 changes: 4 additions & 0 deletions lib/builddll.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
::for build windows dll
echo "building windows dll"
SET CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ GOOS=windows GOARCH=amd64
go build -o ./build/amd64/windows/gateway.dll -buildmode=c-shared
18 changes: 18 additions & 0 deletions lib/builddylib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#for build MacOS/iOS dylib
echo "building MacOS/iOS dylib"
#iOS
export CFLAGS="-arch arm64 -miphoneos-version-min=9.0 -isysroot "$(xcrun -sdk iphoneos --show-sdk-path)
export CGO_LDFLAGS="-arch arm64 -miphoneos-version-min=9.0 -isysroot "$(xcrun -sdk iphoneos --show-sdk-path)
CGO_ENABLED=1 GOARCH=arm64 GOOS=darwin CC="clang $CFLAGS $CGO_LDFLAGS" go build -tags ios -ldflags=-w -trimpath -v -o "./build/arm64/ios/gateway.a" -buildmode c-archive

export CFLAGS="-arch x86_64 -miphoneos-version-min=9.0 -isysroot "$(xcrun -sdk iphonesimulator --show-sdk-path)
export CGO_LDFLAGS="-arch x86_64 -miphoneos-version-min=9.0 -isysroot "$(xcrun -sdk iphonesimulator --show-sdk-path)
CGO_ENABLED=1 GOARCH=amd64 GOOS=darwin CC="clang $CFLAGS $CGO_LDFLAGS" go build -tags ios -ldflags=-w -trimpath -v -o "./build/amd64/ios/gateway.a" -buildmode c-archive

#Mac
export CFLAGS="-mmacosx-version-min=10.9 -isysroot "$(xcrun -sdk macosx --show-sdk-path)
export CGO_LDFLAGS="-mmacosx-version-min=10.9 -isysroot "$(xcrun -sdk macosx --show-sdk-path)
#CGO_ENABLED=1 GOARCH=amd64 GOOS=darwin CC="clang $CFLAGS $CGO_LDFLAGS" go build -tags macosx -ldflags=-w -trimpath -v -o "test.a" -buildmode c-archive
CGO_ENABLED=1 GOARCH=amd64 GOOS=darwin CC="clang $CFLAGS $CGO_LDFLAGS" go build -tags macosx -ldflags=-w -trimpath -v -o "./build/amd64/macos/gateway.dylib" -buildmode c-shared
CGO_ENABLED=1 GOARCH=arm64 GOOS=darwin CC="clang $CFLAGS $CGO_LDFLAGS" go build -tags macosx -ldflags=-w -trimpath -v -o "./build/arm64/macos/gateway.dylib" -buildmode c-shared

5 changes: 5 additions & 0 deletions lib/buildso.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#for build linux/android so file
echo "building linux/android so file"
#linux和Android共用动态链接库
CGO_ENABLED=1 GOARCH=amd64 GOOS=linux go build -tags linux -ldflags=-w -trimpath -v -o "build/amd64/linux/gateway.so" -buildmode c-shared
CGO_ENABLED=1 GOARCH=arm64 GOOS=linux go build -tags linux -ldflags=-w -trimpath -v -o "build/arm64/linux/gateway.so" -buildmode c-shared
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ func main() {
}
}

//export run
func Run() {
client.Run()
}

func buildVersion(version, commit, date, builtBy string) string {
var result = version
if commit != "" {
Expand Down

0 comments on commit b5c4a9e

Please # to comment.