#!/usr/bin/env Rscript
# to do before running this script:
# 1. increase version number in ../DESCRIPTION
# 2. describe changes in changelog.txt
# RUN FROM MAIN PACKAGE FOLDER, i.e. "specificity"
packwd <- getwd()
if(!file.exists("DESCRIPTION")){
stop("Wrong directory!")
}
# add files to .Rbuildignore (files ignored during package building)
write("^specificity\\.Rproj$", file=".Rbuildignore",append=FALSE)
write("^\\.Rproj\\.user$", file=".Rbuildignore",append=TRUE)
write("^vignette$", file=".Rbuildignore",append=TRUE)
write("^\\.travis.yml$", file=".Rbuildignore",append=TRUE)
write("^other$", file=".Rbuildignore",append=TRUE)
write("specificity.pdf", file=".Rbuildignore",append=TRUE)
library(devtools)
library(roxygen2)
library(Rcpp)
library(testthat)
usethis::use_package("ape")
usethis::use_package("parallel")
usethis::use_package("Rcpp")
if(packageVersion("Rcpp") < "1.0.0"){
stop("Rcpp needs to be updated to 1.0.0 or above.")
}
# this looks for Rcpp::export in cpp files
Rcpp::compileAttributes("./")
document()
# ADD C++ namespace stuff to NAMESPACE file, because document() above OVERWRITES it:
# originally made via Rcpp::compileAttributes("./") above
lines2add <- readLines("other/additional_namespace/rcpp_namespace.txt")
write(lines2add, file="NAMESPACE", append=TRUE)
# add stuff to namespace that's not in BASE R but sure is in VANILLA R
# generated by (in shell):
# cd ../
# R CMD build specificity
# R CMD check specificity_XYZ.tar.gz
# look at specificity.Rcheck/00check.log
lines2add <- readLines("other/additional_namespace/vanillaR_namespace.txt")
write(lines2add, file="NAMESPACE", append=TRUE)
# install
install("../specificity")
# test
setwd("tests/")
### doing tests can take a minute! ###
capture.output(test_check("specificity"), file="../other/test_results.txt", split=TRUE)
setwd(packwd)
# document packageVersions used for this test and build:
pkgvers_fp <- "other/package_versions.txt"
write("Pagage versions used in this build and tests:", file=pkgvers_fp)
writepkgvers <- function(pkgname, fp=pkgvers_fp){
write(paste0(pkgname, "=", packageVersion(pkgname)), file=fp, append=T)
}
writepkgvers("devtools")
writepkgvers("roxygen2")
writepkgvers("Rcpp")
writepkgvers("testthat")
writepkgvers("ape")
writepkgvers("parallel")
writepkgvers("fields") # NOTE: only suggested now!
writepkgvers("specificity")
# make pdf manual
# texinfo required: sudo apt-get install texinfo
pack <- "specificity"
path <- find.package(pack)
system("rm specificity.pdf")
# commmand below requires: texlive-fonts-extra, texinfo (install both with apt)
system(paste(shQuote(file.path(R.home("bin"), "R")), "CMD", "Rd2pdf", shQuote(path)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.