You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Implement comprehensive Go WIT bindgen integration for WebAssembly components
This commit implements complex Go WIT bindings support for the WebAssembly Component Model build system, addressing the core issue where Go components were building as WASI CLI components instead of custom WIT interface components.
## Key Features Implemented
### ✅ wit-bindgen-go Integration
- Fully integrated wit-bindgen-go tool in TinyGo toolchain setup
- Proper installation and sandbox accessibility of wit-bindgen-go binary
- Generated Go bindings from WIT files with correct package structure
- Support for complex WIT types: records, variants, options, and results
### ✅ TinyGo WIT Component Support
- Added --wit-package and --wit-world flags to TinyGo compilation
- Fixed WIT file path resolution in workspace setup
- Proper component generation (not just WebAssembly modules)
- Support for both manual exports and generated binding approaches
### ✅ Enhanced Build System
- Fixed Go binary path resolution in sandbox environments
- Improved workspace preparation with WIT binding integration
- Added wit-bindgen-go files to toolchain for hermetic builds
- Support for conditional WIT binding generation
## Component Examples Added
1. **simple_wasi.go** - Basic WASI Preview 2 component without WIT
2. **calculator_manual.go** - Manual exports using //export annotations
3. **calculator_with_bindings.go** - Uses generated wit-bindgen-go bindings
4. **simple-calculator.wit** - Simplified WIT interface without dependencies
## Technical Improvements
### Toolchain Enhancements
- Updated TinyGo to v0.39.0 with Go 1.25.0 support
- Added wit-bindgen-go installation via `go install` command
- Proper wit-bindgen-go files packaging for Bazel sandbox access
- Enhanced error handling and validation
### Build Rule Updates
- Fixed workspace setup to preserve WIT file original names
- Added support for generated binding directory inclusion
- Improved TinyGo argument construction for WIT integration
- Added optional WIT validation support
### File Operations Improvements
- Enhanced Go module workspace preparation
- Fixed Go binary path resolution in hermetic builds
- Better handling of WIT file staging and path resolution
- Support for generated binding directory copying
## Verification Status
✅ **Architecture Complete** - Full wit-bindgen-go integration working
✅ **Binding Generation** - wit-bindgen-go generates proper Go structures
✅ **TinyGo Integration** - Processes WIT files and world specifications
✅ **Component Build** - Creates WebAssembly components (not just modules)
⏳ **WASI Dependencies** - Requires WASI interface resolution for complete functionality
This implementation provides the foundation for building complex Go WebAssembly components that export custom WIT interfaces like `add()`, `subtract()`, etc., instead of only WASI CLI components.
0 commit comments