dmsurti / AssimpKit

A library (macOS, iOS) that converts the files supported by Assimp to Scene Kit scenes.
http://assimpkit.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
474 stars 54 forks source link

Fix clang format #21

Closed dmsurti closed 7 years ago

dmsurti commented 7 years ago

This updates to a simplified clang format. Reused the format from: http://tonyarnold.com/2014/05/31/autoformatting-your-code.html. I have changed the Indent to 2.

I have also integrated a behavior to format on save. I have this script from http://stackoverflow.com/questions/39747415/how-to-get-clang-format-for-xcode-8:

#!/bin/bash

CDP=$(osascript -e '
tell application "Xcode"
    activate
    tell application "System Events" to keystroke "s" using {command down}
    --wait for Xcode to remove edited flag from filename
    delay 0.3
    set last_word_in_main_window to (word -1 of (get name of window 1))
    set current_document to document 1 whose name ends with last_word_in_main_window
    set current_document_path to path of current_document
    --CDP is assigned last set value: current_document_path
end tell ')

LOGPATH=$(dirname "$0")
LOGNAME=formatWithClangLog.txt
echo "Filepath: ${CDP}" > ${LOGPATH}/${LOGNAME}
sleep 0.6 ### during save Xcode stops listening for file changes
/usr/local/bin/clang-format -style=file -i -sort-includes ${CDP} >> ${LOGPATH}/${LOGNAME} 2>&1

# EOF

All this pain after upgrading to Xcode 8 !!!