Browse Source

Build ios

pull/16/head
Linus Gasser 7 months ago
committed by Dan Ballard
parent
commit
3d8164c06d
  1. 1
      .gitignore
  2. 19
      Makefile
  3. 14
      clangwrap.sh
  4. 6
      switch-ffi.sh

1
.gitignore

@ -4,3 +4,4 @@ cwtch.aar
libCwtch.h
libCwtch.so
libCwtch.dll
ios/

19
Makefile

@ -1,3 +1,5 @@
IOS_OUT := ./ios
.PHONY: all linux android windows clean
DEFAULT_GOAL: linux
@ -24,3 +26,20 @@ libCwtch.dll: lib.go
clean:
rm -f cwtch.aar cwtch_go.apk libCwtch.h libCwtch.so cwtch-sources.jar libCwtch.dll
ios-arm64:
CGO_ENABLED=1 \
GOOS=darwin \
GOARCH=arm64 \
CGO_CFLAGS="-fembed-bitcode" \
go build -buildmode=c-archive -tags ios -o $(IOS_OUT)/arm64.a .
ios-x86_64:
CGO_ENABLED=1 \
GOOS=darwin \
GOARCH=amd64 \
go build -buildmode=c-archive -tags ios -o $(IOS_OUT)/x86_64.a .
ios: ios-arm64 ios-x86_64
lipo $(IOS_OUT)/x86_64.a $(IOS_OUT)/arm64.a -create -output $(IOS_OUT)/cwtch.a
cp $(IOS_OUT)/arm64.h $(IOS_OUT)/cwtch.h

14
clangwrap.sh

@ -0,0 +1,14 @@
#!/bin/sh
# go/clangwrap.sh
SDK_PATH=`xcrun --sdk $SDK --show-sdk-path`
CLANG=`xcrun --sdk $SDK --find clang`
if [ "$GOARCH" == "amd64" ]; then
CARCH="x86_64"
elif [ "$GOARCH" == "arm64" ]; then
CARCH="arm64"
fi
exec $CLANG -arch $CARCH -isysroot $SDK_PATH -mios-version-min=10.0 "$@"

6
switch-ffi.sh

@ -1,5 +1,5 @@
#!/bin/sh
sed -i "s/^package cwtch/\/\/package cwtch/" lib.go
sed -i "s/^\/\/package main/package main/" lib.go
sed -i "s/^\/\/func main()/func main()/" lib.go
perl -pi -e "s/^package cwtch/\/\/package cwtch/" lib.go
perl -pi -e "s/^\/\/package main/package main/" lib.go
perl -pi -e "s/^\/\/func main()/func main()/" lib.go
Loading…
Cancel
Save