Skip to content

Integrate Bazel build system with rules_wasm_component #27

@avrabe

Description

@avrabe

Summary

Integrate the PulseEngine MCP framework with Bazel build system using rules_wasm_component to enable WebAssembly Component Model builds and composition.

Background

The framework currently uses Cargo for builds, but to fully leverage WebAssembly Component Model features and integrate with the broader PulseEngine ecosystem, we need Bazel integration with:

  • Component Model compilation via rules_wasm_component
  • WIT interface definitions and bindings
  • Component composition and linking
  • Optimized builds with proper caching

Implementation Tasks

Initial Bazel Setup

  • Create root MODULE.bazel with rules_wasm_component dependency
  • Add WORKSPACE.bazel for legacy compatibility if needed
  • Create .bazelrc with WASM-specific build configurations
  • Add .bazelignore to exclude non-Bazel directories

Crate-level BUILD Files

  • Create BUILD.bazel files for each workspace member:
    • mcp-protocol/BUILD.bazel
    • mcp-server/BUILD.bazel
    • mcp-auth/BUILD.bazel
    • mcp-macros/BUILD.bazel
    • mcp-cli/BUILD.bazel
    • mcp-external-validation/BUILD.bazel
    • Example crates BUILD files

WIT Interface Integration

  • Define component interfaces in .wit files
  • Use wit_library rules for interface definitions
  • Generate Rust bindings with wit_bindgen
  • Create component exports and imports

WASM Component Rules

  • Configure rust_wasm_component rules for each crate
  • Set up component composition with wac_compose
  • Add component validation with wasm_validate
  • Implement WIT linting with wit_lint

Build Optimization

  • Configure caching strategies for incremental builds
  • Set up cross-compilation for multiple targets
  • Optimize WASM binary size with build flags
  • Add debug/release configurations

CI/CD Integration

  • Update GitHub Actions to use Bazel
  • Add Bazel caching to CI pipeline
  • Test both Cargo and Bazel builds in parallel
  • Benchmark build performance

Acceptance Criteria

  • All crates build successfully with Bazel
  • WASM components can be composed and linked
  • Build performance is comparable or better than Cargo
  • CI/CD pipeline supports both build systems
  • Documentation for Bazel development workflow

Related Issues

References

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions