Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update build ios script #50

Merged
merged 4 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# openim-sdk-cpp
# openim-sdk-cpp

openim-sdk-core
8 changes: 4 additions & 4 deletions gen/gen_android_so.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 21 additions & 8 deletions gen/gen_ios_dylib.sh
Original file line number Diff line number Diff line change
@@ -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
# 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=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
# 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

# lipo -create libopenimsdk_ios.a libopenimsdk_iossimulator.a -output libopenimsdk.a
File renamed without changes.
9 changes: 9 additions & 0 deletions gen/gen_mac_dylib.sh
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/IMSDK.cpp → src/imsdk.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include "IMSDK.h"
#include "imsdk.h"

#include <iostream>
#include <sstream>
#include "json.hpp"
using json = nlohmann::json;

char *GetOperationId(const char *prefix)
{
static int operationIndex = 0;
Expand All @@ -15,6 +16,5 @@ char *GetOperationId(const char *prefix)

void OpenIM::InitSDK()
{

init_sdk(GetOperationId("init_sdk"), "");
}
Loading