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

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值