FaceBooK/infer-Mac下安装Java分析环境

来源:互联网 发布:mac版谷歌dhc插件下载 编辑:程序博客网 时间:2024/05/16 16:20

将github上的源码download到本地后,一步一步往下看.
Mac OS X :10.10.2

Python版本

首先安装Python,版本要高于2.7,包括2.7.

58deMacBook-Pro:infer wuxian$ python -VPython 2.7.6

由于Mac OS X自带Python,所以一般都无需安装,如果你没有,请自行安装.

Opam安装

(OCaml环境支持)

使用brew install opam 命令安装:

58deMacBook-Pro:infer wuxian$ sudo brew install opam Password:==> Installing dependencies for opam: objective-caml, camlp4, boost, cmak==> Installing opam dependency: objective-caml==> Downloading https://homebrew.bintray.com/bottles/objective-caml-4.02.1_2.yos######################################################################## 100.0%==> Pouring objective-caml-4.02.1_2.yosemite.bottle.1.tar.gz��  /usr/local/Cellar/objective-caml/4.02.1_2: 776 files,  75M==> Installing opam dependency: camlp4==> Downloading https://homebrew.bintray.com/bottles/camlp4-4.02.1+2.yosemite.bo######################################################################## 100.0%==> Pouring camlp4-4.02.1+2.yosemite.bottle.tar.gz��  /usr/local/Cellar/camlp4/4.02.1+2: 164 files, 180M==> Installing opam dependency: boost==> Downloading https://homebrew.bintray.com/bottles/boost-1.57.0.yosemite.bottl######################################################################## 100.0%==> Pouring boost-1.57.0.yosemite.bottle.tar.gz��  /usr/local/Cellar/boost/1.57.0: 10572 files, 439M==> Installing opam dependency: cmake==> Downloading https://homebrew.bintray.com/bottles/cmake-3.2.1.yosemite.bottle######################################################                    75.9%curl: (56) SSLRead() return error -9806Error: Failed to download resource "cmake"Download failed: https://homebrew.bintray.com/bottles/cmake-3.2.1.yosemite.bottle.2.tar.gzWarning: Bottle installation failed: building from source.==> Downloading http://www.cmake.org/files/v3.2/cmake-3.2.1.tar.gz######################################################################## 100.0%==> Downloading https://pypi.python.org/packages/source/S/Sphinx/Sphinx-1.2.3.ta######################################################################## 100.0%==> python -c import setuptools... --no-user-cfg install --prefix=/private/tmp/c==> Downloading https://pypi.python.org/packages/source/d/docutils/docutils-0.12######################################################################## 100.0%==> python -c import setuptools... --no-user-cfg install --prefix=/private/tmp/c==> Downloading https://pypi.python.org/packages/source/P/Pygments/Pygments-2.0.######################################################################## 100.0%==> python -c import setuptools... --no-user-cfg install --prefix=/private/tmp/c==> Downloading https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.ta######################################################################## 100.0%==> python -c import setuptools... --no-user-cfg install --prefix=/private/tmp/c==> Downloading https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-######################################################################## 100.0%==> python -c import setuptools... --no-user-cfg install --prefix=/private/tmp/c==> ./bootstrap --prefix=/usr/local/Cellar/cmake/3.2.1 --no-system-libs --parall==> make==> make install��  /usr/local/Cellar/cmake/3.2.1: 1847 files,  32M, built in 14.2 minutes==> Installing opam dependency: re2c==> Downloading https://homebrew.bintray.com/bottles/re2c-0.14.1.yosemite.bottle######################################################################## 100.0%==> Pouring re2c-0.14.1.yosemite.bottle.tar.gz��  /usr/local/Cellar/re2c/0.14.1: 5 files, 364K==> Installing opam dependency: gringo==> Downloading https://homebrew.bintray.com/bottles/gringo-4.4.0_1.yosemite.bot######################################################################## 100.0%==> Pouring gringo-4.4.0_1.yosemite.bottle.tar.gz��  /usr/local/Cellar/gringo/4.4.0_1: 7 files, 5.2M==> Installing opam dependency: clasp==> Downloading https://homebrew.bintray.com/bottles/clasp-3.1.1.yosemite.bottle######################################################################## 100.0%==> Pouring clasp-3.1.1.yosemite.bottle.tar.gz��  /usr/local/Cellar/clasp/3.1.1: 5 files, 1.0M==> Installing opam dependency: aspcud==> Downloading https://downloads.sourceforge.net/project/potassco/aspcud/1.9.0/######################################################################## 100.0%==> Patchingpatching file libcudf/src/dependency.cpp==> cmake .. -DGRINGO_LOC=/usr/local/opt/gringo/bin/gringo -DCLASP_LOC=/usr/loca==> make==> make install��  /usr/local/Cellar/aspcud/1.9.0: 10 files, 536K, built in 27 seconds==> Installing opam==> Downloading https://homebrew.bintray.com/bottles/opam-1.2.1.yosemite.bottle.#################################################                         68.7%curl: (56) SSLRead() return error -36Error: Failed to download resource "opam"Download failed: https://homebrew.bintray.com/bottles/opam-1.2.1.yosemite.bottle.tar.gzWarning: Bottle installation failed: building from source.==> Downloading https://github.com/ocaml/opam/archive/1.2.1.tar.gz######################################################################## 100.0%==> Downloading https://gforge.inria.fr/frs/download.php/file/33593/cudf-0.7.tar######################################################################## 100.0%==> Downloading http://ocaml-extlib.googlecode.com/files/extlib-1.5.3.tar.gz######################################################################## 100.0%==> Downloading https://github.com/ocaml/ocaml-re/archive/ocaml-re-1.2.0.tar.gz######################################################################## 100.0%==> Downloading http://ocamlgraph.lri.fr/download/ocamlgraph-1.8.5.tar.gz######################################################################## 100.0%==> Downloading https://gforge.inria.fr/frs/download.php/file/34277/dose3-3.3.ta######################################################################## 100.0%==> Downloading http://erratique.ch/software/cmdliner/releases/cmdliner-0.9.7.tb######################################################################## 100.0%==> Downloading http://erratique.ch/software/uutf/releases/uutf-0.9.3.tbz######################################################################## 100.0%==> Downloading http://erratique.ch/software/jsonm/releases/jsonm-0.9.1.tbz######################################################################## 100.0%==> ./configure --prefix=/usr/local/Cellar/opam/1.2.1 --mandir=/usr/local/Cellar==> make lib-ext==> make==> make man==> make install==> CaveatsOPAM uses ~/.opam by default for its package database, so you need toinitialize it first by running (as a normal user):$  opam initRun the following to initialize your environment variables:$  eval `opam config env`To export the needed variables every time, add them to your dotfiles.  * On Bash, add them to `~/.bash_profile`.  * On Zsh, add them to `~/.zprofile` instead.Documentation and tutorials are available at https://opam.ocaml.org, orvia 'man opam' and 'opam --help'.Bash completion has been installed to:  /usr/local/etc/bash_completion.dzsh completion has been installed to:  /usr/local/share/zsh/site-functions==> Summary��  /usr/local/Cellar/opam/1.2.1: 30 files,  19M, built in 2.3 minutes

