编译工具优化

This commit is contained in:
2026-07-26 12:17:09 +08:00
parent 18e8098aa4
commit 469a3687ca
4 changed files with 28 additions and 11 deletions
+16 -7
View File
@@ -20,15 +20,14 @@ type Platform struct {
var platforms = []Platform{
{"windows", "amd64", "Windows x86-64", ".exe"},
{"windows", "386", "Windows x86", ".exe"},
{"linux", "amd64", "Linux x86-64", ""},
{"linux", "arm64", "Linux ARM64", ""},
{"linux", "armv7", "Linux ARMv7l", ""},
{"linux", "arm", "Linux ARMv7l", ""}, // GOARCH=arm, GOARM=7
}
const (
Version = "1.0.0"
BuildTime = "2026-07-24"
Version = "1.5.0"
BuildTime = "2026-07-25"
Binary = "frpc-console"
)
@@ -53,7 +52,7 @@ func main() {
}
}
fmt.Println("❌ 不支持的平台:", target)
fmt.Println(" 可用: windows/amd64, windows/386, linux/amd64, linux/arm64, linux/armv7")
fmt.Println(" 可用: windows/amd64, linux/amd64, linux/arm64, linux/armv7")
fmt.Println(" 或: all, list, clean")
return
}
@@ -126,10 +125,14 @@ func build(p Platform, silent bool) {
return
}
outName := Binary + "-" + p.OS + "-" + p.Arch + p.Ext
// 构建输出文件名
outName := Binary + "-" + p.OS + "-" + p.Arch
if p.Arch == "arm" {
outName += "v7" // 标注 ARMv7 版本
}
outName += p.Ext
outPath := filepath.Join(outDir, outName)
// 用 "go" 而不是硬编码路径,让系统去 PATH 里找
cmd := exec.Command("go", "build",
"-ldflags=-s -w -X main.version="+Version,
"-o", outPath,
@@ -140,6 +143,12 @@ func build(p Platform, silent bool) {
"GOARCH="+p.Arch,
"CGO_ENABLED=0",
)
// ARM 架构指定 GOARM=7
if p.Arch == "arm" {
cmd.Env = append(cmd.Env, "GOARM=7")
}
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr