@@ -46,6 +46,9 @@ Complete reference documentation for all Bazel rules provided by rules_wasm_comp
4646- [ Component Tools] ( #component-tools )
4747 - [ wasm_component_new] ( #wasm_component_new )
4848 - [ wasm_component_wizer_library] ( #wasm_component_wizer_library )
49+ - [ wasm_precompile] ( #wasm_precompile )
50+ - [ wasm_run] ( #wasm_run )
51+ - [ wasm_test] ( #wasm_test )
4952 - [ wasm_validate] ( #wasm_validate )
5053- [ Security & Signing] ( #security-signing )
5154 - [ wasm_keygen] ( #wasm_keygen )
@@ -57,6 +60,7 @@ Complete reference documentation for all Bazel rules provided by rules_wasm_comp
5760- [ Providers] ( #providers )
5861 - [ WacCompositionInfo] ( #waccompositioninfo )
5962 - [ WasmComponentInfo] ( #wasmcomponentinfo )
63+ - [ WasmPrecompiledInfo] ( #wasmprecompiledinfo )
6064 - [ WitInfo] ( #witinfo )
6165
6266## WIT & Interface Rules
@@ -952,6 +956,117 @@ wasm_validate(
952956)
953957```
954958
959+ ### wasm_precompile
960+
961+ Ahead-of-time (AOT) compile WebAssembly components using Wasmtime for faster startup times and improved performance.
962+
963+ ** Load from:**
964+ ``` python
965+ load(" @rules_wasm_component//wasm:defs.bzl" , " wasm_precompile" )
966+ ```
967+
968+ ** Attributes:**
969+
970+ | Name | Type | Required | Description |
971+ | ------| ------| ----------| -------------|
972+ | ` component ` | Label | ❌ | WasmComponent target to precompile |
973+ | ` debug_info ` | Boolean | ❌ | Include debug information (default: False) |
974+ | ` name ` | String | ✅ | A unique name for this target |
975+ | ` optimization_level ` | String | ❌ | Optimization level: "0", "1", "2", "s" (default: "2") |
976+ | ` strip_symbols ` | Boolean | ❌ | Strip symbol tables to reduce size (default: True) |
977+ | ` target_triple ` | String | ❌ | Target triple for cross-compilation |
978+ | ` wasm_file ` | Label | ❌ | Input WebAssembly file to precompile |
979+
980+ ** Examples:**
981+
982+ Basic AOT compilation
983+
984+ ``` python
985+ wasm_precompile(
986+ name = " my_component_aot" ,
987+ component = " :my_component" ,
988+ optimization_level = " 2" ,
989+ )
990+ ```
991+
992+ Size-optimized build
993+
994+ ``` python
995+ wasm_precompile(
996+ name = " my_component_size" ,
997+ component = " :my_component" ,
998+ optimization_level = " s" ,
999+ strip_symbols = True ,
1000+ )
1001+ ```
1002+
1003+ ### wasm_run
1004+
1005+ Execute WebAssembly components using Wasmtime runtime. Automatically uses AOT compiled versions when available.
1006+
1007+ ** Load from:**
1008+ ``` python
1009+ load(" @rules_wasm_component//wasm:defs.bzl" , " wasm_run" )
1010+ ```
1011+
1012+ ** Attributes:**
1013+
1014+ | Name | Type | Required | Description |
1015+ | ------| ------| ----------| -------------|
1016+ | ` allow_wasi_filesystem ` | Boolean | ❌ | Allow WASI filesystem access (default: True) |
1017+ | ` allow_wasi_net ` | Boolean | ❌ | Allow WASI network access (default: False) |
1018+ | ` component ` | Label | ❌ | WebAssembly component to run |
1019+ | ` cwasm_file ` | Label | ❌ | Direct precompiled WebAssembly file |
1020+ | ` module_args ` | List of strings | ❌ | Additional arguments to pass to module |
1021+ | ` name ` | String | ✅ | A unique name for this target |
1022+ | ` prefer_aot ` | Boolean | ❌ | Use AOT compiled version if available (default: True) |
1023+ | ` wasm_file ` | Label | ❌ | Direct WebAssembly module file |
1024+
1025+ ** Examples:**
1026+
1027+ Run component with AOT preference
1028+
1029+ ``` python
1030+ wasm_run(
1031+ name = " run_component" ,
1032+ component = " :my_component_aot" ,
1033+ allow_wasi_filesystem = True ,
1034+ )
1035+ ```
1036+
1037+ ### wasm_test
1038+
1039+ Test WebAssembly components using Wasmtime runtime. Similar to wasm_run but designed for testing scenarios.
1040+
1041+ ** Load from:**
1042+ ``` python
1043+ load(" @rules_wasm_component//wasm:defs.bzl" , " wasm_test" )
1044+ ```
1045+
1046+ ** Attributes:**
1047+
1048+ | Name | Type | Required | Description |
1049+ | ------| ------| ----------| -------------|
1050+ | ` allow_wasi_filesystem ` | Boolean | ❌ | Allow WASI filesystem access (default: True) |
1051+ | ` allow_wasi_net ` | Boolean | ❌ | Allow WASI network access (default: False) |
1052+ | ` component ` | Label | ❌ | WebAssembly component to test |
1053+ | ` cwasm_file ` | Label | ❌ | Direct precompiled WebAssembly file |
1054+ | ` module_args ` | List of strings | ❌ | Additional arguments to pass to module |
1055+ | ` name ` | String | ✅ | A unique name for this target |
1056+ | ` prefer_aot ` | Boolean | ❌ | Use AOT compiled version if available (default: True) |
1057+ | ` wasm_file ` | Label | ❌ | Direct WebAssembly module file |
1058+
1059+ ** Examples:**
1060+
1061+ Test component functionality
1062+
1063+ ``` python
1064+ wasm_test(
1065+ name = " component_test" ,
1066+ component = " :my_component" ,
1067+ )
1068+ ```
1069+
9551070## Security & Signing
9561071
9571072### wasm_keygen
@@ -1172,6 +1287,37 @@ def _my_rule_impl(ctx):
11721287 # Use component_info...
11731288```
11741289
1290+ ### WasmPrecompiledInfo
1291+
1292+ Provider that contains information about precompiled WebAssembly components (AOT compilation results).
1293+
1294+ ** Provider Fields:**
1295+
1296+ | Field | Type | Description |
1297+ | -------| ------| -------------|
1298+ | ` compatibility_hash ` | String | Hash for compatibility checking across builds |
1299+ | ` compilation_flags ` | List of Strings | List of compilation flags used |
1300+ | ` cwasm_file ` | File | Precompiled .cwasm file |
1301+ | ` optimization_level ` | String | Optimization level used (0, 1, 2, s) |
1302+ | ` source_wasm ` | File | Original WASM file that was precompiled |
1303+ | ` target_arch ` | String | Target architecture (x86_64, aarch64, etc.) |
1304+ | ` wasmtime_version ` | String | Version of Wasmtime used for compilation |
1305+
1306+ ** Examples:**
1307+
1308+ Access precompiled component information
1309+
1310+ ``` python
1311+ def _my_rule_impl (ctx ):
1312+ if WasmPrecompiledInfo in ctx.attr.component:
1313+ precompiled_info = ctx.attr.component[WasmPrecompiledInfo]
1314+ cwasm_file = precompiled_info.cwasm_file
1315+ optimization = precompiled_info.optimization_level
1316+ # Use precompiled version...
1317+ else :
1318+ # Fallback to regular component...
1319+ ```
1320+
11751321### WitInfo
11761322
11771323Provider that contains information about WIT interfaces and their dependencies.
0 commit comments