Building converts a package source directory into a single bundled file.
If binary = FALSE this creates a tar.gz package that can
be installed on any platform, provided they have a full development
environment (although packages without source code can typically be
installed out of the box). If binary = TRUE, the package will have
a platform specific extension (e.g. .zip for windows), and will
only be installable on the current platform, but no development
environment is needed.
Usage
build(
pkg = ".",
path = NULL,
binary = FALSE,
vignettes = TRUE,
manual = FALSE,
args = NULL,
quiet = FALSE,
...
)Arguments
- pkg
The package to use, can be a file path to the package or a package object. See
as.package()for more information.- path
Path in which to produce package. If
NULL, defaults to the parent directory of the package.- binary
Produce a binary (
--binary) or source (--no-manual --no-resave-data) version of the package.- vignettes, manual
For source packages: if
FALSE, don't build PDF vignettes (--no-build-vignettes) or manual (--no-manual).- args
An optional character vector of additional command line arguments to be passed to
R CMD buildifbinary = FALSE, orR CMD installifbinary = TRUE.- quiet
if
TRUEsuppresses output from this function.- ...
Additional arguments passed to pkgbuild::build.
Details
Configuration
DESCRIPTION entries
Config/build/clean-inst-doccan be set toFALSEto avoid cleaning upinst/docwhen building a source package. Set it toTRUEto force a cleanup. See theclean_docargument.Config/build/copy-methodcan be used to avoid copying large directories inR CMD build. It works by copying (or linking) the files of the package to a temporary directory, leaving out the (possibly large) files that are not part of the package. Possible values:none: pkgbuild does not copy the package tree. This is the default.copy: the package files are copied to a temporary directory beforeR CMD build.link: the package files are symbolic linked to a temporary directory beforeR CMD build. Windows does not have symbolic links, so on Windows this is equivalent tocopy.
You can also use the
pkg.build_copy_methodoption or thePKG_BUILD_COPY_METHODenvironment variable to set the copy method. The option is consulted first, then theDESCRIPTIONentry, then the environment variable.Config/build/extra-sourcescan be used to define extra source files for pkgbuild to decide whether a package DLL needs to be recompiled inneeds_compile(). The syntax is a comma separated list of file names, or globs. (Seeutils::glob2rx().) E.g.src/rust/src/*.rsorconfigure*.Config/build/bootstrapcan be set toTRUEto runRscript bootstrap.Rin the source directory prior to running subsequent build steps.Config/build/never-cleancan be set toTRUEto never add--precleantoR CMD INSTALL, e.g., when header files have changed. This helps avoiding rebuilds that can take long for very large C/C++ codebases and can lead to build failures if object files are out of sync with header files. Control the dependencies between object files and header files by addinginclude file.dtoMakevarsfor eachfile.corfile.cppsource file.
Options
pkg.build_copy_method: use this option to avoid copying large directories when building a package. See possible values above, at theConfig/build/copy-methodDESCRIPTIONentry.pkg.build_stop_for_warnings: if it is set toTRUE, then pkgbuild will stop forR CMD builderrors. It takes precedence over thePKG_BUILD_STOP_FOR_WARNINGSenvironment variable.
Environment variables
PKG_BUILD_COLOR_DIAGNOSTICS: set it tofalseto opt out of colored compiler diagnostics. Set it totrueto force colored compiler diagnostics.PKG_BUILD_COPY_METHOD: use this environment variable to avoid copying large directories when building a package. See possible values above, at theConfig/build/copy-methodDESCRIPTIONentry.
will stop for R CMD build errors. The pkg.build_stop_for_warnings
option takes precedence over this environment variable.
Note
The default manual = FALSE is not suitable for a CRAN
submission, which may require manual = TRUE. Even better, use
submit_cran() or release().
