Skip to contents

Vendoring is the act of making your own copy of the 3rd party packages your project is using. It is often used in the go language community.

Usage

vendor(path = ".", headers = "/inst/include")

Arguments

path

The path to the package root directory

headers

The subdirectory to vendor the headers into

Value

The file path to the vendored code (invisibly).

Details

This function vendors cpp4r into your package by copying the cpp4r headers into the inst/include folder of your package and adding 'cpp4r version: XYZ' to the top of the files, where XYZ is the version of cpp4r currently installed on your machine.

Note: vendoring places the responsibility of updating the code on you. Bugfixes and new features in cpp4r will not be available for your code until you run cpp_vendor() again.

Examples

# create a new directory
dir <- paste0(tempdir(), "/", gsub("\\s+|[[:punct:]]", "", Sys.time()))
dir.create(dir, recursive = TRUE)

# vendor the cpp4r headers into the directory
vendor(dir)
#> Makevars and/or Makevars.win should have a line such as 'PKG_CPPFLAGS = -I../inst/include'
#> DESCRIPTION should not have lines such as 'LinkingTo: cpp4r'

list.files(file.path(dir, "inst", "include", "cpp4r"))
#>  [1] "R.hpp"                "as.hpp"               "attribute_proxy.hpp" 
#>  [4] "complexes.hpp"        "data_frame.hpp"       "declarations.hpp"    
#>  [7] "doubles.hpp"          "environment.hpp"      "external_pointer.hpp"
#> [10] "function.hpp"         "integers.hpp"         "list.hpp"            
#> [13] "list_of.hpp"          "logicals.hpp"         "matrix.hpp"          
#> [16] "named_arg.hpp"        "protect.hpp"          "r_bool.hpp"          
#> [19] "r_complex.hpp"        "r_string.hpp"         "r_vector.hpp"        
#> [22] "raws.hpp"             "sexp.hpp"             "strings.hpp"         

# cleanup
unlink(dir, recursive = TRUE)