• bazel 测试过程


    google的bazel如日中天,尽管我觉得make已经很好用,但是还是尝试一下,记录之。

    首先,从 https://github.com/bazelbuild/bazel/releases 下载对应的bazel 文件,
    我下载的版本是:0.5.2
    三个文件:
    200 MBbazel-0.5.2-installer-linux-x86_64.sh
    104 Bytesbazel-0.5.2-installer-linux-x86_64.sh.sha256
    543 Bytesbazel-0.5.2-installer-linux-x86_64.sh.sig

    安装:
    [root@centos7 tensorflow_test]# chmod +x bazel-0.5.2-installer-linux-x86_64.sh
    [root@centos7 tensorflow_test]# ./bazel-0.5.2-installer-linux-x86_64.sh

    看到如下打印,安装相当快。
    Bazel is now installed!

    Make sure you have "/usr/local/bin" in your path. You can also activate bash
    completion by adding the following line to your ~/.bashrc:
    source /usr/local/lib/bazel/bin/bazel-complete.bash

    See http://bazel.build/docs/getting-started.html to start a new project!


    下一步,参考help文件:
    https://docs.bazel.build/versions/master/tutorial/cpp.html

    下载examples文件:
    [root@centos7 examples-master]# ls
    AUTHORS CONTRIBUTING.md CONTRIBUTORS cpp-tutorial java-maven java-tutorial LICENSE.txt README.md rules tutorial

    进入路径:
    [root@centos7 stage1]# pwd
    /home/caq/code/bazelbuild/examples-master/cpp-tutorial/stage1

    编译,看起来也不快,与期望值不相符合啊:
    [root@centos7 stage1]# bazel build //main:hello-world
    WARNING: ignoring http_proxy in environment.
    ..................................................................................................................
    INFO: Found 1 target...
    Target //main:hello-world up-to-date:
    bazel-bin/main/hello-world
    INFO: Elapsed time: 14.059s, Critical Path: 0.84s

    执行:
    [root@centos7 stage1]# ./bazel-bin/main/hello-world
    Hello world

    分析依赖图:
    bazel query --nohost_deps --noimplicit_deps 'deps(//main:hello-world)'
    --output graph

    WARNING: ignoring http_proxy in environment.
    digraph mygraph {
    node [shape=box];
    "//main:hello-world"
    "//main:hello-world" -> "//main:hello-world.cc" 这个说明只依赖于.cc文件
    "//main:hello-world.cc"
    }

    好,进一步的,增加依赖,进入starge2
    [root@centos7 main]# pwd
    /home/caq/code/bazelbuild/examples-master/cpp-tutorial/stage2/main

    [root@centos7 main]# bazel build //main:hello-world
    WARNING: ignoring http_proxy in environment.
    ..................................................................................................................
    INFO: Found 1 target...
    Target //main:hello-world up-to-date:
    bazel-bin/main/hello-world
    INFO: Elapsed time: 13.470s, Critical Path: 0.35s

    执行bin文件测试:
    [root@centos7 stage2]# ./bazel-bin/main/hello-world
    Thu Jul 27 19:49:41 2017

    发现源文件少了一行代码,补上之后结果:
    [root@centos7 stage2]# bazel-bin/main/hello-world
    Hello world
    Thu Jul 27 19:56:21 2017
    [root@centos7 stage2]# bazel-bin/main/hello-world hahaha
    Hello hahaha
    Thu Jul 27 19:56:25 2017
    [root@centos7 stage2]# bazel-bin/main/hello-world caq
    Hello caq
    Thu Jul 27 19:56:29 2017


    那么,多个依赖怎么写?

    [root@centos7 stage3]# pwd
    /home/caq/code/bazelbuild/examples-master/cpp-tutorial/stage3
    [root@centos7 stage3]# bazel build //main:hello-world
    WARNING: ignoring http_proxy in environment.
    ..................................................................................................................
    INFO: Found 1 target...
    Target //main:hello-world up-to-date:
    bazel-bin/main/hello-world
    INFO: Elapsed time: 13.557s, Critical Path: 0.35s


    [root@centos7 stage3]# bazel-bin/main/hello-world
    Hello world
    Thu Jul 27 19:59:20 2017
    [root@centos7 stage3]# bazel-bin/main/hello-world caq
    Hello caq
    Thu Jul 27 19:59:23 2017


    如果有疑问,可以直接从https://docs.bazel.build/versions/master/tutorial/cpp.html找到答案。
    完毕。

    水平有限,如果有错误,请帮忙提醒我。如果您觉得本文对您有帮助,可以点击下面的 推荐 支持一下我。版权所有,需要转发请带上本文源地址,博客一直在更新,欢迎 关注 。
  • 相关阅读:
    30分钟掌握ES6/ES2015核心内容[上和下], 不错的说
    根据HTML5 获取当前位置的经纬度【百度地图】【高德地图】
    vue2 入门 教程 单页应用最佳实战[*****]
    JavaScript如何比较两个数组的内容是否相同【转】
    推荐下:开源ckplayer 网页播放器, 跨平台(html5, mobile),flv, f4v, mp4, rtmp协议. webm, ogg, m3u8 !
    浅谈 Underscore.js 中 _.throttle 和 _.debounce 的差异[转]
    原生JavaScript插件开发[转]
    性能监控之Spotlight
    Jmeter(三十五)聚合报告
    Jmeter(三十四)Jmeter-Question之“Cookie获取”
  • 原文地址:https://www.cnblogs.com/10087622blog/p/7246843.html
Copyright © 2020-2023  润新知