Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7a1dfa3

Browse files
committed
Merge pull request#474 from RcppCore/feature/minimal-compiler
first crack at checking compiler versions from R
2 parentsd635089 +91cf8f3 commit7a1dfa3

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

‎DESCRIPTION‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ URL: http://www.rcpp.org, http://dirk.eddelbuettel.com/code/rcpp.html, https://g
2121
License: GPL (>= 2)
2222
BugReports: https://github.com/RcppCore/Rcpp/issues
2323
MailingList: Please send questions and comments regarding Rcpp to rcpp-devel@lists.r-forge.r-project.org
24+
RoxygenNote: 5.0.1

‎R/compilerCheck.R‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
##' Helper function to establish minimal compiler versions, currently limited
2+
##' only to \code{g++} which (particularly for older RHEL/CentOS releases) is
3+
##' too far behind current C++11 standards required for some packages.
4+
##'
5+
##' This function looks up \code{g++} (as well as optional values in the
6+
##' \code{CXX} and \code{CXX1X} environment variables) in the \code{PATH}. For
7+
##' all values found, the output of \code{g++ -v} is analyzed for the version
8+
##' string, which is then compared to the given minimal version.
9+
##' @title Check for Minimal (g++) Compiler Version
10+
##' @param minVersion An object of type \code{package_version}, with a default
11+
##' of version 4.6.0
12+
##' @return A boolean value is returned, indicating if the minimal version is
13+
##' being met
14+
##' @author Dirk Eddelbuettel
15+
compilerCheck<-function(minVersion=package_version("4.6.0")) {
16+
17+
binaries<- c("g++", Sys.getenv("CXX",unset=""), Sys.getenv("CXX1X",unset=""))
18+
binpaths<- lapply(binaries,function(b) {if (b=="")NULLelse Sys.which(b) })
19+
20+
allgood<-FALSE
21+
rl<- lapply(binpaths,function(b) {
22+
if (is.null(b))return(NULL)
23+
con<- pipe(paste(b,"-v 2>&1"),"r")# NB: not --version, but -v
24+
lines<- readLines(con)
25+
close(con)
26+
lines<-lines[grepl("^g.. version",lines)]
27+
if (length(lines)==0)return(NULL)
28+
ver<- strsplit(lines,"")[[1]][3]# format is 'gcc version x.y.z ....'
29+
package_version(ver)>=minVersion
30+
})
31+
all(do.call(c,rl))# drops NULLs
32+
}
33+
34+
## TODO: maybe not limit to gcc/g++
35+
## TODO: maybe be smarter about combination of path, CXX and CXX1X ?
36+
## TODO: maybe make env.var optional arguments too

‎man/compilerCheck.Rd‎

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp