mirror of
https://git.mills.io/saltyim/saltyim.git
synced 2024-06-28 09:41:02 +00:00
3fccb3ae5f
This PR also: - Tidies up the default options and config - Tidies up the service user code Co-authored-by: James Mills <prologic@shortcircuit.net.au> Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/116
106 lines
3.4 KiB
Makefile
106 lines
3.4 KiB
Makefile
-include environ.inc
|
|
.PHONY: help deps dev build install image release test clean clean-all
|
|
|
|
export CGO_ENABLED=0
|
|
VERSION=$(shell git describe --abbrev=0 --tags 2>/dev/null || echo "$VERSION")
|
|
COMMIT=$(shell git rev-parse --short HEAD || echo "$COMMIT")
|
|
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
|
|
GOCMD=go
|
|
GOVER=$(shell go version | grep -o -E 'go1\.17\.[0-9]+')
|
|
|
|
DESTDIR=/usr/local/bin
|
|
|
|
ifeq ($(BRANCH), master)
|
|
IMAGE := prologic/saltyim
|
|
TAG := latest
|
|
else
|
|
IMAGE := prologic/saltyim
|
|
TAG := dev
|
|
endif
|
|
|
|
all: help
|
|
|
|
.PHONY: help
|
|
|
|
help: ## Show this help message
|
|
@echo "salty.im - secure, easy, self-hosted messaging"
|
|
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
|
|
|
preflight: ## Run preflight checks to ensure you have the right build tools
|
|
@./preflight.sh
|
|
|
|
deps: ## Install any dependencies required
|
|
@$(GOCMD) install github.com/jsha/minica@latest
|
|
@$(GOCMD) install github.com/coredns/coredns@latest
|
|
|
|
certs: certs/minica-key.pem certs/minica.pem certs/_.home.arpa/key.pem certs/_.home.arpa/cert.pem
|
|
@/bin/sh -c 'cd certs && minica --domains salty.home.arpa'
|
|
|
|
dev : DEBUG=1
|
|
dev : certs ## Build debug version of salty-chat (CLI and TUI) and saltyd (Broker and PWA)
|
|
@CGO_ENABLED=1 $(GOCMD) build ./cmd/salty-chat/...
|
|
@CGO_ENABLED=1 $(GOCMD) build -tags "embed" ./cmd/saltyd/...
|
|
@./saltyd -D -b :https --tls \
|
|
--tls-key ./certs/_.home.arpa/key.pem \
|
|
--tls-cert ./certs/_.home.arpa/cert.pem
|
|
|
|
cli: ## Build the salty-chat command-line client and tui
|
|
@$(GOCMD) build -tags "netgo static_build" -installsuffix netgo \
|
|
-ldflags "-w \
|
|
-X $(shell go list).Version=$(VERSION) \
|
|
-X $(shell go list).Commit=$(COMMIT)" \
|
|
./cmd/salty-chat/
|
|
|
|
server: generate pwa ## Build the saltyd server and broker (also includes the PWA)
|
|
@$(GOCMD) build -tags "embed netgo static_build" -installsuffix netgo \
|
|
-ldflags "-w \
|
|
-X $(shell go list).Version=$(VERSION) \
|
|
-X $(shell go list).Commit=$(COMMIT)" \
|
|
./cmd/saltyd/
|
|
|
|
build: cli server ## Build the cli and the server
|
|
|
|
generate: ## Genereate any code required by the build
|
|
@if [ x"$(DEBUG)" = x"1" ]; then \
|
|
echo 'Running in debug mode...'; \
|
|
fi
|
|
|
|
PWA_SRCS = $(shell ls *.go) ./internal/server.go $(shell find ./internal/pwa -type f)
|
|
|
|
internal/web/app.wasm: $(PWA_SRCS)
|
|
@GOARCH=wasm GOOS=js $(GOCMD) build -o ./internal/web/app.wasm ./internal/pwa/
|
|
|
|
pwa: internal/web/app.wasm
|
|
|
|
install: build ## Install salty-chat (cli) and saltyd (server) to $DESTDIR
|
|
@install -D -m 755 salty-chat $(DESTDIR)/salty-chat
|
|
@install -D -m 755 saltyd $(DESTDIR)/saltyd
|
|
|
|
ifeq ($(PUBLISH), 1)
|
|
image: generate ## Build the Docker image
|
|
@docker build --build-arg VERSION="$(VERSION)" --build-arg COMMIT="$(COMMIT)" -t $(IMAGE):$(TAG) .
|
|
@docker push $(IMAGE):$(TAG)
|
|
else
|
|
image: generate
|
|
@docker build --build-arg VERSION="$(VERSION)" --build-arg COMMIT="$(COMMIT)" -t $(IMAGE):$(TAG) .
|
|
endif
|
|
|
|
release: generate ## Release a new version to Gitea
|
|
@./tools/release.sh
|
|
|
|
fmt: ## Format sources fiels
|
|
@$(GOCMD) fmt ./...
|
|
|
|
test: ## Run test suite
|
|
@CGO_ENABLED=1 $(GOCMD) test -v -cover -race ./...
|
|
|
|
coverage: ## Get test coverage report
|
|
@CGO_ENABLED=1 $(GOCMD) test -v -cover -race -cover -coverprofile=coverage.out ./...
|
|
@$(GOCMD) tool cover -html=coverage.out
|
|
|
|
clean: ## Remove untracked files
|
|
@git clean -f -d -x -e certs
|
|
|
|
clean-all: ## Remove untracked and Git ignores files
|
|
@git clean -f -d -X
|