ITK/Release 4/Coding Style/KWStyle: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
 
(9 intermediate revisions by 5 users not shown)
Line 1: Line 1:
= Source Code =
= Source Code =


Download via Git from
Download via Git from


   fetch = +refs/heads/*:refs/remotes/origin/*
   git clone  git@github.com:Kitware/KWStyle.git
  url = http://public.kitware.com/KWStyle.git
 
  pushurl = git@public.kitware.com:KWStyle.git
You can visit the KWStyle webpage at http://kitware.github.io/KWStyle/


= Build =
= Build =
See ''Utilities/Maintenance/BuildKWStyle/README''.  Use the script ''Utilities/Maintenace/BuildKWStyle/BuildKWStyle.sh'' if desired.
Otherwise:


* Configure with CMake
* Configure with CMake
* Default options should do just fine
* Default options should do just fine
== Linux Example ==
If you are lucky enough to be using Linux, (or a *nix system), you can do:
    mkdir ~/bin/KWStyle
    cd  ~/bin/KWStyle
    ccmake ~/src/KWStyle
 
for convienence do:
  CMAKE_INSTALL_PREFIX ~/local
if you want to install it in $HOME/local
and also configure it to build for Release:
  CMAKE_BUILD_TYPE  Release
finally build and install with:
    make
    make install
= Use on ITK =
== Build Time and Test Time Checks ==
Rerun CMake in your ITK build.
Turn ON the flag:
  ITK_USE_KWSTYLE    ON
Indicate where the KWStyle executable is located.
For example, if you installed it as suggested above, then set:
    KWSTYLE_EXECUTABLE    ~/local/bin/KWStyle
and finally, set your favorite format for error reporting.
The options are:
KWSTYLE_USE_VIM_FORMAT
KWSTYLE_USE_GCC_FORMAT
KWSTYLE_USE_MSVC_FORMAT
This will allow you to run KWStyle from your development environment and process the style errors just the same way that you manage compilation errors. Please note that the vim format is also compatible with Emacs.
For example, if you are a fortunate enough to be a user of Vim, you can do:
  cd  $ITK_BINARY_DIR
  vim
 
and from inside the editor type
  :make StyleCheckCode
if any errors are reported, the relevant files will be open inside the editor, just the same way as if C++ compilation errors had occurred during a normal build.
If you are not familiar with the Vim mode for "edit-compile-edit cycle", do yourself a favor and read:
    :help quickfix
It will change your life.
An additional target for coding style is
    :make StyleCheckCode
You can also run the Style checks as tests by doing from the command line:
    ctest -R KWStyleCodeTest -V
== Commit Time Check ==
A Git commit-time check will automatically be performed on all indexed changes if KWStyle is available in the shell ''PATH'' environmental variable.
If the KWStyle executable is not installed to a location in the ''PATH'', its location can be specified by running
  git config hooks.KWStyle.path ~/local/bin/KWStyle
for example, in the source tree.
The KWStyle commit check can temporarily be disabled with
  git config hooks.KWStyle false
and re-enabled (don't forget to re-enable!) with
  git config hooks.KWStyle true

Latest revision as of 08:36, 24 January 2014

Source Code

Download via Git from

  git clone  git@github.com:Kitware/KWStyle.git

You can visit the KWStyle webpage at http://kitware.github.io/KWStyle/

Build

See Utilities/Maintenance/BuildKWStyle/README. Use the script Utilities/Maintenace/BuildKWStyle/BuildKWStyle.sh if desired. Otherwise:

  • Configure with CMake
  • Default options should do just fine

Linux Example

If you are lucky enough to be using Linux, (or a *nix system), you can do:

   mkdir ~/bin/KWStyle
   cd  ~/bin/KWStyle
   ccmake ~/src/KWStyle
 

for convienence do:

  CMAKE_INSTALL_PREFIX ~/local 

if you want to install it in $HOME/local

and also configure it to build for Release:

  CMAKE_BUILD_TYPE  Release

finally build and install with:

   make 
   make install

Use on ITK

Build Time and Test Time Checks

Rerun CMake in your ITK build.

Turn ON the flag:

 ITK_USE_KWSTYLE    ON

Indicate where the KWStyle executable is located. For example, if you installed it as suggested above, then set:

   KWSTYLE_EXECUTABLE    ~/local/bin/KWStyle

and finally, set your favorite format for error reporting.

The options are:

KWSTYLE_USE_VIM_FORMAT
KWSTYLE_USE_GCC_FORMAT
KWSTYLE_USE_MSVC_FORMAT

This will allow you to run KWStyle from your development environment and process the style errors just the same way that you manage compilation errors. Please note that the vim format is also compatible with Emacs.

For example, if you are a fortunate enough to be a user of Vim, you can do:

  cd  $ITK_BINARY_DIR
  vim
  

and from inside the editor type

  :make StyleCheckCode

if any errors are reported, the relevant files will be open inside the editor, just the same way as if C++ compilation errors had occurred during a normal build.

If you are not familiar with the Vim mode for "edit-compile-edit cycle", do yourself a favor and read:

   :help quickfix

It will change your life.

An additional target for coding style is

   :make StyleCheckCode


You can also run the Style checks as tests by doing from the command line:

   ctest -R KWStyleCodeTest -V

Commit Time Check

A Git commit-time check will automatically be performed on all indexed changes if KWStyle is available in the shell PATH environmental variable.

If the KWStyle executable is not installed to a location in the PATH, its location can be specified by running

 git config hooks.KWStyle.path ~/local/bin/KWStyle

for example, in the source tree.

The KWStyle commit check can temporarily be disabled with

 git config hooks.KWStyle false

and re-enabled (don't forget to re-enable!) with

 git config hooks.KWStyle true