Skip to content

Commit b8da18c

Browse files
committed
use stage0 file in bootstrap.py
Signed-off-by: onur-ozkan <[email protected]>
1 parent efb153e commit b8da18c

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

src/bootstrap/bootstrap.py

+21-13
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def get(base, url, path, checksums, verbose=False):
5252

5353
try:
5454
if url not in checksums:
55-
raise RuntimeError(("src/stage0.json doesn't contain a checksum for {}. "
55+
raise RuntimeError(("src/stage0 doesn't contain a checksum for {}. "
5656
"Pre-built artifacts might not be available for this "
5757
"target at this time, see https://doc.rust-lang.org/nightly"
5858
"/rustc/platform-support.html for more information.")
@@ -421,9 +421,9 @@ def output(filepath):
421421

422422

423423
class Stage0Toolchain:
424-
def __init__(self, stage0_payload):
425-
self.date = stage0_payload["date"]
426-
self.version = stage0_payload["version"]
424+
def __init__(self, date, version):
425+
self.date = date
426+
self.version = version
427427

428428
def channel(self):
429429
return self.version + "-" + self.date
@@ -439,7 +439,7 @@ def __init__(
439439
bin_root,
440440
tarball_path,
441441
tarball_suffix,
442-
checksums_sha256,
442+
stage0_data,
443443
pattern,
444444
verbose,
445445
):
@@ -448,7 +448,7 @@ def __init__(
448448
self.bin_root = bin_root
449449
self.tarball_path = tarball_path
450450
self.tarball_suffix = tarball_suffix
451-
self.checksums_sha256 = checksums_sha256
451+
self.stage0_data = stage0_data
452452
self.pattern = pattern
453453
self.verbose = verbose
454454

@@ -458,7 +458,7 @@ def download_component(download_info):
458458
download_info.base_download_url,
459459
download_info.download_path,
460460
download_info.tarball_path,
461-
download_info.checksums_sha256,
461+
download_info.stage0_data,
462462
verbose=download_info.verbose,
463463
)
464464

@@ -510,11 +510,9 @@ def __init__(self, config_toml="", args=None):
510510
build_dir = args.build_dir or self.get_toml('build-dir', 'build') or 'build'
511511
self.build_dir = os.path.abspath(build_dir)
512512

513-
with open(os.path.join(self.rust_root, "src", "stage0.json")) as f:
514-
data = json.load(f)
515-
self.checksums_sha256 = data["checksums_sha256"]
516-
self.stage0_compiler = Stage0Toolchain(data["compiler"])
517-
self.download_url = os.getenv("RUSTUP_DIST_SERVER") or data["config"]["dist_server"]
513+
self.stage0_data = parse_stage0_file(os.path.join(self.rust_root, "src", "stage0"))
514+
self.stage0_compiler = Stage0Toolchain(self.stage0_data["compiler_date"], self.stage0_data["compiler_version"])
515+
self.download_url = os.getenv("RUSTUP_DIST_SERVER") or self.stage0_data["dist_server"]
518516

519517
self.build = args.build or self.build_triple()
520518

@@ -581,7 +579,7 @@ def download_toolchain(self):
581579
bin_root=self.bin_root(),
582580
tarball_path=os.path.join(rustc_cache, filename),
583581
tarball_suffix=tarball_suffix,
584-
checksums_sha256=self.checksums_sha256,
582+
stage0_data=self.stage0_data,
585583
pattern=pattern,
586584
verbose=self.verbose,
587585
)
@@ -1071,6 +1069,16 @@ def parse_args(args):
10711069

10721070
return parser.parse_known_args(args)[0]
10731071

1072+
def parse_stage0_file(path):
1073+
result = {}
1074+
with open(path, 'r') as file:
1075+
for line in file:
1076+
line = line.strip()
1077+
if line and not line.startswith('#'):
1078+
key, value = line.split('=', 1)
1079+
result[key.strip()] = value.strip()
1080+
return result
1081+
10741082
def bootstrap(args):
10751083
"""Configure, fetch, build and run the initial bootstrap"""
10761084
rust_root = os.path.abspath(os.path.join(__file__, '../../..'))

0 commit comments

Comments
 (0)