Java版本

Java版本的要求是1.8以下都可以,不支持1.8.好在我的环境是1.6.

58deMacBook-Pro:~ wuxian$ java -versionjava version "1.6.0_65"Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

Android开发环境

  • SDK
  • Eclipse/Android Studio

我选择了Android Studio的IDE.

安装OCaml依赖

opam init –comp=4.01.0

58deMacBook-Pro:infer wuxian$ opam init --comp=4.01.0Checking for available remotes: rsync and local, git.  - you won't be able to use mercurial repositories unless you install the hg    command on your system.  - you won't be able to use darcs repositories unless you install the darcs    command on your system.=-=- Fetching repository information =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=Processing: [default: http]http[default] synchronized from https://opam.ocaml.org=-=- Installing compiler 4.01.0 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=Processing: [4.01.0: http]y[compiler.get] http://caml.inria.fr/pub/distrib/ocaml-4.01/ocaml-4.01.0.tar.gz downloadedNow compiling OCaml. This may take a while, please bear with us...Done.[ERROR] At        ~/.opam/repo/default/packages/lwt-parallel/lwt-parallel.0.1.0/opam:2:19:          Unexpected name lwt_parallel[WARNING] conflict is an unknown field in          /Users/wuxian/.opam/repo/default/packages/mirage/mirage.2.4.0/opam.=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=∗  installed base-bigarray.base∗  installed base-threads.base∗  installed base-unix.baseDone.In normal operation, OPAM only alters files within ~/.opam.During this initialisation, you can allow OPAM to add information to twoother files for best results. You can also make these additions manuallyif you wish.If you agree, OPAM will modify:  - ~/.bash_profile (or a file you specify) to set the right environment    variables and to load the auto-completion scripts for your shell (bash)    on startup. Specifically, it checks for and appends the following line:    . /Users/wuxian/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true  - ~/.ocamlinit to ensure that non-system installations of `ocamlfind`    (i.e. those installed by OPAM) will work correctly when running the    OCaml toplevel. It does this by adding $OCAML_TOPLEVEL_PATH to the list    of include directories.If you choose to not configure your system now, you can either configureOPAM manually (instructions will be displayed) or launch the automatic setuplater by running:   opam config setup -aDo you want OPAM to modify ~/.bash_profile and ~/.ocamlinit?(default is 'no', use 'f' to name a file other than ~/.bash_profile)    [N/y/f] Global configuration:  Updating ~/.opam/opam-init/init.sh  Updating ~/.opam/opam-init/init.zsh  Updating ~/.opam/opam-init/init.csh  Updating ~/.opam/opam-init/init.fish=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=1. To configure OPAM in the current shell session, you need to run:      eval `opam config env`2. To correctly configure OPAM for subsequent use, add the following   line to your profile file (for instance ~/.bash_profile):      . /Users/wuxian/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true3. To avoid issues related to non-system installations of `ocamlfind`   add the following lines to ~/.ocamlinit (create it if necessary):      let () =        try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")        with Not_found -> ()      ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=58deMacBook-Pro:infer wuxian$ opam init --comp=4.01.0OPAM has already been initialized.[ERROR] At        ~/.opam/repo/default/packages/lwt-parallel/lwt-parallel.0.1.0/opam:2:19:          Unexpected name lwt_parallel[WARNING] conflict is an unknown field in          /Users/wuxian/.opam/repo/default/packages/mirage/mirage.2.4.0/opam.In normal operation, OPAM only alters files within ~/.opam.During this initialisation, you can allow OPAM to add information to twoother files for best results. You can also make these additions manuallyif you wish.If you agree, OPAM will modify:  - ~/.bash_profile (or a file you specify) to set the right environment    variables and to load the auto-completion scripts for your shell (bash)    on startup. Specifically, it checks for and appends the following line:    . /Users/wuxian/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true  - ~/.ocamlinit to ensure that non-system installations of `ocamlfind`    (i.e. those installed by OPAM) will work correctly when running the    OCaml toplevel. It does this by adding $OCAML_TOPLEVEL_PATH to the list    of include directories.If you choose to not configure your system now, you can either configureOPAM manually (instructions will be displayed) or launch the automatic setuplater by running:   opam config setup -aDo you want OPAM to modify ~/.bash_profile and ~/.ocamlinit?(default is 'no', use 'f' to name a file other than ~/.bash_profile)    [N/y/f] yUser configuration:  Generating ~/.ocamlinit.  Updating ~/.bash_profile.Global configuration:  ~/.opam/opam-init/init.sh is already up-to-date.  ~/.opam/opam-init/init.zsh is already up-to-date.  ~/.opam/opam-init/init.csh is already up-to-date.  ~/.opam/opam-init/init.fish is already up-to-date.# To setup the new switch in the current shell, you need to run:eval `opam config env`

