Permalink
Browse files

Merge pull request #1542 from bilderbuchi/code-formatting

Code styling tool for all of OF
  • Loading branch information...
bilderbuchi committed Nov 14, 2012
2 parents a112899 + a27fe75 commit c2f6662d91ed55627386765089580e8b695d6a09
View
@@ -2,15 +2,12 @@
!.project
!ofx3DModelLoader
!ofxAccelerometer
-!ofxDirList
!ofxiPhone
!ofxMultiTouch
!ofxNetwork
!ofxOpenCv
!ofxOsc
-!ofxThread
!ofxVectorGraphics
-!ofxVectorMath
!ofxXmlSettings
!ofxAndroid
ofxAndroid/ofAndroidLib/bin
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,2 @@
+# Ignore created log files
+*.log
@@ -5,6 +5,10 @@ https://github.com/openframeworks/openFrameworks/wiki/oF-code-style
The formatter used is `uncrustify`: http://uncrustify.sourceforge.net/
+The minimum version of `uncrustify` is 0.58.
+If an earlier version is used, certain code segments may be formatted incorrectly.
+E.g., 0.58 corrects a formatting edgecase with the `tok_split_gte` flag.
+
Install it to your standard path for the scripts to work:
* Mac OSX
@@ -51,4 +55,20 @@ Example:
## styleOFCore
-This script runs the OF styler on the core in `libs/openFrameworks/`.
+This script runs the OF styler on the core in `libs/openFrameworks/`.
+
+## styleWholeOF
+
+This script runs the OF styler on all of OF - the core, files in src folders in official addons, and in all examples.
+
+## Commit messages
+
+If you end up committing the formatted code, use a commit message which mentions 'code style', for example
+'Formating pass according to the current OF code style.'
+
+## Whitespace and git(hub)
+
+Uncrustify produces mostly whitespace changes.
+When using git, you can ignore whitespace changes in relevant commands by using the '-w' option.
+On Github, the same can be accomplished by appending '?w=1' to any URL.
+
@@ -1,2 +1 @@
-// Copyright (c) 2012 openFrameworks team
// openFrameworks is released under the MIT License. See libs/_Licence.txt
@@ -62,7 +62,7 @@ nl_before_case=true
nl_after_case=true
nl_after_return=false
nl_after_semicolon=true
-nl_after_brace_open=false
+nl_after_brace_open=true
nl_after_brace_open_cmt=false
nl_after_vbrace_open=false
nl_after_vbrace_open_empty=false
@@ -19,3 +19,4 @@ cd $WD
# run styler
./ofStyler -a core_header.txt ../../../libs/openFrameworks h
./ofStyler -a core_header.txt ../../../libs/openFrameworks cpp
+# add option '-a core_header.txt' to add a license header to every file
@@ -0,0 +1,76 @@
+#! /bin/bash
+#
+# This script runs the OF styler on all of OF: core, examples, official addons
+# and developer apps are formatted correctly
+#
+# 2012 Christoph Buchner for openFrameworks
+
+
+# get the current working dir
+WD=$(dirname $0)
+# move to this scripts dir
+cd $WD
+
+# OIFS="$IFS" # preserve default separator characters
+# IFS=$'\n' # set IFS to newline to handle spaces in paths
+
+echo "Style script for all of OF"
+echo
+#---------------------------------------------------
+echo
+echo "Running styler on OF core"
+echo
+ ./styleOFCore
+#---------------------------------------------------
+echo
+echo "Running styler on official addons"
+echo
+
+list_of_official_addons=`grep -o "!ofx.*" ../../../addons/.gitignore | grep -o "ofx.*"`
+
+for i in $list_of_official_addons; do
+ echo "Found addon $i"
+ ./styleAddon $i
+done
+#---------------------------------------------------
+echo
+echo "Running styler on examples"
+echo
+
+# find all src folders in examples. maxdepth to exclude false-positives in
+# android examples
+src_dir_list=`find ../../../examples/ -maxdepth 3 -name "src" -type d`
+for exampledir in $src_dir_list; do
+ echo "Found example src directory $exampledir"
+ ./ofStyler $exampledir cpp
+ ./ofStyler $exampledir h
+done
+
+#---------------------------------------------------
+echo
+echo "Running styler on apps/devApps"
+echo
+
+src_devApps_list=`find ../../../apps/devApps/ -maxdepth 2 -name "src" -type d`
+for dev in $src_devApps_list; do
+ echo "Found devApps src directory $dev"
+ ./ofStyler $dev cpp
+ ./ofStyler $dev h
+done
+
+# IFS="$OIFS"
+
+farewell="
+Finished styling all of openFrameworks!
+
+Please commit these whitespace-only changes in a separate commit.
+Be sure to mention 'code style' in the commit message, for example
+'Formatting pass to ensure code style conformance'.
+
+When using git, you can ignore whitespace changes in relevant commands
+by using the '-w' option.
+On Github, the same can be accomplished by appending '?w=1' to any URL.
+
+"
+echo "$farewell"
+

0 comments on commit c2f6662

Please sign in to comment.