简体   繁体   English

如果未安装,如何绕过IncrediBuild控制台?

[英]How to bypass IncrediBuild console if not installed?

There are some bash scripts running on our build machines where IncrediBuild is installed. 在安装IncrediBuild的构建计算机上运行着一些bash脚本。 The idea of IncrediBuild is to utilize all cores available in the network to speed up the build process. IncrediBuild的想法是利用网络中可用的所有内核来加快构建过程。

Example shell script: 外壳脚本示例:

...
ib_console cmake --build .

The shell script shall not be changed. 外壳脚本不得更改。 I would like to run the script on machines without ib_console. 我想在没有ib_console的机器上运行脚本。 Is there a possibility to somehow simulate it or forward the call to cmake ? 有可能以某种方式模拟它或将调用转发给cmake吗?

Place this into your .bashrc file: 将其放入您的.bashrc文件中:

if [ ! -f ´whereis ib_console´ ] then
    alias ib_console='$@'
fi

Explanation: 说明:

  • -f checks, whether the ib_console binary exists -f检查ib_console二进制文件是否存在
  • $@ take all arguments into one single string (they are then executed standalone) $ @将所有参数合并为一个字符串(然后独立执行)

@alex: the alias works from the shell but not in the shell script above since aliases are not expanded in non interactive shell scripts. @alex:别名可在外壳程序中使用,但不能在上面的外壳程序脚本中使用,因为在非交互式外壳程序脚本中不会扩展别名。

With Why doesn't my Bash script recognize aliases? 为什么我的Bash脚本无法识别别名? I could fix it. 我可以解决。

if ! [ -f 'whereis ib_console' ]; then
    ib_console()
    {
        echo "ib_console dummy: run '$@'..."
        $@
        echo "ib_console dummy: done"
    }
    export -f ib_console
fi

It is recommended to run 'exec bash' after updating .bashrc 建议在更新.bashrc之后运行'exec bash'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM