From a0a92dd7a5bad2fb57a9674b8e3caddbc5e523c4 Mon Sep 17 00:00:00 2001 From: iotserv Date: Sun, 29 Oct 2023 14:01:41 +0800 Subject: [PATCH] goreleaser --- .github/workflows/release.yml | 20 ++++++++++---------- lib/builddll.bat | 2 +- lib/builddll.sh | 2 +- lib/builddylib.sh | 8 ++++---- lib/buildso.sh | 12 ++++++------ lib/lib.go | 23 +++++++++++++++++++++++ main.go | 2 -- 7 files changed, 45 insertions(+), 24 deletions(-) create mode 100644 lib/lib.go diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 994b738..8141d21 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,19 +82,19 @@ jobs: ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} - name: build ios xcframework run: gomobile bind -ldflags '-w -s -extldflags "-lresolve"' --target=ios,macos,iossimulator -o OpenIoTHubGateway.xcframework ./client - - name: Upload the installer as an artifact - uses: actions/upload-artifact@v3 - if: ${{ github.event_name != 'pull_request' }} + - name: Release windows setup + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') with: - name: OpenIoTHubGateway.xcframework - path: OpenIoTHubGateway.xcframework + files: | + OpenIoTHubGateway.xcframework - name: build android aar run: gomobile bind -target=android -o gateway.aar ./client env: ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} - - name: Upload the installer as an artifact - uses: actions/upload-artifact@v3 - if: ${{ github.event_name != 'pull_request' }} + - name: Release windows setup + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') with: - name: gateway.aar - path: gateway.aar \ No newline at end of file + files: | + gateway.aar \ No newline at end of file diff --git a/lib/builddll.bat b/lib/builddll.bat index fd1a50c..6920500 100644 --- a/lib/builddll.bat +++ b/lib/builddll.bat @@ -9,4 +9,4 @@ SET CC=x86_64-w64-mingw32-gcc SET CXX=x86_64-w64-mingw32-g++ SET GOOS=windows SET GOARCH=amd64 -go build -tags windows -ldflags=-w -trimpath -o ./build/windows/gateway_amd64.dll -buildmode=c-shared \ No newline at end of file +go build -tags windows -ldflags=-w -trimpath -o ./build/windows/gateway_amd64.dll -buildmode=c-shared lib/lib.go \ No newline at end of file diff --git a/lib/builddll.sh b/lib/builddll.sh index 6ad7404..1e71b4e 100755 --- a/lib/builddll.sh +++ b/lib/builddll.sh @@ -7,4 +7,4 @@ export CGO_ENABLED=1 export CC=x86_64-w64-mingw32-gcc export CXX=x86_64-w64-mingw32-g++ export GOOS=windows GOARCH=amd64 -go build -tags windows -ldflags=-w -trimpath -o ./build/windows/gateway_amd64.dll -buildmode=c-shared \ No newline at end of file +go build -tags windows -ldflags=-w -trimpath -o ./build/windows/gateway_amd64.dll -buildmode=c-shared lib/lib.go \ No newline at end of file diff --git a/lib/builddylib.sh b/lib/builddylib.sh index ac67498..5bc9f08 100755 --- a/lib/builddylib.sh +++ b/lib/builddylib.sh @@ -5,13 +5,13 @@ echo "building MacOS/iOS dylib" export CFLAGS="-arch arm64 -miphoneos-version-min=9.0 -isysroot "$(xcrun -sdk iphoneos --show-sdk-path) # shellcheck disable=SC2155 export CGO_LDFLAGS="-arch arm64 -miphoneos-version-min=9.0 -isysroot "$(xcrun -sdk iphoneos --show-sdk-path) -CGO_ENABLED=1 GOARCH=arm64 GOOS=ios CC="clang $CFLAGS $CGO_LDFLAGS" go build -tags ios -ldflags=-w -trimpath -o "./build/ios/gateway_arm64.a" -buildmode c-archive +CGO_ENABLED=1 GOARCH=arm64 GOOS=ios CC="clang $CFLAGS $CGO_LDFLAGS" go build -tags ios -ldflags=-w -trimpath -o "./build/ios/gateway_arm64.a" -buildmode c-archive lib/lib.go # shellcheck disable=SC2155 export CFLAGS="-arch x86_64 -miphoneos-version-min=9.0 -isysroot "$(xcrun -sdk iphonesimulator --show-sdk-path) # shellcheck disable=SC2155 export CGO_LDFLAGS="-arch x86_64 -miphoneos-version-min=9.0 -isysroot "$(xcrun -sdk iphonesimulator --show-sdk-path) -CGO_ENABLED=1 GOARCH=amd64 GOOS=ios CC="clang $CFLAGS $CGO_LDFLAGS" go build -tags ios -ldflags=-w -trimpath -o "./build/ios/gateway_simulator_amd64.a" -buildmode c-archive +CGO_ENABLED=1 GOARCH=amd64 GOOS=ios CC="clang $CFLAGS $CGO_LDFLAGS" go build -tags ios -ldflags=-w -trimpath -o "./build/ios/gateway_simulator_amd64.a" -buildmode c-archive lib/lib.go lipo -create ./build/ios/gateway_arm64.a ./build/ios/gateway_simulator_amd64.a -output ./build/ios/libgateway_amd64_arm64.a @@ -21,7 +21,7 @@ export CFLAGS="-mmacosx-version-min=10.9 -isysroot "$(xcrun -sdk macosx --show-s # shellcheck disable=SC2155 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 -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 -o "./build/macos/gateway_amd64.a" -buildmode c-archive -CGO_ENABLED=1 GOARCH=arm64 GOOS=darwin CC="clang $CFLAGS $CGO_LDFLAGS" go build -tags macosx -ldflags=-w -trimpath -o "./build/macos/gateway_arm64.a" -buildmode c-archive +CGO_ENABLED=1 GOARCH=amd64 GOOS=darwin CC="clang $CFLAGS $CGO_LDFLAGS" go build -tags macosx -ldflags=-w -trimpath -o "./build/macos/gateway_amd64.a" -buildmode c-archive lib/lib.go +CGO_ENABLED=1 GOARCH=arm64 GOOS=darwin CC="clang $CFLAGS $CGO_LDFLAGS" go build -tags macosx -ldflags=-w -trimpath -o "./build/macos/gateway_arm64.a" -buildmode c-archive lib/lib.go lipo -create ./build/macos/gateway_amd64.a ./build/macos/gateway_arm64.a -output ./build/macos/libgateway_amd64_arm64.a diff --git a/lib/buildso.sh b/lib/buildso.sh index 9041741..f2dec3a 100755 --- a/lib/buildso.sh +++ b/lib/buildso.sh @@ -4,7 +4,7 @@ echo "building linux/android so file" export CGO_ENABLED=1 export GOARCH=amd64 export GOOS=linux -go build -tags linux -ldflags=-w -trimpath -o build/linux/libgateway_amd64.so -buildmode c-shared +go build -tags linux -ldflags=-w -trimpath -o build/linux/libgateway_amd64.so -buildmode c-shared lib/lib.go # shellcheck disable=SC2034 export CGO_ENABLED=1 export GOARCH=arm64 @@ -15,7 +15,7 @@ export CC=aarch64-linux-gnu-gcc #export CXX=aarch64-linux-gnu-g++ ##sudo apt-get install binutils-aarch64-linux-gnu #export AR=aarch64-linux-gnu-ar -go build -tags linux -ldflags=-w -trimpath -o build/linux/libgateway_arm64.so -buildmode c-shared +go build -tags linux -ldflags=-w -trimpath -o build/linux/libgateway_arm64.so -buildmode c-shared lib/lib.go #export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:~/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH ##android/app/src/main/jniLibs/armeabi-v7a @@ -24,25 +24,25 @@ go build -tags linux -ldflags=-w -trimpath -o build/linux/libgateway_arm64.so -b #export GOARCH=arm #export GOOS=android #export CC=armv7a-linux-androideabi33-clang -#go build -tags android -ldflags=-w -trimpath -o build/android/armeabi-v7a/libgateway.so -buildmode c-shared +#go build -tags android -ldflags=-w -trimpath -o build/android/armeabi-v7a/libgateway.so -buildmode c-shared lib/lib.go ##android/app/src/main/jniLibs/arm64-v8a ## shellcheck disable=SC2034 #export CGO_ENABLED=1 #export GOARCH=arm64 #export GOOS=android #export CC=aarch64-linux-android33-clang -#go build -tags android -ldflags=-w -trimpath -o build/android/arm64-v8a/libgateway.so -buildmode c-shared +#go build -tags android -ldflags=-w -trimpath -o build/android/arm64-v8a/libgateway.so -buildmode c-shared lib/lib.go ##android/app/src/main/jniLibs/x86 ## shellcheck disable=SC2034 #export CGO_ENABLED=1 #export GOARCH=386 #export GOOS=android #export CC=i686-linux-android33-clang -#go build -tags android -ldflags=-w -trimpath -o build/android/x86/libgateway.so -buildmode c-shared +#go build -tags android -ldflags=-w -trimpath -o build/android/x86/libgateway.so -buildmode c-shared lib/lib.go ##android/app/src/main/jniLibs/x86_64 ## shellcheck disable=SC2034 #export CGO_ENABLED=1 #export GOARCH=amd64 #export GOOS=android #export CC=x86_64-linux-android33-clang -#go build -tags android -ldflags=-w -trimpath -o build/android/x86_64/libgateway.so -buildmode c-shared \ No newline at end of file +#go build -tags android -ldflags=-w -trimpath -o build/android/x86_64/libgateway.so -buildmode c-shared lib/lib.go \ No newline at end of file diff --git a/lib/lib.go b/lib/lib.go new file mode 100644 index 0000000..83f4baf --- /dev/null +++ b/lib/lib.go @@ -0,0 +1,23 @@ +package main + +import "C" + +import ( + client "github.com/OpenIoTHub/gateway-go/client" +) + +var ( + version = "dev" + commit = "" + date = "time" + builtBy = "" +) + +func main() { + +} + +//export Run +func Run() { + go client.Run() +} diff --git a/main.go b/main.go index 4b31ca1..e8c0b93 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,5 @@ package main -import "C" - import ( "fmt" client "github.com/OpenIoTHub/gateway-go/client"