[Rcpp-commits] r4067 - pkg/Rcpp/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Dec 4 03:55:09 CET 2012


Author: jjallaire
Date: 2012-12-04 03:55:08 +0100 (Tue, 04 Dec 2012)
New Revision: 4067

Modified:
   pkg/Rcpp/R/Attributes.R
Log:
print error if tools required for R CMD SHLIB aren't available

Modified: pkg/Rcpp/R/Attributes.R
===================================================================
--- pkg/Rcpp/R/Attributes.R	2012-12-03 23:31:24 UTC (rev 4066)
+++ pkg/Rcpp/R/Attributes.R	2012-12-04 02:55:08 UTC (rev 4067)
@@ -74,6 +74,8 @@
         
         # on.exit handler calls hook and restores environment and working dir
         on.exit({
+            if (!succeeded)
+                .showBuildFailureDiagnostics()
             .callBuildCompleteHook(succeeded, output)
             setwd(cwd)
             .restoreEnvironment(envRestore)
@@ -618,9 +620,38 @@
     gsub("\\s", "", linkingTo)
 }
 
+# show diagnostics for failed builds
+.showBuildFailureDiagnostics <- function() {
+    
+    # RStudio does it's own diagnostics so only do this for other environments
+    if (nzchar(Sys.getenv("RSTUDIO")))
+        return();
+        
+    # if we can't call R CMD SHLIB then notify the user they should 
+    # install the appropriate development tools
+    if (!.checkDevelTools()) {
+        msg <- paste("The tools required to build C/C++ code for R",
+                     "are not currently installed.")
+        sysName <- Sys.info()[['sysname']]
+        if (identical(sysName, "Windows")) {
+            msg <- paste(msg, "Please download and install the appropriate",
+                              "version of Rtools before proceeding:\n\n",
+                              "http://cran.r-project.org/bin/windows/Rtools/");
+        } else if (identical(sysName, "Darwin")) {
+            msg <- paste(msg, "Please install Command Line Tools for XCode",
+                              "(or equivalent).")
+        } else {
+            msg <- paste(msg, "Please install GNU software development tools",
+                              "including a C/C++ compiler.")
+        }
+        message(msg)
+    }
+}
+
 # check if R development tools are installed (cache successful result)
 .hasDevelTools <- FALSE
 .checkDevelTools <- function() {  
+    
     if (!.hasDevelTools) {     
         # create temp source file
         tempFile <- file.path(tempdir(), "foo.c")



More information about the Rcpp-commits mailing list