Skip to content

Lightweight native Discord client for Windows, Linux and macOS, written in Rust. No Electron, no browser engine.

2.2 KB
Raw Blame
@echo off
rem Builds dist\RustCordSetup-<version>.exe: RustCord's installer for Windows,
rem and next to it RustCordSetup-<version>.exe.sha256, its checksum (for
rem anyone downloading it to check they got exactly this file).
rem It builds RustCord and the uninstaller first, because the installer
rem carries both inside it, compressed (rustcord-pack does that).
setlocal
cd /d "%~dp0"

rem Paths on the building PC (its user folder, where the code is) stay out of
rem the programs: file names in panic messages start at "~" or "rustcord".
set "REMAP=--config "build.rustflags=['--remap-path-prefix=%USERPROFILE%=~','--remap-path-prefix=%CD%=rustcord']""
rem (The same for C code built along the way, such as Opus: MSVC's file-name trim.)
set "CFLAGS=/d1trimfile:%USERPROFILE%\"

rem The registry's address (server\README.md) is built in from the environment
rem variable RUSTCORD_REGISTRY_URL or, without it, from the first line of
rem registry-url.local (a file that stays on this PC). Neither: no registry.
if not defined RUSTCORD_REGISTRY_URL if exist registry-url.local set /p RUSTCORD_REGISTRY_URL=<registry-url.local
if defined RUSTCORD_REGISTRY_URL (echo Registry: built in) else (echo Registry: none)

cargo build --release %REMAP% -p rustcord || exit /b 1
cargo build --release %REMAP% -p rustcord-setup --bin rustcord-uninstall --bin rustcord-pack || exit /b 1
target\release\rustcord-pack.exe || exit /b 1
cargo build --release %REMAP% -p rustcord-setup --bin rustcord-setup || exit /b 1

rem The installer's name carries the version (the workspace's, in Cargo.toml).
set "VER="
for /f "tokens=2 delims== " %%v in ('findstr /b /c:"version = " Cargo.toml') do if not defined VER set "VER=%%~v"
if not defined VER (echo Couldn't read the version from Cargo.toml & exit /b 1)

if not exist dist mkdir dist
copy /y target\release\rustcord-setup.exe "dist\RustCordSetup-%VER%.exe" >nul || exit /b 1
powershell -NoProfile -Command "$h = (Get-FileHash -Algorithm SHA256 'dist\RustCordSetup-%VER%.exe').Hash.ToLower(); Set-Content -Encoding ascii 'dist\RustCordSetup-%VER%.exe.sha256' ($h + '  RustCordSetup-%VER%.exe')" || exit /b 1
echo.
echo Built dist\RustCordSetup-%VER%.exe
type "dist\RustCordSetup-%VER%.exe.sha256"