[Rust] Tweak rustc/rustup installation in CI
#!/usr/local/bin/python3
+import os
+import stat
import shutil
import argparse
from pathlib import Path
@@ -41,32 +43,32 @@ def clone_git_repo(directory: Path, url: str) -> Path:
return repo_path
-def setup_rust_toolchain():
- # Build libc (C stdlib / axle syscall FFI bindings to Rust)
- with TemporaryDirectory() as temp_dir_raw:
- temp_dir = Path(temp_dir_raw)
-
+def _install_rustc(temp_dir: Path) -> None:
# Install Rust nightly via rustup
rustup_install_script = temp_dir / 'rustup.sh'
run_and_check(
[
"curl",
- "--proto",
- "'=https'",
- "--tlsv1.2",
- "-sSf",
"https://sh.rustup.rs",
"-o",
rustup_install_script.as_posix()
]
)
- run_and_check([rustup_install_script.as_posix()])
+ # Mark the rustup installation script as executable
+ st = os.stat(rustup_install_script.as_posix())
+ os.chmod(rustup_install_script.as_posix(), st.st_mode | stat.S_IEXEC)
+ # Run the install script with -y to skip prompts
+ run_and_check([rustup_install_script.as_posix(), "-y"])
+
+ # Install our toolchail and required components
run_and_check(["rustup", "install", "nightly-2021-12-05"])
run_and_check(["rustup", "default", "nightly-2021-12-05"])
run_and_check(["rustup", "component", "add", "rust-src"])
run_and_check(["rustup", "component", "add", "clippy-preview"])
run_and_check(["rustup", "component", "add", "rustfmt"])
+
+def _build_rust_libc_port(temp_dir: Path) -> None:
libc_dir = temp_dir / "libc"
clone_git_repo(temp_dir, 'https://github.com/rust-lang/libc')
@@ -104,6 +106,14 @@ def setup_rust_toolchain():
shutil.copy(file.as_posix(), rust_target_dir.as_posix())
+def setup_rust_toolchain() -> None:
+ # Build libc (C stdlib / axle syscall FFI bindings to Rust)
+ with TemporaryDirectory() as temp_dir_raw:
+ temp_dir = Path(temp_dir_raw)
+ _install_rustc(temp_dir)
+ _build_rust_libc_port(temp_dir)
+
+
def test_rust_programs() -> None:
programs_with_tests = [
"libfs",
