diff --git a/.gitattributes b/.gitattributes index 852441530..7f18b085d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12,13 +12,10 @@ # Denote all files that are truly binary and should not be modified. tools/** binary +tools/rustup_wrapper/** -binary *.jar binary *.exe binary *.apk binary *.png binary *.jpg binary *.ttf binary - -# Help GitHub detect languages -native/jni/external/** linguist-vendored -native/jni/systemproperties/** linguist-language=C++ diff --git a/build.py b/build.py index 090d32dc7..ee1e2d3bc 100755 --- a/build.py +++ b/build.py @@ -553,7 +553,7 @@ def setup_rustup(): cargo_bin = cargo_home / "bin" for src in cargo_bin.iterdir(): tgt = wrapper_dir / src.name - tgt.symlink_to(src) + tgt.symlink_to(f"rustup{EXE_EXT}") # Build rustup_wrapper wrapper_src = Path("tools", "rustup_wrapper") diff --git a/tools/rustup_wrapper/Cargo.lock b/tools/rustup_wrapper/Cargo.lock index 98169f355..6943e2377 100644 --- a/tools/rustup_wrapper/Cargo.lock +++ b/tools/rustup_wrapper/Cargo.lock @@ -1,12 +1,12 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "home" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" dependencies = [ "windows-sys", ] @@ -20,18 +20,18 @@ dependencies = [ [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -45,48 +45,48 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/tools/rustup_wrapper/Cargo.toml b/tools/rustup_wrapper/Cargo.toml index b8f5e6045..b52684d81 100644 --- a/tools/rustup_wrapper/Cargo.toml +++ b/tools/rustup_wrapper/Cargo.toml @@ -3,7 +3,10 @@ name = "rustup_wrapper" version = "0.0.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] home = "0.5" + +[profile.release] +strip = true +lto = true +codegen-units = 1 diff --git a/tools/rustup_wrapper/src/main.rs b/tools/rustup_wrapper/src/main.rs index 6cd9ec49e..38317baee 100644 --- a/tools/rustup_wrapper/src/main.rs +++ b/tools/rustup_wrapper/src/main.rs @@ -1,4 +1,5 @@ use std::env; +use std::path::Path; use std::process::{Command, Stdio}; use home::cargo_home; @@ -10,34 +11,34 @@ use home::cargo_home; * The command `rustup component list` does not work with custom toolchains: * > error: toolchain 'magisk' does not support components * - * However, this command is used by several IDEs to determine available - * components that can be used, such as clippy, rustfmt etc. - * In this script, we simply redirect the output when using the nightly + * However, this command is used by several IDEs to determine component + * availability, such as clippy, rustfmt etc. + * In this program, we use the output of the command with the nightly * channel if any `component` command failed. */ fn main() -> std::io::Result<()> { - let rustup = cargo_home()?.join("bin").join("rustup"); + let exe = env::args().next().unwrap(); + let exe = Path::new(&exe).file_name().unwrap().to_str().unwrap(); + let real_exe = cargo_home()?.join("bin").join(exe); let argv: Vec = env::args().skip(1).collect(); - if argv.iter().any(|s| s == "component") { - let status = Command::new(&rustup) + if exe.starts_with("rustup") && argv.iter().any(|s| s == "component") { + let status = Command::new(&real_exe) .args(&argv) .stdout(Stdio::null()) .stderr(Stdio::null()) .status()?; if !status.success() { - let mut cmd = Command::new(&rustup); + let mut cmd = Command::new(&real_exe); + // Hardcode to use the nightly channel cmd.arg("+nightly"); - if argv[0].starts_with('+') { - cmd.args(argv.iter().skip(1)); - } else { - cmd.args(&argv); - } + // Remove any explicit channel specification + cmd.args(argv.iter().filter(|s| !s.starts_with('+'))); return cmd.status().map(|_| ()); } } // Simply pass through - Command::new(&rustup).args(argv.iter()).status().map(|_| ()) + Command::new(&real_exe).args(argv.iter()).status().map(|_| ()) }