64 lines
2.1 KiB
Batchfile
64 lines
2.1 KiB
Batchfile
@echo off
|
|
setlocal enabledelayedexpansion
|
|
|
|
rem Build the Windows shell. Picks the GNU/MinGW target based on host arch:
|
|
rem ARM64 -> aarch64-pc-windows-gnullvm (clangarm64 llvm-mingw toolchain)
|
|
rem x86_64 -> x86_64-pc-windows-gnu (ucrt64 gcc-mingw toolchain)
|
|
rem A user override via LAYERS_RUST_TARGET wins.
|
|
|
|
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"
|
|
)
|
|
echo target: %RUST_TARGET%
|
|
|
|
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 Optional: render icons from the SVG if rsvg-convert is on PATH (winget install GNOME.librsvg).
|
|
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 nng 1.x (bundled by nng-sys 1.4.0-rc.0) has two type mismatches that become hard
|
|
rem errors under clang 16+ (which ships in MSYS2 clangarm64). Downgrade them so the
|
|
rem vendored C builds cleanly. Harmless on older clang / gcc too.
|
|
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%"
|
|
)
|
|
|
|
cargo build --release --bin layers --target %RUST_TARGET%
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo cargo build failed
|
|
popd
|
|
exit /b 1
|
|
)
|
|
|
|
copy /y "%ROOT%\target\%RUST_TARGET%\release\layers.exe" "%APPDIR%\Layers.exe" >nul
|
|
if exist "%ROOT%\plugin.json" copy /y "%ROOT%\plugin.json" "%STAGE%\plugin.json" >nul
|
|
if exist "%ROOT%\LICENCE" copy /y "%ROOT%\LICENCE" "%STAGE%\LICENCE" >nul
|
|
xcopy /e /i /y /q "%ROOT%\resources" "%STAGE%\resources" >nul
|
|
|
|
echo staged: %STAGE%
|
|
echo exe: %APPDIR%\Layers.exe
|
|
popd
|
|
endlocal
|