diff --git a/.gitignore b/.gitignore index 1d7b735..b9f60e5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /gateway-go /*.log /cn-hk.yaml +/build/ diff --git a/lib/build.sh b/lib/build.sh new file mode 100755 index 0000000..e69de29 diff --git a/lib/builddll.bat b/lib/builddll.bat new file mode 100755 index 0000000..f7cb5d1 --- /dev/null +++ b/lib/builddll.bat @@ -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 \ No newline at end of file diff --git a/lib/builddylib.sh b/lib/builddylib.sh new file mode 100755 index 0000000..d83462c --- /dev/null +++ b/lib/builddylib.sh @@ -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 + diff --git a/lib/buildso.sh b/lib/buildso.sh new file mode 100755 index 0000000..dacbab2 --- /dev/null +++ b/lib/buildso.sh @@ -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 \ No newline at end of file diff --git a/main.go b/main.go index 7d9e374..6a55afd 100644 --- a/main.go +++ b/main.go @@ -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 != "" {