From 66d1a90398c6162fcaeb3d1ba85376cdf448025e Mon Sep 17 00:00:00 2001 From: yejian <596306006@qq.com> Date: Tue, 28 May 2024 07:27:54 +0800 Subject: [PATCH 1/4] build: gen dylib scripts --- gen/gen_android_so.bat | 8 ++++---- gen/gen_ios_dylib.sh | 27 ++++++++++++++++++++------- gen/gen_mac_dylib.sh | 9 +++++++++ 3 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 gen/gen_mac_dylib.sh diff --git a/gen/gen_android_so.bat b/gen/gen_android_so.bat index 22f3c4f..e4825e5 100644 --- a/gen/gen_android_so.bat +++ b/gen/gen_android_so.bat @@ -4,26 +4,26 @@ set OUT_PATH=android\ set CGO_ENABLED=1 -REM 生成 armeabi-v7a +REM armeabi-v7a set GOOS=android set GOARCH=arm set CC=%NDK_PATH%\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi16-clang.cmd go build -buildmode=c-shared -trimpath -ldflags="-s -w" -o %OUT_PATH%armeabi-v7a\%SO_NAME%.so export.go protocol.go message.go -REM 生成 arm64-v8a +REM arm64-v8a set GOARCH=arm64 set CC=%NDK_PATH%\toolchains\llvm\prebuilt\windows-x86_64\bin\aarch64-linux-android21-clang.cmd go build -buildmode=c-shared -trimpath -ldflags="-s -w" -o %OUT_PATH%arm64-v8a\%SO_NAME%.so export.go protocol.go message.go -REM 生成 x86 +REM x86 set GOARCH=386 set CC=%NDK_PATH%\toolchains\llvm\prebuilt\windows-x86_64\bin\i686-linux-android16-clang.cmd go build -buildmode=c-shared -trimpath -ldflags="-s -w" -o %OUT_PATH%x86\%SO_NAME%.so export.go protocol.go message.go -REM 生成 x86_64 +REM x86_64 set GOARCH=amd64 set CC=%NDK_PATH%\toolchains\llvm\prebuilt\windows-x86_64\bin\x86_64-linux-android21-clang.cmd diff --git a/gen/gen_ios_dylib.sh b/gen/gen_ios_dylib.sh index dc3e7e8..d4fd408 100644 --- a/gen/gen_ios_dylib.sh +++ b/gen/gen_ios_dylib.sh @@ -1,8 +1,21 @@ -export GOOS=darwin -export GOARCH=arm64 -export CGO_ENABLED=1 -export CC=clang - -go build -buildmode=c-shared -o libopenimsdk.dylib export.go protocol.go message.go - +#!/bin/sh +export LANG=en_US.UTF-8 +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) +export CGO_ENABLED=1 +export GOARCH=arm64 +export GOOS=darwin +export CC="clang $CFLAGS $CGO_LDFLAGS" +go build -tags ios -ldflags=-w -trimpath -v -o libopenimsdk_ios.a -buildmode c-archive export.go protocol.go message.go + +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 libopenimsdk_iossimulator.a -buildmode c-archive + +lipo -create libopenimsdk_ios.a libopenimsdk_iossimulator.a -output libopenimsdk.a +# lipo -info ${baseDir}/test.a diff --git a/gen/gen_mac_dylib.sh b/gen/gen_mac_dylib.sh new file mode 100644 index 0000000..da5947b --- /dev/null +++ b/gen/gen_mac_dylib.sh @@ -0,0 +1,9 @@ +export GOOS=darwin +export CGO_ENABLED=1 +export CC=clang +export GOARCH=arm64 +go build -buildmode=c-shared -o libopenimsdk_arm64.dylib export.go protocol.go message.go + +export GOARCH=amd64 +go build -buildmode=c-shared -o libopenimsdk_amd64.dylib export.go protocol.go message.go +lipo -create -output libopenimsdk.dylib libopenimsdk_arm64.dylib libopenimsdk_amd64.dylib \ No newline at end of file From fd157b1719763b932ca7c079f08e405274a8836b Mon Sep 17 00:00:00 2001 From: yejian <596306006@qq.com> Date: Tue, 28 May 2024 08:37:36 +0800 Subject: [PATCH 2/4] gen_ios_dylib.sh --- gen/gen_ios_dylib.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/gen/gen_ios_dylib.sh b/gen/gen_ios_dylib.sh index d4fd408..da54134 100644 --- a/gen/gen_ios_dylib.sh +++ b/gen/gen_ios_dylib.sh @@ -1,21 +1,21 @@ #!/bin/sh export LANG=en_US.UTF-8 - +# ios device 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) export CGO_ENABLED=1 export GOARCH=arm64 export GOOS=darwin export CC="clang $CFLAGS $CGO_LDFLAGS" -go build -tags ios -ldflags=-w -trimpath -v -o libopenimsdk_ios.a -buildmode c-archive export.go protocol.go message.go +go build -tags ios -ldflags=-w -trimpath -v -o libopenimsdk.a -buildmode c-archive export.go protocol.go message.go +# go build -tags ios -ldflags=-w -trimpath -v -o libopenimsdk_ios.a -buildmode c-archive export.go protocol.go message.go +# ios simulator +# 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 libopenimsdk_iossimulator.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 libopenimsdk_iossimulator.a -buildmode c-archive - -lipo -create libopenimsdk_ios.a libopenimsdk_iossimulator.a -output libopenimsdk.a -# lipo -info ${baseDir}/test.a +# lipo -create libopenimsdk_ios.a libopenimsdk_iossimulator.a -output libopenimsdk.a From 0a86b79f3d21d3812813c9df247ef541bc0ad4fb Mon Sep 17 00:00:00 2001 From: yejian <596306006@qq.com> Date: Fri, 31 May 2024 20:25:30 +0800 Subject: [PATCH 3/4] build: change script --- README.md | 4 +++- gen/{build_so.sh => gen_linux_so.sh} | 0 gen/{build_dll.bat => gen_win_dll.bat} | 0 include/{IMSDK.h => imsdk.h} | 0 src/{IMSDK.cpp => imsdk.cpp} | 4 ++-- 5 files changed, 5 insertions(+), 3 deletions(-) rename gen/{build_so.sh => gen_linux_so.sh} (100%) rename gen/{build_dll.bat => gen_win_dll.bat} (100%) rename include/{IMSDK.h => imsdk.h} (100%) rename src/{IMSDK.cpp => imsdk.cpp} (93%) diff --git a/README.md b/README.md index 254b52c..6726ffe 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# openim-sdk-cpp \ No newline at end of file +# openim-sdk-cpp + +openim-sdk-core \ No newline at end of file diff --git a/gen/build_so.sh b/gen/gen_linux_so.sh similarity index 100% rename from gen/build_so.sh rename to gen/gen_linux_so.sh diff --git a/gen/build_dll.bat b/gen/gen_win_dll.bat similarity index 100% rename from gen/build_dll.bat rename to gen/gen_win_dll.bat diff --git a/include/IMSDK.h b/include/imsdk.h similarity index 100% rename from include/IMSDK.h rename to include/imsdk.h diff --git a/src/IMSDK.cpp b/src/imsdk.cpp similarity index 93% rename from src/IMSDK.cpp rename to src/imsdk.cpp index 2911ac2..5727da9 100644 --- a/src/IMSDK.cpp +++ b/src/imsdk.cpp @@ -1,9 +1,10 @@ -#include "IMSDK.h" +#include "imsdk.h" #include #include #include "json.hpp" using json = nlohmann::json; + char *GetOperationId(const char *prefix) { static int operationIndex = 0; @@ -15,6 +16,5 @@ char *GetOperationId(const char *prefix) void OpenIM::InitSDK() { - init_sdk(GetOperationId("init_sdk"), ""); } \ No newline at end of file From 1d31af0b9a40dd563147401703090451b2947c9b Mon Sep 17 00:00:00 2001 From: yj12138 <58063150+yj12138@users.noreply.github.com> Date: Sun, 29 Sep 2024 17:14:20 +0800 Subject: [PATCH 4/4] Update gen_ios_dylib.sh --- gen/gen_ios_dylib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gen/gen_ios_dylib.sh b/gen/gen_ios_dylib.sh index da54134..b659a89 100644 --- a/gen/gen_ios_dylib.sh +++ b/gen/gen_ios_dylib.sh @@ -5,7 +5,7 @@ export CFLAGS="-arch arm64 -miphoneos-version-min=9.0 -isysroot "$(xcrun -sdk ip export CGO_LDFLAGS="-arch arm64 -miphoneos-version-min=9.0 -isysroot "$(xcrun -sdk iphoneos --show-sdk-path) export CGO_ENABLED=1 export GOARCH=arm64 -export GOOS=darwin +export GOOS=ios export CC="clang $CFLAGS $CGO_LDFLAGS" go build -tags ios -ldflags=-w -trimpath -v -o libopenimsdk.a -buildmode c-archive export.go protocol.go message.go # go build -tags ios -ldflags=-w -trimpath -v -o libopenimsdk_ios.a -buildmode c-archive export.go protocol.go message.go