5b7f7d9f31
A packed binary opened the system browser, so it felt like a tab, not an app. Build with -tags webview (cgo) and the viewer instead opens the site in its own window backed by the OS WebView: WKWebView on macOS, WebView2 on Windows, WebKitGTK on Linux. The viewer package picks an implementation at build time. The default file opens the browser and keeps the build pure Go, so CGO_ENABLED=0 and the release pipeline are untouched. The webview file links the platform WebView and runs its event loop on the main goroutine, which main now pins with LockOSThread before anything else, since macOS requires UI on the initial thread. Both kage open and the embedded viewer serve over HTTP in a goroutine and hand the URL to the viewer, then tear the server down when the window closes or Ctrl-C cancels. The window title comes from the archive's M/Title. OpenInBrowser moves out of pack into the viewer package, its only caller.
46 lines
1.2 KiB
Makefile
46 lines
1.2 KiB
Makefile
BIN := kage
|
|
PKG := ./cmd/kage
|
|
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
|
|
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
|
|
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
LDFLAGS := -s -w \
|
|
-X github.com/tamnd/kage/cli.Version=$(VERSION) \
|
|
-X github.com/tamnd/kage/cli.Commit=$(COMMIT) \
|
|
-X github.com/tamnd/kage/cli.Date=$(DATE)
|
|
|
|
export CGO_ENABLED := 0
|
|
|
|
.PHONY: build build-webview install test test-short vet tidy clean run
|
|
|
|
build:
|
|
go build -ldflags "$(LDFLAGS)" -o bin/$(BIN) $(PKG)
|
|
|
|
# A native-window viewer: opens packed sites in their own OS WebView window
|
|
# instead of the browser. Needs cgo, so it is built separately from the default
|
|
# pure-Go binary and the release pipeline.
|
|
build-webview:
|
|
CGO_ENABLED=1 go build -tags webview -ldflags "$(LDFLAGS)" -o bin/$(BIN) $(PKG)
|
|
|
|
install:
|
|
go install -ldflags "$(LDFLAGS)" $(PKG)
|
|
|
|
# Full suite, including the Chrome-driven end-to-end tests.
|
|
test:
|
|
go test -race ./...
|
|
|
|
# Skip the tests that launch a real browser (CI without Chrome, quick loops).
|
|
test-short:
|
|
go test -short ./...
|
|
|
|
vet:
|
|
go vet ./...
|
|
|
|
tidy:
|
|
go mod tidy
|
|
|
|
clean:
|
|
rm -rf bin
|
|
|
|
run: build
|
|
./bin/$(BIN)
|