代码拉取完成,页面将自动刷新
SHELL := /bin/bash
GO_BUILD_OPTION := -trimpath
.PHONY: check format vet lint build test
help:
@echo "Please use \`make <target>\` where <target> is one of"
@echo " check to format code and vet check"
@echo " build to create bin directory and build beyondtp"
@echo " build-frontend to build flutter web and copy to api/ui directory"
@echo " generate to generate code"
@echo " test to run unit tests"
@echo " tidy to tidy and check the go mod files"
check: format vet
format:
@echo "go fmt"
@go fmt ./...
@echo "ok"
generate:
@echo "generate code"
@go generate ./...
@echo "ok"
vet:
@echo "go vet"
@go vet ./...
@echo "ok"
build-frontend:
@echo "build frontend"
cd ./ui && flutter build web --release
cp -r ui/build/web/* api/ui
@echo "ok"
# We remove check target to work around build failed in container build.
# If we build in container, we will meet errors like:
#
# > go fmt
# > go: not formatting packages in dependency modules
# > package github.com/google/flatbuffers/grpc/tests: C++ source files not allowed when not using cgo or SWIG: grpctest.cpp message_builder_test.cpp
# > package github.com/google/flatbuffers/samples: C++ source files not allowed when not using cgo or SWIG: sample_bfbs.cpp sample_binary.cpp sample_text.cpp
# > package github.com/google/flatbuffers/tests: C++ source files not allowed when not using cgo or SWIG: monster_test.grpc.fb.cc native_type_test_impl.cpp test.cpp test_assert.cpp test_builder.cpp
# > make: *** [Makefile:19: format] Error 1
build: tidy build-frontend
@echo "build beyondtp"
CGO_ENABLED=1 go build ${GO_BUILD_OPTION} -race -o ./bin/beyondtp ./cmd/beyondtp
@echo "ok"
release: generate tidy check build-frontend
@echo "release beyondtp"
@-rm ./releases/*
@mkdir -p ./releases
@echo "build for linux amd64"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${GO_BUILD_OPTION} -o ./bin/linux-amd64/beyondtp ./cmd/beyondtp
tar -C ./bin/linux-amd64/ -czf ./releases/beyondtp_linux_amd64.tar.gz beyondtp
@echo "build for macos amd64"
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build ${GO_BUILD_OPTION} -o ./bin/darwin-amd64/beyondtp ./cmd/beyondtp
tar -C ./bin/darwin-amd64/ -czf ./releases/beyondtp_darwin_amd64.tar.gz beyondtp
@echo "build for macos arm64"
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build ${GO_BUILD_OPTION} -o ./bin/darwin-arm64/beyondtp ./cmd/beyondtp
tar -C ./bin/darwin-arm64/ -czf ./releases/beyondtp_darwin_arm64.tar.gz beyondtp
@echo "build for windows amd64"
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build ${GO_BUILD_OPTION} -o ./bin/windows-amd64/beyondtp ./cmd/beyondtp
tar -C ./bin/windows-amd64/ -czf ./releases/beyondtp_windows_amd64.tar.gz beyondtp
test:
@echo "run test"
@go test -race -v -count=1 ./...
@echo "ok"
tidy:
@echo "Tidy and check the go mod files"
@go mod tidy
@go mod verify
@echo "Done"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。