Skip to content

Commit dbf9134

Browse files
committed
perf: change build go client
1 parent d9e381d commit dbf9134

File tree

6 files changed

+56
-7
lines changed

6 files changed

+56
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ BLUE=\033[0;34m
1010
NC=\033[0m # No Color
1111

1212
# 项目信息
13-
PROJECT_NAME=jump-server-client
13+
PROJECT_NAME=jumpserver-client
1414
VERSION=1.4.0
1515
NODE_VERSION=23
1616
PNPM_VERSION=10.17.0

go-client/Makefile

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,41 @@ LDFLAGS=-w -s
99

1010
CLIENTBUILD=CGO_ENABLED=0 go build -trimpath
1111

12-
build-client:
12+
# 自动检测当前平台
13+
CURRENT_OS := $(shell go env GOOS)
14+
CURRENT_ARCH := $(shell go env GOARCH)
15+
16+
# 默认目标:只构建当前平台
17+
.PHONY: default
18+
default: build-current
19+
20+
# 构建当前平台
21+
.PHONY: build-current
22+
build-current:
23+
@echo "Building for current platform: $(CURRENT_OS)/$(CURRENT_ARCH)"
24+
@rm -rf $(BUILDDIR)
25+
@mkdir -p $(BUILDDIR)/$(CURRENT_OS)-$(CURRENT_ARCH)
26+
@if [ "$(CURRENT_OS)" = "windows" ]; then \
27+
$(CLIENTBUILD) -ldflags "$(LDFLAGS) -H windowsgui" -o $(BUILDDIR)/$(CURRENT_OS)-$(CURRENT_ARCH)/JumpServerClient.exe $(CLIENTSRCFILE); \
28+
$(CLIENTBUILD) -ldflags "$(LDFLAGS)" -o $(BUILDDIR)/$(CURRENT_OS)-$(CURRENT_ARCH)/client.exe $(SSHCSRCFILE); \
29+
else \
30+
$(CLIENTBUILD) -ldflags "$(LDFLAGS)" -o $(BUILDDIR)/$(CURRENT_OS)-$(CURRENT_ARCH)/JumpServerClient $(CLIENTSRCFILE); \
31+
$(CLIENTBUILD) -ldflags "$(LDFLAGS)" -o $(BUILDDIR)/$(CURRENT_OS)-$(CURRENT_ARCH)/client $(SSHCSRCFILE); \
32+
fi
33+
@if [ "$(CURRENT_OS)" = "darwin" ]; then \
34+
cp -R $(BASEPATH)/Scripts $(BUILDDIR)/$(CURRENT_OS)-$(CURRENT_ARCH)/; \
35+
fi
36+
@mkdir -p $(BASEPATH)/../src-tauri/resources/bin/
37+
@cp -R $(BUILDDIR)/* $(BASEPATH)/../src-tauri/resources/bin/
38+
@cp $(BASEPATH)/config.json $(BASEPATH)/../src-tauri/resources/bin/
39+
@if [ "$(CURRENT_OS)" = "windows" ]; then \
40+
cp $(BASEPATH)/putty.exe $(BASEPATH)/../src-tauri/resources/bin/windows/; \
41+
cp $(BASEPATH)/pkg/autoit/*.dll $(BASEPATH)/../src-tauri/resources/bin/windows/; \
42+
fi
43+
44+
# 构建所有平台
45+
.PHONY: build-all
46+
build-all:
1347
GOARCH=amd64 GOOS=darwin $(CLIENTBUILD) -ldflags "$(LDFLAGS)" -o $(BUILDDIR)/darwin-amd64/JumpServerClient $(CLIENTSRCFILE)
1448
GOARCH=amd64 GOOS=darwin $(CLIENTBUILD) -ldflags "$(LDFLAGS)" -o $(BUILDDIR)/darwin-amd64/client $(SSHCSRCFILE)
1549

@@ -33,3 +67,18 @@ build-client:
3367
cp $(BASEPATH)/config.json $(BASEPATH)/../src-tauri/resources/bin/
3468
cp $(BASEPATH)/putty.exe $(BASEPATH)/../src-tauri/resources/bin/windows/
3569
cp $(BASEPATH)/pkg/autoit/*.dll $(BASEPATH)/../src-tauri/resources/bin/windows/
70+
71+
# 帮助信息
72+
.PHONY: help
73+
help:
74+
@echo "Available targets:"
75+
@echo " make - Build for current platform only (default)"
76+
@echo " make build-client - Build for current platform only"
77+
@echo " make build-all - Build for all platforms (darwin, windows, linux)"
78+
@echo " make help - Show this help message"
79+
@echo ""
80+
@echo "Current platform: $(CURRENT_OS)/$(CURRENT_ARCH)"
81+
82+
# build-client 就是 build-current
83+
.PHONY: build-client
84+
build-client: build-current

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "jump-server-client",
2+
"name": "jumpserver-client",
33
"type": "module",
44
"version": "1.4.0",
55
"private": true,

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "jump-server-client"
2+
name = "jumpserver-client"
33
version = "1.4.0"
44
description = "JumpServer client tool"
55
authors = [ "ZhaoJiSen" ]

0 commit comments

Comments
 (0)