mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-04 15:35:27 +00:00
Switch rustup_wrapper to Rust implementation
For better Windows portability
This commit is contained in:
parent
3f2264f2c7
commit
f61827cbec
14
build.py
14
build.py
@ -638,10 +638,16 @@ def setup_rustup(args):
|
|||||||
for src in cargo_bin.iterdir():
|
for src in cargo_bin.iterdir():
|
||||||
tgt = wrapper_dir / src.name
|
tgt = wrapper_dir / src.name
|
||||||
tgt.symlink_to(src)
|
tgt.symlink_to(src)
|
||||||
# Replace rustup with python script
|
|
||||||
wrapper = wrapper_dir / "rustup"
|
# Build rustup_wrapper
|
||||||
wrapper.unlink()
|
wrapper_src = Path("tools", "rustup_wrapper")
|
||||||
cp(Path("scripts", "rustup_wrapper.py"), wrapper)
|
cargo_toml = wrapper_src / "Cargo.toml"
|
||||||
|
execv([cargo, "build", "--release", f"--manifest-path={cargo_toml}"])
|
||||||
|
|
||||||
|
# Replace rustup with wrapper
|
||||||
|
wrapper = wrapper_dir / (f"rustup{EXE_EXT}")
|
||||||
|
wrapper.unlink(missing_ok=True)
|
||||||
|
cp(wrapper_src / "target" / "release" / (f"rustup_wrapper{EXE_EXT}"), wrapper)
|
||||||
wrapper.chmod(0o755)
|
wrapper.chmod(0o755)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
################################
|
|
||||||
# Why do we need this wrapper?
|
|
||||||
################################
|
|
||||||
#
|
|
||||||
# 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
|
|
||||||
# channel if any `component` command failed.
|
|
||||||
|
|
||||||
if "CARGO_HOME" in os.environ:
|
|
||||||
cargo_home = Path(os.environ["CARGO_HOME"])
|
|
||||||
else:
|
|
||||||
cargo_home = Path.home() / ".cargo"
|
|
||||||
|
|
||||||
rustup = cargo_home / "bin" / "rustup"
|
|
||||||
|
|
||||||
if "component" in sys.argv:
|
|
||||||
proc = subprocess.run(
|
|
||||||
[rustup, *sys.argv[1:]],
|
|
||||||
stdout=subprocess.DEVNULL,
|
|
||||||
stderr=subprocess.DEVNULL,
|
|
||||||
)
|
|
||||||
if proc.returncode != 0:
|
|
||||||
# Remove any channel overrides
|
|
||||||
if sys.argv[1].startswith("+"):
|
|
||||||
sys.argv.pop(1)
|
|
||||||
# Return the nightly channel results
|
|
||||||
sys.exit(subprocess.run([rustup, "+nightly", *sys.argv[1:]]).returncode)
|
|
||||||
|
|
||||||
# Passthrough
|
|
||||||
sys.exit(subprocess.run([rustup, *sys.argv[1:]]).returncode)
|
|
BIN
tools/rustup_wrapper/.gitignore
vendored
Normal file
BIN
tools/rustup_wrapper/.gitignore
vendored
Normal file
Binary file not shown.
BIN
tools/rustup_wrapper/Cargo.lock
generated
Normal file
BIN
tools/rustup_wrapper/Cargo.lock
generated
Normal file
Binary file not shown.
BIN
tools/rustup_wrapper/Cargo.toml
Normal file
BIN
tools/rustup_wrapper/Cargo.toml
Normal file
Binary file not shown.
BIN
tools/rustup_wrapper/src/main.rs
Normal file
BIN
tools/rustup_wrapper/src/main.rs
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user