Skip to content

Commit 57309f1

Browse files
committed
Don't modify the file name on cpp_source
1 parent c1050db commit 57309f1

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ vignettes/*_cache
1212
compile_commands.json
1313
revdep/*/
1414
talk/
15+
TAGS

R/source.R

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

134135
the <- new.env(parent = emptyenv())

0 commit comments

Comments
 (0)