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
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2014-09-23 JJ Allaire <jj@rstudio.org>

* R/Attributes.R: Add dryRun parameter to sourceCpp.

2014-09-21 Kevin Ushey <kevinushey@gmail.com>

* inst/unitTests/runit.environments.R: Use 'checkIdentical' as it's a
Expand Down
8 changes: 7 additions & 1 deletion R/Attributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ sourceCpp <- function(file = "",
embeddedR = TRUE,
rebuild = FALSE,
showOutput = verbose,
verbose = getOption("verbose")) {
verbose = getOption("verbose"),
dryRun = FALSE) {

# resolve code into a file if necessary. also track the working
# directory to source the R embedded code chunk within
Expand Down Expand Up @@ -112,6 +113,7 @@ sourceCpp <- function(file = "",
"CMD SHLIB ",
"-o ", shQuote(context$dynlibFilename), " ",
ifelse(rebuild, "--preclean ", ""),
ifelse(dryRun, "--dry-run ", ""),
shQuote(context$cppSourceFilename), sep="")
if (showOutput)
cat(cmd, "\n")
Expand Down Expand Up @@ -152,6 +154,10 @@ sourceCpp <- function(file = "",
"force a rebuild)\n\n", sep="")
}

# return immediately if this was a dry run
if (dryRun)
return(invisible(NULL))

# load the module if we have exported symbols
if (length(context$exportedFunctions) > 0 || length(context$modules) > 0) {

Expand Down
1 change: 1 addition & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
\itemize{
\item Include LinkingTo in DESCRIPTION fields scanned to confirm that
C++ dependencies are referenced by package.
\item Add \code{dryRun} parameter to \code{sourceCpp}.
}
\item Changes in Rcpp Documentation:
\itemize{
Expand Down
11 changes: 8 additions & 3 deletions man/sourceCpp.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ Source C++ Code from a File or String
and RCPP_MODULE declarations. A shared library is then built and its exported functions and Rcpp modules are made available in the specified environment.
}
\usage{
sourceCpp(file = "", code = NULL, env = globalenv(),
embeddedR = TRUE, rebuild = FALSE,
showOutput = verbose, verbose = getOption("verbose"))
sourceCpp(file = "", code = NULL, env = globalenv(),
embeddedR = TRUE, rebuild = FALSE,
showOutput = verbose, verbose = getOption("verbose"),
dryRun = FALSE)
}
\arguments{
\item{file}{
Expand All @@ -33,6 +34,10 @@ sourceCpp(file = "", code = NULL, env = globalenv(),
}
\item{verbose}{
\code{TRUE} to print detailed information about generated code to the console.
}
\item{dryRun}{
\code{TRUE} to do a dry run (showing commands that would be used rather than
actually executing the commands).
}
}
\details{
Expand Down