Skip to content

Commit

Permalink
Mobile SDK build and README changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
blockcodemagic committed Dec 22, 2019
1 parent 8d466ea commit 9e077c7
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 49 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ gosdk-test:

install-gosdk: | gosdk-build gosdk-test

$(GOPATH)/bin/modvendor:
@go get -u github.com/goware/modvendor

vendor: $(GOPATH)/bin/modvendor
@GO111MODULE=on go mod vendor -v
@modvendor -copy="**/*.c **/*.h **/*.a" -v

getrev:
$(eval VERSION_STR=$(shell git describe --tags --dirty --always))
@echo "" > $(VERSION_FILE)
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,30 @@ It is possible to support the sdk for other variations of Linux as well.
./sdkver
- If it prints the gosdk version installed then setup is complete.


### Mobile Builds (iOS and Android) ###
- gosdk can be build to use on Mobile platforms iOS and Android using gomobile.
- Xcode Command Line Tools is required to build SDK for iOS.
- Android studio with NDK is required to build SDK for Android
- Run below command for the first time to setup gomobile environment

make setup-gomobile

- Use below commands in the root folder of the repo to build Mobile SDK

For iOS and Android:
make build-mobilesdk IOS=1 ANDROID=1
For iOS only:
make build-mobilesdk IOS=1
For Android only:
make build-mobilesdk ANDROID=1

### FAQ ###

