Skip to content

Commit f1ba94d

Browse files
aero.py: build minimal sysroot instead of fetching the bad prebuilt one
Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
1 parent ba7886c commit f1ba94d

File tree

1 file changed

+18
-44
lines changed

1 file changed

+18
-44
lines changed

aero.py

+18-44
Original file line numberDiff line numberDiff line change
@@ -89,46 +89,8 @@ def __init__(self, target_arch: str, args: argparse.Namespace):
8989
self.args = args
9090

9191

92-
def download_userland_host_rust():
93-
out_file = os.path.join(BUNDLED_DIR, "host-rust-prebuilt.tar.gz")
94-
95-
# we have already cloned the toolchain
96-
if os.path.exists(out_file):
97-
return
98-
99-
log_info("downloading prebuilt userland host rust toolchain")
100-
101-
cmd = r"""
102-
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=FILE_HASH" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILE_HASH" -O OUTPUT_FILE && rm -rf /tmp/cookies.txt
103-
""".replace("FILE_HASH", "1TTC9qa1z-KdLaQkhgMCYxLE5nuKg4gcx").replace("OUTPUT_FILE", out_file)
104-
105-
subprocess.run(cmd, shell=True)
106-
107-
log_info("extracting prebuilt userland host rust toolchain")
108-
109-
# the toolchain is compressed, so we need to extract it
110-
file = tarfile.open(out_file)
111-
file.extractall(os.path.join(BUNDLED_DIR, "host-rust-prebuilt"))
112-
file.close()
113-
114-
115-
def get_userland_tool():
116-
toolchain = os.path.join(SYSROOT_DIR, "tools")
117-
118-
if os.path.exists(toolchain):
119-
return toolchain
120-
121-
return os.path.join(BUNDLED_DIR, "host-rust-prebuilt/aero")
122-
123-
124-
def get_userland_package():
125-
toolchain = os.path.join(SYSROOT_DIR, "packages")
126-
127-
if os.path.exists(toolchain):
128-
return toolchain
129-
130-
return os.path.join(BUNDLED_DIR, "host-rust-prebuilt/aero")
131-
92+
def get_userland_tool(): return os.path.join(SYSROOT_DIR, "tools")
93+
def get_userland_package(): return os.path.join(SYSROOT_DIR, "packages")
13294

13395
def remove_prefix(string: str, prefix: str):
13496
if string.startswith(prefix):
@@ -240,7 +202,8 @@ def download_bundled():
240202
'--depth', '1', LIMINE_URL, limine_path])
241203

242204
if not os.path.exists(SYSROOT_DIR):
243-
download_userland_host_rust()
205+
log_info("building minimal sysroot")
206+
build_userland_sysroot(True)
244207

245208

246209
def extract_artifacts(stdout):
@@ -300,7 +263,7 @@ def symlink_rel(src, dst):
300263
os.symlink(rel_path_src, dst)
301264

302265

303-
def build_userland_sysroot(args):
266+
def build_userland_sysroot(minimal):
304267
if not os.path.exists(SYSROOT_DIR):
305268
os.mkdir(SYSROOT_DIR)
306269

@@ -330,10 +293,21 @@ def build_userland_sysroot(args):
330293
# symlink the bootstrap.yml file in the src root to sysroot/bootstrap.link
331294
symlink_rel('bootstrap.yml', blink)
332295

333-
run_command(['xbstrap', 'install', '-u', '--all'], cwd=SYSROOT_DIR)
296+
if minimal:
297+
run_command(['xbstrap', 'install', '-u', 'bash', 'coreutils'], cwd=SYSROOT_DIR)
298+
else:
299+
run_command(['xbstrap', 'install', '-u', '--all'], cwd=SYSROOT_DIR)
334300

335301

336302
def build_userland(args):
303+
# We need to check if we have host-cargo in-order for us to build
304+
# our rust userland applications in `userland/`.
305+
host_cargo = os.path.join(SYSROOT_DIR, "tools/host-cargo")
306+
307+
if not os.path.exists(host_cargo):
308+
log_error("host-cargo not built as a part of the sysroot, skipping compilation of `userland/`")
309+
return
310+
337311
HOST_CARGO = "host-cargo/bin/cargo"
338312
HOST_RUST = "host-rust/bin/rustc"
339313
HOST_GCC = "host-gcc/bin/x86_64-aero-gcc"
@@ -635,7 +609,7 @@ def main():
635609
if os.path.exists(userland_target):
636610
shutil.rmtree(userland_target)
637611
elif args.sysroot:
638-
build_userland_sysroot(args)
612+
build_userland_sysroot(False)
639613
elif args.document:
640614
build_kernel(args)
641615

0 commit comments

Comments
 (0)