6
1
mirror of https://git.mills.io/saltyim/saltyim.git synced 2024-06-27 09:18:22 +00:00
prologic-saltyim/Makefile
James Mills be4b4a5e9d Add a basic structure for a go-app PWA + integrated Broker (#36)
Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Co-authored-by: Jon Lundy <jon@xuu.cc>
Reviewed-on: https://git.mills.io/prologic/saltyim/pulls/36
2022-03-21 22:27:35 +00:00

81 lines
1.8 KiB
Makefile

-include environ.inc
.PHONY: deps dev build install image release test clean
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/salty-chat
TAG := latest
else
IMAGE := prologic/salty-chat
TAG := dev
endif
all: preflight build
preflight:
@./preflight.sh
deps:
dev : DEBUG=1
dev : build
@./salty-chat -v
cli:
@$(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
@$(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
generate:
@if [ x"$(DEBUG)" = x"1" ]; then \
echo 'Running in debug mode...'; \
fi
GOARCH=wasm GOOS=js $(GOCMD) build -o ./internal/web/app.wasm ./internal/pwa/
install: build
@install -D -m 755 salty-chat $(DESTDIR)/salty-chat
ifeq ($(PUBLISH), 1)
image: generate
@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
@./tools/release.sh
fmt:
@$(GOCMD) fmt ./...
test:
@CGO_ENABLED=1 $(GOCMD) test -v -cover -race ./...
coverage:
@CGO_ENABLED=1 $(GOCMD) test -v -cover -race -cover -coverprofile=coverage.out ./...
@$(GOCMD) tool cover -html=coverage.out
clean:
@git clean -f -d -X