@echo off setlocal enabledelayedexpansion rem Build the Windows shell — Rust cdylib + C# WinUI 3 host. rem rem Rust target (MSYS2 llvm-mingw / gcc-mingw): rem ARM64 -> aarch64-pc-windows-gnullvm rem x86_64 -> x86_64-pc-windows-gnu rem .NET publish target: rem ARM64 -> win-arm64 rem x86_64 -> win-x64 rem Override via LAYERS_RUST_TARGET / LAYERS_NET_RID if needed. pushd %~dp0 set "ROOT=%CD%" if defined LAYERS_RUST_TARGET ( set "RUST_TARGET=%LAYERS_RUST_TARGET%" ) else if /I "%PROCESSOR_ARCHITECTURE%"=="ARM64" ( set "RUST_TARGET=aarch64-pc-windows-gnullvm" ) else ( set "RUST_TARGET=x86_64-pc-windows-gnu" ) if defined LAYERS_NET_RID ( set "NET_RID=%LAYERS_NET_RID%" ) else if /I "%PROCESSOR_ARCHITECTURE%"=="ARM64" ( set "NET_RID=win-arm64" ) else ( set "NET_RID=win-x64" ) echo rust target: %RUST_TARGET% echo .NET RID: %NET_RID% set "STAGE=%ROOT%\build\bin\com.jesshunter.layers" set "APPDIR=%STAGE%\bin" if exist "%STAGE%" rmdir /s /q "%STAGE%" mkdir "%APPDIR%" >nul 2>&1 mkdir "%STAGE%\resources" >nul 2>&1 rem Icons from the SVG via rsvg-convert (optional). where rsvg-convert >nul 2>&1 if %ERRORLEVEL% equ 0 ( for %%s in (24 48 128 256) do ( if not exist "%ROOT%\resources\icon-%%s.png" ( rsvg-convert --width %%s --height %%s "%ROOT%\resources\Layers.svg" -o "%ROOT%\resources\icon-%%s.png" ) ) ) rem The Windows exe icon is generated by an MSBuild Target inside LayersShell.csproj rem (matches Acord's build.rs pattern). No action needed here. rem nng 1.x triggers clang 16+ hard errors on type-incompatibilities; downgrade to warnings. set "NNG_RELAX=-Wno-error=incompatible-pointer-types -Wno-error=incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-incompatible-function-pointer-types" if defined CFLAGS ( set "CFLAGS=%CFLAGS% %NNG_RELAX%" ) else ( set "CFLAGS=%NNG_RELAX%" ) rem --- 1. Rust cdylib (layers.dll) --- cargo build --release --lib --target %RUST_TARGET% if %ERRORLEVEL% neq 0 ( echo cargo build failed popd exit /b 1 ) rem --- 2. C# WinUI 3 shell --- pushd "%ROOT%\shell\windows\LayersShell" dotnet publish -c Release -r %NET_RID% --self-contained false -p:WindowsPackageType=None -p:PublishReadyToRun=true if %ERRORLEVEL% neq 0 ( echo dotnet publish failed popd popd exit /b 1 ) popd rem --- 3. Stage --- set "CSHARP_OUT=%ROOT%\shell\windows\LayersShell\bin\Release\net8.0-windows10.0.19041.0\%NET_RID%\publish" xcopy /e /i /y /q "%CSHARP_OUT%" "%APPDIR%" >nul copy /y "%ROOT%\target\%RUST_TARGET%\release\layers.dll" "%APPDIR%\layers_native.dll" >nul if exist "%ROOT%\LICENCE" copy /y "%ROOT%\LICENCE" "%STAGE%\LICENCE" >nul xcopy /e /i /y /q "%ROOT%\resources" "%STAGE%\resources" >nul rem Render plugin.json.in -> stage\plugin.json with the shell exe as entrypoint. if not exist "%ROOT%\plugin.json.in" ( echo ERROR: %ROOT%\plugin.json.in not found popd exit /b 1 ) powershell -NoProfile -Command "(Get-Content -Raw -LiteralPath '%ROOT%\plugin.json.in') -replace '@ENTRYPOINT@', 'bin/Layers.exe' | Set-Content -LiteralPath '%STAGE%\plugin.json' -NoNewline" echo. echo staged: %STAGE% echo exe: %APPDIR%\Layers.exe popd endlocal