This commit is contained in:
dukai 2025-05-28 17:28:15 +08:00
parent f62751366b
commit fca5d537a2
2 changed files with 12 additions and 11 deletions

View File

@ -13,7 +13,12 @@ UNAME_S := $(shell uname -s)
BINARY_NAME := robotfs BINARY_NAME := robotfs
.PHONY: all .PHONY: all
all: proto build all: deps proto build
.PHONY: deps
deps:
@echo "Installing project dependencies..."
go install .
.PHONY: proto .PHONY: proto
proto: proto:
@ -21,7 +26,7 @@ proto:
protoc --go_out=. --go_opt=paths=source_relative pb/*.proto protoc --go_out=. --go_opt=paths=source_relative pb/*.proto
.PHONY: build .PHONY: build
build: build: deps proto
ifeq ($(UNAME_S),Darwin) ifeq ($(UNAME_S),Darwin)
@echo "Building for MacOS..." @echo "Building for MacOS..."
GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME) ./ GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME) ./
@ -31,7 +36,7 @@ else
endif endif
.PHONY: build-linux .PHONY: build-linux
build-linux: build-linux: deps proto
@echo "Building for Linux..." @echo "Building for Linux..."
GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME) ./ GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME) ./
@ -44,7 +49,8 @@ clean:
help: help:
@echo "Available targets:" @echo "Available targets:"
@echo " all - Generate protobuf files and build for current platform (default)" @echo " all - Generate protobuf files and build for current platform (default)"
@echo " deps - Install project dependencies"
@echo " proto - Generate protobuf files" @echo " proto - Generate protobuf files"
@echo " build - Build for current platform" @echo " build - Build for current platform"
@echo " build-linux - Build for linux platform" @echo " build-linux - Build for linux platform"
@echo " clean - Remove built binaries and generated protobuf files" @echo " clean - Remove built binaries and generated protobuf files"

View File

@ -17,12 +17,7 @@ RobotFS 是一个轻量级的文件系统服务,提供用于管理文件和目
### 编译步骤 ### 编译步骤
1. 生成 Protocol Buffers 文件 1. 编译项目
```bash
make proto
```
2. 编译项目
- 在当前平台编译: - 在当前平台编译:
```bash ```bash
make build make build
@ -32,7 +27,7 @@ make build
make build-linux make build-linux
``` ```
3. 清理编译文件 2. 清理编译文件
```bash ```bash
make clean make clean
``` ```