@@ -453,63 +453,72 @@ build_cmdstan <- function(dir,
453453 } else {
454454 run_cmd <- make_cmd()
455455 }
456- withr :: with_path(
457- c(
458- toolchain_PATH_env_var(),
459- tbb_path(dir = dir )
460- ),
461- wsl_compatible_run(
462- command = run_cmd ,
463- args = c(translation_args , paste0(" -j" , cores ), " build" ),
464- wd = dir ,
465- echo_cmd = is_verbose_mode(),
466- echo = ! quiet || is_verbose_mode(),
467- spinner = quiet ,
468- error_on_status = FALSE ,
469- stderr_callback = function (x , p ) { if (quiet ) message(x ) },
470- timeout = timeout
456+ withr :: with_envvar(
457+ c(" HOME" = short_path(Sys.getenv(" HOME" ))),
458+ withr :: with_path(
459+ c(
460+ toolchain_PATH_env_var(),
461+ tbb_path(dir = dir )
462+ ),
463+ wsl_compatible_run(
464+ command = run_cmd ,
465+ args = c(translation_args , paste0(" -j" , cores ), " build" ),
466+ wd = dir ,
467+ echo_cmd = is_verbose_mode(),
468+ echo = ! quiet || is_verbose_mode(),
469+ spinner = quiet ,
470+ error_on_status = FALSE ,
471+ stderr_callback = function (x , p ) { if (quiet ) message(x ) },
472+ timeout = timeout
473+ )
471474 )
472475 )
473476}
474477
475478clean_cmdstan <- function (dir = cmdstan_path(),
476479 cores = getOption(" mc.cores" , 2 ),
477480 quiet = FALSE ) {
478- withr :: with_path(
479- c(
480- toolchain_PATH_env_var(),
481- tbb_path(dir = dir )
482- ),
483- wsl_compatible_run(
484- command = make_cmd(),
485- args = " clean-all" ,
486- wd = dir ,
487- echo_cmd = is_verbose_mode(),
488- echo = ! quiet || is_verbose_mode(),
489- spinner = quiet ,
490- error_on_status = FALSE ,
491- stderr_callback = function (x , p ) { if (quiet ) message(x ) }
481+ withr :: with_envvar(
482+ c(" HOME" = short_path(Sys.getenv(" HOME" ))),
483+ withr :: with_path(
484+ c(
485+ toolchain_PATH_env_var(),
486+ tbb_path(dir = dir )
487+ ),
488+ wsl_compatible_run(
489+ command = make_cmd(),
490+ args = " clean-all" ,
491+ wd = dir ,
492+ echo_cmd = is_verbose_mode(),
493+ echo = ! quiet || is_verbose_mode(),
494+ spinner = quiet ,
495+ error_on_status = FALSE ,
496+ stderr_callback = function (x , p ) { if (quiet ) message(x ) }
497+ )
492498 )
493499 )
494500}
495501
496502build_example <- function (dir , cores , quiet , timeout ) {
497- withr :: with_path(
498- c(
499- toolchain_PATH_env_var(),
500- tbb_path(dir = dir )
501- ),
502- wsl_compatible_run(
503- command = make_cmd(),
504- args = c(paste0(" -j" , cores ),
505- cmdstan_ext(file.path(" examples" , " bernoulli" , " bernoulli" ))),
506- wd = dir ,
507- echo_cmd = is_verbose_mode(),
508- echo = ! quiet || is_verbose_mode(),
509- spinner = quiet ,
510- error_on_status = FALSE ,
511- stderr_callback = function (x , p ) { if (quiet ) message(x ) },
512- timeout = timeout
503+ withr :: with_envvar(
504+ c(" HOME" = short_path(Sys.getenv(" HOME" ))),
505+ withr :: with_path(
506+ c(
507+ toolchain_PATH_env_var(),
508+ tbb_path(dir = dir )
509+ ),
510+ wsl_compatible_run(
511+ command = make_cmd(),
512+ args = c(paste0(" -j" , cores ),
513+ cmdstan_ext(file.path(" examples" , " bernoulli" , " bernoulli" ))),
514+ wd = dir ,
515+ echo_cmd = is_verbose_mode(),
516+ echo = ! quiet || is_verbose_mode(),
517+ spinner = quiet ,
518+ error_on_status = FALSE ,
519+ stderr_callback = function (x , p ) { if (quiet ) message(x ) },
520+ timeout = timeout
521+ )
513522 )
514523 )
515524}
@@ -849,7 +858,11 @@ toolchain_PATH_env_var <- function() {
849858rtools4x_toolchain_path <- function () {
850859 toolchain <- ifelse(is_ucrt_toolchain(), " ucrt64" , " mingw64" )
851860 if (Sys.getenv(" CMDSTANR_USE_RTOOLS" ) != " " ) {
852- toolchain <- " x86_64-w64-mingw32.static.posix"
861+ if (arch_is_aarch64()) {
862+ toolchain <- " aarch64-w64-mingw32.static.posix"
863+ } else {
864+ toolchain <- " x86_64-w64-mingw32.static.posix"
865+ }
853866 }
854867 repair_path(file.path(rtools4x_home_path(), toolchain , " bin" ))
855868}
@@ -871,10 +884,16 @@ rtools4x_version <- function() {
871884
872885rtools4x_home_path <- function () {
873886 rtools_ver <- rtools4x_version()
887+ if (arch_is_aarch64()) {
888+ rtools_ver <- paste0(rtools_ver , " _AARCH64" )
889+ }
874890 path <- Sys.getenv(paste0(" RTOOLS" , rtools_ver , " _HOME" ))
875891
876892 if (! nzchar(path )) {
877893 default_path <- repair_path(file.path(paste0(" C:/rtools" , rtools_ver )))
894+ if (arch_is_aarch64()) {
895+ default_path <- paste0(default_path , " -aarch64" )
896+ }
878897 if (dir.exists(default_path )) {
879898 path <- default_path
880899 }
0 commit comments