Skip to content

Commit 9da9c6c

Browse files
committed
Merge pull request #181 from RcppCore/feature/source-cpp-dryrun
add dryRun parameter to sourceCpp
2 parents 04d0afe + aaaf4bd commit 9da9c6c

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2014-09-23 JJ Allaire <[email protected]>
2+
3+
* R/Attributes.R: Add dryRun parameter to sourceCpp.
4+
15
2014-09-21 Kevin Ushey <[email protected]>
26

37
* inst/unitTests/runit.environments.R: Use 'checkIdentical' as it's a

R/Attributes.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ sourceCpp <- function(file = "",
2323
embeddedR = TRUE,
2424
rebuild = FALSE,
2525
showOutput = verbose,
26-
verbose = getOption("verbose")) {
26+
verbose = getOption("verbose"),
27+
dryRun = FALSE) {
2728

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

157+
# return immediately if this was a dry run
158+
if (dryRun)
159+
return(invisible(NULL))
160+
155161
# load the module if we have exported symbols
156162
if (length(context$exportedFunctions) > 0 || length(context$modules) > 0) {
157163

inst/NEWS.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
\itemize{
3333
\item Include LinkingTo in DESCRIPTION fields scanned to confirm that
3434
C++ dependencies are referenced by package.
35+
\item Add \code{dryRun} parameter to \code{sourceCpp}.
3536
}
3637
\item Changes in Rcpp Documentation:
3738
\itemize{

man/sourceCpp.Rd

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ Source C++ Code from a File or String
88
and RCPP_MODULE declarations. A shared library is then built and its exported functions and Rcpp modules are made available in the specified environment.
99
}
1010
\usage{
11-
sourceCpp(file = "", code = NULL, env = globalenv(),
12-
embeddedR = TRUE, rebuild = FALSE,
13-
showOutput = verbose, verbose = getOption("verbose"))
11+
sourceCpp(file = "", code = NULL, env = globalenv(),
12+
embeddedR = TRUE, rebuild = FALSE,
13+
showOutput = verbose, verbose = getOption("verbose"),
14+
dryRun = FALSE)
1415
}
1516
\arguments{
1617
\item{file}{
@@ -33,6 +34,10 @@ sourceCpp(file = "", code = NULL, env = globalenv(),
3334
}
3435
\item{verbose}{
3536
\code{TRUE} to print detailed information about generated code to the console.
37+
}
38+
\item{dryRun}{
39+
\code{TRUE} to do a dry run (showing commands that would be used rather than
40+
actually executing the commands).
3641
}
3742
}
3843
\details{

0 commit comments

Comments
 (0)