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