Build the WASM component with debug info and linker map.
(output_dir, profile)
| 154 | |
| 155 | |
| 156 | def build_wasm(output_dir, profile): |
| 157 | """Build the WASM component with debug info and linker map.""" |
| 158 | map_path = output_dir / "wasm.map" |
| 159 | env = { |
| 160 | "RUSTFLAGS": f"-C debuginfo=2 -C link-arg=--Map={map_path}", |
| 161 | } |
| 162 | if profile == "release-debug": |
| 163 | # Override workspace release profile without modifying Cargo.toml |
| 164 | env["CARGO_PROFILE_RELEASE_STRIP"] = "false" |
| 165 | env["CARGO_PROFILE_RELEASE_DEBUG"] = "2" |
| 166 | cargo_profile = "release" |
| 167 | else: |
| 168 | cargo_profile = profile |
| 169 | |
| 170 | cmd = [ |
| 171 | "cargo", "build", |
| 172 | "--target", "wasm32-wasip2", |
| 173 | "--profile", cargo_profile, |
| 174 | ] |
| 175 | run(cmd, capture=False, env=env, cwd=PACKAGE_DIR) |
| 176 | |
| 177 | wasm_path = TARGET_DIR / "wasm32-wasip2" / cargo_profile / "vercel_python_analysis.wasm" |
| 178 | if not wasm_path.exists(): |
| 179 | print(f"{RED}Error: expected WASM at {wasm_path}{RESET}", file=sys.stderr) |
| 180 | sys.exit(1) |
| 181 | |
| 182 | return wasm_path, map_path |
| 183 | |
| 184 | |
| 185 | def extract_core_module(component_path, output_path): |