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

来源:互联网 发布:磁力解析在线播放软件 编辑:程序博客网 时间:2024/05/16 14:05

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 -- gradleusage: 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 analyzerglobal 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 alarmsbackend 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 executiongradle module:  Run analysis of code built with a command like:  gradle [options] [task]  Analysis examples:  infer -- gradle build  infer -- ./gradlew buildsupported 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>

0 0
原创粉丝点击