[Rcpp-commits] r4208 - in pkg/Rcpp: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jan 14 16:38:05 CET 2013


Author: jjallaire
Date: 2013-01-14 16:38:05 +0100 (Mon, 14 Jan 2013)
New Revision: 4208

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/R/Attributes.R
   pkg/Rcpp/R/RcppLdpath.R
   pkg/Rcpp/R/tools.R
Log:
handle build paths with spaces on windows

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2013-01-14 15:00:50 UTC (rev 4207)
+++ pkg/Rcpp/ChangeLog	2013-01-14 15:38:05 UTC (rev 4208)
@@ -1,4 +1,8 @@
 2014-01-14  JJ Allaire <jj at rstudio.org>
+
+        * R/Attributes.R: handle build paths with spaces on windows
+        * R/RcppLdpath.R: handle build paths with spaces on windows
+        * R/tools.R: handle build paths with spaces on windows
         * R/: set svn eol-style native for source files
         * src/: set svn eol-style native for source files 
         * inst/include/: set svn eol-style native for source files 

Modified: pkg/Rcpp/R/Attributes.R
===================================================================
--- pkg/Rcpp/R/Attributes.R	2013-01-14 15:00:50 UTC (rev 4207)
+++ pkg/Rcpp/R/Attributes.R	2013-01-14 15:38:05 UTC (rev 4208)
@@ -37,12 +37,6 @@
     
     # validate that there are no spaces in the path on windows
     if (.Platform$OS.type == "windows") {
-        if (grepl(' ', find.package("Rcpp"), fixed=TRUE)) {
-            stop("Rcpp is installed within a package library that has spaces ",
-                 "in it's path (", find.package("Rcpp"), "). Rcpp cannot be ",
-                 "built against in this configuration. Please re-install ",
-                 "Rcpp in a package library without spaces in it's path.")
-        }
         if (grepl(' ', basename(file), fixed=TRUE)) {
             stop("The filename '", basename(file), "' contains spaces. This ",
                  "is not permitted.")
@@ -439,20 +433,6 @@
              error = function(e) NULL) 
 }
 
-# Function to normalize build paths for passing to gcc on the command line
-# Leave them alone for posix (they'll be quoted). For Windows, mirror the
-# behavior of the R package build system by taking the fully resolved
-# absolute path (as a short path name) then convert backslashes to forward
-# slashes.
-.asBuildPath <- function(path) {
-    if (.Platform$OS.type == "windows") {
-        path <- normalizePath(path)
-        path <- utils::shortPathName(path)
-        path <- gsub("\\\\", "/", path)
-    }
-    return(path)
-}
-
 # Setup the build environment based on the specified dependencies. Returns an
 # opaque object that can be passed to .restoreEnvironment to reverse whatever
 # changes that were made
@@ -529,7 +509,7 @@
     buildEnv$CLINK_CPPFLAGS <- .buildClinkCppFlags(linkingToPackages)
     
     # add source file's directory to the compilation
-    srcDir <- .asBuildPath(dirname(sourceFile))
+    srcDir <- asBuildPath(dirname(sourceFile))
     buildEnv$CLINK_CPPFLAGS <- paste(buildEnv$CLINK_CPPFLAGS, 
                                      paste0('-I"', srcDir, '"'), 
                                      collapse=" ")
@@ -537,7 +517,7 @@
     # if the source file is in a package then add inst/include
     if (.isPackageSourceFile(sourceFile)) {
         incDir <- file.path(dirname(sourceFile), "..", "inst", "include")
-        incDir <- .asBuildPath(incDir)
+        incDir <- asBuildPath(incDir)
         buildEnv$CLINK_CPPFLAGS <- paste(buildEnv$CLINK_CPPFLAGS, 
                                          paste0('-I"', incDir, '"'), 
                                          collapse=" ")
@@ -615,6 +595,7 @@
     pkgCxxFlags <- NULL
     for (package in linkingToPackages) {
         packagePath <- find.package(package, NULL, quiet=TRUE)
+        packagePath <- asBuildPath(packagePath)
         pkgCxxFlags <- paste(pkgCxxFlags, 
             paste0('-I"', packagePath, '/include"'), 
             collapse=" ")

Modified: pkg/Rcpp/R/RcppLdpath.R
===================================================================
--- pkg/Rcpp/R/RcppLdpath.R	2013-01-14 15:00:50 UTC (rev 4207)
+++ pkg/Rcpp/R/RcppLdpath.R	2013-01-14 15:38:05 UTC (rev 4208)
@@ -49,9 +49,10 @@
     rcppdir <- RcppLdPath()
     if (static) {                               # static is default on Windows and OS X
         flags <- paste(rcppdir, "/libRcpp.a", sep="")
-        #if (.Platform$OS.type=="windows") {
-        #    flags <- shQuote(flags)
-        #}
+        if (.Platform$OS.type=="windows") {
+            flags <- asBuildPath(flags)
+            flags <- shQuote(flags)
+        }
     } else {					# else for dynamic linking
         flags <- paste("-L", rcppdir, " -lRcpp", sep="") # baseline setting
         if ((.Platform$OS.type == "unix") &&    # on Linux, we can use rpath to encode path
@@ -69,9 +70,10 @@
 RcppCxxFlags <- function(cxx0x=FALSE) {
     # path <- RcppLdPath()
     path <- Rcpp.system.file( "include" )
-    #if (.Platform$OS.type=="windows") {
-    #    path <- shQuote(path)
-    #}
+    if (.Platform$OS.type=="windows") {
+        path <- asBuildPath(path)
+        path <- shQuote(path)
+    }
     paste("-I", path, if( cxx0x && canUseCXX0X() ) " -std=c++0x" else "", sep="")
 }
 

Modified: pkg/Rcpp/R/tools.R
===================================================================
--- pkg/Rcpp/R/tools.R	2013-01-14 15:00:50 UTC (rev 4207)
+++ pkg/Rcpp/R/tools.R	2013-01-14 15:38:05 UTC (rev 4208)
@@ -31,3 +31,20 @@
         lockBinding( x, env )
     }
 }
+
+# Transform a path for passing to the build system on the command line.
+# Leave paths alone for posix. For Windows, mirror the behavior of the 
+# R package build system by starting with the fully resolved absolute path,
+# transforming it to a short path name if it contains spaces, and then 
+# converting backslashes to forward slashes
+asBuildPath <- function(path) {
+    
+    if (.Platform$OS.type == "windows") {
+        path <- normalizePath(path)
+        if (grepl(' ', path, fixed=TRUE))
+            path <- utils::shortPathName(path)
+        path <- gsub("\\\\", "/", path)
+    }
+    
+    return(path)
+}



More information about the Rcpp-commits mailing list