@@ -1353,6 +1353,8 @@ class RustCompiledComponentsRecipe(PyProjectRecipe):
1353
1353
"x86_64" : "x86_64-linux-android" ,
1354
1354
"x86" : "i686-linux-android" ,
1355
1355
}
1356
+ # Rust toolchain to be used for building
1357
+ toolchain = "stable"
1356
1358
1357
1359
call_hostpython_via_targetpython = False
1358
1360
@@ -1365,6 +1367,7 @@ def get_recipe_env(self, arch, **kwargs):
1365
1367
build_target .upper ().replace ("-" , "_" )
1366
1368
)
1367
1369
env ["CARGO_BUILD_TARGET" ] = build_target
1370
+ env ["TARGET" ] = build_target
1368
1371
env [cargo_linker_name ] = join (
1369
1372
self .ctx .ndk .llvm_prebuilt_dir ,
1370
1373
"bin" ,
@@ -1386,10 +1389,6 @@ def get_recipe_env(self, arch, **kwargs):
1386
1389
realpython_dir , "android-build" , "build" ,
1387
1390
"lib.linux-*-{}/" .format (self .python_major_minor_version ),
1388
1391
))[0 ])
1389
-
1390
- info_main ("Ensuring rust build toolchain" )
1391
- shprint (sh .rustup , "target" , "add" , build_target )
1392
-
1393
1392
# Add host python to PATH
1394
1393
env ["PATH" ] = ("{hostpython_dir}:{old_path}" ).format (
1395
1394
hostpython_dir = Recipe .get_recipe (
@@ -1399,17 +1398,24 @@ def get_recipe_env(self, arch, **kwargs):
1399
1398
)
1400
1399
return env
1401
1400
1401
+ def ensure_rust_toolchain (self , arch ):
1402
+ info_main ("Ensuring rust build toolchain : {}" .format (self .toolchain ))
1403
+ shprint (sh .rustup , "toolchain" , "install" , self .toolchain )
1404
+ shprint (sh .rustup , "target" , "add" , "--toolchain" , self .toolchain , self .RUST_ARCH_CODES [arch .arch ])
1405
+ shprint (sh .rustup , "default" , self .toolchain )
1406
+
1402
1407
def check_host_deps (self ):
1403
1408
if not hasattr (sh , "rustup" ):
1404
1409
error (
1405
- "`rustup` was not found on host system."
1410
+ "\n `rustup` was not found on host system."
1406
1411
"Please install it using :"
1407
1412
"\n `curl https://sh.rustup.rs -sSf | sh`\n "
1408
1413
)
1409
1414
exit (1 )
1410
1415
1411
1416
def build_arch (self , arch ):
1412
1417
self .check_host_deps ()
1418
+ self .ensure_rust_toolchain (arch )
1413
1419
super ().build_arch (arch )
1414
1420
1415
1421
0 commit comments