|
1 | | -# Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois |
| 1 | +# Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois |
2 | 2 | # |
3 | 3 | # This file is part of Rcpp. |
4 | 4 | # |
@@ -48,3 +48,31 @@ asBuildPath <- function(path) { |
48 | 48 |
|
49 | 49 | return(path) |
50 | 50 | } |
| 51 | + |
| 52 | + |
| 53 | +##' Helper function to report the package version of the R installation. |
| 54 | +##' |
| 55 | +##' While \code{packageVersion(Rcpp)} exports the version registers in |
| 56 | +##' {DESCRIPTION}, this version does get incremented more easily |
| 57 | +##' during development and can therefore be higher than the released |
| 58 | +##' version. The actual \code{#define} long used at the C++ level |
| 59 | +##' corresponds more to an \sQuote{API Version} which is now provided |
| 60 | +##' by this function, and use for example in the package skeleton |
| 61 | +##' generator. |
| 62 | +##' |
| 63 | +##' @title Export the Rcpp (API) Package Version |
| 64 | +##' @param devel An logical value indicating if the development or |
| 65 | +##' release version number should be returned, default is release. |
| 66 | +##' @return A \code{package_version} object with either the release |
| 67 | +##' or development version. |
| 68 | +##' @author Dirk Eddelbuettel |
| 69 | +##' @seealso \code{\link{packageVersion}}, |
| 70 | +##' \code{\link{Rcpp.package.skeleton}} |
| 71 | +##' @examples getRcppVersion() |
| 72 | +getRcppVersion <- function(devel = FALSE) { |
| 73 | + rcpp <- .Call("getRcppVersionStrings")[if(devel) 2 else 1] |
| 74 | + .make_numeric_version(rcpp, |
| 75 | + TRUE, |
| 76 | + .standard_regexps()$valid_package_version, |
| 77 | + "package_version") |
| 78 | +} |
0 commit comments