Summary
Replace the custom file_ops WASM component with Bazel-native file operations to reduce dependencies and improve performance.
Current State
- Custom
file_ops WASM component for cross-platform file operations
- Runs via wasmtime to copy/move/create files
- Adds overhead: wasmtime startup + WASI filesystem operations
- Used extensively in cpp_component, wit_library, etc.
Why file_ops Exists
- Cross-platform (Windows) compatibility
- Replaces shell scripts (cp, mv, mkdir)
- Provides consistent behavior
Proposed Solution
Replace file_ops with Bazel-native operations:
| file_ops Operation |
Bazel Alternative |
copy_file |
ctx.actions.symlink() or ctx.actions.run() with platform tool |
create_directory |
Implicit in output paths |
move_file |
ctx.actions.run() with platform tool |
concatenate_files |
ctx.actions.write() or small helper binary |
For Complex Cases
Use a small Go binary (already have Go toolchain for wac_deps tool).
Benefits
- Remove wasmtime dependency from basic builds
- Faster file operations (no WASM overhead)
- Simpler debugging (native tools)
- Smaller toolchain footprint
Risks
- file_ops was created to solve real cross-platform issues
- Need to verify Bazel-native alternatives work on Windows
- Some operations may not have direct equivalents
New Features Enabled
- Pure Bazel builds without runtime dependencies
- Better integration with Bazel's action cache
Impact
- Effort: Medium
- Risk: Medium
- Value: Medium
Related
- Phase 4 shell elimination work already reduced file_ops usage
Summary
Replace the custom
file_opsWASM component with Bazel-native file operations to reduce dependencies and improve performance.Current State
file_opsWASM component for cross-platform file operationsWhy file_ops Exists
Proposed Solution
Replace file_ops with Bazel-native operations:
copy_filectx.actions.symlink()orctx.actions.run()with platform toolcreate_directorymove_filectx.actions.run()with platform toolconcatenate_filesctx.actions.write()or small helper binaryFor Complex Cases
Use a small Go binary (already have Go toolchain for
wac_depstool).Benefits
Risks
New Features Enabled
Impact
Related