[Rcpp-commits] r4142 - in pkg/Rcpp: . R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Dec 10 22:47:39 CET 2012
Author: jjallaire
Date: 2012-12-10 22:47:39 +0100 (Mon, 10 Dec 2012)
New Revision: 4142
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/R/Attributes.R
Log:
add Rtools to PATH for duration of sourceCpp
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2012-12-10 20:28:49 UTC (rev 4141)
+++ pkg/Rcpp/ChangeLog 2012-12-10 21:47:39 UTC (rev 4142)
@@ -1,7 +1,8 @@
2012-12-10 JJ Allaire <jj at rstudio.org>
* R/Attributes.R: warn when depends attribute is not matched with
- required entries in package description
+ required entries in package description; add Rtools to PATH for
+ duration of sourceCpp
* src/Attributes.cpp: warn when depends attribute is not matched with
required entries in package description
* src/AttributesGen.cpp: prune unnecessary includes from RcppExports
Modified: pkg/Rcpp/R/Attributes.R
===================================================================
--- pkg/Rcpp/R/Attributes.R 2012-12-10 20:28:49 UTC (rev 4141)
+++ pkg/Rcpp/R/Attributes.R 2012-12-10 21:47:39 UTC (rev 4142)
@@ -459,6 +459,15 @@
# add cygwin message muffler
buildEnv$CYGWIN = "nodosfilewarning"
+ # on windows see if we need to add Rtools to the path
+ # (don't do this for RStudio since it has it's own handling)
+ if (identical(Sys.info()[['sysname']], "Windows") &&
+ !nzchar(Sys.getenv("RSTUDIO"))) {
+ path <- .pathWithRtools()
+ if (!is.null(path))
+ buildEnv$PATH <- path
+ }
+
# create restore list
restore <- list()
for (name in names(buildEnv))
@@ -471,6 +480,49 @@
return (restore)
}
+
+# If we don't have the GNU toolchain already on the path then see if
+# we can find Rtools and add it to the path
+.pathWithRtools <- function() {
+
+ # Only proceed if we don't have the required tools on the path
+ hasRtools <- nzchar(Sys.which("ls.exe")) && nzchar(Sys.which("gcc.exe"))
+ if (!hasRtools) {
+
+ # Read the Rtools registry key
+ key <- NULL
+ try(key <- utils::readRegistry("SOFTWARE\\R-core\\Rtools",
+ hive = "HLM", view = "32-bit"),
+ silent = TRUE)
+
+ # If we found the key examine it
+ if (!is.null(key)) {
+
+ # Check version -- we only support 2.15 and 2.16 right now
+ ver <- key$`Current Version`
+ if (identical("2.15", ver) || identical("2.16", ver)) {
+
+ # See if the InstallPath leads to the expected directories
+ rToolsPath <- key$`InstallPath`
+ if (!is.null(rToolsPath)) {
+
+ # Return modified PATH if execpted directories exist
+ binPath <- file.path(rToolsPath, "bin", fsep="\\")
+ gccPath <- file.path(rToolsPath, "gcc-4.6.3", "bin", fsep="\\")
+ if (file.exists(binPath) && file.exists(gccPath))
+ return(paste(binPath,
+ gccPath,
+ Sys.getenv("PATH"),
+ sep=.Platform$path.sep))
+ }
+ }
+ }
+ }
+
+ return(NULL)
+}
+
+
# Build CLINK_CPPFLAGS from include directories of LinkingTo packages
.buildClinkCppFlags <- function(linkingToPackages) {
pkgCxxFlags <- NULL
@@ -660,27 +712,11 @@
"were not found.\n\n", sep="")
sysName <- Sys.info()[['sysname']]
if (identical(sysName, "Windows")) {
-
- # different message depending on whether Rtools is installed
- key <- NULL
- try(key <- utils::readRegistry("SOFTWARE\\R-core\\Rtools",
- hive = "HLM",
- view = "32-bit"),
- silent = TRUE)
+ msg <- paste(msg, "Please download and install the appropriate ",
+ "version of Rtools:\n\n",
+ "http://cran.r-project.org/bin/windows/Rtools/\n",
+ sep="");
- if (!is.null(key) && !is.null(key$`Current Version`)) {
- msg <- paste(msg, "Rtools appears to be installed however you ",
- "may not have updated the PATH.\n",
- "Please run the Rtools installer and follow ",
- "the instructions for updating\n",
- "the system PATH during installation.\n",
- sep="")
- } else {
- msg <- paste(msg, "Please download and install the appropriate ",
- "version of Rtools:\n\n",
- "http://cran.r-project.org/bin/windows/Rtools/\n",
- sep="");
- }
} else if (identical(sysName, "Darwin")) {
msg <- paste(msg, "Please install Command Line Tools for XCode ",
"(or equivalent).\n", sep="")
More information about the Rcpp-commits
mailing list