Merge pull request #4469 from halseth/mobile-global-config
mobile+make: restore mobile compilation
This commit is contained in:
commit
9d147c55d7
@ -44,6 +44,8 @@ jobs:
|
||||
- make lint workers=1
|
||||
- make btcd
|
||||
- make release sys=windows-amd64
|
||||
- make mobile-rpc
|
||||
- go build --tags="mobile" ./mobile
|
||||
- stage: Test
|
||||
script: make travis-cover
|
||||
name: Unit Cover
|
||||
|
20
Makefile
20
Makefile
@ -6,6 +6,8 @@ BTCD_PKG := github.com/btcsuite/btcd
|
||||
GOVERALLS_PKG := github.com/mattn/goveralls
|
||||
LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
GOACC_PKG := github.com/ory/go-acc
|
||||
FALAFEL_PKG := github.com/lightninglabs/falafel
|
||||
GOIMPORTS_PKG := golang.org/x/tools/cmd/goimports
|
||||
|
||||
GO_BIN := ${GOPATH}/bin
|
||||
BTCD_BIN := $(GO_BIN)/btcd
|
||||
@ -32,6 +34,7 @@ BTCD_COMMIT := $(shell cat go.mod | \
|
||||
|
||||
LINT_COMMIT := v1.18.0
|
||||
GOACC_COMMIT := ddc355013f90fea78d83d3a6c71f1d37ac07ecd5
|
||||
FALAFEL_COMMIT := v0.7.1
|
||||
|
||||
DEPGET := cd /tmp && GO111MODULE=on go get -v
|
||||
GOBUILD := GO111MODULE=on go build -v
|
||||
@ -107,6 +110,14 @@ btcd:
|
||||
@$(call print, "Installing btcd.")
|
||||
$(DEPGET) $(BTCD_PKG)@$(BTCD_COMMIT)
|
||||
|
||||
falafel:
|
||||
@$(call print, "Installing falafel.")
|
||||
$(DEPGET) $(FALAFEL_PKG)@$(FALAFEL_COMMIT)
|
||||
|
||||
goimports:
|
||||
@$(call print, "Installing goimports.")
|
||||
$(DEPGET) $(GOIMPORTS_PKG)
|
||||
|
||||
# ============
|
||||
# INSTALLATION
|
||||
# ============
|
||||
@ -213,9 +224,9 @@ rpc-check: rpc
|
||||
for rpc in $$(find lnrpc/ -name "*.proto" | $(XARGS) awk '/ rpc /{print $$2}'); do if ! grep -q $$rpc lnrpc/rest-annotations.yaml; then echo "RPC $$rpc not added to lnrpc/rest-annotations.yaml"; exit 1; fi; done
|
||||
if test -n "$$(git describe --dirty | grep dirty)"; then echo "Protos not properly formatted or not compiled with v3.4.0"; git status; git diff; exit 1; fi
|
||||
|
||||
mobile-rpc:
|
||||
mobile-rpc: falafel goimports
|
||||
@$(call print, "Creating mobile RPC from protos.")
|
||||
cd ./mobile; ./gen_bindings.sh
|
||||
cd ./mobile; ./gen_bindings.sh $(FALAFEL_COMMIT)
|
||||
|
||||
vendor:
|
||||
@$(call print, "Re-creating vendor directory.")
|
||||
@ -224,12 +235,12 @@ vendor:
|
||||
ios: vendor mobile-rpc
|
||||
@$(call print, "Building iOS framework ($(IOS_BUILD)).")
|
||||
mkdir -p $(IOS_BUILD_DIR)
|
||||
$(GOMOBILE_BIN) bind -target=ios -tags="ios $(DEV_TAGS) autopilotrpc experimental" $(LDFLAGS) -v -o $(IOS_BUILD) $(MOBILE_PKG)
|
||||
$(GOMOBILE_BIN) bind -target=ios -tags="mobile $(DEV_TAGS) autopilotrpc experimental" $(LDFLAGS) -v -o $(IOS_BUILD) $(MOBILE_PKG)
|
||||
|
||||
android: vendor mobile-rpc
|
||||
@$(call print, "Building Android library ($(ANDROID_BUILD)).")
|
||||
mkdir -p $(ANDROID_BUILD_DIR)
|
||||
$(GOMOBILE_BIN) bind -target=android -tags="android $(DEV_TAGS) autopilotrpc experimental" $(LDFLAGS) -v -o $(ANDROID_BUILD) $(MOBILE_PKG)
|
||||
$(GOMOBILE_BIN) bind -target=android -tags="mobile $(DEV_TAGS) autopilotrpc experimental" $(LDFLAGS) -v -o $(ANDROID_BUILD) $(MOBILE_PKG)
|
||||
|
||||
mobile: ios android
|
||||
|
||||
@ -252,6 +263,7 @@ clean:
|
||||
unit \
|
||||
unit-cover \
|
||||
unit-race \
|
||||
falafel \
|
||||
goveralls \
|
||||
travis-race \
|
||||
travis-cover \
|
||||
|
@ -1,4 +1,4 @@
|
||||
// +build ios android
|
||||
// +build mobile
|
||||
|
||||
package lndmobile
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
|
||||
flags "github.com/jessevdk/go-flags"
|
||||
"github.com/lightningnetwork/lnd"
|
||||
"github.com/lightningnetwork/lnd/signal"
|
||||
)
|
||||
|
||||
// Start starts lnd in a new goroutine.
|
||||
@ -40,10 +41,21 @@ func Start(extraArgs string, unlockerReady, rpcReady Callback) {
|
||||
splitArgs = append(splitArgs, "--"+a)
|
||||
}
|
||||
|
||||
// Add the extra arguments to os.Args, as that will be parsed during
|
||||
// startup.
|
||||
// Add the extra arguments to os.Args, as that will be parsed in
|
||||
// LoadConfig below.
|
||||
os.Args = append(os.Args, splitArgs...)
|
||||
|
||||
// Load the configuration, and parse the extra arguments as command
|
||||
// line options. This function will also set up logging properly.
|
||||
loadedConfig, err := lnd.LoadConfig()
|
||||
if err != nil {
|
||||
_, _ = fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Hook interceptor for os signals.
|
||||
signal.Intercept()
|
||||
|
||||
// Set up channels that will be notified when the RPC servers are ready
|
||||
// to accept calls.
|
||||
var (
|
||||
@ -67,7 +79,9 @@ func Start(extraArgs string, unlockerReady, rpcReady Callback) {
|
||||
// Call the "real" main in a nested manner so the defers will properly
|
||||
// be executed in the case of a graceful shutdown.
|
||||
go func() {
|
||||
if err := lnd.Main(cfg); err != nil {
|
||||
if err := lnd.Main(
|
||||
loadedConfig, cfg, signal.ShutdownChannel(),
|
||||
); err != nil {
|
||||
if e, ok := err.(*flags.Error); ok &&
|
||||
e.Type == flags.ErrHelp {
|
||||
} else {
|
||||
@ -84,7 +98,7 @@ func Start(extraArgs string, unlockerReady, rpcReady Callback) {
|
||||
|
||||
// We must set the TLS certificates in order to properly
|
||||
// authenticate with the wallet unlocker service.
|
||||
auth, err := lnd.WalletUnlockerAuthOptions()
|
||||
auth, err := lnd.WalletUnlockerAuthOptions(loadedConfig)
|
||||
if err != nil {
|
||||
unlockerReady.OnError(err)
|
||||
return
|
||||
@ -102,7 +116,7 @@ func Start(extraArgs string, unlockerReady, rpcReady Callback) {
|
||||
// Now that the RPC server is ready, we can get the needed
|
||||
// authentication options, and add them to the global dial
|
||||
// options.
|
||||
auth, err := lnd.AdminAuthOptions()
|
||||
auth, err := lnd.AdminAuthOptions(loadedConfig)
|
||||
if err != nil {
|
||||
rpcReady.OnError(err)
|
||||
return
|
||||
|
@ -3,11 +3,17 @@
|
||||
mkdir -p build
|
||||
|
||||
# Check falafel version.
|
||||
falafelVersion="0.7"
|
||||
falafelVersion=$1
|
||||
if [ -z $falafelVersion ]
|
||||
then
|
||||
echo "falafel version not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
falafel=$(which falafel)
|
||||
if [ $falafel ]
|
||||
then
|
||||
version=$($falafel -v)
|
||||
version="v$($falafel -v)"
|
||||
if [ $version != $falafelVersion ]
|
||||
then
|
||||
echo "falafel version $falafelVersion required"
|
||||
@ -45,7 +51,7 @@ protoc -I/usr/local/include -I. \
|
||||
# If prefix=1 is specified, prefix the generated methods with subserver name.
|
||||
# This must be enabled to support subservers with name conflicts.
|
||||
use_prefix="0"
|
||||
if [[ $prefix = "1" ]]
|
||||
if [ "$prefix" = "1" ]
|
||||
then
|
||||
echo "Prefixing methods with subserver name"
|
||||
use_prefix="1"
|
||||
|
Loading…
Reference in New Issue
Block a user