Skip to content

Commit

Permalink
Update Makefile to include android, adding extra function in main.go …
Browse files Browse the repository at this point in the history
…for debug purposes on Android
  • Loading branch information
Simbad Marino authored and Simbad Marino committed Sep 6, 2022
1 parent f00b942 commit d6c1283
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
38 changes: 37 additions & 1 deletion cmd/btfs/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# go/Makefile
ANDROID_OUT=./jniLibs
ANDROID_SDK=$(HOME)/Library/Android/sdk
NDK_BIN=$(ANDROID_SDK)/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/bin


ios-arm64:
CGO_ENABLED=1 \
Expand All @@ -21,4 +25,36 @@ ios-x86_64:

ios: ios-arm64 ios-x86_64
lipo $(IOS_OUT)/x86_64.a $(IOS_OUT)/arm64.a -create -output $(IOS_OUT)/btfs.a
cp $(IOS_OUT)/arm64.h $(IOS_OUT)/btfs.h
cp $(IOS_OUT)/arm64.h $(IOS_OUT)/btfs.h


android-armv7a:
CGO_ENABLED=1 \
GOOS=android \
GOARCH=arm \
GOARM=7 \
CC=$(NDK_BIN)/armv7a-linux-androideabi21-clang \
go build -buildmode=c-shared -o $(ANDROID_OUT)/armeabi-v7a/libfoo.so .

android-arm64:
CGO_ENABLED=1 \
GOOS=android \
GOARCH=arm64 \
CC=$(NDK_BIN)/aarch64-linux-android21-clang \
go build -buildmode=c-shared -o $(ANDROID_OUT)/arm64-v8a/libfoo.so .

android-x86:
CGO_ENABLED=1 \
GOOS=android \
GOARCH=386 \
CC=$(NDK_BIN)/i686-linux-android21-clang \
go build -buildmode=c-shared -o $(ANDROID_OUT)/x86/libfoo.so .

android-x86_64:
CGO_ENABLED=1 \
GOOS=android \
GOARCH=amd64 \
CC=$(NDK_BIN)/x86_64-linux-android21-clang \
go build -buildmode=c-shared -o $(ANDROID_OUT)/x86_64/libfoo.so .

android: android-armv7a android-arm64 android-x86 android-x86_64
4 changes: 4 additions & 0 deletions cmd/btfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ func mainC(in *C.char) *C.char {
exitCode := mainRet(args)
return C.CString("exit code:" + strconv.Itoa(exitCode))
}
//export mainCMod
func mainCMod(in *C.char) *C.char{
return C.CString(C.GoString(in))
}

func mainRet(args []string) int {
rand.Seed(time.Now().UnixNano())
Expand Down

0 comments on commit d6c1283

Please sign in to comment.