Makefile 605 B

123456789101112131415161718192021222324
  1. BINARY_NAME := cc-officialweb
  2. GOOS := linux
  3. GOARCH := amd64
  4. all: build
  5. # 运行
  6. run:
  7. @echo "Running $(BINARY_NAME)..."
  8. go run main.go
  9. # 编译为linux下的二进制文件
  10. build:
  11. @echo "Cross-compiling for $(GOOS)/$(GOARCH)..."
  12. go build -o $(BINARY_NAME)-$(GOOS)-$(GOARCH) -ldflags="-s -w" -tags netgo -a -installsuffix cgo -x -v -gcflags=all=-trimpath=$(GOPATH) -asmflags=all=-trimpath=$(GOPATH)
  13. # 安装必要的依赖
  14. deps:
  15. @echo "Installing dependencies..."
  16. go mod tidy
  17. go mod download
  18. # 删除编译生成的文件
  19. clean:
  20. @echo "Cleaning..."
  21. del /Q $(BINARY_NAME)-*
  22. .PHONY: all build clean