diff options
| author | onur-ozkan <work@onurozkan.dev> | 2024-05-09 17:26:35 +0300 |
|---|---|---|
| committer | onur-ozkan <work@onurozkan.dev> | 2024-05-09 17:51:12 +0300 |
| commit | f2d50b6d36f6c1a2b00c7dc6dcbcbc422957c443 (patch) | |
| tree | 0ab4e26d2455069e841bdcc6265ca3858a466033 /src/bootstrap/bootstrap.py | |
| parent | efb153eb5a85499e71c424af9261e4b339c83c5e (diff) | |
| download | rust-f2d50b6d36f6c1a2b00c7dc6dcbcbc422957c443.tar.gz rust-f2d50b6d36f6c1a2b00c7dc6dcbcbc422957c443.zip | |
use stage0 file in `bootstrap.py`
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Diffstat (limited to 'src/bootstrap/bootstrap.py')
| -rw-r--r-- | src/bootstrap/bootstrap.py | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index e464e444fea..e60e8f0aa1f 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -3,7 +3,6 @@ import argparse import contextlib import datetime import hashlib -import json import os import re import shutil @@ -52,7 +51,7 @@ def get(base, url, path, checksums, verbose=False): try: if url not in checksums: - raise RuntimeError(("src/stage0.json doesn't contain a checksum for {}. " + raise RuntimeError(("src/stage0 doesn't contain a checksum for {}. " "Pre-built artifacts might not be available for this " "target at this time, see https://doc.rust-lang.org/nightly" "/rustc/platform-support.html for more information.") @@ -421,9 +420,9 @@ def output(filepath): class Stage0Toolchain: - def __init__(self, stage0_payload): - self.date = stage0_payload["date"] - self.version = stage0_payload["version"] + def __init__(self, date, version): + self.date = date + self.version = version def channel(self): return self.version + "-" + self.date @@ -439,7 +438,7 @@ class DownloadInfo: bin_root, tarball_path, tarball_suffix, - checksums_sha256, + stage0_data, pattern, verbose, ): @@ -448,7 +447,7 @@ class DownloadInfo: self.bin_root = bin_root self.tarball_path = tarball_path self.tarball_suffix = tarball_suffix - self.checksums_sha256 = checksums_sha256 + self.stage0_data = stage0_data self.pattern = pattern self.verbose = verbose @@ -458,7 +457,7 @@ def download_component(download_info): download_info.base_download_url, download_info.download_path, download_info.tarball_path, - download_info.checksums_sha256, + download_info.stage0_data, verbose=download_info.verbose, ) @@ -510,11 +509,12 @@ class RustBuild(object): build_dir = args.build_dir or self.get_toml('build-dir', 'build') or 'build' self.build_dir = os.path.abspath(build_dir) - with open(os.path.join(self.rust_root, "src", "stage0.json")) as f: - data = json.load(f) - self.checksums_sha256 = data["checksums_sha256"] - self.stage0_compiler = Stage0Toolchain(data["compiler"]) - self.download_url = os.getenv("RUSTUP_DIST_SERVER") or data["config"]["dist_server"] + self.stage0_data = parse_stage0_file(os.path.join(self.rust_root, "src", "stage0")) + self.stage0_compiler = Stage0Toolchain( + self.stage0_data["compiler_date"], + self.stage0_data["compiler_version"] + ) + self.download_url = os.getenv("RUSTUP_DIST_SERVER") or self.stage0_data["dist_server"] self.build = args.build or self.build_triple() @@ -581,7 +581,7 @@ class RustBuild(object): bin_root=self.bin_root(), tarball_path=os.path.join(rustc_cache, filename), tarball_suffix=tarball_suffix, - checksums_sha256=self.checksums_sha256, + stage0_data=self.stage0_data, pattern=pattern, verbose=self.verbose, ) @@ -1071,6 +1071,16 @@ def parse_args(args): return parser.parse_known_args(args)[0] +def parse_stage0_file(path): + result = {} + with open(path, 'r') as file: + for line in file: + line = line.strip() + if line and not line.startswith('#'): + key, value = line.split('=', 1) + result[key.strip()] = value.strip() + return result + def bootstrap(args): """Configure, fetch, build and run the initial bootstrap""" rust_root = os.path.abspath(os.path.join(__file__, '../../..')) |
