OKAY, FUCK C#, FUCK DOT NET - IM DONE. DIFFERENT APPROACH
This commit is contained in:
parent
9d28aadf26
commit
5cf8e23b47
|
|
@ -3,8 +3,3 @@
|
||||||
|
|
||||||
# Generated at build time from plugin.json.in by each platform's build script.
|
# Generated at build time from plugin.json.in by each platform's build script.
|
||||||
/plugin.json
|
/plugin.json
|
||||||
|
|
||||||
# WinUI 3 shell generated artefacts.
|
|
||||||
/shell/windows/LayersShell/Assets/app.ico
|
|
||||||
/shell/windows/LayersShell/bin/
|
|
||||||
/shell/windows/LayersShell/obj/
|
|
||||||
|
|
|
||||||
14
Cargo.toml
14
Cargo.toml
|
|
@ -27,13 +27,6 @@ raw-window-handle = "0.6"
|
||||||
pollster = "0.4"
|
pollster = "0.4"
|
||||||
winit = "0.30"
|
winit = "0.30"
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
|
||||||
windows = { version = "0.58", features = [
|
|
||||||
"Win32_Foundation",
|
|
||||||
"Win32_Graphics_Dwm",
|
|
||||||
"Win32_UI_WindowsAndMessaging",
|
|
||||||
] }
|
|
||||||
|
|
||||||
iced_wgpu = "0.14"
|
iced_wgpu = "0.14"
|
||||||
iced_graphics = "0.14"
|
iced_graphics = "0.14"
|
||||||
iced_runtime = "0.14"
|
iced_runtime = "0.14"
|
||||||
|
|
@ -73,3 +66,10 @@ tempfile = "3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
debug = []
|
debug = []
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
|
windows = { version = "0.58", features = [
|
||||||
|
"Win32_Foundation",
|
||||||
|
"Win32_Graphics_Dwm",
|
||||||
|
"Win32_UI_WindowsAndMessaging",
|
||||||
|
] }
|
||||||
|
|
|
||||||
41
README.md
41
README.md
|
|
@ -29,9 +29,9 @@ Installs to `~/Documents/KiCad/10.0/plugins/com.jesshunter.layers/`.
|
||||||
|
|
||||||
### Windows (10 / 11, ARM64 or x86_64)
|
### Windows (10 / 11, ARM64 or x86_64)
|
||||||
|
|
||||||
The Windows shell is a **WinUI 3** (.NET 8) app that hosts the Rust renderer through
|
A single native Rust binary — no .NET, no WinUI, no Visual Studio. Mica backdrop
|
||||||
a `SwapChainPanel`. The Rust side builds as a cdylib via **MSYS2 + MinGW** — no full
|
on Windows 11 22H2+ via `DwmSetWindowAttribute`, falls back gracefully on older
|
||||||
Visual Studio Build Tools required. Both ARM64 and x86_64 hosts work the same way.
|
Windows. Both ARM64 and x86_64 hosts work the same way.
|
||||||
|
|
||||||
#### 1. Install MSYS2
|
#### 1. Install MSYS2
|
||||||
|
|
||||||
|
|
@ -103,20 +103,7 @@ PATH. Run this **once** in PowerShell (elevated shell not required):
|
||||||
|
|
||||||
Close and reopen every PowerShell / cmd window after this so they pick up the change.
|
Close and reopen every PowerShell / cmd window after this so they pick up the change.
|
||||||
|
|
||||||
#### 5. Install .NET 8 SDK + Windows App SDK workload
|
#### 5. Build + install
|
||||||
|
|
||||||
In PowerShell:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
winget install Microsoft.DotNet.SDK.8
|
|
||||||
dotnet workload install maui-windows
|
|
||||||
```
|
|
||||||
|
|
||||||
The Windows App SDK itself is pulled in via NuGet when the shell builds. The
|
|
||||||
`maui-windows` workload supplies the MSBuild tasks that WinUI 3's PRI/MRT targets
|
|
||||||
reach for, which would otherwise only be available with a full Visual Studio install.
|
|
||||||
|
|
||||||
#### 6. Build + install
|
|
||||||
|
|
||||||
```bat
|
```bat
|
||||||
git clone https://git.else-if.org/jess/Layers
|
git clone https://git.else-if.org/jess/Layers
|
||||||
|
|
@ -127,24 +114,8 @@ install.bat
|
||||||
Installs to `%USERPROFILE%\Documents\KiCad\10.0\plugins\com.jesshunter.layers\`
|
Installs to `%USERPROFILE%\Documents\KiCad\10.0\plugins\com.jesshunter.layers\`
|
||||||
(or the OneDrive-redirected equivalent).
|
(or the OneDrive-redirected equivalent).
|
||||||
|
|
||||||
Runtime requirement on the target machine: **.NET 8 Desktop Runtime**. `winget install
|
No external runtime required — the exe is statically linked against the MSYS2
|
||||||
Microsoft.DotNet.DesktopRuntime.8` — the installer's ~100 MB and common on modern
|
clangarm64 / ucrt64 toolchain. Just ship the folder.
|
||||||
Windows boxes.
|
|
||||||
|
|
||||||
For a polished build you'll also want ImageMagick — it composes the Windows `.ico`
|
|
||||||
from the SVG, called from an MSBuild `<Target>` inside `LayersShell.csproj` so it runs
|
|
||||||
as part of `dotnet publish`. `rsvg-convert` was already pulled in via the MSYS2
|
|
||||||
`…-librsvg` package.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
winget install ImageMagick.ImageMagick
|
|
||||||
```
|
|
||||||
|
|
||||||
Neither tool is strictly required — the Target's `ContinueOnError="true"` and the
|
|
||||||
ApplicationIcon `Condition="Exists(...)"` let the build skip icon baking and fall
|
|
||||||
through to the default .NET exe icon if either is missing. If you don't want MSYS2
|
|
||||||
and need a standalone `rsvg-convert` (x86_64 only), grab a release from
|
|
||||||
<https://github.com/charls-data/static-rsvg-convert/releases> and drop it on PATH.
|
|
||||||
|
|
||||||
### Linux — Debian / Ubuntu / Pop!_OS (apt)
|
### Linux — Debian / Ubuntu / Pop!_OS (apt)
|
||||||
|
|
||||||
|
|
|
||||||
47
build.bat
47
build.bat
|
|
@ -1,15 +1,10 @@
|
||||||
@echo off
|
@echo off
|
||||||
setlocal enabledelayedexpansion
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
rem Build the Windows shell — Rust cdylib + C# WinUI 3 host.
|
rem Picks the GNU/MinGW target based on host arch:
|
||||||
rem
|
rem ARM64 -> aarch64-pc-windows-gnullvm (clangarm64 llvm-mingw toolchain)
|
||||||
rem Rust target (MSYS2 llvm-mingw / gcc-mingw):
|
rem x86_64 -> x86_64-pc-windows-gnu (ucrt64 gcc-mingw toolchain)
|
||||||
rem ARM64 -> aarch64-pc-windows-gnullvm
|
rem LAYERS_RUST_TARGET overrides.
|
||||||
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
|
pushd %~dp0
|
||||||
set "ROOT=%CD%"
|
set "ROOT=%CD%"
|
||||||
|
|
@ -21,15 +16,7 @@ if defined LAYERS_RUST_TARGET (
|
||||||
) else (
|
) else (
|
||||||
set "RUST_TARGET=x86_64-pc-windows-gnu"
|
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 rust target: %RUST_TARGET%
|
||||||
echo .NET RID: %NET_RID%
|
|
||||||
|
|
||||||
set "STAGE=%ROOT%\build\bin\com.jesshunter.layers"
|
set "STAGE=%ROOT%\build\bin\com.jesshunter.layers"
|
||||||
set "APPDIR=%STAGE%\bin"
|
set "APPDIR=%STAGE%\bin"
|
||||||
|
|
@ -37,7 +24,6 @@ if exist "%STAGE%" rmdir /s /q "%STAGE%"
|
||||||
mkdir "%APPDIR%" >nul 2>&1
|
mkdir "%APPDIR%" >nul 2>&1
|
||||||
mkdir "%STAGE%\resources" >nul 2>&1
|
mkdir "%STAGE%\resources" >nul 2>&1
|
||||||
|
|
||||||
rem Icons from the SVG via rsvg-convert (optional).
|
|
||||||
where rsvg-convert >nul 2>&1
|
where rsvg-convert >nul 2>&1
|
||||||
if %ERRORLEVEL% equ 0 (
|
if %ERRORLEVEL% equ 0 (
|
||||||
for %%s in (24 48 128 256) do (
|
for %%s in (24 48 128 256) do (
|
||||||
|
|
@ -47,10 +33,6 @@ if %ERRORLEVEL% equ 0 (
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
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"
|
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 (
|
if defined CFLAGS (
|
||||||
set "CFLAGS=%CFLAGS% %NNG_RELAX%"
|
set "CFLAGS=%CFLAGS% %NNG_RELAX%"
|
||||||
|
|
@ -58,34 +40,17 @@ if defined CFLAGS (
|
||||||
set "CFLAGS=%NNG_RELAX%"
|
set "CFLAGS=%NNG_RELAX%"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem --- 1. Rust cdylib (layers.dll) ---
|
cargo build --release --bin layers --target %RUST_TARGET%
|
||||||
cargo build --release --lib --target %RUST_TARGET%
|
|
||||||
if %ERRORLEVEL% neq 0 (
|
if %ERRORLEVEL% neq 0 (
|
||||||
echo cargo build failed
|
echo cargo build failed
|
||||||
popd
|
popd
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
rem --- 2. C# WinUI 3 shell ---
|
copy /y "%ROOT%\target\%RUST_TARGET%\release\layers.exe" "%APPDIR%\Layers.exe" >nul
|
||||||
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
|
if exist "%ROOT%\LICENCE" copy /y "%ROOT%\LICENCE" "%STAGE%\LICENCE" >nul
|
||||||
xcopy /e /i /y /q "%ROOT%\resources" "%STAGE%\resources" >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" (
|
if not exist "%ROOT%\plugin.json.in" (
|
||||||
echo ERROR: %ROOT%\plugin.json.in not found
|
echo ERROR: %ROOT%\plugin.json.in not found
|
||||||
popd
|
popd
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue