Build linux under windows with MUSL

This commit is contained in:
Jaby
2022-09-22 19:26:13 +02:00
parent 1a1749531c
commit e358ad7bd6
5 changed files with 25 additions and 18 deletions

View File

@@ -1,21 +1,26 @@
@echo off
setlocal EnableDelayedExpansion
rem run_cargo.bat project build|check|clean debug|release [linux|windows]
rem run_cargo.bat project {build|check|clean|test} {debug|release} [linux|windows]
set org_dir=%cd%
set bin_ext=.exe
set target=x86_64-pc-windows-msvc
IF "%4" == "linux" (
set prefix=wsl $HOME/.cargo/bin/
IF %4 == linux (
set bin_ext=
set target=x86_64-unknown-linux-musl
)
IF %2 == build set run_build=1
IF %2 == test set run_build=1
cd %1
IF %2 == build (
IF defined run_build (
echo cargo build %1 --%3
%prefix%cargo build --%3 %target%
IF %ERRORLEVEL% == 0 (
xcopy target\%3\%1%bin_ext% %org_dir%\..\..\bin /y
cargo build --%3 --target=%target%
IF %2 == build IF %ERRORLEVEL% == 0 (
xcopy target\%target%\%3\%1%bin_ext% %org_dir%\..\..\bin /y
)
exit /B %ERRORLEVEL%
@@ -23,21 +28,21 @@ IF %2 == build (
IF %2 == run (
echo cargo run %1 --%3
%prefix%cargo run --%3 %target%
cargo run --%3 --target=%target%
exit /B %ERRORLEVEL%
)
IF %2 == check (
echo cargo check %1 --%3
%prefix%cargo check --%3 %target%
cargo check --%3 --target=%target%
exit /B %ERRORLEVEL%
)
IF %2 == clean (
echo cargo clean %1
%prefix%cargo clean
cargo clean
rem We do not delete the bin folder anymore - is kinda to much
rem @del %org_dir%\..\..\bin\%1%bin_ext%