2022-09-27 17:59:05 +08:00
|
|
|
.PHONY: build clean ui
|
|
|
|
|
2023-01-16 10:52:06 +08:00
|
|
|
VERSION=1.0.3
|
2022-09-27 17:59:05 +08:00
|
|
|
BIN=answer
|
|
|
|
DIR_SRC=./cmd/answer
|
|
|
|
DOCKER_CMD=docker
|
|
|
|
|
2022-10-20 10:22:46 +08:00
|
|
|
#GO_ENV=CGO_ENABLED=0
|
2022-10-18 12:19:07 +08:00
|
|
|
Revision=$(shell git rev-parse --short HEAD)
|
2022-10-28 13:34:23 +08:00
|
|
|
GO_FLAGS=-ldflags="-X main.Version=$(VERSION) -X 'main.Revision=$(Revision)' -X 'main.Time=`date`' -extldflags -static"
|
2022-09-27 17:59:05 +08:00
|
|
|
GO=$(GO_ENV) $(shell which go)
|
|
|
|
|
|
|
|
build:
|
|
|
|
@$(GO_ENV) $(GO) build $(GO_FLAGS) -o $(BIN) $(DIR_SRC)
|
|
|
|
|
2022-11-01 15:50:46 +08:00
|
|
|
# https://dev.to/thewraven/universal-macos-binaries-with-go-1-16-3mm3
|
|
|
|
universal:
|
|
|
|
@GOOS=darwin GOARCH=amd64 $(GO_ENV) $(GO) build $(GO_FLAGS) -o ${BIN}_amd64 $(DIR_SRC)
|
|
|
|
@GOOS=darwin GOARCH=arm64 $(GO_ENV) $(GO) build $(GO_FLAGS) -o ${BIN}_arm64 $(DIR_SRC)
|
|
|
|
@lipo -create -output ${BIN} ${BIN}_amd64 ${BIN}_arm64
|
|
|
|
@rm -f ${BIN}_amd64 ${BIN}_arm64
|
|
|
|
|
2022-09-29 16:00:57 +08:00
|
|
|
generate:
|
|
|
|
go get github.com/google/wire/cmd/wire@latest
|
2022-12-14 17:20:48 +08:00
|
|
|
go install github.com/golang/mock/mockgen@v1.6.0
|
2022-09-29 16:00:57 +08:00
|
|
|
go generate ./...
|
|
|
|
go mod tidy
|
|
|
|
|
2022-09-27 17:59:05 +08:00
|
|
|
test:
|
2022-11-18 20:11:19 +08:00
|
|
|
@$(GO) test ./internal/repo/repo_test
|
2022-09-27 17:59:05 +08:00
|
|
|
|
|
|
|
# clean all build result
|
|
|
|
clean:
|
|
|
|
@$(GO) clean ./...
|
|
|
|
@rm -f $(BIN)
|
|
|
|
|
|
|
|
install-ui-packages:
|
|
|
|
@corepack enable
|
|
|
|
@corepack prepare pnpm@v7.12.2 --activate
|
|
|
|
|
|
|
|
ui:
|
2022-11-11 14:39:56 +08:00
|
|
|
@cd ui && pnpm install && pnpm build && cd -
|
2022-09-27 17:59:05 +08:00
|
|
|
|
|
|
|
all: clean build
|