Skip to content

Commit 9c94470

Browse files
authored
Merge pull request #15 from gaarutyunov/claude/add-webgpu-support-01WRhPGT2ZsQkd7JqVjnV5Hj
feat: Add WebGPU DSL support to Guix language
2 parents a22f6b2 + f56e5b0 commit 9c94470

39 files changed

Lines changed: 4223 additions & 617 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ go.work
1515
*.wasm
1616
wasm_exec.js
1717
main.wasm
18+
examples/*/calculator
19+
examples/*/counter
20+
examples/*/webgpu-cube
1821

1922
# Cache
2023
.guix/

CLAUDE.md

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,27 @@ This document contains guidelines and rules for Claude when working on the Guix
44

55
## Pre-Commit Requirements
66

7-
Before committing any changes, Claude must ensure the following checks pass:
7+
Before committing any changes, Claude must ensure the following checks pass.
88

9-
### 1. Code Formatting
9+
### Using Mage (Recommended)
10+
11+
The easiest way to run all pre-commit checks is using Mage:
12+
13+
```bash
14+
# Run all pre-commit checks (format, vet, test, build)
15+
go run github.com/magefile/mage@latest
16+
17+
# Or if mage is installed locally
18+
mage
19+
```
20+
21+
This will automatically run all the checks below in the correct order.
22+
23+
### Manual Pre-Commit Checks
24+
25+
If you prefer to run checks manually:
26+
27+
#### 1. Code Formatting
1028

1129
All Go files must be formatted with `gofmt`:
1230

@@ -16,15 +34,15 @@ gofmt -w .
1634

1735
This ensures consistent code style across the entire codebase.
1836

19-
### 2. Linting
37+
#### 2. Linting
2038

2139
Run `go vet` to catch common Go mistakes:
2240

2341
```bash
2442
go vet ./...
2543
```
2644

27-
### 3. Testing
45+
#### 3. Testing
2846

2947
Run all tests to ensure no regressions:
3048

@@ -34,7 +52,7 @@ go test ./...
3452

3553
All tests must pass before committing.
3654

37-
### 4. Build Verification
55+
#### 4. Build Verification
3856

3957
Verify the code compiles for both native and WASM targets:
4058

@@ -46,9 +64,23 @@ go build ./...
4664
GOOS=js GOARCH=wasm go build ./pkg/runtime/...
4765
```
4866

49-
## Complete Pre-Commit Checklist
67+
## Available Mage Targets
68+
69+
The following Mage targets are available:
70+
71+
- `mage` or `mage preCommit` - Run all pre-commit checks (default)
72+
- `mage format` - Format all Go files
73+
- `mage vet` - Run go vet
74+
- `mage test` - Run all tests
75+
- `mage build` - Build all packages
76+
- `mage buildWasm` - Build WASM runtime
77+
- `mage generate` - Regenerate all example code
78+
- `mage clean` - Remove build artifacts
79+
- `mage ci` - Run all CI checks
80+
81+
## Complete Pre-Commit Checklist (Manual)
5082

51-
Run these commands before every commit:
83+
If not using Mage, run these commands before every commit:
5284

5385
```bash
5486
# Format all Go files

calculator

2.74 MB
Binary file not shown.

counter

2.66 MB
Binary file not shown.

examples/calculator/calculator_gen.go

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

examples/counter/counter_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build js && wasm
2+
// +build js,wasm
3+
14
package main
25

36
import (

examples/webgpu-cube/app.gx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func App() (Component) {
6+
rotationX := 0.0
7+
rotationY := 0.0
8+
autoRotate := true
9+
speed := 1.0
10+
commands := make(chan ControlCommand, 10)
11+
controlState := make(chan ControlState, 10)
12+
13+
go func() {
14+
state := ControlState{AutoRotate: autoRotate, Speed: float32(speed)}
15+
log(fmt.Sprintf("[App] Sending initial state: %s", state.String()))
16+
controlState <- state
17+
}()
18+
19+
go func() {
20+
for cmd := range commands {
21+
log(fmt.Sprintf("[App] Received command: %s", cmd.String()))
22+
23+
switch cmd.Type {
24+
case "rotX":
25+
rotationX += float64(cmd.Value)
26+
case "rotY":
27+
rotationY += float64(cmd.Value)
28+
case "autoRotate":
29+
autoRotate = !autoRotate
30+
case "speed":
31+
speed = float64(cmd.Value)
32+
}
33+
34+
state := ControlState{AutoRotate: autoRotate, Speed: float32(speed)}
35+
select {
36+
case controlState <- state:
37+
log(fmt.Sprintf("[App] Sent state update: %s", state.String()))
38+
default:
39+
log("[App] Channel full, skipping state update")
40+
}
41+
}
42+
}()
43+
44+
Div(
45+
Class("webgpu-container")
46+
) {
47+
Canvas(
48+
ID("webgpu-canvas"),
49+
Width(600),
50+
Height(400)
51+
) {
52+
GPUScene(NewCubeScene(float32(rotationX), float32(rotationY)))
53+
}
54+
Controls(WithCommands(commands), WithState(controlState))
55+
}
56+
}

examples/webgpu-cube/app_gen.go

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

0 commit comments

Comments
 (0)