Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some clang scripts; add ChangeLog function; update clang_format
- Loading branch information
1 parent
5ec0d1d
commit 83532a9
Showing
10 changed files
with
244 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
##' Update a Package ChangeLog | ||
##' | ||
##' This function compares the time that files were last modified with the | ||
##' time that the current \R session was started (well, the time that | ||
##' \code{Kmisc} was loaded), generates stubs for them in a file called | ||
##' \code{ChangeLog}, and then opens that file in an editor. | ||
##' @param msg A message to use for the first file. | ||
##' @export | ||
ChangeLog <- function(msg="") { | ||
|
||
if (!exists(".Start.time")) { | ||
stop("No variable '.Start.time' available; unable to infer what ", | ||
"files have been modified in the current session!") | ||
} | ||
|
||
if (!file.exists("ChangeLog")) { | ||
message("Creating a new ChangeLog file...") | ||
file.create("ChangeLog") | ||
} | ||
|
||
## Find out what files have been modified in the current session | ||
files <- list.files(full.names=TRUE, include.dirs=FALSE) | ||
|
||
times <- unlist( lapply(files, function(x) { | ||
as.numeric(system(paste("stat -f%c", x), intern=TRUE)) | ||
})) | ||
|
||
modified <- files[ times > .Start.time ] | ||
|
||
## The ChangeLog is not a candidate for listing in modifies | ||
modified <- modified[ modified != "./ChangeLog" ] | ||
|
||
## Strip off the initial './' | ||
modified <- substring(modified, 3, nchar(modified)) | ||
|
||
if (length(modified)) { | ||
|
||
## Generate the header | ||
header <- paste0( Sys.Date(), " ", Sys.getenv("USERNAME"), " <", Sys.getenv("EMAIL"), ">" ) | ||
|
||
## Stubs for each modified file | ||
body_first <- paste0(" * ", modified[1], ": ", msg) | ||
body_rest <- paste0(" * ", modified[2:length(modified)], ": Idem") | ||
|
||
changes <- c(header, "", body_first, body_rest) | ||
|
||
## Read in the ChangeLog, put the new changes on top, and write it back out | ||
ChangeLog <- readLines("ChangeLog") | ||
New <- c(changes, ChangeLog) | ||
|
||
## Write out the new ChangeLog, and open it in an editor | ||
cat(New, file="ChangeLog", sep="\n") | ||
return( file.edit("ChangeLog") ) | ||
} else { | ||
message("No files have been modified in the current session.") | ||
return (invisible(NULL)) | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
\name{ChangeLog} | ||
\alias{ChangeLog} | ||
\title{Update a Package ChangeLog} | ||
\usage{ | ||
ChangeLog(msg = "") | ||
} | ||
\arguments{ | ||
\item{msg}{A message to use for the first file.} | ||
} | ||
\description{ | ||
This function compares the time that files were last | ||
modified with the time that the current \R session was | ||
started (well, the time that \code{Kmisc} was loaded), | ||
generates stubs for them in a file called \code{ChangeLog}, | ||
and then opens that file in an editor. | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
\name{clang_format} | ||
\alias{clang_format} | ||
\title{Reformat C/C++ Code using clang-format} | ||
\usage{ | ||
clang_format(files = NULL, style = c("Chromium", "LLVM", "Google", | ||
"Mozilla", "WebKit"), verbose = FALSE) | ||
} | ||
\description{ | ||
This function requires \code{clang-format} to be in your | ||
\code{PATH}. | ||
} | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env sh | ||
|
||
IN_KMISC=`pwd | grep Kmisc$` | ||
if [ ${#IN_KMISC} == 0 ]; then | ||
echo "Error: not in base Kmisc directory." | ||
exit 0 | ||
fi; | ||
|
||
## NOTE: For some reason, clang-modernize tries to add a second | ||
## set of overrides to Rstreambuf.h, so we exclude it explicitly | ||
|
||
## I also currently get assertion errors if I try to use | ||
## '-use-auto', hence I explicitly set some parameters for modernizing | ||
|
||
clang-check src/*.cpp \ | ||
-analyze \ | ||
-- \ | ||
-std=c++1y \ | ||
-I/Users/kevinushey/.llvm/libcxx/include \ | ||
-I/Library/Frameworks/R.framework/Headers \ | ||
-I/Library/Frameworks/R.framework/Resources/library/Rcpp/include \ | ||
-Iinst/include | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env sh | ||
|
||
IN_KMISC=`pwd | grep Kmisc$` | ||
if [ ${#IN_KMISC} == 0 ]; then | ||
echo "Error: not in base Kmisc directory." | ||
exit 0 | ||
fi; | ||
|
||
## NOTE: For some reason, clang-modernize tries to add a second | ||
## set of overrides to Rstreambuf.h, so we exclude it explicitly | ||
|
||
## I also currently get assertion errors if I try to use | ||
## '-use-auto', hence I explicitly set some parameters for modernizing | ||
|
||
clang-modernize src/*.cpp \ | ||
-final-syntax-check \ | ||
-style="Chromium" \ | ||
-risk=risky \ | ||
-pass-by-value \ | ||
-loop-convert \ | ||
-add-override \ | ||
-for-compilers=clang-3.5 \ | ||
-- \ | ||
-std=c++1y \ | ||
-I/Users/kevinushey/.llvm/libcxx/include \ | ||
-I/Library/Frameworks/R.framework/Headers \ | ||
-I/Library/Frameworks/R.framework/Resources/library/Rcpp/include \ | ||
-Iinst/include | ||
|