Skip to content

Commit 91fa5c8

Browse files
committed
Package examples with releases
1 parent 319032c commit 91fa5c8

5 files changed

Lines changed: 43 additions & 14 deletions

File tree

‎PdVm.Runner/Program.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
internal static class Program
66
{
77
[STAThread]
8-
public static Task<int> Main(string[] args)
8+
public static int Main(string[] args)
99
{
1010
PdVmDotNetHost.InitializeWindowsFormsApplication();
11-
return ProgramEntry.RunAsync(args);
11+
return ProgramEntry.RunAsync(args).GetAwaiter().GetResult();
1212
}
1313
}
1414

‎docs/dotnet-interop-wrapper-plan.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The wrapper materializes virtual modules in an overlay source root. The source r
3030
use System::Console;
3131
use System::IO::Path;
3232

33-
Console::WriteLine("hello");
33+
Console::WriteLineString("hello");
3434
let name = Path::GetFileName("scripts/main.rss");
3535
```
3636

@@ -51,10 +51,10 @@ CLR objects use typed module functions rather than string-based instance dispatc
5151
```rust
5252
use System::Text::StringBuilder;
5353

54-
let builder = StringBuilder::New();
55-
StringBuilder::Append(builder, "hello");
54+
let builder = StringBuilder::NewStringBuilder();
55+
StringBuilder::AppendStringInstance(builder, "hello");
5656
let text = StringBuilder::ToString(builder);
57-
StringBuilder::Release(builder);
57+
StringBuilder::ReleaseStringBuilder(builder);
5858
```
5959

6060
The first version represents CLR references as checked integer handles. A later language-level opaque-handle schema can replace this without changing the binding descriptor format.

‎examples/dotnet-typed-console.rss‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ use System::Console;
22
use System::IO::Path;
33
use System::Text::StringBuilder;
44

5-
Console::WriteLine("typed .NET interop from RustScript");
5+
Console::WriteLineString("typed .NET interop from RustScript");
66
let name = Path::GetFileName("examples/demo.rss");
7-
Console::WriteLine(name);
7+
Console::WriteLineString(name);
88

9-
let builder = StringBuilder::New();
10-
StringBuilder::Append(builder, "CLR ");
11-
StringBuilder::Append(builder, "object handle");
12-
Console::WriteLine(StringBuilder::ToString(builder));
13-
StringBuilder::Release(builder);
9+
let builder = StringBuilder::NewStringBuilder();
10+
StringBuilder::AppendStringInstance(builder, "CLR ");
11+
StringBuilder::AppendStringInstance(builder, "object handle");
12+
Console::WriteLineString(StringBuilder::ToString(builder));
13+
StringBuilder::ReleaseStringBuilder(builder);

‎run-minesweeper.bat‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@echo off
2+
setlocal
3+
4+
set "ROOT=%~dp0"
5+
set "RUNNER=%ROOT%PdVm.Runner.dll"
6+
if not exist "%RUNNER%" set "RUNNER=%ROOT%PdVm.Runner\bin\Release\net10.0\PdVm.Runner.dll"
7+
8+
if not exist "%RUNNER%" (
9+
echo PdVm.Runner.dll was not found. Build the solution or run this file from a release package.
10+
exit /b 1
11+
)
12+
13+
dotnet "%RUNNER%" run "%ROOT%examples\dotnet-minesweeper.rss" --profile winforms %*
14+
exit /b %ERRORLEVEL%

‎scripts/package-release.ps1‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ if (Test-Path -LiteralPath $packageRoot) {
2020
}
2121
New-Item -ItemType Directory -Path $packageRoot -Force | Out-Null
2222

23+
$examplesSource = Join-Path $repoRoot 'examples'
24+
$examplesDestination = Join-Path $packageRoot 'examples'
25+
Copy-Item -LiteralPath $examplesSource -Destination $examplesDestination -Recurse
26+
Copy-Item -LiteralPath (Join-Path $repoRoot 'run-minesweeper.bat') -Destination $packageRoot
27+
2328
$manifest = Join-Path $repoRoot 'native/pd-vm-compiler/Cargo.toml'
2429
cargo build --locked --release --target $RustTarget --manifest-path $manifest
2530
if ($LASTEXITCODE -ne 0) {
@@ -62,14 +67,24 @@ $requiredFiles = @(
6267
'PdVm.Compiler.pdb',
6368
'PdVm.Runtime.dll',
6469
'PdVm.Runtime.pdb',
65-
$nativeName
70+
$nativeName,
71+
'run-minesweeper.bat'
6672
)
6773
foreach ($file in $requiredFiles) {
6874
if (-not (Test-Path -LiteralPath (Join-Path $packageRoot $file))) {
6975
throw "Release package is missing $file"
7076
}
7177
}
7278

79+
$examplesPrefix = $examplesSource.TrimEnd([System.IO.Path]::DirectorySeparatorChar) + [System.IO.Path]::DirectorySeparatorChar
80+
foreach ($example in Get-ChildItem -LiteralPath $examplesSource -File -Recurse) {
81+
$relative = $example.FullName.Substring($examplesPrefix.Length)
82+
$packagedExample = Join-Path $examplesDestination $relative
83+
if (-not (Test-Path -LiteralPath $packagedExample)) {
84+
throw "Release package is missing example $relative"
85+
}
86+
}
87+
7388
$archiveExtension = if ($RuntimeIdentifier -eq 'win-x64') { 'zip' } else { 'tar.gz' }
7489
$archive = Join-Path $releaseRoot "pd-vm-clr-$RuntimeIdentifier.$archiveExtension"
7590
if (Test-Path -LiteralPath $archive) {

0 commit comments

Comments
 (0)