@@ -84,11 +84,11 @@ cpp_source <- function(file, code = NULL, env = parent.frame(), clean = TRUE, qu
8484 stop(" `file` must have a `.cpp` or `.cc` extension" )
8585 }
8686
87- new_file <- generate_cpp_name (file )
88- package <- tools :: file_path_sans_ext(new_file )
87+ name <- basename (file )
88+ package <- tools :: file_path_sans_ext(generate_cpp_name( file ) )
8989
90- file.copy(file , file.path(dir , " src" , new_file ))
91- file <- file.path(dir , " src" , new_file )
90+ file.copy(file , file.path(dir , " src" , name ))
91+ file <- file.path(dir , " src" , name )
9292
9393 suppressWarnings(
9494 all_decorations <- decor :: cpp_decorations(dir , is_attribute = TRUE )
@@ -122,13 +122,14 @@ cpp_source <- function(file, code = NULL, env = parent.frame(), clean = TRUE, qu
122122 stop(" Compilation failed." , call. = FALSE )
123123 }
124124
125- shared_lib <- file.path(dir , " src" , paste0(tools :: file_path_sans_ext(basename(file )), .Platform $ dynlib.ext ))
126-
125+ slib1 <- file.path(dir , " src" , paste0(tools :: file_path_sans_ext(name ), .Platform $ dynlib.ext ))
126+ slib2 <- file.path(dir , " src" , paste0(package , .Platform $ dynlib.ext ))
127+ file.rename(slib1 , slib2 )
127128 r_path <- file.path(dir , " R" , " cpp11.R" )
128129 brio :: write_lines(r_functions , r_path )
129130 source(r_path , local = env )
130131
131- dyn.load(shared_lib , local = TRUE , now = TRUE )
132+ dyn.load(slib2 , local = TRUE , now = TRUE )
132133}
133134
134135the <- new.env(parent = emptyenv())
0 commit comments