opam install sawja.1.5 atdgen.1.5.0 javalib.2.3 extlib.1.5.4

tlib.1.5.4[ERROR] At        ~/.opam/repo/default/packages/lwt-parallel/lwt-parallel.0.1.0/opam:2:19:          Unexpected name lwt_parallel[WARNING] conflict is an unknown field in          /Users/wuxian/.opam/repo/default/packages/mirage/mirage.2.4.0/opam.The following actions will be performed:  ∗  install camlp4      4.01.0               [required by extlib]  ∗  install ocamlfind   1.5.5                [required by javalib, atdgen, extlib, sawja]  ∗  install menhir      20140422             [required by atd]  ∗  install extlib      1.5.4     ∗  install easy-format 1.0.2                [required by biniou, atd, yojson]  ∗  install cppo        1.1.2                [required by yojson]  ∗  install camlzip     1.05                 [required by javalib]  ∗  install biniou      1.0.9                [required by atdgen]  ∗  install atd         1.1.2                [required by atdgen]  ∗  install javalib     2.3       ∗  install yojson      1.2.1                [required by atdgen]  ∗  install sawja       1.5       ∗  install atdgen      1.5.0   ===== ∗  13 =====Do you want to continue ? [Y/n] y=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=[default] https://opam.ocaml.org/archives/biniou.1.0.9+opam.tar.gz downloaded[default] https://opam.ocaml.org/archives/atd.1.1.2+opam.tar.gz downloaded[default] https://opam.ocaml.org/archives/cppo.1.1.2+opam.tar.gz downloaded[default] https://opam.ocaml.org/archives/camlzip.1.05+opam.tar.gz downloaded[default] https://opam.ocaml.org/archives/atdgen.1.5.0+opam.tar.gz downloaded[default] https://opam.ocaml.org/archives/easy-format.1.0.2+opam.tar.gz downloaded[default] https://opam.ocaml.org/archives/extlib.1.5.4+opam.tar.gz downloaded[default] https://opam.ocaml.org/archives/ocamlfind.1.5.5+opam.tar.gz downloaded[default] https://opam.ocaml.org/archives/javalib.2.3+opam.tar.gz downloaded[default] https://opam.ocaml.org/archives/menhir.20140422+opam.tar.gz downloaded[default] https://opam.ocaml.org/archives/yojson.1.2.1+opam.tar.gz downloaded[default] https://opam.ocaml.org/archives/sawja.1.5+opam.tar.gz downloaded=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=∗  installed camlp4.4.01.0∗  installed ocamlfind.1.5.5∗  installed easy-format.1.0.2∗  installed camlzip.1.05∗  installed biniou.1.0.9∗  installed cppo.1.1.2∗  installed yojson.1.2.1∗  installed extlib.1.5.4∗  installed javalib.2.3∗  installed menhir.20140422∗  installed atd.1.1.2∗  installed sawja.1.5∗  installed atdgen.1.5.0Done.

最后一步

先切换到infer源码根目录,(由于我已经切换过了,这里就不在切换),然后继续执行:

58deMacBook-Pro:infer wuxian$ make -C infer javamake -C src java/bin/sh: line 0: cd: /Users/wuxian/Documents/sourcecode/self/infer/../facebook-clang-plugin: No such file or directory/bin/sh: line 0: cd: /Users/wuxian/Documents/sourcecode/self/infer/../facebook-clang-plugin: No such file or directory/bin/sh: line 0: cd: /Users/wuxian/Documents/sourcecode/self/infer/../facebook-clang-plugin: No such file or directorysed -e 's/@MAJOR@/0/g' \        -e 's/@MINOR@/1/g' \        -e 's/@PATCH@/0/g' \        -e 's/@GIT_COMMIT@/2bce7c6c3dbb22646e2d67a2c6ade77f060b4bca/g' \        -e 's/@GIT_BRANCH@/master/g' \        -e 's/@GIT_TAG@//g' \        backend/version.ml.in > backend/version.mlmkdir -p ../_build-inferatdgen -t backend/jsonbug.atd -o backend/jsonbugmake[1]: atdgen: No such file or directorymake[1]: *** [backend/jsonbug_t.ml] Error 1make: *** [java] Error 2
0 0