Use Rust graph solver in React viewer
This commit is contained in:
parent
2c13f36da7
commit
4e7d352583
7 changed files with 285 additions and 4 deletions
28
web/epiphany-graph-viewer/scripts/Build-RustSolverWasm.ps1
Normal file
28
web/epiphany-graph-viewer/scripts/Build-RustSolverWasm.ps1
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
param(
|
||||
[string]$SolverRoot = "E:\Projects\epiphany-graph-rs"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$packageRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
|
||||
$solverRootPath = Resolve-Path $SolverRoot
|
||||
|
||||
Push-Location $solverRootPath
|
||||
try {
|
||||
rustup target add wasm32-unknown-unknown | Out-Host
|
||||
cargo build --release --target wasm32-unknown-unknown | Out-Host
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
$wasmPath = Join-Path $solverRootPath "target\wasm32-unknown-unknown\release\epiphany_graph_rs.wasm"
|
||||
$outputPath = Join-Path $packageRoot "src\lib\solver-wasm-bytes.ts"
|
||||
$base64 = [Convert]::ToBase64String([IO.File]::ReadAllBytes($wasmPath))
|
||||
|
||||
@(
|
||||
"export const epiphanyGraphSolverWasmBase64 =",
|
||||
" `"$base64`";"
|
||||
) | Set-Content -LiteralPath $outputPath -Encoding UTF8
|
||||
|
||||
Write-Host "Updated $outputPath"
|
||||
Loading…
Reference in a new issue