The goal of pkgbuild is to make it easy to build packages withcompiled code. It provides tools to configure your R session, and checkthat everything is working ok. If you are using RStudio, it also helpsyou trigger automatic install of the build tools.
Install the released version from CRAN
install.packages("pkgbuild")Or install the development version from GitHub:
# install.packages("pak")pak::pak("r-lib/pkgbuild")# Check that you have the build tools installedpkgbuild::check_build_tools(debug =TRUE)# Build a packagepkgbuild::build("/path/to/my/package")# Run your own code in an environment guaranteed to# have build tools availablepkgbuild::with_build_tools(my_code)DESCRIPTION entriesConfig/build/clean-inst-doc can be set toFALSE to avoid cleaning upinst/doc whenbuilding a source package. Set it toTRUE to force acleanup. See theclean_doc argument ofbuild()as well.
Config/build/copy-method can be used to avoidcopying large directories inR CMD build. It works bycopying (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 isthe default.copy: the package files are copied to a temporarydirectory beforeR CMD build.link: the package files are symbolic linked to atemporary directory beforeR CMD build. Windows does nothave symbolic links, so on Windows this is equivalent tocopy.You can also use thepkg.build_copy_method option or thePKG_BUILD_COPY_METHOD environment variable to set the copymethod. The option is consulted first, then theDESCRIPTIONentry, then the environment variable.
Config/build/extra-sources can be used to defineextra source files for pkgbuild to decide whether a package DLL needs tobe recompiled inneeds_compile(). The syntax is a commaseparated list of file names, or globs. (See?utils::glob2rx().) E.g.src/rust/src/*.rs orconfigure*.
pkg.build_copy_method: use this option to avoidcopying large directories when building a package. See possible valuesabove, at theConfig/build/copy-methodDESCRIPTION entry.
pkg.build_extra_flags: set this toFALSE to to opt out from adding debug compiler flags incompile_dll(). Takes precedence over thePKG_BUILD_EXTRA_FLAGS environment variable. Possiblevalues:
TRUE: add extra flags,FALSE: do not add extra flags,"missing": add extra flags if the user does not have a$HOME/.R/Makevars file.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_WARNINGS environment variable.
PKG_BUILD_COLOR_DIAGNOSTICS: set it tofalse to opt out of colored compiler diagnostics. Set it totrue to force colored compiler diagnostics.
PKG_BUILD_COPY_METHOD: use this environment variableto avoid copying large directories when building a package. See possiblevalues above, at theConfig/build/copy-methodDESCRIPTION entry.
PKG_BUILD_EXTRA_FLAGS: set this tofalse to to opt out from adding debug compiler flags incompile_dll(). Thepkg.build_extra_flagsoption takes precedence over this environment variable. Possiblevalues:
"true": add extra flags,"false": do not add extra flags,"missing": add extra flags if the user does not have a$HOME/.R/Makevars file.PKG_BUILD_STOP_FOR_WARNINGS: if it is set totrue, then pkgbuild will stop forR CMD builderrors. Thepkg.build_stop_for_warnings option takesprecedence over this environment variable.
Please note that the pkgbuild project is released with aContributor Codeof Conduct. By contributing to this project, you agree to abide byits terms.