github.com/0chain/gosdk@v1.17.11/_util/build_mobile.mk (about)

     1  0CHAIN_PATH	:=  github.com/0chain
     2  GOSDK_PATH :=  $(0CHAIN_PATH)/gosdk
     3  OUTDIR := $(ROOT_DIR)/out
     4  IOSMOBILESDKDIR     := $(OUTDIR)/iossdk
     5  ANDROIDMOBILESDKDIR := $(OUTDIR)/androidsdk
     6  MACSDKDIR	:= $(OUTDIR)/macossdk
     7  IOSBINNAME 		:= zcncore.xcframework
     8  ANDROIDBINNAME	:= zcncore.aar
     9  MINIOSVERSIONMIN := "-miphoneos-version-min=7.0=7.0 -mios-version-min=7.0 -mios-simulator-version-min=7.0"
    10  MINMACOSVERSIONMIN := "-mmacosx-version-min=10.12"
    11  
    12  PKG_EXPORTS := $(GOSDK_PATH)/zcncore $(GOSDK_PATH)/core/common $(GOSDK_PATH)/mobilesdk/sdk $(GOSDK_PATH)/mobilesdk/zbox $(GOSDK_PATH)/mobilesdk/zboxapi $(GOSDK_PATH)/mobilesdk/zcn
    13  
    14  .PHONY: setup-gomobile build-iossimulator build-ios build-android build-android-debug
    15  
    16  $(IOSMOBILESDKDIR):
    17  	$(shell mkdir -p $(IOSMOBILESDKDIR))
    18  
    19  $(ANDROIDMOBILESDKDIR):
    20  	$(shell mkdir -p $(ANDROIDMOBILESDKDIR))
    21  
    22  $(MACSDKDIR):
    23  	$(shell mkdir -p $(MACSDKDIR))
    24  
    25  setup-gomobile: $(IOSMOBILESDKDIR) $(ANDROIDMOBILESDKDIR) $(MACSDKDIR)
    26  	@$(PRINT_MAG)
    27  	@echo "============================================================"
    28  	@echo "    Initializing gomobile. Please wait it may take a while ..."
    29  	@echo "------------------------------------------------------------"
    30  	@go install golang.org/x/mobile/cmd/gomobile@latest
    31  	@$(PRINT_NON)
    32  	@gomobile init
    33  	@$(PRINT_GRN)
    34  	@echo "  ___ __  _  _ ____ __   ____ ____ ____ ____  "
    35  	@echo " / __/  \( \/ (  _ (  ) (  __(_  _(  __(    \ "
    36  	@echo "( (_(  O / \/ \) __/ (_/\) _)  )(  ) _) ) D ( "
    37  	@echo " \___\__/\_)(_(__) \____(____)(__)(____(____/ "
    38  	@$(PRINT_NON)
    39  
    40  $(GOPATH)/src/$(GOSDK_PATH):
    41  	@echo "gosdk is not in GOPATH. Creating softlink..."
    42  ifneq ($(GOPATH), )
    43  	$(shell ln -sf $(ROOT_DIR) $(GOPATH)/src/$(0CHAIN_PATH))
    44  endif
    45  
    46  
    47  clean-mobilesdk:
    48  	@rm -rf $(ANDROIDMOBILESDKDIR)/$(ANDROIDBINNAME)
    49  	@rm -rf $(IOSMOBILESDKDIR)/$(IOSBINNAME)
    50  
    51  cleanall-gomobile:
    52  	@rm -rf $(OUTDIR)
    53  	@rm -rf $(BLS_LIB_BASE_PATH)
    54  
    55  gomobile-install:
    56  	go install golang.org/x/mobile/cmd/gomobile@latest
    57  	gomobile init
    58  
    59  build-iossimulator: $(IOSMOBILESDKDIR) getrev
    60  	@echo "Building iOS Simulator framework. Please wait..."
    61  	@CGO_CFLAGS=$(MINIOSVERSIONMIN) gomobile bind -v -ldflags="-s -w" -target=iossimulator -tags "ios iossimulator mobile" -o $(IOSMOBILESDKDIR)/simulator/$(IOSBINNAME) $(PKG_EXPORTS)
    62  	@echo "   $(IOSMOBILESDKDIR)/simulator/$(IOSBINNAME). - [OK]"
    63  
    64  build-ios: $(IOSMOBILESDKDIR) getrev
    65  	@echo "Building iOS framework. Please wait..."
    66  	@go get golang.org/x/mobile/bind
    67  	@CGO_CFLAGS=$(MINIOSVERSIONMIN) gomobile bind -v -ldflags="-s -w" -target=ios,iossimulator -tags "ios mobile" -o $(IOSMOBILESDKDIR)/ios/$(IOSBINNAME) $(PKG_EXPORTS)
    68  	@echo "   $(IOSMOBILESDKDIR)/ios/$(IOSBINNAME). - [OK]"	
    69  
    70  build-android: $(ANDROIDMOBILESDKDIR) getrev
    71  	@echo "Building Android framework. Please wait..."
    72  	@go get golang.org/x/mobile/bind
    73  	@gomobile bind -v -ldflags="-s -w -extldflags=-Wl,-soname,libgojni.so" -target=android/arm64,android/amd64 -androidapi 19 -tags mobile  -o $(ANDROIDMOBILESDKDIR)/$(ANDROIDBINNAME) $(PKG_EXPORTS)
    74  	@echo "   $(ANDROIDMOBILESDKDIR)/$(ANDROIDBINNAME). - [OK]"
    75  
    76  build-android-debug: $(ANDROIDMOBILESDKDIR) getrev
    77  	@echo "Building Android framework. Please wait..."
    78  	@go get golang.org/x/mobile/bind
    79  	@gomobile bind -v -ldflags="-s -w -extldflags=-Wl,-soname,libgojni.so" -gcflags '-N -l' -target=android/arm64,android/amd64 -tags mobile  -o $(ANDROIDMOBILESDKDIR)/$(ANDROIDBINNAME) $(PKG_EXPORTS)
    80  	@echo "   $(ANDROIDMOBILESDKDIR)/$(ANDROIDBINNAME). - [OK]"
    81  
    82  build-macos: $(MACSDKDIR) getrev
    83  	@echo "Building MAC framework. Please wait..."
    84  	@go get golang.org/x/mobile/bind
    85  	@CGO_CFLAGS=$(MINMACOSVERSIONMIN)  gomobile bind -v -ldflags="-s -w" -target=macos -tags mobile -o $(MACSDKDIR)/$(IOSBINNAME) $(PKG_EXPORTS)
    86  	@echo "   $(MACSDKDIR)/$(IOSBINNAME). - [OK]"