diff --git a/bin/build.ps1 b/bin/build.ps1 index b7a41fb..1dae3cc 100644 --- a/bin/build.ps1 +++ b/bin/build.ps1 @@ -1,21 +1,22 @@ $here = $PSScriptRoot $project_root = (Get-Item $here).Parent.FullName - $target = $args[0] -if ($target -eq "release") { - $extra = "--release" -} else { - $target = "debug" - $extra = "" -} - -$module_dir = "$project_root\target\$target" Push-Location $project_root - -cargo build --all $extra - -Pop-Location +try { + switch ($target) { + 'release' { + $module_dir = "$project_root\target\release" + cargo build --all --release + } + default { + $module_dir = "$project_root\target\debug" + cargo build --all + } + } +} finally { + Pop-Location +} Copy-Item $module_dir\emacs_rs_module.dll $module_dir\rs-module.dll Copy-Item $module_dir\test_module.dll $module_dir\t.dll diff --git a/bin/test.ps1 b/bin/test.ps1 index 67d5329..dfb28a0 100644 --- a/bin/test.ps1 +++ b/bin/test.ps1 @@ -5,8 +5,11 @@ $module_dir = "$project_root\target\$target" if ($args[0] -eq "watch") { Push-Location $project_root - cargo watch -s "powershell bin\build.ps1" -s "powershell bin\test.ps1" - Pop-Location + try { + cargo watch -s "powershell bin\build.ps1" -s "powershell bin\test.ps1" + } finally { + Pop-Location + } } else { # XXX: It seems that Emacs writes to stderr, so PowerShell thinks it's an error. Redirecting to # stdout alone doesn't help, because it's the processed stderr, which contain error records, not