@@ -89,46 +89,8 @@ def __init__(self, target_arch: str, args: argparse.Namespace):
89
89
self .args = args
90
90
91
91
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" )
132
94
133
95
def remove_prefix (string : str , prefix : str ):
134
96
if string .startswith (prefix ):
@@ -240,7 +202,8 @@ def download_bundled():
240
202
'--depth' , '1' , LIMINE_URL , limine_path ])
241
203
242
204
if not os .path .exists (SYSROOT_DIR ):
243
- download_userland_host_rust ()
205
+ log_info ("building minimal sysroot" )
206
+ build_userland_sysroot (True )
244
207
245
208
246
209
def extract_artifacts (stdout ):
@@ -300,7 +263,7 @@ def symlink_rel(src, dst):
300
263
os .symlink (rel_path_src , dst )
301
264
302
265
303
- def build_userland_sysroot (args ):
266
+ def build_userland_sysroot (minimal ):
304
267
if not os .path .exists (SYSROOT_DIR ):
305
268
os .mkdir (SYSROOT_DIR )
306
269
@@ -330,10 +293,21 @@ def build_userland_sysroot(args):
330
293
# symlink the bootstrap.yml file in the src root to sysroot/bootstrap.link
331
294
symlink_rel ('bootstrap.yml' , blink )
332
295
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 )
334
300
335
301
336
302
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
+
337
311
HOST_CARGO = "host-cargo/bin/cargo"
338
312
HOST_RUST = "host-rust/bin/rustc"
339
313
HOST_GCC = "host-gcc/bin/x86_64-aero-gcc"
@@ -635,7 +609,7 @@ def main():
635
609
if os .path .exists (userland_target ):
636
610
shutil .rmtree (userland_target )
637
611
elif args .sysroot :
638
- build_userland_sysroot (args )
612
+ build_userland_sysroot (False )
639
613
elif args .document :
640
614
build_kernel (args )
641
615
0 commit comments