@@ -91,11 +91,14 @@ cpp_source <- function(file, code = NULL, env = parent.frame(), clean = TRUE, qu
9191 package <- tools :: file_path_sans_ext(name )
9292 }
9393 else {
94+ # name and package might be different if cpp_source was called multiple times
9495 name <- basename(file )
9596 package <- tools :: file_path_sans_ext(generate_cpp_name(file ))
9697 }
9798
99+ # file not points to another location
98100 file.copy(file , file.path(dir , " src" , name ))
101+ # change variable name to reflect this
99102 file <- file.path(dir , " src" , name )
100103
101104
@@ -131,13 +134,8 @@ cpp_source <- function(file, code = NULL, env = parent.frame(), clean = TRUE, qu
131134 stop(" Compilation failed." , call. = FALSE )
132135 }
133136
134- if (base_cpp ) {
135- shared_lib <- file.path(dir , " src" , paste0(tools :: file_path_sans_ext(basename(file )), .Platform $ dynlib.ext ))
136- }
137- else {
138- shared_lib <- file.path(dir , " src" , paste0(package , .Platform $ dynlib.ext ))
139- }
140137
138+ shared_lib <- file.path(dir , " src" , paste0(tools :: file_path_sans_ext(basename(file )), .Platform $ dynlib.ext ))
141139 r_path <- file.path(dir , " R" , " cpp11.R" )
142140 brio :: write_lines(r_functions , r_path )
143141 source(r_path , local = env )
0 commit comments