|
| 1 | +"""Single source of truth for tool versions |
| 2 | +
|
| 3 | +This file defines the canonical versions for all WebAssembly toolchain components. |
| 4 | +All toolchain setup code MUST reference these constants to ensure version consistency. |
| 5 | +
|
| 6 | +IMPORTANT: When updating versions here: |
| 7 | +1. Update corresponding JSON registry in checksums/tools/<tool>.json |
| 8 | +2. Verify compatibility using validate_tool_compatibility() in checksums/registry.bzl |
| 9 | +3. Check embedded runtimes (rust_wasm_component_bindgen.bzl) for API compatibility |
| 10 | +4. Update Cargo.toml dependencies if using the tool as a crate |
| 11 | +5. Test the full build pipeline |
| 12 | +""" |
| 13 | + |
| 14 | +# Tool versions - single source of truth |
| 15 | +TOOL_VERSIONS = { |
| 16 | + # Core WebAssembly toolchain |
| 17 | + "wasm-tools": "1.240.0", # Component model tools (validate, parse, compose, etc.) |
| 18 | + "wasmtime": "28.0.0", # WebAssembly runtime for testing/execution |
| 19 | + |
| 20 | + # WIT and binding generation |
| 21 | + "wit-bindgen": "0.46.0", # WIT binding generator (MUST match Cargo.toml if used as crate) |
| 22 | + "wac": "0.8.0", # WebAssembly Composition tool |
| 23 | + "wkg": "0.11.0", # WebAssembly package manager |
| 24 | + |
| 25 | + # Optimization and initialization |
| 26 | + "wizer": "8.1.0", # WebAssembly pre-initialization tool |
| 27 | + |
| 28 | + # Signatures and security |
| 29 | + "wasmsign2": "0.2.6", # WebAssembly signing tool |
| 30 | + |
| 31 | + # Platform SDKs |
| 32 | + "wasi-sdk": "26", # WASI SDK for C/C++ compilation |
| 33 | + "tinygo": "0.39.0", # TinyGo compiler for Go→WASM |
| 34 | + |
| 35 | + # Node.js ecosystem |
| 36 | + "nodejs": "20.18.0", # Node.js runtime for jco toolchain |
| 37 | +} |
| 38 | + |
| 39 | +# Compatibility matrix - defines which versions work together |
| 40 | +# Key: wasm-tools version |
| 41 | +# Value: Dict of compatible tool versions |
| 42 | +TOOL_COMPATIBILITY_MATRIX = { |
| 43 | + "1.240.0": { |
| 44 | + "wit-bindgen": ["0.46.0"], |
| 45 | + "wac": ["0.7.0", "0.8.0"], |
| 46 | + "wkg": ["0.11.0"], |
| 47 | + "wasmsign2": ["0.2.6"], |
| 48 | + "wasmtime": ["27.0.0", "28.0.0"], |
| 49 | + }, |
| 50 | + "1.239.0": { |
| 51 | + "wit-bindgen": ["0.43.0", "0.46.0"], |
| 52 | + "wac": ["0.7.0", "0.8.0"], |
| 53 | + "wkg": ["0.11.0"], |
| 54 | + "wasmsign2": ["0.2.6"], |
| 55 | + "wasmtime": ["27.0.0", "28.0.0"], |
| 56 | + }, |
| 57 | + "1.235.0": { |
| 58 | + "wit-bindgen": ["0.43.0", "0.46.0"], |
| 59 | + "wac": ["0.7.0", "0.8.0"], |
| 60 | + "wkg": ["0.11.0"], |
| 61 | + "wasmsign2": ["0.2.6"], |
| 62 | + "wasmtime": ["27.0.0"], |
| 63 | + }, |
| 64 | +} |
| 65 | + |
| 66 | +def get_tool_version(tool_name): |
| 67 | + """Get the canonical version for a tool |
| 68 | +
|
| 69 | + Args: |
| 70 | + tool_name: Name of the tool (e.g., "wasm-tools", "wit-bindgen") |
| 71 | +
|
| 72 | + Returns: |
| 73 | + String: Version number |
| 74 | +
|
| 75 | + Fails: |
| 76 | + If tool_name is not defined in TOOL_VERSIONS |
| 77 | + """ |
| 78 | + if tool_name not in TOOL_VERSIONS: |
| 79 | + fail("Unknown tool: {}. Available tools: {}".format( |
| 80 | + tool_name, |
| 81 | + ", ".join(TOOL_VERSIONS.keys()) |
| 82 | + )) |
| 83 | + return TOOL_VERSIONS[tool_name] |
| 84 | + |
| 85 | +def get_compatible_versions(base_tool, base_version): |
| 86 | + """Get compatible versions for other tools based on a base tool version |
| 87 | +
|
| 88 | + Args: |
| 89 | + base_tool: Name of the base tool (usually "wasm-tools") |
| 90 | + base_version: Version of the base tool |
| 91 | +
|
| 92 | + Returns: |
| 93 | + Dict: Mapping of tool names to list of compatible versions |
| 94 | + Empty dict if no compatibility info available |
| 95 | + """ |
| 96 | + if base_tool == "wasm-tools" and base_version in TOOL_COMPATIBILITY_MATRIX: |
| 97 | + return TOOL_COMPATIBILITY_MATRIX[base_version] |
| 98 | + return {} |
| 99 | + |
| 100 | +def validate_tool_versions(tools_config): |
| 101 | + """Validate that a set of tool versions are compatible |
| 102 | +
|
| 103 | + Args: |
| 104 | + tools_config: Dict mapping tool names to versions |
| 105 | +
|
| 106 | + Returns: |
| 107 | + List: List of warning messages (empty if all compatible) |
| 108 | + """ |
| 109 | + warnings = [] |
| 110 | + |
| 111 | + # Check if wasm-tools is in the config |
| 112 | + if "wasm-tools" not in tools_config: |
| 113 | + return warnings |
| 114 | + |
| 115 | + wasm_tools_version = tools_config["wasm-tools"] |
| 116 | + compat_info = get_compatible_versions("wasm-tools", wasm_tools_version) |
| 117 | + |
| 118 | + if not compat_info: |
| 119 | + warnings.append( |
| 120 | + "Warning: No compatibility information for wasm-tools {}".format(wasm_tools_version) |
| 121 | + ) |
| 122 | + return warnings |
| 123 | + |
| 124 | + # Check each tool against compatibility matrix |
| 125 | + for tool, version in tools_config.items(): |
| 126 | + if tool == "wasm-tools": |
| 127 | + continue |
| 128 | + |
| 129 | + if tool in compat_info: |
| 130 | + if version not in compat_info[tool]: |
| 131 | + warnings.append( |
| 132 | + "Warning: {} version {} may not be compatible with wasm-tools {}. " + |
| 133 | + "Recommended versions: {}".format( |
| 134 | + tool, |
| 135 | + version, |
| 136 | + wasm_tools_version, |
| 137 | + ", ".join(compat_info[tool]), |
| 138 | + ) |
| 139 | + ) |
| 140 | + |
| 141 | + return warnings |
| 142 | + |
| 143 | +def get_all_tool_versions(): |
| 144 | + """Get all tool versions as a dict |
| 145 | +
|
| 146 | + Returns: |
| 147 | + Dict: Copy of TOOL_VERSIONS |
| 148 | + """ |
| 149 | + return dict(TOOL_VERSIONS) |
| 150 | + |
| 151 | +# Export compatibility matrix for external use |
| 152 | +def get_compatibility_matrix(): |
| 153 | + """Get the full compatibility matrix |
| 154 | +
|
| 155 | + Returns: |
| 156 | + Dict: Copy of TOOL_COMPATIBILITY_MATRIX |
| 157 | + """ |
| 158 | + return dict(TOOL_COMPATIBILITY_MATRIX) |
0 commit comments