Created
September 27, 2017 13:19
-
-
Save mpadge/af71512eca0ed74b42099ad42d857a38 to your computer and use it in GitHub Desktop.
clang manual compile R package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run script anywhere in R package directory to manually run a clang pedantic check on all src files | |
cpp_flgs <- c_flgs <- "-Wall -pedantic -Werror" | |
setwd (here::here ("src")) | |
cmd_base <- paste ("-I/usr/share/R/include -DNDEBUG", | |
"-I\"/usr/local/lib/R/site-library/Rcpp/include\" -fpic", | |
"-g -O2 -fstack-protector-strong -Wformat", | |
"-Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g") | |
flist_c <- list.files (".", pattern = "\\.c$") | |
for (f in flist_c) | |
{ | |
obj <- paste0 (tools::file_path_sans_ext (f), ".o") | |
cmd <- paste ("clang -std=gnu99", cmd_base, c_flgs, | |
"-c", f, "-o", obj) | |
message (cmd) | |
system (cmd) | |
} | |
flist_cpp <- list.files (".", pattern = "\\.cpp") | |
for (f in flist_cpp) | |
{ | |
obj <- paste0 (tools::file_path_sans_ext (f), ".o") | |
cmd <- paste ("clang++ -std=gnu++11", cmd_base, cpp_flgs, | |
"-c", f, "-o", obj) | |
message (cmd) | |
system (cmd) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment