Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,3 +12,4 @@ vignettes/*_cache
compile_commands.json
revdep/*/
talk/
TAGS
15 changes: 8 additions & 7 deletions R/source.R
Original file line numberDiff line numberDiff line change
Expand Up@@ -84,11 +84,11 @@ cpp_source <- function(file, code = NULL, env = parent.frame(), clean = TRUE, qu
stop("`file` must have a `.cpp` or `.cc` extension")
}

new_file <- generate_cpp_name(file)
package <- tools::file_path_sans_ext(new_file)
name <- basename(file)
package <- tools::file_path_sans_ext(generate_cpp_name(file))

file.copy(file, file.path(dir, "src", new_file))
file <- file.path(dir, "src", new_file)
file.copy(file, file.path(dir, "src", name))
file <- file.path(dir, "src", name)

suppressWarnings(
all_decorations <- decor::cpp_decorations(dir, is_attribute = TRUE)
Expand DownExpand Up@@ -122,13 +122,14 @@ cpp_source <- function(file, code = NULL, env = parent.frame(), clean = TRUE, qu
stop("Compilation failed.", call. = FALSE)
}

shared_lib <- file.path(dir, "src", paste0(tools::file_path_sans_ext(basename(file)), .Platform$dynlib.ext))

slib1 <- file.path(dir, "src", paste0(tools::file_path_sans_ext(name), .Platform$dynlib.ext))
slib2 <- file.path(dir, "src", paste0(package, .Platform$dynlib.ext))
file.rename(slib1, slib2)
r_path <- file.path(dir, "R", "cpp11.R")
brio::write_lines(r_functions, r_path)
source(r_path, local = env)

dyn.load(shared_lib, local = TRUE, now = TRUE)
dyn.load(slib2, local = TRUE, now = TRUE)
}

the <- new.env(parent = emptyenv())
Expand Down