[rkward-cvs] SF.net SVN: rkward:[3862] trunk/rkward/rkward/rbackend/rpackages/rkwarddev
m-eik at users.sourceforge.net
m-eik at users.sourceforge.net
Thu Sep 29 17:18:44 UTC 2011
Revision: 3862
http://rkward.svn.sourceforge.net/rkward/?rev=3862&view=rev
Author: m-eik
Date: 2011-09-29 17:18:43 +0000 (Thu, 29 Sep 2011)
Log Message:
-----------
rkwarddev: added function rk.build.plugin()
Modified Paths:
--------------
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/ChangeLog
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.plugin.skeleton.R
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.plugin.skeleton.Rd
Added Paths:
-----------
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.build.plugin.R
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.build.plugin.Rd
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/ChangeLog 2011-09-29 16:35:59 UTC (rev 3861)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/ChangeLog 2011-09-29 17:18:43 UTC (rev 3862)
@@ -2,6 +2,7 @@
## 0.02-2 (2011-09-29)
- added "load" and "show" options to rk.plugin.skeleton() to call rk.load.pluginmaps() and the plugin itself
+ - added function rk.build.plugin()
## 0.02-1 (2011-09-28)
- added functions rk.XML.insert(), rk.XML.include(), rk.XML.embed(), rk.XML.preview(),
Added: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.build.plugin.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.build.plugin.R (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.build.plugin.R 2011-09-29 17:18:43 UTC (rev 3862)
@@ -0,0 +1,67 @@
+#' Build an RKWard plugin package
+#'
+#' @param plugin A character string, path to the plugin package root directory (hint: it's the directory with
+#' the DESCRIPTION file in it).
+#' @param check Logical, whether the package should be checked for errors. Always do this before you
+#' publick a package!
+#' @param install Logical, whether the built package should also be installed locally.
+#' @param R.libs A character string, path to local R packages, used by \code{install} to figure
+#' out where to install to.
+#' @export
+#' @examples
+#' \dontrun{
+#' plugin.dir <- rk.plugin.skeleton("MyPlugin", dialog=full.dialog, wizard=full.wizard)
+#' rk.build.plugin(plugin.dir, R.libs="~/R", check=TRUE)
+#' }
+
+rk.build.plugin <- function(plugin, check=FALSE, install=FALSE, R.libs=NULL){
+ jmp.back <- getwd()
+ plugin.path <- normalizePath(plugin)
+ build.path <- normalizePath(file.path(plugin.path, ".."))
+ plugin.desc.file <- file.path(plugin.path, "DESCRIPTION")
+ # read info from DESCRIPTION or die
+ if(file_test("-f", plugin.desc.file)){
+ plugin.desc <- read.dcf(plugin.desc.file)
+ } else {
+ stop(simpleError("Invalid plugin: No DESCRIPTION file found!"))
+ }
+ plugin.name <- as.character(plugin.desc[,"Package"])
+ plugin.version <- as.character(plugin.desc[,"Version"])
+ pckg.basename <- paste(plugin.name, "_", plugin.version, sep="")
+ pckg.name.src <- paste(pckg.basename, ".tar.gz", sep="")
+ package.path <- file.path(build.path, pckg.name.src)
+ R.bin <- R.home(file.path("bin","R"))
+
+ if(isTRUE(check)){
+ # check for examples check file before
+ chk.ex.file <- file.path(plugin.path, paste(plugin.name, "-Ex.R", sep=""))
+ chk.ex.file.present <- ifelse(file_test("-f", chk.ex.file), TRUE, FALSE)
+ tryCatch(chk.out.dir <- tempdir(), error=function(e) stop(e))
+ setwd(chk.out.dir)
+ set.R.libs <- ifelse(is.null(R.libs), "", paste("R_LIBS_USER=", R.libs, " ; ", sep=""))
+ r.cmd.check.call <- paste(set.R.libs, R.bin, " CMD check ", plugin.path, " || exit 1", sep="")
+ message(paste("check: calling R CMD check, this might take a while...", sep=""))
+ print(system(r.cmd.check.call, intern=TRUE))
+ on.exit(message(paste("check: results were saved to ", chk.out.dir, "/", plugin.name, ".Rcheck", sep="")), add=TRUE)
+ setwd(jmp.back)
+ # need to clean up?
+ if(!isTRUE(chk.ex.file.present) & file_test("-f", chk.ex.file)){
+ # there's an example file which wasn't here before
+ unlink(chk.ex.file)
+ } else {}
+ } else {}
+
+ setwd(build.path)
+ r.cmd.build.call <- paste(R.bin, " CMD build --no-vignettes ", plugin.path, " || exit 1", sep="")
+ system(r.cmd.build.call, intern=TRUE)
+ message(paste("build: package built as ", package.path, sep=""))
+
+ if(isTRUE(install)){
+ install.packages(package.path, lib=R.libs, repos=NULL)
+ message("build: package installed.")
+ } else {}
+
+ setwd(jmp.back)
+
+ return(invisible(NULL))
+}
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.plugin.skeleton.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.plugin.skeleton.R 2011-09-29 16:35:59 UTC (rev 3861)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.plugin.skeleton.R 2011-09-29 17:18:43 UTC (rev 3862)
@@ -44,6 +44,7 @@
#' to its menu structure by calling \code{rk.load.pluginmaps}. You can then try the plugin immediately.
#' @param show Logical, if \code{TRUE} and \code{"pmap"} in \code{create}, RKWard will automatically call the created plugin after
#' it was loaded (i.e., this implies and also sets \code{load=TRUE}).
+#' @return Character string with the path to the plugin root directory.
#' @export
#' @examples
#' \dontrun{
@@ -285,5 +286,5 @@
} else {}
} else {}
- return(invisible(NULL))
+ return(main.dir)
}
Added: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.build.plugin.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.build.plugin.Rd (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.build.plugin.Rd 2011-09-29 17:18:43 UTC (rev 3862)
@@ -0,0 +1,33 @@
+\name{rk.build.plugin}
+\alias{rk.build.plugin}
+\title{Build an RKWard plugin package}
+\usage{
+ rk.build.plugin(plugin, check = FALSE, install = FALSE,
+ R.libs = NULL)
+}
+\arguments{
+ \item{plugin}{A character string, path to the plugin
+ package root directory (hint: it's the directory with the
+ DESCRIPTION file in it).}
+
+ \item{check}{Logical, whether the package should be
+ checked for errors. Always do this before you publick a
+ package!}
+
+ \item{install}{Logical, whether the built package should
+ also be installed locally.}
+
+ \item{R.libs}{A character string, path to local R
+ packages, used by \code{install} to figure out where to
+ install to.}
+}
+\description{
+ Build an RKWard plugin package
+}
+\examples{
+\dontrun{
+plugin.dir <- rk.plugin.skeleton("MyPlugin", dialog=full.dialog, wizard=full.wizard)
+rk.build.plugin(plugin.dir, R.libs="~/R", check=TRUE)
+}
+}
+
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.plugin.skeleton.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.plugin.skeleton.Rd 2011-09-29 16:35:59 UTC (rev 3861)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.plugin.skeleton.Rd 2011-09-29 17:18:43 UTC (rev 3862)
@@ -106,6 +106,10 @@
plugin after it was loaded (i.e., this implies and also
sets \code{load=TRUE}).}
}
+\value{
+ Character string with the path to the plugin root
+ directory.
+}
\description{
Create skeleton for RKWard plugins
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list