@@ -4,25 +4,27 @@ This document explains how to build Windshift for multiple platforms.
44
55## Quick Build
66
7- ### Build Everything (Recommended)
7+ ### Using the Makefile (Recommended)
8+
89``` bash
9- # Build both server and ws client for all platforms
10- ./build- all.sh
10+ # Build everything (frontend + server)
11+ make all
1112
12- # Clean and build everything
13- ./build-all.sh -- clean
13+ # Clean and rebuild
14+ make clean && make all
1415
15- # Build only the server
16- ./build-all.sh --server-only
16+ # Build server only
17+ make build
1718
18- # Build only the ws client
19- ./build-all.sh --client-only
19+ # Build frontend only
20+ make frontend
2021
21- # Get help
22- ./build-all.sh -- help
22+ # Show all available make targets
23+ make help
2324```
2425
2526### Manual Build
27+
2628``` bash
2729# Build frontend
2830cd frontend
@@ -41,22 +43,69 @@ cd ../..
4143
4244## Build Output
4345
44- The build script creates the following structure:
46+ ### Development Builds (Makefile)
47+
48+ The Makefile produces binaries in the project root:
49+
50+ ```
51+ windshift # Main server binary (current platform)
52+ windshift_unix # Linux binary (from make build-linux)
53+ windshift.exe # Windows binary (from make build-windows)
54+ ```
55+
56+ ### Release Builds (release.sh)
57+
58+ The release script creates a ` dist/ ` structure:
4559
4660```
4761dist/
48- ├── server /
62+ ├── binaries /
4963│ ├── windshift-linux-amd64
5064│ ├── windshift-linux-arm64
5165│ ├── windshift-windows-amd64.exe
5266│ ├── windshift-darwin-amd64
5367│ └── windshift-darwin-arm64
54- └── client/
55- ├── ws-linux-amd64
56- ├── ws-linux-arm64
57- ├── ws-windows-amd64.exe
58- ├── ws-darwin-amd64
59- └── ws-darwin-arm64
68+ └── releases/
69+ ├── windshift-v1.0.0-linux-amd64.tar.gz
70+ ├── windshift-v1.0.0-linux-arm64.tar.gz
71+ ├── windshift-v1.0.0-windows-amd64.zip
72+ ├── windshift-v1.0.0-darwin-amd64.tar.gz
73+ ├── windshift-v1.0.0-darwin-arm64.tar.gz
74+ └── SHA256SUMS.txt
75+ ```
76+
77+ ## Cross-Platform/Release Builds
78+
79+ ### Using the Makefile
80+
81+ ``` bash
82+ # Cross-compile for Linux
83+ make build-linux
84+
85+ # Cross-compile for Windows
86+ make build-windows
87+ ```
88+
89+ ### Using release.sh (Full Release)
90+
91+ ``` bash
92+ # Full release with binaries + Docker + GitHub release
93+ ./release.sh release -v v1.0.0 -n releases/v1.0.0.md
94+
95+ # Build binaries and packages locally (no publish)
96+ ./release.sh build -v v1.0.0
97+
98+ # Build and push Docker images only
99+ ./release.sh push -v v1.0.0-dev
100+
101+ # Dry run to preview actions
102+ ./release.sh release -v v1.0.0 -n releases/v1.0.0.md --dry-run
103+
104+ # Skip frontend build (use existing dist/)
105+ ./release.sh build --skip-frontend
106+
107+ # Show help
108+ ./release.sh --help
60109```
61110
62111## Supported Platforms
@@ -69,24 +118,6 @@ dist/
69118| macOS (Intel) | ✅ | ✅ |
70119| macOS (Apple Silicon) | ✅ | ✅ |
71120
72- ## Cross-Compilation
73-
74- Go makes cross-compilation easy. You can build for any platform from any platform:
75-
76- ``` bash
77- # Build server for Linux from macOS/Windows
78- GOOS=linux GOARCH=amd64 go build -o windshift-linux main.go
79-
80- # Build ws client for Windows from Linux/macOS
81- cd cmd/ws
82- GOOS=windows GOARCH=amd64 go build -o ws-windows.exe
83- cd ../..
84-
85- # Build for ARM64 (Apple Silicon, ARM Linux)
86- GOOS=darwin GOARCH=arm64 go build -o windshift-darwin-arm64 main.go
87- GOOS=linux GOARCH=arm64 go build -o windshift-linux-arm64 main.go
88- ```
89-
90121## Build Requirements
91122
92123### For Server + Frontend
@@ -97,45 +128,48 @@ GOOS=linux GOARCH=arm64 go build -o windshift-linux-arm64 main.go
97128### For WS Client Only
98129- ** Go 1.21+** - Client compilation only
99130
131+ ### For Cross-Compilation (release.sh)
132+ - ** Zig** - Cross-compilation toolchain (optional, native builds work without it)
133+ - ** Docker + Buildx** - Multi-arch Docker images
134+
100135## Usage Examples
101136
102137### Linux
103138``` bash
104- # Extract and run
105- tar -xzf windshift-linux-amd64.tar.gz
106- ./dist/server/windshift-linux-amd64 &
107- ./dist/client/ws-linux-amd64 workspace list
139+ # After building
140+ ./windshift &
141+ ./cmd/ws/ws workspace list
108142```
109143
110144### Windows
111145``` bash
112- # Extract and run
113- dist \s erver \ w indshift-windows-amd64 .exe
114- dist \c lient \w s-windows-amd64 .exe workspace list
146+ # After building
147+ windshift.exe
148+ cmd \w s \w s.exe workspace list
115149```
116150
117151### macOS
118152``` bash
119- # Extract and run
120- ./dist/server/ windshift-darwin-arm64 &
121- ./dist/client /ws-darwin-arm64 workspace list
153+ # After building
154+ ./windshift &
155+ ./cmd/ws /ws workspace list
122156```
123157
124158## Build Optimization
125159
126- The build script uses these Go build flags for production :
160+ Production builds use these Go build flags:
127161
128162- ` -ldflags "-s -w" ` - Strip debug information and reduce binary size
163+ - ` -tags="!test" ` - Exclude test code from production binaries
129164- Version information embedded at build time
130- - Static linking for standalone binaries
131165
132166## Troubleshooting
133167
134168### Frontend Build Issues
135169``` bash
136170# Clear npm cache and reinstall
137171cd frontend
138- rm -rf node_modules package-lock.json
172+ rm -rf node_modules package-lock.json
139173npm install
140174npm run build
141175```
@@ -154,21 +188,31 @@ go clean -modcache
154188
155189** Windows** : If you don't have ` zip ` command available, Windows archives won't be created but binaries will still build.
156190
157- ** macOS** : If you get permission errors, make sure the build script is executable:
158- ``` bash
159- chmod +x build-all.sh
160- ```
191+ ** macOS** : Darwin binaries can only be built on macOS hosts due to CGO requirements.
161192
162193** Linux** : Ensure you have sufficient disk space. Cross-compilation creates multiple large binaries.
163194
164- ## Build Script Features
195+ ## Makefile Targets
196+
197+ Run ` make help ` to see all available targets:
198+
199+ ** Production builds:**
200+ - ` make build ` - Build production binary (excludes test code)
201+ - ` make build-linux ` - Cross-compile for Linux
202+ - ` make build-windows ` - Cross-compile for Windows
203+ - ` make release ` - Full production release build
204+
205+ ** Development builds:**
206+ - ` make dev-build ` - Development binary (includes test utils)
207+ - ` make dev ` - Full development cycle
165208
166- - 🎯 ** Smart Platform Detection** - Automatically builds for all supported platforms
167- - 🧹 ** Clean Builds** - Optional cleanup of previous builds
168- - 📦 ** Modular Building** - Build server-only or client-only
169- - 🎨 ** Colorized Output** - Clear progress indication
170- - 📊 ** Build Summary** - Shows file sizes and locations
171- - 🔧 ** Error Handling** - Stops on any build failure
172- - 📋 ** Documentation** - Generates usage examples
209+ ** Testing:**
210+ - ` make test ` - Run all unit tests
211+ - ` make test-coverage ` - Run tests with coverage report
212+ - ` make test-verbose ` - Run tests with verbose output
173213
174- The build script is production-ready and handles edge cases like missing dependencies, wrong directories, and cross-platform differences.
214+ ** Utilities:**
215+ - ` make frontend ` - Build frontend only
216+ - ` make clean ` - Clean build artifacts
217+ - ` make deps ` - Update dependencies
218+ - ` make verify-size ` - Compare binary sizes with/without tests
0 commit comments