multi: add support for building without UI

This commit adds support for building without UI.
If the build tag "litd no_ui" is set the UI will
be disabled.
This commit is contained in:
sputn1ck 2023-02-22 15:55:23 +01:00
parent 303312c2af
commit bc0bc687ae
No known key found for this signature in database
GPG key ID: 671103D881A5F0E4
5 changed files with 42 additions and 10 deletions

View file

@ -130,11 +130,22 @@ go-build:
$(GOBUILD) -tags="$(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" -o litd-debug $(PKG)/cmd/litd
$(GOBUILD) -tags="$(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" -o litcli-debug $(PKG)/cmd/litcli
go-build-noui:
@$(call print, "Building lightning-terminal without UI.")
$(GOBUILD) -tags="litd_no_ui $(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" -o litd-debug $(PKG)/cmd/litd
$(GOBUILD) -tags="litd_no_ui $(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" -o litcli-debug $(PKG)/cmd/litcli
go-install:
@$(call print, "Installing lightning-terminal.")
$(GOINSTALL) -trimpath -tags="$(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" $(PKG)/cmd/litd
$(GOINSTALL) -trimpath -tags="$(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" $(PKG)/cmd/litcli
go-install-noui:
@$(call print, "Installing lightning-terminal without UI.")
$(GOINSTALL) -tags="litd_no_ui $(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" $(PKG)/cmd/litd
$(GOINSTALL) -tags="litd_no_ui $(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" $(PKG)/cmd/litcli
go-install-cli:
@$(call print, "Installing all CLI binaries.")
$(GOINSTALL) -trimpath -tags="$(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" github.com/lightningnetwork/lnd/cmd/lncli

19
app.go Normal file
View file

@ -0,0 +1,19 @@
//go:build !litd_no_ui
// +build !litd_no_ui
package terminal
import (
"embed"
)
var (
// appBuildFS is an in-memory file system that contains all the static
// HTML/CSS/JS files of the UI. It is compiled into the binary with the
// go 1.16 embed directive below. Because the path is relative to the
// root package, all assets will have a path prefix of /app/build/ which
// we'll strip by giving a sub directory to the HTTP server.
//
//go:embed app/build/*
appBuildFS embed.FS
)

10
app_noui.go Normal file
View file

@ -0,0 +1,10 @@
//go:build litd_no_ui
// +build litd_no_ui
package terminal
import "embed"
var (
appBuildFS embed.FS
)

View file

@ -6,6 +6,8 @@
- [Fixed a bug where REST calls for the `WalletUnlocker` service weren't allowed
on startup](https://github.com/lightninglabs/lightning-terminal/pull/806).
- [Added build flag 'litd_no_ui' for building litd without the ui, accessible
with 'make go-build-noui' and 'make go-install-noui'](https://github.com/lightninglabs/lightning-terminal/pull/500).
### LND

View file

@ -3,7 +3,6 @@ package terminal
import (
"context"
"crypto/tls"
"embed"
"encoding/binary"
"encoding/hex"
"errors"
@ -91,15 +90,6 @@ var (
// the macaroon database before we give up with an error.
macDatabaseOpenTimeout = time.Second * 5
// appBuildFS is an in-memory file system that contains all the static
// HTML/CSS/JS files of the UI. It is compiled into the binary with the
// go 1.16 embed directive below. Because the path is relative to the
// root package, all assets will have a path prefix of /app/build/ which
// we'll strip by giving a sub directory to the HTTP server.
//
//go:embed app/build/*
appBuildFS embed.FS
// appFilesDir is the sub directory of the above build directory which
// we pass to the HTTP server.
appFilesDir = "app/build"