Skip to content

Commit ffadf4e

Browse files
committed
Merge pull request #274 from RcppCore/feature/rtools-33
Use Rtools 3.3 for compilation under R 3.2
2 parents c53492d + 82a1274 commit ffadf4e

File tree

3 files changed

+47
-18
lines changed

3 files changed

+47
-18
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2015-03-11 JJ Allaire <[email protected]>
2+
3+
* R/Attributes.R: Rtools 3.3 is now located and used for compilation under R 3.2.
4+
15
2015-03-04 Dirk Eddelbuettel <[email protected]>
26

37
* DESCRIPTION: Release 0.11.5

R/Attributes.R

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,9 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
656656
# (don't do this for RStudio since it has it's own handling)
657657
if (identical(Sys.info()[['sysname']], "Windows") &&
658658
!nzchar(Sys.getenv("RSTUDIO"))) {
659-
path <- .pathWithRtools()
660-
if (!is.null(path))
661-
buildEnv$PATH <- path
659+
env <- .environmentWithRtools()
660+
for (var in names(env))
661+
buildEnv[[var]] <- env[[var]]
662662
}
663663

664664
# create restore list
@@ -676,7 +676,7 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
676676

677677
# If we don't have the GNU toolchain already on the path then see if
678678
# we can find Rtools and add it to the path
679-
.pathWithRtools <- function() {
679+
.environmentWithRtools <- function() {
680680

681681
# Only proceed if we don't have the required tools on the path
682682
hasRtools <- nzchar(Sys.which("ls.exe")) && nzchar(Sys.which("gcc.exe"))
@@ -691,24 +691,28 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
691691
# If we found the key examine it
692692
if (!is.null(key)) {
693693

694-
# Check version -- we only support 2.15 and 2.16 right now
694+
# Check version
695695
ver <- key$`Current Version`
696-
if (identical("2.15", ver) || identical("2.16", ver) ||
697-
identical("3.0", ver) || identical("3.1", ver) ||
698-
identical("3.2", ver)) {
699-
696+
if (ver %in% (c("2.15", "2.16", "3.0", "3.1", "3.2", "3.3"))) {
700697
# See if the InstallPath leads to the expected directories
698+
isGcc49 <- ver %in% c("3.3")
701699
rToolsPath <- key$`InstallPath`
702700
if (!is.null(rToolsPath)) {
703-
704-
# Return modified PATH if execpted directories exist
705-
binPath <- file.path(rToolsPath, "bin", fsep="\\")
706-
gccPath <- file.path(rToolsPath, "gcc-4.6.3", "bin", fsep="\\")
707-
if (file.exists(binPath) && file.exists(gccPath))
708-
return(paste(binPath,
709-
gccPath,
710-
Sys.getenv("PATH"),
711-
sep=.Platform$path.sep))
701+
# add appropriate path entries
702+
path <- file.path(rToolsPath, "bin", fsep="\\")
703+
if (!isGcc49)
704+
path <- c(path, file.path(rToolsPath, "gcc-4.6.3", "bin", fsep="\\"))
705+
706+
# if they all exist then return a list with modified
707+
# environment variables for the compilation
708+
if (all(file.exists(path))) {
709+
env <- list()
710+
path <- paste(path, collapse = .Platform$path.sep)
711+
env$PATH <- paste(path, Sys.getenv("PATH"), sep=.Platform$path.sep)
712+
if (isGcc49)
713+
env$RTOOLS <- .rtoolsPath(rToolsPath)
714+
return(env)
715+
}
712716
}
713717
}
714718
}
@@ -718,6 +722,17 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
718722
}
719723

720724

725+
# Ensure that the path is suitable for passing as an RTOOLS
726+
# environment variable
727+
.rtoolsPath <- function(path) {
728+
path <- gsub("\\\\", "/", path)
729+
path <- trimws(path)
730+
if (substring(path, nchar(path)) != "/")
731+
path <- paste(path, "/", sep="")
732+
path
733+
}
734+
735+
721736
# Build CLINK_CPPFLAGS from include directories of LinkingTo packages
722737
.buildClinkCppFlags <- function(linkingToPackages) {
723738
pkgCxxFlags <- NULL

inst/NEWS.Rd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
\title{News for Package 'Rcpp'}
33
\newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
44

5+
\section{Changes in Rcpp version 0.11.6 (Unreleased)}{
6+
\itemize{
7+
\item Changes in Rcpp Attributes:
8+
\itemize{
9+
\item Rtools 3.3 is now located and used for compilation under
10+
R 3.2.
11+
}
12+
}
13+
}
14+
515
\section{Changes in Rcpp version 0.11.5 (2015-03-04)}{
616
\itemize{
717
\item Changes in Rcpp API:

0 commit comments

Comments
 (0)