-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild-wasm.ps1
More file actions
58 lines (52 loc) · 2.14 KB
/
build-wasm.ps1
File metadata and controls
58 lines (52 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
if ($env:EMSDK) {
$envScript = Join-Path $env:EMSDK "emsdk_env.ps1"
if (Test-Path $envScript) { & $envScript }
}
$emccArgs = "external/ayumi/ayumi.c", "-o", "public/ayumi.wasm", "-O3",
"-s", "WASM=1",
"-s", "EXPORTED_FUNCTIONS=`"[\`"_ayumi_configure\`", \`"_ayumi_set_pan\`", \`"_ayumi_set_tone\`", \`"_ayumi_set_noise\`", \`"_ayumi_set_mixer\`", \`"_ayumi_set_volume\`", \`"_ayumi_set_envelope\`", \`"_ayumi_set_envelope_shape\`", \`"_ayumi_process\`", \`"_ayumi_remove_dc\`", \`"_malloc\`", \`"_free\`"]`"",
"-s", "ALLOW_MEMORY_GROWTH=1", "-s", "INITIAL_MEMORY=16777216", "-s", "MAXIMUM_MEMORY=16777216",
"-s", "ENVIRONMENT=web", "-s", "STANDALONE_WASM=1", "--no-entry"
$python = $null
foreach ($name in @('python', 'python3')) {
$c = Get-Command $name -EA SilentlyContinue
if ($c) { $python = $c.Source; break }
}
if (-not $python) {
$paths = @(
"$env:LOCALAPPDATA\Programs\Python\Python*\python.exe",
"$env:ProgramFiles\Python*\python.exe",
"${env:ProgramFiles(x86)}\Python*\python.exe"
)
foreach ($p in $paths) {
$f = Get-ChildItem $p -EA SilentlyContinue | Select-Object -First 1
if ($f) { $python = $f.FullName; break }
}
}
if (-not $env:EMSDK) {
$try = @("$env:USERPROFILE\emsdk", "${env:ProgramFiles}\emsdk", "C:\emsdk")
foreach ($d in $try) {
$py = Join-Path $d "upstream\emscripten\emcc.py"
if (Test-Path $py) {
$env:EMSDK = $d
$envScript = Join-Path $d "emsdk_env.ps1"
if (Test-Path $envScript) { & $envScript }
break
}
}
}
if (-not $env:EMSDK) {
Write-Host "Error: EMSDK not set. Set EMSDK to your Emscripten install path (e.g. $env:USERPROFILE\emsdk)." -ForegroundColor Red
exit 1
}
$emccPy = Join-Path $env:EMSDK "upstream\emscripten\emcc.py"
if (-not (Test-Path $emccPy)) {
Write-Host "Error: emcc.py not found at $emccPy" -ForegroundColor Red
exit 1
}
if (-not $python) {
Write-Host "Error: Python not found. Add Python to PATH or install from https://www.python.org/" -ForegroundColor Red
exit 1
}
& $python $emccPy @emccArgs
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }