Files
tencentcloud__tencentmeetin…/Makefile
2026-04-15 11:26:11 +08:00

63 lines
3.0 KiB
Makefile
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ── 配置 ──────────────────────────────────────────────────────────────────────
APP_NAME := tmeet
OUTPUT_DIR := dist
MAIN_PKG := .
# 版本号:通过 make install VERSION=v1.0.0 传入
VERSION ?=
BUILD_TIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := -s -w -X tmeet/cmd.Version=$(VERSION) -X tmeet/cmd.BuildTime=$(BUILD_TIME)
# 编译目标列表:GOOS/GOARCH/平台友好名称
TARGETS := \
darwin/amd64/macOS-Intel \
darwin/arm64/macOS-AppleSilicon \
linux/amd64/Linux-x86_64 \
linux/arm64/Linux-ARM64 \
windows/amd64/Windows-x86_64
# ── 默认目标 ──────────────────────────────────────────────────────────────────
.PHONY: clean build sync-version
# ── 编译 ──────────────────────────────────────────────────────────────────────
build:
ifndef VERSION
$(error ❌ 请传入版本号,例如:make install VERSION=v1.0.0)
endif
@rm -rf $(OUTPUT_DIR)
@mkdir -p $(OUTPUT_DIR)
@echo "版本: $(VERSION) 构建时间: $(BUILD_TIME)"
@echo "────────────────────────────────────────"
@$(foreach target,$(TARGETS), \
$(eval GOOS := $(word 1,$(subst /, ,$(target)))) \
$(eval GOARCH := $(word 2,$(subst /, ,$(target)))) \
$(eval PLAT := $(word 3,$(subst /, ,$(target)))) \
$(eval EXT := $(if $(filter windows,$(GOOS)),.exe,)) \
$(eval OUT := $(OUTPUT_DIR)/$(APP_NAME)-$(PLAT)$(EXT)) \
printf "编译 %-30s → %s\n" "$(GOOS)/$(GOARCH) ($(PLAT))" "$(OUT)" && \
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) \
go build -trimpath -ldflags "$(LDFLAGS)" -o $(OUT) $(MAIN_PKG) && \
) true
@echo "────────────────────────────────────────"
@echo "✅ 全部编译完成,产物位于 ./$(OUTPUT_DIR)/"
@ls -lh $(OUTPUT_DIR)/
# ── 同步版本号到 package.json ─────────────────────────────────────────────────
sync-version:
ifndef VERSION
$(error ❌ 请传入版本号,例如:make install VERSION=v1.0.0)
endif
@echo ""
@echo "🔖 同步版本号到 package.json: $(VERSION)"
ifeq ($(shell uname),Darwin)
@sed -i '' 's/"version": ".*"/"version": "$(VERSION)"/' package.json
else
@sed -i 's/"version": ".*"/"version": "$(VERSION)"/' package.json
endif
# ── 清理 ──────────────────────────────────────────────────────────────────────
clean:
@rm -rf $(OUTPUT_DIR)
@echo "🧹 已清理 $(OUTPUT_DIR)/"