add ios build
This commit is contained in:
46
build_lib.sh
46
build_lib.sh
@@ -8,7 +8,40 @@ NDK_HOME="$HOME/Android/Sdk/ndk/28.2.13676358" # <--- CHECK YOUR VERSION
|
||||
API=21
|
||||
|
||||
TOOLCHAIN="$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin"
|
||||
OS="$(uname -s)"
|
||||
|
||||
if [ "$OS" = "Darwin" ]; then
|
||||
export IOS_SDK=$(xcrun --sdk iphoneos --show-sdk-path)
|
||||
export IOS_SIM_SDK=$(xcrun --sdk iphonesimulator --show-sdk-path)
|
||||
|
||||
echo "Building for iOS arm64..."
|
||||
GOOS=ios GOARCH=arm64 CGO_ENABLED=1 \
|
||||
CC="$(xcrun --sdk iphoneos --find clang)" \
|
||||
CGO_CFLAGS="-isysroot $IOS_SDK -arch arm64" \
|
||||
CGO_LDFLAGS="-isysroot $IOS_SDK -arch arm64" \
|
||||
go build -buildmode=c-archive -o build/ios/device/libgofunc_arm64.a .
|
||||
|
||||
GOOS=ios GOARCH=amd64 CGO_ENABLED=1 \
|
||||
CC="$(xcrun --sdk iphonesimulator --find clang)" \
|
||||
CGO_CFLAGS="-isysroot $IOS_SIM_SDK -arch x86_64" \
|
||||
CGO_LDFLAGS="-isysroot $IOS_SIM_SDK -arch x86_64" \
|
||||
go build -buildmode=c-archive -o build/ios/sim/libgofunc_arm64_sim.a .
|
||||
|
||||
# xcodebuild -create-xcframework \
|
||||
# -library build/ios/device/libgofunc_arm64.a -headers build/ios/device/ \
|
||||
# -library build/ios/sim/libgofunc_arm64_sim.a -headers build/ios/sim/ \
|
||||
# -output build/libgofunc.xcframework
|
||||
|
||||
# CGO_ENABLED=1 GOOS=ios GOARCH=arm64 SDK=iphoneos \
|
||||
# go build -buildmode=c-archive -o ./build/libgofunc_arm64.a .
|
||||
|
||||
# CGO_ENABLED=1 GOOS=ios GOARCH=arm64 SDK=iphonesimulator \
|
||||
# go build -buildmode=c-archive -o ./build/libgofunc_arm64_sim.a .
|
||||
|
||||
lipo -create build/ios/device/libgofunc_arm64.a build/ios/sim/libgofunc_arm64_sim.a -output build/ios/libgofunc.a
|
||||
|
||||
cp ./build/ios/libgofunc.a $HOME/ws/forward_pos/native/ios/x86_64/libgofunc.a
|
||||
elif [ "$OS" = "Linux" ]; then
|
||||
echo "Building for Android x86_64..."
|
||||
CC="$TOOLCHAIN/x86_64-linux-android$API-clang" \
|
||||
CGO_ENABLED=1 GOOS=android GOARCH=amd64 \
|
||||
@@ -24,16 +57,13 @@ CC="$TOOLCHAIN/armv7a-linux-androideabi$API-clang" \
|
||||
CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 \
|
||||
go build -buildmode=c-shared -o ./build/libgofunc_armv7a.so .
|
||||
|
||||
|
||||
# echo "Building for iOS ARM64..."
|
||||
# CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 \
|
||||
# go build -buildmode=c-archive -o ./libgofunc_arm64.a .
|
||||
|
||||
# cp ./libgofunc_x64.so /home/sainw/ws/forward_pos/android/app/src/main/jniLibs/x86_64/libgofuncso
|
||||
|
||||
cp ./build/libgofunc_x64.so $HOME/ws/forward_pos/native/android/x86_64/libgofunc.so
|
||||
cp ./build/libgofunc_arm64.so $HOME/ws/forward_pos/native/android/arm64-v8a/libgofunc.so
|
||||
cp ./build/libgofunc_armv7a.so $HOME/ws/forward_pos/native/android/armeabi-v7a/libgofunc.so
|
||||
|
||||
cp ./build/libgofunc_armv7a.so $HOME/ws/forward_pos/native/android/armeabi-v7a/libgofunc.so
|
||||
else
|
||||
echo "Unsupported OS: $OS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Done!"
|
||||
3
img.go
3
img.go
@@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
/*
|
||||
#include <stdint.h>
|
||||
*/
|
||||
"C"
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
8
main.go
8
main.go
@@ -1,11 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
/*
|
||||
#include <stdint.h>
|
||||
*/
|
||||
"C"
|
||||
"fmt"
|
||||
_ "image/png"
|
||||
)
|
||||
|
||||
//export Sum
|
||||
func Sum(a, b int) int {
|
||||
return a + b
|
||||
}
|
||||
|
||||
func main() {
|
||||
payload := `{"Name":"Ko Myo","Amount":3000}`
|
||||
const temp = `
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
/*
|
||||
#include <stdint.h>
|
||||
*/
|
||||
"C"
|
||||
_ "image/png"
|
||||
"os"
|
||||
|
||||
Reference in New Issue
Block a user