- [How to install GO on any platform](https://golang.org/doc/install)
- [How to install different version of GO](https://golang.org/doc/install#extra_versions)
- [How to use go mod](https://blog.golang.org/using-go-modules)
- [What is gomobile](https://godoc.org/golang.org/x/mobile/cmd/gomobile)
- [About XCode](https://developer.apple.com/xcode/)
- [Android Studio](https://developer.android.com/studio)
- [Android NDK](https://developer.android.com/ndk/)
61 changes: 14 additions & 47 deletions _util/build_mobile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,13 @@ ANDROIDBINNAME := zcncore.aar

.PHONY: build-mobilesdk

BLS_LIB_BASE_PATH=$(GOPATH)/src/github.com/herumi
export CGO_CFLAGS+=-I$(BLS_LIB_BASE_PATH)/bls/include -I$(BLS_LIB_BASE_PATH)/mcl/include

$(BLS_LIB_BASE_PATH):
@git clone http://github.com/herumi/mcl.git $(BLS_LIB_BASE_PATH)/mcl
@cd $(BLS_LIB_BASE_PATH)/mcl && git checkout cc9762f14f7f6d4bbc29c0ca418781af4a74f92d && cd - >/dev/null
@git clone http://github.com/herumi/bls.git $(BLS_LIB_BASE_PATH)/bls
@cd $(BLS_LIB_BASE_PATH)/bls && git checkout 058c89ea4262b6131e704f12583b2a852462d4f9 && cd - >>/dev/null
$(eval NCPU=$(shell sysctl -n hw.ncpu))
@$(PRINT_MAG)
@echo "============================================================"
@echo " Building BLS for MAC... "
@echo "------------------------------------------------------------"
@$(PRINT_NON)
@sudo $(MAKE) -C $(BLS_LIB_BASE_PATH)/bls -j$(NCPU) install
@$(PRINT_MAG)
@echo "============================================================"
@echo " Building MCL for MAC... "
@echo "------------------------------------------------------------"
@$(PRINT_NON)
@sudo $(MAKE) -C $(BLS_LIB_BASE_PATH)/mcl -j$(NCPU) lib/libmclbn256.dylib install

$(IOSMOBILESDKDIR):
$(shell mkdir -p $(IOSMOBILESDKDIR)/lib)

$(ANDROIDMOBILESDKDIR):
$(shell mkdir -p $(ANDROIDMOBILESDKDIR)/lib)

setup-gomobile: $(BLS_LIB_BASE_PATH) $(IOSMOBILESDKDIR) $(ANDROIDMOBILESDKDIR)
@cd $(BLS_LIB_BASE_PATH)/bls && git checkout . && git checkout 058c89ea && git apply $(ROOT_DIR)/patches/github.com-herumi-bls-gomobile_ios.patch && cd -
@$(PRINT_CYN)
@echo "============================================================"
@echo " Building BLS for iOS "
@echo "------------------------------------------------------------"
@$(PRINT_NON)
@$(MAKE) -C $(BLS_LIB_BASE_PATH)/bls gomobile_ios CURVE_BIT=256
@$(MAKE) -C $(BLS_LIB_BASE_PATH)/bls gomobile_ios CURVE_BIT=384
@cp -Rf $(BLS_LIB_BASE_PATH)/bls/ios/* $(IOSMOBILESDKDIR)/lib
ifeq ($(NOANDROID),)
@$(PRINT_CYN)
@echo "============================================================"
@echo " Building BLS for Android "
@echo "------------------------------------------------------------"
@$(PRINT_NON)
@$(MAKE) -C $(BLS_LIB_BASE_PATH)/bls gomobile_android CURVE_BIT=256
@$(MAKE) -C $(BLS_LIB_BASE_PATH)/bls gomobile_android CURVE_BIT=384
@cp -Rf $(BLS_LIB_BASE_PATH)/bls/android/* $(ANDROIDMOBILESDKDIR)/lib
endif
setup-gomobile: $(IOSMOBILESDKDIR) $(ANDROIDMOBILESDKDIR)
@$(PRINT_MAG)
@echo "============================================================"
@echo " Initializing gomobile. Please wait it may take a while ..."
Expand All @@ -76,19 +35,27 @@ ifneq ($(GOPATH), )
$(shell ln -sf $(ROOT_DIR) $(GOPATH)/src/$(0CHAIN_PATH))
endif

build-mobilesdk: $(GOPATH)/src/$(GOSDK_PATH) getrev
build-mobilesdk: $(GOPATH)/src/$(GOSDK_PATH)
ifeq ($(filter-out undefined,$(foreach v, IOS ANDROID,$(origin $(v)))),)
@$(PRINT_RED)
@echo ""
@echo "Usage:"
@echo ' For iOS and Android: make build-mobilesdk IOS=1 ANDROID=1'
@echo ' For iOS only: make build-mobilesdk IOS=1'
@echo ' For Android only: make build-mobilesdk ANDROID=1'
endif
@$(PRINT_CYN)
ifneq ($(IOS),)
@echo "Building iOS framework. Please wait..."
@cd $(BLS_LIB_BASE_PATH)/bls && git checkout . && git apply $(ROOT_DIR)/patches/github.com-herumi-bls-gomobile_ios.patch && cd - >> /dev/null
@gomobile bind -ldflags="-s -w" -target=ios -o $(IOSMOBILESDKDIR)/$(IOSBINNAME) $(GOSDK_PATH)/zcncore
@echo " $(IOSMOBILESDKDIR)/$(IOSBINNAME). - [OK]"
ifeq ($(NOANDROID),)
endif
ifneq ($(ANDROID),)
@echo "Building Android framework. Please wait..."
@cd $(BLS_LIB_BASE_PATH)/bls && git checkout . && git apply $(ROOT_DIR)/patches/github.com-herumi-bls-gomobile_android.patch && cd - >> /dev/null
@gomobile bind -target=android/arm64,android/amd64 -ldflags=-extldflags=-Wl,-soname,libgojni.so -o $(ANDROIDMOBILESDKDIR)/$(ANDROIDBINNAME) $(GOSDK_PATH)/zcncore
@echo " $(ANDROIDMOBILESDKDIR)/$(ANDROIDBINNAME). - [OK]"
endif
@cd $(BLS_LIB_BASE_PATH)/bls && git checkout . && cd - >> /dev/null
@echo ""
@$(PRINT_NON)

clean-mobilesdk:
Expand Down
2 changes: 1 addition & 1 deletion core/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
//====== THIS IS AUTOGENERATED FILE. DO NOT MODIFY ========

package version
const VERSIONSTR = "v1.0.29"
const VERSIONSTR = "v1.0.30"

2 changes: 1 addition & 1 deletion core/zcncrypto/ed255190chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package zcncrypto

import (
"bytes"
"crypto/ed25519"
"encoding/hex"
"errors"
"fmt"
"time"

"github.com/0chain/gosdk/core/encryption"
"github.com/tyler-smith/go-bip39"
"golang.org/x/crypto/ed25519"
)

//ED255190chainScheme - a signature scheme based on ED25519
Expand Down

0 comments on commit 9e077c7

Please sign in to comment.