zl程序教程

您现在的位置是:首页 >  系统

当前栏目

mac下通过xcodebuild使用oclint

Mac 通过 使用
2023-09-27 14:29:22 时间

下载地址: http://oclint.org/downloads.html

选择mac os x或者darwin的包,下载到本地。

目录类似下面:

oclint-release

|-bin

|-lib

|---clang

|-----3.4

|-------include

|-------lib

|---oclint

|-----rules

|-----reporters


安装官方指南: http://docs.oclint.org/en/dev/intro/installation.html

我们此时在bash(终端terminal)中运行oclint会告诉我们命令找不到,我们需要把它的执行文件路径加入到环境变量或者把执行文件拷贝到系统目录。

方法1(推荐):把路径加到环境变量中(实际是.bash_profile或者.bashrc文件中,关于这两者有不知道的同学可以搜索之)

OCLINT_HOME=/path/to/oclint-release // /path/to/oclint-release 是执行文件存放路径,例如:/Users/xxx/Desktop/oclint-0.9.dev.a6ffa25

export PATH=$OCLINT_HOME/bin:$PATH
关于.bash_profile,mac系统里本身可能不存在,创建和编辑的步骤见下文:
http://blog.csdn.net/openglnewbee/article/details/36663591

关于bashrc,位于/etc目录下,使用command+shift+g 可以前往/etc,找到bashrc文件修改权限后可以编辑。


方法2:把执行文件拷贝到系统目录(请自行尝试)


A few directories are supposed to be in the system PATH already, to mention a few, /usr/local/bin, /usr/bin, /bin, etc. Therefore, it’s also possible to copy the OCLint binaries into one of these folders, and move the dependencies over. As an example, presumes /usr/local/bin is in the PATH (may require root permission).


Dependency libraries are required to be put into appropriate directory, because oclint executable searches $(/path/to/bin/oclint)/../lib/clang, $(/path/to/bin/oclint)/../lib/oclint/rules and $(/path/to/bin/oclint)/../lib/oclint/reporters for builtin headers and dynamic libraries by default.

以上两个方法执行完其中1个我们就可以说oclint已经安装完成了,此时在bash中运行oclint应该得到如下提示:

oclint: Not enough positional command line arguments specified!


step 2:通过xcodebuild执行oclint命令
1.在bash中通过cd命令进到需要lint的工程路径下
2.在bash中执行:xcodebuild | tee xcodebuild.log 
(若工程中存在多个不同的target,按照如下格式输入: xcodebuild -target selectedTargetName | tee xcodebuild.log,将需要跑的target名字填入到命令中  )
 此命令调用xcodebuild进行了编译并把相关日志信息输入到xcodebuild.log,该log文件是后续步骤的必要条件,生成在当前的工程目录中.官方解释如下:
We need to save the xcodebuild output to a log file, by convention, name it xcodebuild.log. We can use xcodebuild options | tee xcodebuild.log to pipe every line of the output to xcodebuild.log file.

3.在bash中执行 oclint-xcodebuild xcodebuild.log
此步骤是利用之前的.log文件通过oclint-xcodebuild的可执行文件生成了名为compile_commands.json的json格式文件,该文件应该包含了多组内容,其中的key分别为directory、command、file,该文件不应该为空。此文件是下一步输入的必要条件。

4. 在bash中执行 oclint-json-compilation-database,此步骤是真正执行了lint,执行完应该在终端输出结果。

若希望输出报告到文件中,运行如下命令:
oclint-json-compilation-database -- -o=report.html


官方参考指南:http://docs.oclint.org/en/dev/guide/xcodebuild.html


注意事项:
1.octool 0.7及以前的版本不支持xcode5.
2.在运行前注意执行clean,也可在step2中的第二步执行如下命令:

xcodebuild -dry-run | tee xcodebuild.log 说明如下:

If a source file has been built by xcodebuild, and it’s not been modified since last build, then it might not be compiled again when you invoke xcodebuild the second time. In other words, if it happens, this file won’t be shown in the log. So we won’t see it in the compile_commands.json. To avoid that, use clean build by removing all build products and intermediate files from the build directory.

However, cleaning and building the entire project takes longer time, especially for those big projects. In this case, if file structure hasn’t been changed, and build settings haven’t been modified, then it’s okay to keep the existing xcodebuild.log and compile_commands.json to save time.

If the xcodebuild build can be guaranteed to be successful with the options specified, then we could also use -dry-run option to build the project without actually running the commands, so that we can still capture the xcodebuild log but with reduced time.







Mac系统清理软件有必要安装CleanMyMac吗 Mac电脑怎么彻底清理卸载的软件 Mac电脑相比与其他品牌电脑有着较大优势,例如:流畅的Mac系统,强大的设备互联能力等,所以现在使用Mac电脑的人越来越多。与此同时,对于Mac电脑需不需要清理软件的讨论越来越多,究竟需不需要在Mac上下载一款清理软件呢?卸载软件留下的残留文件又该怎么清理呢?本文就来解答大家关于“Mac系统清理软件有必要安装CleanMyMac吗”的疑问,并且教大家Mac电脑怎么彻底清理卸载的软件。
【奶奶看了也不会】AI绘画 Mac安装stable-diffusion-webui绘制AI妹子保姆级教程 目前网上能搜到的stable-diffusion-webui的安装教程都是Window和Mac M1芯片的,而对于因特尔芯片的文章少之又少,这就导致我们还在用老Intel 芯片的Mac本,看着别人生成美女图片只能眼馋。所以小卷这周末折腾了一天,总算是让老Mac本发挥作用了。
mac安装nvm nvm,全称 node.js version management,就是nodejs版本管理用具,nvm可以快速切换使用不用版本的node。 nodejs,Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境。 Node.js使用了一个事件驱动、非阻塞式I/O的模型( Node.js的特性),使其轻量级又高效 npm,Node Package Manager,nodejs 包管理工具。在安装的 nodejs 的时候,npm 也会跟着一起安装,它是包管理工具。npm 管理 nodejs 中的第三方插件 nvm 管理 nodejs 和 npm 的版
mac安装brew(国内地址,可成功安装!) Brew全称叫Homebrew,是Mac系统上的软件包管理工具。这里的软件并不是指从AppStore或从网上下载的dmg文件,而是开发所需要用的一些工具软件,如gawk等。 只需要一个命令, 安装和卸载它们非常方便。