diff --git a/.drone.yml b/.drone.yml index 3fc2b93..5bedeb4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -82,7 +82,7 @@ steps: - find . -type f -exec sha256sum {} \; > ./../sha256s.txt - mv ./../sha256s.txt . - cd .. - - scp -r -o StrictHostKeyChecking=no -i ~/id_rsa $DIR buildfiles@openprivacy.ca:/home/buildfiles/buildfiles/ + - scp -r -o StrictHostKeyChecking=no -i ~/id_rsa $DIR buildfiles@build.openprivacy.ca:/home/buildfiles/buildfiles/ - name: gitea-release image: plugins/gitea-release diff --git a/.gitignore b/.gitignore index dbb20d7..53069a5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ cwtch.aar libCwtch.h libCwtch.so libCwtch.dll +ios/ diff --git a/Makefile b/Makefile index 179e701..57972fe 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,15 @@ -.PHONY: all linux android windows clean +IOS_OUT := ./ios + +.PHONY: all linux android windows macos clean ios DEFAULT_GOAL: linux -all: linux android +all: linux android windows linux: libCwtch.so +macos: libCwtch.so + android: cwtch.aar windows: libCwtch.dll @@ -24,3 +28,26 @@ libCwtch.dll: lib.go clean: rm -f cwtch.aar cwtch_go.apk libCwtch.h libCwtch.so cwtch-sources.jar libCwtch.dll + +# iOS - for testing purposes only for now, not officially supported + +ios-arm64: + CGO_ENABLED=1 \ + GOOS=darwin \ + GOARCH=arm64 \ + SDK=iphoneos \ + CGO_CFLAGS="-fembed-bitcode" \ + CC=$(PWD)/clangwrap.sh \ + go build -buildmode=c-archive -tags ios -o $(IOS_OUT)/arm64.a . + +ios-x86_64: + CGO_ENABLED=1 \ + GOOS=darwin \ + GOARCH=amd64 \ + SDK=iphonesimulator \ + CC=$(PWD)/clangwrap.sh \ + 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 diff --git a/README.md b/README.md index 8fb7bc7..f2f4c80 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,13 @@ C-bindings for the Go Cwtch Library. -# Build Instructions... +# Build Instructions make linux make android + make windows + +## Experimental iOS support + make ios # Using @@ -16,3 +20,7 @@ C-bindings for the Go Cwtch Library. ## Android - copy `cwtch.aar` into `flutter_app/android/cwtch` + +## Windows + +- copy libCwtch.dll into the directory of the `.exe` using it diff --git a/clangwrap.sh b/clangwrap.sh new file mode 100644 index 0000000..763187e --- /dev/null +++ b/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 "$@" diff --git a/switch-ffi.sh b/switch-ffi.sh index 7985e9f..221fe92 100755 --- a/switch-ffi.sh +++ b/switch-ffi.sh @@ -1,5 +1,6 @@ #!/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 \ No newline at end of file +# using '-i.bak' and 'rm .bak' for gnu sed (linux) and bsd sed (macosx) compat +sed -i.bak "s/^package cwtch/\/\/package cwtch/" lib.go +sed -i.bak "s/^\/\/package main/package main/" lib.go +sed -i.bak "s/^\/\/func main()/func main()/" lib.go +rm lib.go.bak diff --git a/switch-gomobile.sh b/switch-gomobile.sh index be90765..f89c584 100755 --- a/switch-gomobile.sh +++ b/switch-gomobile.sh @@ -1,5 +1,6 @@ #!/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 +# using '-i.bak' and 'rm .bak' for gnu sed (linux) and bsd sed (macosx) compat +sed -i.bak "s/^\/\/package cwtch/package cwtch/" lib.go +sed -i.bak "s/^package main/\/\/package main/" lib.go +sed -i.bak "s/^func main()/\/\/func main()/" lib.go +rm lib.go.bak