59 lines
1.1 KiB
Batchfile
59 lines
1.1 KiB
Batchfile
@echo off
|
|
setlocal EnableDelayedExpansion
|
|
rem run_cargo.bat project build|check|clean debug|release [linux|windows]
|
|
|
|
set org_dir=%cd%
|
|
set bin_ext=.exe
|
|
|
|
IF "%4" == "linux" (
|
|
set cfg=x86_64-unknown-linux-musl
|
|
set target=--target=!cfg!
|
|
set bin_ext=
|
|
)
|
|
|
|
cd %1
|
|
IF %2 == build (
|
|
echo cargo build %1 --%3
|
|
call:build_rust %1 %2 %3 %4
|
|
IF %ERRORLEVEL% == 0 (
|
|
xcopy target\%cfg%\%3\%1%bin_ext% %org_dir%\..\..\bin /y
|
|
)
|
|
|
|
exit /B %ERRORLEVEL%
|
|
)
|
|
|
|
IF %2 == run (
|
|
echo cargo run %1 --%3
|
|
IF "%4" == "linux" (
|
|
rem call:build_rust %1 %2 %3 %4
|
|
IF %ERRORLEVEL% == 0 (
|
|
wsl $PWD/target/%cfg%/%3/%1
|
|
)
|
|
) ELSE (
|
|
cargo run --%3 %target%
|
|
)
|
|
|
|
exit /B %ERRORLEVEL%
|
|
)
|
|
|
|
IF %2 == check (
|
|
echo cargo check %1 --%3
|
|
cargo check --%3 %target%
|
|
|
|
exit /B %ERRORLEVEL%
|
|
)
|
|
|
|
IF %2 == clean (
|
|
echo cargo clean %1
|
|
cargo clean
|
|
@del %org_dir%\..\..\bin\%1%bin_ext%
|
|
|
|
exit /B %ERRORLEVEL%
|
|
)
|
|
|
|
echo "Unkown cargo command "%2" for project "%1"
|
|
GOTO:eof
|
|
|
|
:build_rust
|
|
cargo build --%3 %target%
|
|
GOTO:eof |