forked from ipfs-shipyard/gomobile-ipfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (56 loc) · 2.58 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
MAKEFILE_DIR = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
GO_DIR = $(MAKEFILE_DIR)/go
ANDROID_DIR = $(MAKEFILE_DIR)/android
IOS_DIR = $(MAKEFILE_DIR)/ios
GO_SRC = $(shell find $(GO_DIR) -not \( -path $(GO_DIR)/vendor -prune \) -name \*.go)
BIND_PACKAGE = github.com/berty/gomobile-ipfs/go/bind/ipfs
GOMOBILE = $(GOPATH)/bin/gomobile
GOMOBILE_OPT ?=
ADDITIONAL_GO_PKG ?=
VERSION_FILE = $(MAKEFILE_DIR)/version
LIB_VERSION = $(shell cat $(VERSION_FILE))
VENDOR = $(GO_DIR)/vendor
MOD_FILES = $(GO_DIR)/go.mod $(GO_DIR)/go.sum
BUILD_DIR_IOS = $(IOS_DIR)/Frameworks
BUILD_LIB_IOS = $(BUILD_DIR_IOS)/Ipfs.framework
BUILD_DIR_ANDROID = $(ANDROID_DIR)/local_repo/ipfs/gomobile/gomobile-ipfs/$(LIB_VERSION)
BUILD_LIB_ANDROID = $(BUILD_DIR_ANDROID)/gomobile-ipfs-$(LIB_VERSION).aar
BUILD_POM_ANDROID = $(BUILD_DIR_ANDROID)/gomobile-ipfs-$(LIB_VERSION).pom
POM_TEMPLATE = $(ANDROID_DIR)/pom_template
.PHONY: help build build.android build.ios test deps clean clean.android clean.ios re re.ios re.android
help:
@echo "Commands:"
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | grep -v / | sed 's/^/ $(HELP_MSG_PREFIX)make /'
build: build.android build.ios
build.android: $(BUILD_LIB_ANDROID) $(BUILD_POM_ANDROID)
$(BUILD_LIB_ANDROID): $(BUILD_DIR_ANDROID) $(GO_SRC) $(VENDOR) | $(GOMOBILE)
GO111MODULE=off $(GOMOBILE) bind -v $(GOMOBILE_OPT) -target=android -o $(BUILD_LIB_ANDROID) $(BIND_PACKAGE) $(ADDITIONAL_GO_PKG)
$(BUILD_DIR_ANDROID):
mkdir -p $(BUILD_DIR_ANDROID)
$(BUILD_POM_ANDROID):
sed -e 's/{{LIB_VERSION}}/$(LIB_VERSION)/g' $(POM_TEMPLATE) > $(BUILD_POM_ANDROID)
build.ios: $(BUILD_LIB_IOS)
$(BUILD_LIB_IOS): $(BUILD_DIR_IOS) $(GO_SRC) $(VENDOR) | $(GOMOBILE)
GO111MODULE=off $(GOMOBILE) bind -v $(GOMOBILE_OPT) -target=ios -o $(BUILD_LIB_IOS) $(BIND_PACKAGE) $(ADDITIONAL_GO_PKG)
$(BUILD_DIR_IOS):
mkdir -p $(BUILD_DIR_IOS)
test: $(VENDOR)
cd $(GO_DIR) && go test -v ./...
deps: $(VENDOR)
$(GOMOBILE):
GO111MODULE=off go get golang.org/x/mobile/cmd/gomobile
gomobile init -v
$(VENDOR): $(MOD_FILES)
ifneq ($(wildcard /bin/bash),)
@bash -c 'echo "GO111MODULE=on go mod vendor" && cd $(GO_DIR) && GO111MODULE=on go mod vendor 2> >(grep -v "warning: ignoring symlink" 1>&2)'
else
cd $(GO_DIR) && GO111MODULE=on go mod vendor
endif
clean: clean.android clean.ios
clean.android:
rm -rf $(BUILD_DIR_ANDROID)
clean.ios:
rm -rf $(BUILD_DIR_IOS)
re: re.android re.ios
re.android: clean.android build.android
re.ios: clean.ios build.ios