Uncrustify, Windows Shell Script and Visual Studio Build Events


If you’re here, you probably know this already, but Uncrustify is a “code beautifier” with 454 configurable options at the time of writing (in short, you can pretty much set up any any code style convention you can imagine).

Since I am a massive supporter of “anything that can be automated should be automated” I decided to use Visual Studio build events and a Windows shell script to ensure that the style convention for our C++ code base is enforced consistently and (no surprises here) automatically.

For example, by using the script (linked to above) and simply adding the following command line to a pre/post build event in your project’s properties, you could walk the entire project directory tree, “uncrustifying” as you go:

call "C:\path\to\Uncrustify\uncrusty.bat" $(ProjectDir)

Note: Please see the script’s REM comments for how it works and what it does, you will also have to edit some paths for your own use.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s