Skip to content

Commit efd2958

Browse files
authored
Merge 447f5f7 into 48a2b3e
2 parents 48a2b3e + 447f5f7 commit efd2958

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

R/model.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,8 @@ compile <- function(quiet = TRUE,
634634
}
635635
stancflags_standalone <- c("--standalone-functions", stancflags_val, stancflags_combined)
636636
self$functions$hpp_code <- get_standalone_hpp(temp_stan_file, stancflags_standalone)
637+
private$model_methods_env_ <- new.env()
638+
private$model_methods_env_$hpp_code_ <- get_standalone_hpp(temp_stan_file, c(stancflags_val, stancflags_combined))
637639
self$functions$external <- !is.null(user_header)
638640
self$functions$existing_exe <- FALSE
639641

@@ -720,10 +722,8 @@ compile <- function(quiet = TRUE,
720722
private$precompile_cpp_options_ <- NULL
721723
private$precompile_stanc_options_ <- NULL
722724
private$precompile_include_paths_ <- NULL
723-
private$model_methods_env_ <- new.env()
724725

725726
if(!dry_run) {
726-
suppressWarnings(private$model_methods_env_$hpp_code_ <- readLines(private$hpp_file_, warn = FALSE))
727727
if (compile_model_methods) {
728728
expose_model_methods(env = private$model_methods_env_,
729729
verbose = !quiet,

R/utils.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -800,23 +800,23 @@ create_skeleton <- function(param_metadata, model_variables,
800800
}
801801

802802
get_standalone_hpp <- function(stan_file, stancflags) {
803+
name <- strip_ext(basename(stan_file))
804+
path <- dirname(stan_file)
805+
hpp_path <- file.path(path, paste0(name, ".hpp"))
806+
803807
status <- withr::with_path(
804808
c(
805809
toolchain_PATH_env_var(),
806810
tbb_path()
807811
),
808812
wsl_compatible_run(
809813
command = stanc_cmd(),
810-
args = c(stan_file,
811-
stancflags),
814+
args = c(paste0("--o=", hpp_path), stancflags, stan_file),
812815
wd = cmdstan_path(),
813816
error_on_status = FALSE
814817
)
815818
)
816819
if (status$status == 0) {
817-
name <- strip_ext(basename(stan_file))
818-
path <- dirname(stan_file)
819-
hpp_path <- file.path(path, paste0(name, ".hpp"))
820820
hpp <- suppressWarnings(readLines(hpp_path, warn = FALSE))
821821
unlink(hpp_path)
822822
hpp

0 commit comments

Comments
 (0)