-
Notifications
You must be signed in to change notification settings - Fork 0
Development
Aviezer Lifshitz edited this page Nov 26, 2021
·
3 revisions
In order to edit R code:
- Edit the relevant .R file.
- Call
devtools::load_all()
and make sure it works. - Write some tests to verify the desired behaviour.
- Run
devtools::test()
and make sure no test fails.
In order to edit c++ code:
- Edit the relevant file in the
src
directory. - Make sure you have an empty file named
~/.R/Makevars
in your unix environment. See below. See also the note regarding parallel compilation. - Call
devtools::load_all()
to compile the code. Now you can test your change. - Write some tests to verify the desired behaviour.
- Run
devtools::test()
and make sure no test fails.
devtools::load_all()
calls pkgbuild::compile_dll()
that uses its own compilation flags (pkgbuild::compiler_flags(TRUE)
) and ignores the ones we use in our Makefile. This currently causes compilation to fail due to include issues. Fortunately, the flags are not added when we have a file named ~/.R/Makevars
in our environment. This is the easiest solution, but if for some reason we prefer not to rely on our environment, we another solution is to run devtools::load_all()
with fake makevars environment:
makevars <- c(CFLAGS="-O3 -DNDEBUG -fpic -I$(R_INCLUDE_DIR) -Wformat -Wformat-security -Wal
l -pedantic -fdiagnostics-color=always",
CXXFLAGS="-O3 -DNDEBUG -fpic -I$(R_INCLUDE_DIR) -std=c++11 -Wformat -Wformat-security -Wall
-pedantic -fdiagnostics-color=always",
CXX11FLAGS="-O3 -DNDEBUG -fpic -I$(R_INCLUDE_DIR) -std=c++11 -Wformat -Wformat-security -Wa
ll -pedantic -fdiagnostics-color=always",
FFLAGS="-g -O3",
FCFLAGS="-g -O3",
PKG_LIBS = "-lpthread")
withr::with_makevars(makevars, devtools::load_all())
If you want compilation to happen in parallel (i.e. make -j
):
In R run usethis::edit_r_environ()
and add the following line (e.g. in order to use 20 cores):
MAKE=make -j20