Use cargo in y.sh

This will allow adding dependencies to the build system in the future.
This commit is contained in:
bjorn3 2024-05-12 12:47:09 +00:00
parent 2df34f9091
commit cfc919f532
6 changed files with 11 additions and 18 deletions

4
.gitignore vendored
View file

@ -1,8 +1,4 @@
# Build artifacts during normal use
/y.bin
/y.bin.dSYM
/y.exe
/y.pdb
/download
/build
/dist

View file

@ -11,3 +11,6 @@ path = "main.rs"
unstable-features = [] # for rust-analyzer
# Do not add any dependencies
[profile.dev]
debug = 1

View file

@ -147,9 +147,11 @@ fn main() {
let rustup_toolchain_name = match (env::var("CARGO"), env::var("RUSTC"), env::var("RUSTDOC")) {
(Ok(_), Ok(_), Ok(_)) => None,
(Err(_), Err(_), Err(_)) => Some(rustc_info::get_toolchain_name()),
_ => {
eprintln!("All of CARGO, RUSTC and RUSTDOC need to be set or none must be set");
(_, Err(_), Err(_)) => Some(rustc_info::get_toolchain_name()),
vars => {
eprintln!(
"If RUSTC or RUSTDOC is set, both need to be set and in addition CARGO needs to be set: {vars:?}"
);
process::exit(1);
}
};

4
y.cmd
View file

@ -1,8 +1,6 @@
@echo off
echo [BUILD] build system >&2
mkdir build 2>nul
rustc build_system/main.rs -o build\y.exe -Cdebuginfo=1 --edition 2021 || goto :error
build\y.exe %* || goto :error
cargo run --manifest-path build_system/Cargo.toml -- %* || goto :error
goto :EOF
:error

7
y.ps1 Normal file → Executable file
View file

@ -1,12 +1,7 @@
$ErrorActionPreference = "Stop"
$host.ui.WriteErrorLine("[BUILD] build system")
New-Item -ItemType Directory -Force -Path build | Out-Null
& rustc build_system/main.rs -o build\y.exe -Cdebuginfo=1 --edition 2021
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
& build\y.exe $args
& cargo run --manifest-path build_system/Cargo.toml -- $args
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}

3
y.sh
View file

@ -2,5 +2,4 @@
set -e
echo "[BUILD] build system" 1>&2
rustc build_system/main.rs -o y.bin -Cdebuginfo=1 --edition 2021
exec ./y.bin "$@"
exec cargo run --manifest-path build_system/Cargo.toml -- "$@"