go-paste/Makefile

62 lines
1.5 KiB
Makefile

ROUTE_ASSET=src/routes/bindata.go
DOCS_ASSET=src/docs/bindata.go
SOURCE=$(wildcard cmd/paste/*.go) $(filter-out src/routes/bindata.go, $(wildcard src/routes/*.go))
BINARY=paste
PKG=./cmd/paste
VERSION=$(shell git describe --tags `git rev-list --tags --max-count=1`|cut -b2-)
VERSION_PAT=$(shell debian/inc_version.sh -p $(VERSION))
VERSION_MIN=$(shell debian/inc_version.sh -m $(VERSION))
VERSION_MAJ=$(shell debian/inc_version.sh -M $(VERSION))
DATE:=$(shell date -u +%FT%TZ)
define DUMMY_BINDATA
package docs
import "net/http"
func assetFS() (fs http.FileSystem) { return }
endef
export DUMMY_BINDATA
all: $(BINARY)
clean:
rm -rf $(BINARY)
setup:
go mod download
fmt:
go fmt ./...
test: $(ROUTE_ASSET) $(DOCS_ASSET)
go test ./...
go vet ./...
run:
go run \
-ldflags "-X main.AppVersion=$(VERSION_PAT) -X main.AppBuild=$(DATE)" \
$(PKG) -vv serve
$(BINARY): $(SOURCE) $(ROUTE_ASSET) $(DOCS_ASSET)
go build -v \
-ldflags "-X main.AppVersion=$(VERSION) -X main.AppBuild=$(DATE)" \
"sour.is/x/paste/cmd/paste"
clean-ui:
rm -rf $(ROUTE_ASSET) $(DOCS_ASSET)
build-ui: clean-ui $(ROUTE_ASSET) $(DOCS_ASSET)
$(ROUTE_ASSET):
cd assets; \
rm -rf build ../public; \
npm i; npm run build; \
cp -r build ../public
go generate "sour.is/x/paste/src/routes"
$(DOCS_ASSET):
echo "$$DUMMY_BINDATA" > src/docs/bindata.go
go generate "sour.is/x/paste/cmd/paste"
go generate "sour.is/x/paste/src/docs"
deploy: $(SOURCE) $(ROUTE_ASSET)
cd debian && make
.PHONEY: all clean build deploy run setup
# DO NOT DELETE