Skip to content

Commit 28d86a3

Browse files
committed
Update rustup_wrapper
[skip ci]
1 parent c6c1a17 commit 28d86a3

File tree

5 files changed

+44
-43
lines changed

5 files changed

+44
-43
lines changed

.gitattributes

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212

1313
# Denote all files that are truly binary and should not be modified.
1414
tools/** binary
15+
tools/rustup_wrapper/** -binary
1516
*.jar binary
1617
*.exe binary
1718
*.apk binary
1819
*.png binary
1920
*.jpg binary
2021
*.ttf binary
21-
22-
# Help GitHub detect languages
23-
native/jni/external/** linguist-vendored
24-
native/jni/systemproperties/** linguist-language=C++

build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ def setup_rustup():
553553
cargo_bin = cargo_home / "bin"
554554
for src in cargo_bin.iterdir():
555555
tgt = wrapper_dir / src.name
556-
tgt.symlink_to(src)
556+
tgt.symlink_to(f"rustup{EXE_EXT}")
557557

558558
# Build rustup_wrapper
559559
wrapper_src = Path("tools", "rustup_wrapper")

tools/rustup_wrapper/Cargo.lock

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/rustup_wrapper/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ name = "rustup_wrapper"
33
version = "0.0.0"
44
edition = "2021"
55

6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7-
86
[dependencies]
97
home = "0.5"
8+
9+
[profile.release]
10+
strip = true
11+
lto = true
12+
codegen-units = 1

tools/rustup_wrapper/src/main.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::env;
2+
use std::path::Path;
23
use std::process::{Command, Stdio};
34

45
use home::cargo_home;
@@ -10,34 +11,34 @@ use home::cargo_home;
1011
* The command `rustup component list` does not work with custom toolchains:
1112
* > error: toolchain 'magisk' does not support components
1213
*
13-
* However, this command is used by several IDEs to determine available
14-
* components that can be used, such as clippy, rustfmt etc.
15-
* In this script, we simply redirect the output when using the nightly
14+
* However, this command is used by several IDEs to determine component
15+
* availability, such as clippy, rustfmt etc.
16+
* In this program, we use the output of the command with the nightly
1617
* channel if any `component` command failed.
1718
*/
1819

1920
fn main() -> std::io::Result<()> {
20-
let rustup = cargo_home()?.join("bin").join("rustup");
21+
let exe = env::args().next().unwrap();
22+
let exe = Path::new(&exe).file_name().unwrap().to_str().unwrap();
23+
let real_exe = cargo_home()?.join("bin").join(exe);
2124
let argv: Vec<String> = env::args().skip(1).collect();
2225

23-
if argv.iter().any(|s| s == "component") {
24-
let status = Command::new(&rustup)
26+
if exe.starts_with("rustup") && argv.iter().any(|s| s == "component") {
27+
let status = Command::new(&real_exe)
2528
.args(&argv)
2629
.stdout(Stdio::null())
2730
.stderr(Stdio::null())
2831
.status()?;
2932
if !status.success() {
30-
let mut cmd = Command::new(&rustup);
33+
let mut cmd = Command::new(&real_exe);
34+
// Hardcode to use the nightly channel
3135
cmd.arg("+nightly");
32-
if argv[0].starts_with('+') {
33-
cmd.args(argv.iter().skip(1));
34-
} else {
35-
cmd.args(&argv);
36-
}
36+
// Remove any explicit channel specification
37+
cmd.args(argv.iter().filter(|s| !s.starts_with('+')));
3738
return cmd.status().map(|_| ());
3839
}
3940
}
4041

4142
// Simply pass through
42-
Command::new(&rustup).args(argv.iter()).status().map(|_| ())
43+
Command::new(&real_exe).args(argv.iter()).status().map(|_| ())
4344
}

0 commit comments

Comments
 (0)