Use WSL to build Rust Linux

This commit is contained in:
jaby 2022-09-11 21:38:30 +02:00
parent 92954ce53e
commit bbe5bdcb2f
2 changed files with 7 additions and 22 deletions

View File

@ -1,2 +0,0 @@
[target.x86_64-unknown-linux-musl]
linker = "rust-lld"

View File

@ -6,17 +6,16 @@ set org_dir=%cd%
set bin_ext=.exe
IF "%4" == "linux" (
set cfg=x86_64-unknown-linux-musl
set target=--target=!cfg!
set prefix=wsl $HOME/.cargo/bin/
set bin_ext=
)
cd %1
IF %2 == build (
echo cargo build %1 --%3
call:build_rust %1 %2 %3 %4
%prefix%cargo build --%3 %target%
IF %ERRORLEVEL% == 0 (
xcopy target\%cfg%\%3\%1%bin_ext% %org_dir%\..\..\bin /y
xcopy target\%3\%1%bin_ext% %org_dir%\..\..\bin /y
)
exit /B %ERRORLEVEL%
@ -24,36 +23,24 @@ IF %2 == build (
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%
)
%prefix%cargo run --%3 %target%
exit /B %ERRORLEVEL%
)
IF %2 == check (
echo cargo check %1 --%3
cargo check --%3 %target%
%prefix%cargo check --%3 %target%
exit /B %ERRORLEVEL%
)
IF %2 == clean (
echo cargo clean %1
cargo clean
%prefix%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
echo "Unkown cargo command "%2" for project "%1"