Skip to content

Commit fd9dd41

Browse files
committed
Makefile: LNC mobile
1 parent f7d7bb9 commit fd9dd41

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@
1515
# vendor/
1616

1717
wasm-client.wasm
18+
19+
# Mobile build output
20+
build/
21+
22+
# Misc
23+
*.DS_Store

.golangci.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
run:
22
# timeout for analysis
33
deadline: 4m
4+
build-tags:
5+
- autopilotrpc
6+
- chainrpc
7+
- invoicesrpc
8+
- neutrinorpc
9+
- peersrpc
10+
- signrpc
11+
- walletrpc
12+
- watchtowerrpc
413

514
linters-settings:
615
govet:
@@ -31,4 +40,4 @@ linters:
3140
- funlen
3241

3342
# Gosec is outdated and reports false positives.
34-
- gosec
43+
- gosec

Makefile

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ GOLIST := go list $(PKG)/... | grep -v '/vendor/'
2020
XARGS := xargs -L 1
2121

2222
LDFLAGS := -s -w -buildid=
23+
LDFLAGS_MOBILE := -ldflags "$(call make_ldflags, ${tags}, -s -w)"
2324

2425
RM := rm -f
2526
CP := cp
@@ -28,6 +29,18 @@ XARGS := xargs -L 1
2829

2930
LINT = $(LINT_BIN) run -v --build-tags itest
3031

32+
PKG := github.com/lightninglabs/lightning-node-connect
33+
MOBILE_PKG := $(PKG)/mobile
34+
MOBILE_BUILD_DIR :=${GOPATH}/src/$(PKG)/build
35+
IOS_BUILD_DIR := $(MOBILE_BUILD_DIR)/ios
36+
IOS_BUILD := $(IOS_BUILD_DIR)/Lndmobile.xcframework
37+
ANDROID_BUILD_DIR := $(MOBILE_BUILD_DIR)/android
38+
ANDROID_BUILD := $(ANDROID_BUILD_DIR)/lnc-mobile.aar
39+
40+
GOMOBILE_BIN := $(GO_BIN)/gomobile
41+
42+
RPC_TAGS := appengine autopilotrpc chainrpc invoicesrpc neutrinorpc peersrpc signrpc wtclientrpc watchtowerrpc routerrpc walletrpc verrpc
43+
3144
include make/testing_flags.mk
3245

3346
default: build
@@ -48,14 +61,36 @@ $(LINT_BIN):
4861

4962
build:
5063
@$(call print, "Building lightning-node-connect.")
51-
$(GOBUILD) $(PKG)/...
64+
$(GOBUILD) -tags="$(RPC_TAGS)" $(PKG)/...
5265

5366
wasm:
5467
# The appengine build tag is needed because of the jessevdk/go-flags library
5568
# that has some OS specific terminal code that doesn't compile to WASM.
56-
cd cmd/wasm-client; GOOS=js GOARCH=wasm go build -trimpath -ldflags="$(LDFLAGS)" -tags="appengine autopilotrpc chainrpc invoicesrpc neutrinorpc peersrpc signrpc wtclientrpc watchtowerrpc routerrpc walletrpc verrpc" -v -o wasm-client.wasm .
69+
cd cmd/wasm-client; GOOS=js GOARCH=wasm go build -trimpath -ldflags="$(LDFLAGS)" -tags="$(RPC_TAGS)" -v -o wasm-client.wasm .
5770
$(CP) cmd/wasm-client/wasm-client.wasm example/wasm-client.wasm
5871

72+
apple:
73+
@$(call print, "Building iOS and macOS cxframework ($(IOS_BUILD)).")
74+
mkdir -p $(IOS_BUILD_DIR)
75+
$(GOMOBILE_BIN) bind -target=ios,iossimulator,macos -tags="mobile $(DEV_TAGS) $(RPC_TAGS)" $(LDFLAGS_MOBILE) -v -o $(IOS_BUILD) $(MOBILE_PKG)
76+
77+
ios:
78+
@$(call print, "Building iOS cxframework ($(IOS_BUILD)).")
79+
mkdir -p $(IOS_BUILD_DIR)
80+
$(GOMOBILE_BIN) bind -target=ios,iossimulator -tags="mobile $(DEV_TAGS) $(RPC_TAGS)" $(LDFLAGS_MOBILE) -v -o $(IOS_BUILD) $(MOBILE_PKG)
81+
82+
macos:
83+
@$(call print, "Building macOS cxframework ($(IOS_BUILD)).")
84+
mkdir -p $(IOS_BUILD_DIR)
85+
$(GOMOBILE_BIN) bind -target=macos -tags="mobile $(DEV_TAGS) $(RPC_TAGS)" $(LDFLAGS_MOBILE) -v -o $(IOS_BUILD) $(MOBILE_PKG)
86+
87+
android:
88+
@$(call print, "Building Android library ($(ANDROID_BUILD)).")
89+
mkdir -p $(ANDROID_BUILD_DIR)
90+
GOOS=js $(GOMOBILE_BIN) bind -target=android -tags="mobile $(DEV_TAGS) $(RPC_TAGS)" -androidapi 21 $(LDFLAGS_MOBILE) -v -o $(ANDROID_BUILD) $(MOBILE_PKG)
91+
92+
mobile: ios android
93+
5994
# =======
6095
# TESTING
6196
# =======
@@ -64,11 +99,11 @@ check: unit
6499

65100
unit:
66101
@$(call print, "Running unit tests.")
67-
$(UNIT)
102+
$(UNIT) -tags="$(RPC_TAGS)"
68103

69104
unit-race:
70105
@$(call print, "Running unit race tests.")
71-
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(UNIT_RACE)
106+
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(UNIT_RACE) -tags="$(RPC_TAGS)"
72107

73108
itest: itest-run
74109

0 commit comments

Comments
 (0)