您的位置:首页 > Web前端

FaceBook/infer-不同构建系统的支持

2015-06-14 16:10 155 查看
Analyzing apps or projects

文件

infer分析文件是通过javac 和clang来编译.当然你也可以使用gcc,但是gcc的内部原理还是使用clang来编译,如果你不使用clang来编译文件,infer是无法分析的.

构建系统

infer支持多个构建系统(buck,gradle,maven,Xcodebuild和Make),而且可以并行的执行编译命令从而让infer变得更快,例如
infer -- make -j8
(不知道make -j8啥意思?自行google).考虑到不同的项目,请尽量使用clean操作在分析前保持项目的纯洁.下面详细说明每一个构建系统的使用方式,如果想查看每个构建系统的命令的使用详细信息,使用如下形式的命令了解.

infer --help -- <build system>


比如我们要了解gradle构建系统:

58deMacBook-Pro:c_hello wuxian$ infer --help -- gradle
usage: infer [-h] [-o <directory>] [-i] [-g] [-a ANALYZER]
[-m <analyzer_mode>] [-nf] [-v] [-j n] [-x <projectname>]
[-r <githash>] [--buck] [--infer_cache <directory>]
[-pr PROJECT_ROOT] [--objc_ml_buckets OBJC_ML_BUCKETS] [-nt]
[-- <cmd>]

optional arguments:
-h, --help            show this help message and exit
-v, --version         Get version of the analyzer

global arguments:
-o <directory>, --out <directory>
Set the Infer results directory
-i, --incremental     Do not delete the results directory across Infer runs
-g, --debug           Generate extra debugging information
-a ANALYZER, --analyzer ANALYZER
Select the analyzer within: compile, capture, infer,
eradicate, checkers, tracing
-m <analyzer_mode>, --analyzer_mode <analyzer_mode>
Select a special analyzer mode such as graphql1 or
graphql2
-nf, --no-filtering   Also show the results from the experimental checks.
Warning: some checks may contain many false alarms

backend arguments:
-j n, --multicore n   Set the number of cores to be used for the analysis
(default uses all cores)
-x <projectname>, --project <projectname>
Project name, for recording purposes only
-r <githash>, --revision <githash>
The githash, for recording purposes only
--buck                To use when run with buck
--infer_cache <directory>
Select a directory to contain the infer cache
-pr PROJECT_ROOT, --project_root PROJECT_ROOT
Location of the project root (default is current
directory)
--objc_ml_buckets OBJC_ML_BUCKETS
memory leak buckets to be checked, separated by
commas. The possible buckets are cf (Core Foundation),
arc, narc (No arc)
-nt, --notest         Prints output of symbolic execution

gradle module:
Run analysis of code built with a command like:
gradle [options] [task]

Analysis examples:
infer -- gradle build
infer -- ./gradlew build

supported compiler/build-system commands:
-- <cmd>              Command to run the compiler/build-system. Supported
build commands (run `infer --help -- <cmd_name>` for
extra help, e.g. `infer --help -- javac`): buck, gcc,
xcodebuild, javac, cc, make, gradlew, g++, clang,
gradle, ant, clang++, analyze, mvn


目前支持的构建系统:

buck, gcc,xcodebuild, javac, cc, make, gradlew, g++, clang,gradle, ant, clang++, analyze, mvn


Gradle

两种方式可以分析gradle构建的项目

gradle

gradlew

infer -- gradle <gradle task, e.g. "build">
infer -- ./gradlew <gradle task, e.g. "build">


后面的任务不局限与build,如果你想分析测试代码,可能使用的就是test.

Buck

infer -- buck <buck target>


Maven

infer -- mvn <maven target>


XcodeBuild

infer支持分析xcodebuild构建的app,但是只支持分析
.m
.c
文件,自动忽略
.cpp
,
.mm
,
.cc
文件后缀的文件.

infer -- xcodebuild -target <target name> -configuration <build configuration> -sdk iphonesimulator


Make

infer支持分析Make构建系统,但是会忽略
C++
文件

infer -- make <make target>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: