Skip to content

Commit 9e077c7

Browse files
Mobile SDK build and README changes.
1 parent 8d466ea commit 9e077c7

File tree

5 files changed

+45
-49
lines changed

5 files changed

+45
-49
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ gosdk-test:
3434

3535
install-gosdk: | gosdk-build gosdk-test
3636

37+
$(GOPATH)/bin/modvendor:
38+
@go get -u github.com/goware/modvendor
39+
40+
vendor: $(GOPATH)/bin/modvendor
41+
@GO111MODULE=on go mod vendor -v
42+
@modvendor -copy="**/*.c **/*.h **/*.a" -v
43+
3744
getrev:
3845
$(eval VERSION_STR=$(shell git describe --tags --dirty --always))
3946
@echo "" > $(VERSION_FILE)

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,30 @@ It is possible to support the sdk for other variations of Linux as well.
3535
./sdkver
3636
- If it prints the gosdk version installed then setup is complete.
3737

38+
39+
### Mobile Builds (iOS and Android) ###
40+
- gosdk can be build to use on Mobile platforms iOS and Android using gomobile.
41+
- Xcode Command Line Tools is required to build SDK for iOS.
42+
- Android studio with NDK is required to build SDK for Android
43+
- Run below command for the first time to setup gomobile environment
44+
45+
make setup-gomobile
46+
47+
- Use below commands in the root folder of the repo to build Mobile SDK
48+
49+
For iOS and Android:
50+
make build-mobilesdk IOS=1 ANDROID=1
51+
For iOS only:
52+
make build-mobilesdk IOS=1
53+
For Android only:
54+
make build-mobilesdk ANDROID=1
55+
3856
### FAQ ###
3957

4058
- [How to install GO on any platform](https://golang.org/doc/install)
4159
- [How to install different version of GO](https://golang.org/doc/install#extra_versions)
4260
- [How to use go mod](https://blog.golang.org/using-go-modules)
61+
- [What is gomobile](https://godoc.org/golang.org/x/mobile/cmd/gomobile)
62+
- [About XCode](https://developer.apple.com/xcode/)
63+
- [Android Studio](https://developer.android.com/studio)
64+
- [Android NDK](https://developer.android.com/ndk/)

_util/build_mobile.mk

Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,13 @@ ANDROIDBINNAME := zcncore.aar
88

99
.PHONY: build-mobilesdk
1010

11-
BLS_LIB_BASE_PATH=$(GOPATH)/src/github.com/herumi
12-
export CGO_CFLAGS+=-I$(BLS_LIB_BASE_PATH)/bls/include -I$(BLS_LIB_BASE_PATH)/mcl/include
13-
14-
$(BLS_LIB_BASE_PATH):
15-
@git clone http://github.com/herumi/mcl.git $(BLS_LIB_BASE_PATH)/mcl
16-
@cd $(BLS_LIB_BASE_PATH)/mcl && git checkout cc9762f14f7f6d4bbc29c0ca418781af4a74f92d && cd - >/dev/null
17-
@git clone http://github.com/herumi/bls.git $(BLS_LIB_BASE_PATH)/bls
18-
@cd $(BLS_LIB_BASE_PATH)/bls && git checkout 058c89ea4262b6131e704f12583b2a852462d4f9 && cd - >>/dev/null
19-
$(eval NCPU=$(shell sysctl -n hw.ncpu))
20-
@$(PRINT_MAG)
21-
@echo "============================================================"
22-
@echo " Building BLS for MAC... "
23-
@echo "------------------------------------------------------------"
24-
@$(PRINT_NON)
25-
@sudo $(MAKE) -C $(BLS_LIB_BASE_PATH)/bls -j$(NCPU) install
26-
@$(PRINT_MAG)
27-
@echo "============================================================"
28-
@echo " Building MCL for MAC... "
29-
@echo "------------------------------------------------------------"
30-
@$(PRINT_NON)
31-
@sudo $(MAKE) -C $(BLS_LIB_BASE_PATH)/mcl -j$(NCPU) lib/libmclbn256.dylib install
32-
3311
$(IOSMOBILESDKDIR):
3412
$(shell mkdir -p $(IOSMOBILESDKDIR)/lib)
3513

3614
$(ANDROIDMOBILESDKDIR):
3715
$(shell mkdir -p $(ANDROIDMOBILESDKDIR)/lib)
3816

39-
setup-gomobile: $(BLS_LIB_BASE_PATH) $(IOSMOBILESDKDIR) $(ANDROIDMOBILESDKDIR)
40-
@cd $(BLS_LIB_BASE_PATH)/bls && git checkout . && git checkout 058c89ea && git apply $(ROOT_DIR)/patches/github.com-herumi-bls-gomobile_ios.patch && cd -
41-
@$(PRINT_CYN)
42-
@echo "============================================================"
43-
@echo " Building BLS for iOS "
44-
@echo "------------------------------------------------------------"
45-
@$(PRINT_NON)
46-
@$(MAKE) -C $(BLS_LIB_BASE_PATH)/bls gomobile_ios CURVE_BIT=256
47-
@$(MAKE) -C $(BLS_LIB_BASE_PATH)/bls gomobile_ios CURVE_BIT=384
48-
@cp -Rf $(BLS_LIB_BASE_PATH)/bls/ios/* $(IOSMOBILESDKDIR)/lib
49-
ifeq ($(NOANDROID),)
50-
@$(PRINT_CYN)
51-
@echo "============================================================"
52-
@echo " Building BLS for Android "
53-
@echo "------------------------------------------------------------"
54-
@$(PRINT_NON)
55-
@$(MAKE) -C $(BLS_LIB_BASE_PATH)/bls gomobile_android CURVE_BIT=256
56-
@$(MAKE) -C $(BLS_LIB_BASE_PATH)/bls gomobile_android CURVE_BIT=384
57-
@cp -Rf $(BLS_LIB_BASE_PATH)/bls/android/* $(ANDROIDMOBILESDKDIR)/lib
58-
endif
17+
setup-gomobile: $(IOSMOBILESDKDIR) $(ANDROIDMOBILESDKDIR)
5918
@$(PRINT_MAG)
6019
@echo "============================================================"
6120
@echo " Initializing gomobile. Please wait it may take a while ..."
@@ -76,19 +35,27 @@ ifneq ($(GOPATH), )
7635
$(shell ln -sf $(ROOT_DIR) $(GOPATH)/src/$(0CHAIN_PATH))
7736
endif
7837

79-
build-mobilesdk: $(GOPATH)/src/$(GOSDK_PATH) getrev
38+
build-mobilesdk: $(GOPATH)/src/$(GOSDK_PATH)
39+
ifeq ($(filter-out undefined,$(foreach v, IOS ANDROID,$(origin $(v)))),)
40+
@$(PRINT_RED)
41+
@echo ""
42+
@echo "Usage:"
43+
@echo ' For iOS and Android: make build-mobilesdk IOS=1 ANDROID=1'
44+
@echo ' For iOS only: make build-mobilesdk IOS=1'
45+
@echo ' For Android only: make build-mobilesdk ANDROID=1'
46+
endif
8047
@$(PRINT_CYN)
48+
ifneq ($(IOS),)
8149
@echo "Building iOS framework. Please wait..."
82-
@cd $(BLS_LIB_BASE_PATH)/bls && git checkout . && git apply $(ROOT_DIR)/patches/github.com-herumi-bls-gomobile_ios.patch && cd - >> /dev/null
8350
@gomobile bind -ldflags="-s -w" -target=ios -o $(IOSMOBILESDKDIR)/$(IOSBINNAME) $(GOSDK_PATH)/zcncore
8451
@echo " $(IOSMOBILESDKDIR)/$(IOSBINNAME). - [OK]"
85-
ifeq ($(NOANDROID),)
52+
endif
53+
ifneq ($(ANDROID),)
8654
@echo "Building Android framework. Please wait..."
87-
@cd $(BLS_LIB_BASE_PATH)/bls && git checkout . && git apply $(ROOT_DIR)/patches/github.com-herumi-bls-gomobile_android.patch && cd - >> /dev/null
8855
@gomobile bind -target=android/arm64,android/amd64 -ldflags=-extldflags=-Wl,-soname,libgojni.so -o $(ANDROIDMOBILESDKDIR)/$(ANDROIDBINNAME) $(GOSDK_PATH)/zcncore
8956
@echo " $(ANDROIDMOBILESDKDIR)/$(ANDROIDBINNAME). - [OK]"
9057
endif
91-
@cd $(BLS_LIB_BASE_PATH)/bls && git checkout . && cd - >> /dev/null
58+
@echo ""
9259
@$(PRINT_NON)
9360

9461
clean-mobilesdk:

core/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
//====== THIS IS AUTOGENERATED FILE. DO NOT MODIFY ========
33

44
package version
5-
const VERSIONSTR = "v1.0.29"
5+
const VERSIONSTR = "v1.0.30"
66

core/zcncrypto/ed255190chain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package zcncrypto
22

33
import (
44
"bytes"
5-
"crypto/ed25519"
65
"encoding/hex"
76
"errors"
87
"fmt"
98
"time"
109

1110
"github.com/0chain/gosdk/core/encryption"
1211
"github.com/tyler-smith/go-bip39"
12+
"golang.org/x/crypto/ed25519"
1313
)
1414

1515
//ED255190chainScheme - a signature scheme based on ED25519

0 commit comments

Comments
 (0)