OCLint
获取源代码
准备工作
参考步骤 https://oclint-docs.readthedocs.io/en/stable/intro/build.html
获取源代码
获取全新代码
git clone https://github.com/oclint/oclint.git
cd oclint
git clone https://github.com/oclint/oclint-json-compilation-database.git
git clone https://github.com/oclint/oclint-xcodebuild.git
cd oclint-scripts
./clang checkout
./countly checkout
./googleTest checkout
cd .. # back to the root folder of OCLint codebase
更新已有代码
cd oclint # start from OCLint root directory
git pull origin master
cd oclint-json-compilation-database
git pull origin master
cd ../oclint-xcodebuild
git pull origin master
cd ../oclint-scripts
./clang update
./googleTest update
cd .. # back to OCLint root directory
参考步骤 https://oclint-docs.readthedocs.io/en/stable/devel/checkout.html
编译
cd oclint-scripts
./make
cd ..
验证
./build/oclint-release/bin/oclint
如果有以下输出,则表示输出成功
oclint: Not enough positional command line arguments specified!
Must specify at least 1 positional argument: See: ./build/oclint-release/bin/oclint -help
Test
cd oclint/oclint-scripts
./countly build
./googleTest co
./googleTest build
./test
全部跑完一次后,下次可以只跑对应的模块
./test rules
更多参考https://oclint-docs.readthedocs.io/en/stable/devel/compiletest.html
打包oclint
测试通过后就可以打包oclint了,oclint/build/oclint-release含有最终生成的各种文件。
如果在本地使用,可以直接加到环境变量使用, 其中src-path是oclint源码所在的父目录
OCLINT_HOME=/src-path/oclint/build/oclint-release
export PATH=$OCLINT_HOME/bin:$PATH
打包到远程使用
使用oclint
xcodebuild -workspace $myworkspace -scheme $myscheme clean
xcodebuild -workspace $myworkspace -scheme $myscheme -configuration $configuration \
| xcpretty -r json-compilation-database -o compile_commands.json && \
oclint-json-compilation-database -e Pods -- \
-report-type html -o oclint_result.html \
-rc LONG_LINE=200 \
-max-priority-1=100000 \
-max-priority-2=100000 \
-max-priority-3=100000