thuai
6/8/2015 - 6:40 PM

OCLint xcode 6.3.2

#!/bin/sh
source ~/.bash_profile

hash oclint > /dev/null
if [ $? -eq 1 ]; then
    echo > "oclint not found, analyzing stopped"
    exit 1
fi

cd ${TARGET_TEMP_DIR}

if [ ! -f compile_commands.json ]; then
    echo "[*] compile_commands.json not found, possibly clean was performed"
    echo "[*] starting xcodebuild to rebuild the project.."
    # clean previous output
    if [ -f xcodebuild.log ]; then
        rm xcodebuild.log
    fi
fi

cd ${SRCROOT}

xcodebuild clean

#build xcodebuild.log
#xcodebuild build | tee ${TARGET_TEMP_DIR}/xcodebuild.log
xcodebuild ONLY_ACTIVE_ARCH=YES -workspace ${PROJECT_NAME}.xcworkspace -scheme ${PROJECT_NAME} -configuration Debug clean build | tee ${TARGET_TEMP_DIR}/xcodebuild.log
echo "[*] transforming xcodebuild.log into compile_commands.json..."
cd ${TARGET_TEMP_DIR}
#transform it into compile_commands.json
oclint-xcodebuild

#if [-d report.html]; then
#rm report.html
#fi

#run static analyzer
#oclint-json-compilation-database -- -o=./report.html -html

echo "[*] starting analyzing"
cd ${TARGET_TEMP_DIR}
oclint-json-compilation-database | sed 's/\(.*\.\m\{1,2\}:[0-9]*:[0-9]*:\)/\1 warning:/'