Skip to content

Commit cfc919f

Browse files
committed
Use cargo in y.sh
This will allow adding dependencies to the build system in the future.
1 parent 2df34f9 commit cfc919f

File tree

6 files changed

+11
-18
lines changed

6 files changed

+11
-18
lines changed

Diff for: .gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
# Build artifacts during normal use
2-
/y.bin
3-
/y.bin.dSYM
4-
/y.exe
5-
/y.pdb
62
/download
73
/build
84
/dist

Diff for: build_system/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ path = "main.rs"
1111
unstable-features = [] # for rust-analyzer
1212

1313
# Do not add any dependencies
14+
15+
[profile.dev]
16+
debug = 1

Diff for: build_system/main.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,11 @@ fn main() {
147147

148148
let rustup_toolchain_name = match (env::var("CARGO"), env::var("RUSTC"), env::var("RUSTDOC")) {
149149
(Ok(_), Ok(_), Ok(_)) => None,
150-
(Err(_), Err(_), Err(_)) => Some(rustc_info::get_toolchain_name()),
151-
_ => {
152-
eprintln!("All of CARGO, RUSTC and RUSTDOC need to be set or none must be set");
150+
(_, Err(_), Err(_)) => Some(rustc_info::get_toolchain_name()),
151+
vars => {
152+
eprintln!(
153+
"If RUSTC or RUSTDOC is set, both need to be set and in addition CARGO needs to be set: {vars:?}"
154+
);
153155
process::exit(1);
154156
}
155157
};

Diff for: y.cmd

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
@echo off
22
echo [BUILD] build system >&2
3-
mkdir build 2>nul
4-
rustc build_system/main.rs -o build\y.exe -Cdebuginfo=1 --edition 2021 || goto :error
5-
build\y.exe %* || goto :error
3+
cargo run --manifest-path build_system/Cargo.toml -- %* || goto :error
64
goto :EOF
75

86
:error

Diff for: y.ps1

100644100755
+1-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
$ErrorActionPreference = "Stop"
22

33
$host.ui.WriteErrorLine("[BUILD] build system")
4-
New-Item -ItemType Directory -Force -Path build | Out-Null
5-
& rustc build_system/main.rs -o build\y.exe -Cdebuginfo=1 --edition 2021
6-
if ($LASTEXITCODE -ne 0) {
7-
exit $LASTEXITCODE
8-
}
9-
& build\y.exe $args
4+
& cargo run --manifest-path build_system/Cargo.toml -- $args
105
if ($LASTEXITCODE -ne 0) {
116
exit $LASTEXITCODE
127
}

Diff for: y.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22

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

0 commit comments

Comments
 (0)