Skip to content

Commit b66c421

Browse files
authored
Merge pull request #52 from lightninglabs/lnc-mobile
LNC Mobile
2 parents 73f0035 + 59518e7 commit b66c421

File tree

13 files changed

+972
-89
lines changed

13 files changed

+972
-89
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ jobs:
4848
- name: go compile
4949
run: make build
5050

51+
- name: gomobile install
52+
run: go install golang.org/x/mobile/cmd/gomobile@v0.0.0-20220928052126-fa6bcb076835
53+
54+
- name: gomobile init
55+
run: gomobile init
56+
57+
- name: android compile
58+
run: make android
59+
5160
- name: wasm compile
5261
run: make wasm
5362

.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

cmd/wasm-client/go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module github.com/lightninglabs/lightning-node-connect/cmd/wasm-client
22

33
require (
4-
github.com/btcsuite/btcd/btcec/v2 v2.2.0
4+
github.com/btcsuite/btcd/btcec/v2 v2.2.1
55
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
66
github.com/golang/protobuf v1.5.2
77
github.com/jessevdk/go-flags v1.4.0
8-
github.com/lightninglabs/faraday v0.2.7-alpha.0.20220614135954-0f761430806c
8+
github.com/lightninglabs/faraday v0.2.8-alpha.0.20220909105059-fea194ffb084
99
github.com/lightninglabs/lightning-node-connect v0.1.9-alpha.0.20220602120524-e9964c685b18
10-
github.com/lightninglabs/loop v0.19.1-beta.0.20220614171321-490fb352ffe9
11-
github.com/lightninglabs/pool v0.5.6-alpha.0.20220615075127-160ae4594f4a
12-
github.com/lightningnetwork/lnd v0.15.0-beta.rc4
10+
github.com/lightninglabs/loop v0.20.1-beta.0.20220916122221-9c3010150016
11+
github.com/lightninglabs/pool v0.5.8-alpha
12+
github.com/lightningnetwork/lnd v0.15.0-beta.rc6.0.20221005111311-2efc70a5c492
1313
google.golang.org/grpc v1.39.0
1414
gopkg.in/macaroon-bakery.v2 v2.0.1
1515
gopkg.in/macaroon.v2 v2.1.0

0 commit comments

Comments
 (0)