diff --git a/src/Tools/.cargo/config.toml b/src/Tools/.cargo/config.toml new file mode 100644 index 00000000..d07fa72e --- /dev/null +++ b/src/Tools/.cargo/config.toml @@ -0,0 +1,2 @@ +[target.x86_64-unknown-linux-musl] +linker = "rust-lld" \ No newline at end of file diff --git a/src/Tools/Tools.code-workspace b/src/Tools/Tools.code-workspace index 9e267f6d..a60b4deb 100644 --- a/src/Tools/Tools.code-workspace +++ b/src/Tools/Tools.code-workspace @@ -19,7 +19,7 @@ { "label": "cargo", "type": "shell", - "command": "./run_cargo ${input:project} ${input:cargo cmd} ${input:build cfg}", + "command": "./run_cargo ${input:project} ${input:cargo cmd} ${input:build cfg} ${input:cargo target}", "group": { "kind": "build", } @@ -45,6 +45,12 @@ "options": ["build", "run", "check", "clean"], "default": "build", "description": "cargo command to run" + }, + { + "id": "cargo target", + "type": "pickString", + "options": ["windows", "linux"], + "description": "The target for the tool to build" } ] } diff --git a/src/Tools/build_all.bat b/src/Tools/build_all.bat index 25e7bd22..44acb4b4 100644 --- a/src/Tools/build_all.bat +++ b/src/Tools/build_all.bat @@ -2,9 +2,11 @@ rem build_all [clean] set bin_projects=psxcdgen psxcdread +set bin_linux_projects=cpp_out set clean_projects=cdtypes set projects=%bin_projects% +set linux_projects=%bin_linux_projects% set build_type=build set cur_dir=%cd% @@ -18,6 +20,11 @@ IF NOT "%~1" == "" ( ) for %%a in (%projects%) do ( - call .\run_cargo %%a %build_type% release + call .\run_cargo %%a %build_type% release windows cd %cur_dir% ) + +for %%a in (%linux_projects%) do ( + call .\run_cargo %%a %build_type% release linux + cd %cur_dir% +) \ No newline at end of file diff --git a/src/Tools/run_cargo.bat b/src/Tools/run_cargo.bat index 9385a870..db50c066 100644 --- a/src/Tools/run_cargo.bat +++ b/src/Tools/run_cargo.bat @@ -1,14 +1,22 @@ @echo off -rem run_cargo.bat project build|check|clean debug|release +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 - cargo build --%3 + call:build_rust %1 %2 %3 %4 IF %ERRORLEVEL% == 0 ( - xcopy target\%3\%1.exe %org_dir%\..\..\bin /y + xcopy target\%cfg%\%3\%1%bin_ext% %org_dir%\..\..\bin /y ) exit /B %ERRORLEVEL% @@ -16,14 +24,21 @@ IF %2 == build ( IF %2 == run ( echo cargo run %1 --%3 - cargo run --%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 + cargo check --%3 %target% exit /B %ERRORLEVEL% ) @@ -31,9 +46,14 @@ IF %2 == check ( IF %2 == clean ( echo cargo clean %1 cargo clean - @del %org_dir%\..\..\bin\%1.exe + @del %org_dir%\..\..\bin\%1%bin_ext% exit /B %ERRORLEVEL% ) -echo "Unkown cargo command "%2" for project "%1" \ No newline at end of file +echo "Unkown cargo command "%2" for project "%1" +GOTO:eof + +:build_rust +cargo build --%3 %target% +GOTO:eof \ No newline at end of file