Skip to content

Commit 91306cb

Browse files
authored
Initial generation of apinotes and wrappers (#18)
1 parent c2c5ca6 commit 91306cb

File tree

62 files changed

+6410
-1332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+6410
-1332
lines changed

.devcontainer/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Dev Container for Linux
2+
3+
This dev container is provided here for working on this project under Linux from a Mac or
4+
Windows using Docker.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ Dawn/dawn_source
88
Dawn/dawn_version.json
99
__pycache__
1010
.venv
11+
BindingsDebug

.vscode/launch.json

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,44 @@
2222
"type": "swift",
2323
"request": "launch",
2424
"args": [
25-
"${workspaceFolder:CrossPlatform}/webgpu_dawn.xcframework/dawn.json",
26-
"${workspaceFolder:CrossPlatform}/Sources/Dawn/Dawn.apinotes"
25+
"--dawn-json",
26+
"${workspaceFolder:swan}/.build/artifacts/swan/DawnLib/dawn_webgpu.artifactbundle/dawn.json",
27+
"--output-directory",
28+
"${workspaceFolder:swan}/BindingsDebug",
29+
"--swift-format-config",
30+
"${workspaceFolder:swan}/.swift-format",
2731
],
2832
"cwd": "${workspaceFolder:swan}",
29-
"name": "Debug UpdateDawnBindings",
30-
"program": "${workspaceFolder:swan}/.build/debug/UpdateDawnBindings",
31-
"preLaunchTask": "swift: Build Debug UpdateDawnBindings"
33+
"name": "Debug GenerateDawnBindings",
34+
"program": "${workspaceFolder:swan}/.build/debug/GenerateDawnBindings",
35+
"preLaunchTask": "swift: Build Debug GenerateDawnBindings"
3236
},
3337
{
3438
"type": "swift",
3539
"request": "launch",
3640
"args": [],
3741
"cwd": "${workspaceFolder:swan}",
38-
"name": "Release UpdateDawnBindings",
39-
"program": "${workspaceFolder:swan}/.build/release/UpdateDawnBindings",
40-
"preLaunchTask": "swift: Build Release UpdateDawnBindings"
42+
"name": "Release GenerateDawnBindings",
43+
"program": "${workspaceFolder:swan}/.build/release/GenerateDawnBindings",
44+
"preLaunchTask": "swift: Build Release GenerateDawnBindings"
45+
},
46+
{
47+
"type": "swift",
48+
"request": "launch",
49+
"args": [],
50+
"cwd": "${workspaceFolder:swan}",
51+
"name": "Debug GenerateDawnAPINotes",
52+
"program": "${workspaceFolder:swan}/.build/debug/GenerateDawnAPINotes",
53+
"preLaunchTask": "swift: Build Debug GenerateDawnAPINotes"
54+
},
55+
{
56+
"type": "swift",
57+
"request": "launch",
58+
"args": [],
59+
"cwd": "${workspaceFolder:swan}",
60+
"name": "Release GenerateDawnAPINotes",
61+
"program": "${workspaceFolder:swan}/.build/release/GenerateDawnAPINotes",
62+
"preLaunchTask": "swift: Build Release GenerateDawnAPINotes"
4163
}
4264
]
4365
}

.vscode/tasks.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "swift",
6+
"args": [
7+
"build",
8+
"--build-tests",
9+
"-Xswiftc",
10+
"-diagnostic-style=llvm",
11+
"--triple",
12+
"arm64-apple-macosx15.0"
13+
],
14+
"env": {
15+
"DEVELOPER_DIR": "/Applications/Xcode.app/Contents/Developer"
16+
},
17+
"cwd": "/Users/mitaylor/Developer/Adobe/photoshop/swan",
18+
"disableTaskQueue": true,
19+
"group": "build",
20+
"problemMatcher": [],
21+
"label": "swift: Build All",
22+
"detail": "swift build --build-tests -Xswiftc -diagnostic-style=llvm --triple arm64-apple-macosx15.0"
23+
},
24+
{
25+
"type": "swift",
26+
"args": [
27+
"build",
28+
"--build-tests",
29+
"-Xswiftc",
30+
"-diagnostic-style=llvm"
31+
],
32+
"env": {
33+
"DEVELOPER_DIR": "/Applications/Xcode.app/Contents/Developer"
34+
},
35+
"cwd": "/Users/mitaylor/Developer/Adobe/photoshop/swan",
36+
"disableTaskQueue": true,
37+
"group": {
38+
"kind": "build",
39+
"isDefault": true
40+
},
41+
"problemMatcher": [],
42+
"label": "swift: Build All",
43+
"detail": "swift build --build-tests -Xswiftc -diagnostic-style=llvm"
44+
}
45+
]
46+
}

CLAUDE.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Swan is a Swift WebGPU binding library that provides Swift APIs for using WebGPU across multiple platforms. The initial implementation is a Swift binding to Google's Dawn library. This is currently a work-in-progress project not ready for production use.
8+
9+
## Architecture
10+
11+
### Core Components
12+
13+
- **Dawn**: Swift wrapper around Google's Dawn WebGPU implementation
14+
- **CDawn**: C bindings layer for Dawn
15+
- **DawnData**: Data structures and utilities for Dawn integration
16+
- **WebGPU**: High-level Swift WebGPU API built on Dawn
17+
- **WebGPULife**: Demo/example applications
18+
19+
### Code Generation
20+
21+
The project uses Swift Package Manager plugins for code generation:
22+
23+
- **GenerateDawnBindingsPlugin**: Generates Swift bindings from Dawn's C API
24+
- **GenerateDawnAPINotesPlugin**: Generates API notes for better Swift integration
25+
26+
Both plugins depend on executable targets that process `dawn.json` to generate appropriate Swift code.
27+
28+
### Binary Dependencies
29+
30+
The project uses a binary target `DawnLib` that contains pre-built Dawn WebGPU libraries for multiple platforms (macOS, iOS, Linux, Windows). These are built via GitHub Actions and distributed as releases.
31+
32+
## Development Commands
33+
34+
### Building
35+
```bash
36+
swift build
37+
```
38+
39+
### Testing
40+
```bash
41+
swift test
42+
```
43+
44+
### Code Generation Plugins
45+
```bash
46+
# Generate Dawn API notes
47+
swift package generate-dawn-apinotes
48+
49+
# Bindings are generated automatically during build via GenerateDawnBindingsPlugin
50+
```
51+
52+
### Code Formatting
53+
The project uses swift-format with configuration in `.swift-format`:
54+
- Line length: 140 characters
55+
- Uses tabs for indentation
56+
- Ordered imports enabled
57+
58+
## Platform Requirements
59+
60+
- macOS 15+
61+
- iOS 18+
62+
- Swift 6.1+
63+
- Uses development snapshot toolchain (swift-DEVELOPMENT-SNAPSHOT-2025-08-16-a)
64+
65+
## Dependencies
66+
67+
- swift-testing (for tests)
68+
- swift-log (for logging)
69+
- swift-syntax (for code generation)
70+
71+
## Key Files
72+
73+
- `Package.swift`: Swift Package Manager configuration
74+
- `Dawn/ci_build_dawn.py`: Python script for building dawn in CI
75+
- `.swift-format`: Code formatting configuration
76+
- `.vscode/settings.json`: VS Code configuration with specific Swift toolchain path
77+
78+
## Dawn Integration
79+
80+
The project maintains its own Dawn builds through GitHub Actions workflows that:
81+
1. Fetch specific Chromium/Dawn versions
82+
2. Build Dawn for multiple platforms
83+
3. Package as binary releases
84+
4. Update Package.swift with new binary target URLs
85+
86+
The Dawn source management and building is handled by Python scripts in the `Dawn/` directory.

Dawn/dawn_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import sys
1414
from typing import Dict, Any, Tuple
1515

16-
DAWN_GIT_URL = "https://dawn.googlesource.com/dawn"
16+
DAWN_GIT_URL = "https://github.com/google/dawn.git"
1717

1818
# URL endpoint for latest release info from the Chromium version history page.
1919
# We arbitrarily select the Windows platform for fetching the information to reduce the payload size.

Package.resolved

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

0 commit comments

Comments
 (0)