IncrediBuild 联合编译

15 篇文章 0 订阅

01 基本信息

官网: https://www.incredibuild.com

Make 和其他构建工具示例

要使用IncrediBuild,必须有License,可以免费申请试用版本的license。
可以到 https://www.incredibuild.com/free-trial-2 去申请30天免费 的 license,申请时需要手机号码和邮件。申请后可以下载安装包。也可以直接使用 visual studio 2019 安装包中的 incredibuild。

01.01 安装方法

01.01.01 使用独立安装包的安装
截至20210624,最新版本是9.50(incredibuild9_50.exe)。

选择 Custom 中的 客户端【Incredibuild Agent】 和 服务端【IncrediBuild coordinator】。

Incredibuild Agent 是联合编译的客户端,可以参与发起联合编译请求和为其他联合编译请求贡献cpu算力。

Incredibuild Coordinator 是联合编译服务端。用来管理和协调联合编译。

visual studio 2019

01.01.02 使用vs安装包安装(推荐)

选择 vs安装的 单个组件 ⇒ 编译器、生成工具和运行时 ⇒ IncrediBuild - 生成加速。这个选项直接包含 [Incredibuild Agent] 和 [IncrediBuild coordinator]。

注意,IncrediBuidl,用vs安装,需要用vs卸载。
使用 vs 单个组件安装时,建议安装 英文语言包。

在这里插入图片描述
安装后效果:
系统托盘菜单

VS扩展插件菜单

02 配置信息

详细配置信息可以参考官方文档
https://incredibuild.atlassian.net/wiki/spaces/IUM/pages/11239495/Make+and+Other+Build+Tools+Samples

02.01 导入license文件

选择 [Coordinator Settings] 菜单,在 [ Coordinator Settings] 窗口选择 [License] 列表。点击 [Load License File]按钮,导入自己的License文件。

当不需要该license文件时,点击 [Unload License] 按钮,卸载该 license 文件即可。

导入license文件

02.02 客户端和服务端配置

Agent设置:
[Agent Settings] ==> [Newwork] ==> [Coordinator] ==> [Coordinator Location]
设置 Computer 为 [Coordinator] 的固定IP地址或者 [Coordinator] 的主机名称,即指定服务端的IP地址或者主机名称。
Port端口号:默认 31104
点击 [Test] 按钮,测试连通性

注意:[Initiator] ==> [General] ==> [Enable standalone mode] 这个选项在联合编译时,不要勾选。

准备联合编译时,不要启动 启用独立模式

Coordinator 端设置

端口号使用默认的 31104 即可。
设置服务端端口号
服务端只要设置了License就可以。
[Coordinator Settings] 设置 License ,主要是导入申请到的许可文件。其他项使用默认值即可。

加载License

03 编译设置

03. 01使用 vs2019 中的扩展中 [IncrediBuild] 菜单

使用管理员权限启动vs2019,选择菜单 [扩展] ==> [IncrediBuild] ==> [Build Solution] 即可编译。

03.02 使用命令行

比如 使用cygwin64编译:

::官网参考资料
:: https://incredibuild.atlassian.net/wiki/spaces/IUM/pages/11239495/Make+and+Other+Build+Tools+Samples
:: IncrediBuild 安装包中的参考
:: vs的 nmake 命令
:: C:\Program Files (x86)\IncrediBuild\Samples\Make And Build Tools\Nmake
:: make 命令
:: C:\Program Files (x86)\IncrediBuild\Samples\Make And Build Tools\Make
set cygwindir=D:\cygwin64
set PATH=%cygwindir%\opt\lo\bin;%cygwindir%\bin;%cygwindir%\sbin;%cygwindir%\usr\bin;%cygwindir%\usr\sbin;%cygwindir%\usr\local\bin;%PATH%;
BuildConsole /command="make -rs -f Makefile build" /openmonitor /title="MakeXXXX"

03.03 在 Coordinator Monitor 设置 agent属性

可以在每个agent上面右键菜单中设置属性,比如:建立分组(同组内联合编译),停止订阅、取消订阅、启用、禁用、授予管理员权限等。

04 一些问题

参考:利用IncrediBuild加速NDK编译

04.01 CompareStringA
IncrediBuild : Error: Attempt to call unsupported import function CompareStringA

去掉-j200之后保持现状; 去掉SHELL=cmd之后居然就没这个错了。
怀疑这个是IB自己的BUG…传入的/COMMAND参数里如果带=就会出这个问题,令人智熄。后来验证了下确实是这样,因为传入NDK-DEBUG=1也是一模一样的下场。

04.02 job server
make: INTERNAL: Exiting with 64 jobserver tokens available; should be 1024!

搜了下有人遇到过一样的问题 Make (Parallel Jobs) on Windows

I found this Danny Thorpe’s blog entry that explains the problems with parallel make build on Windows. Basically what it suggests is to set the following environment variable first:
set SHELL=cmd.exe

一路跟进去看了下大致的解释,这就很难搞了…如果不设置SHELL=cmd就无法并行编译,如果设置了就报上一个错。

我一开始试图找除了命令行传参之外有没有其他方法,但是官方文档Choosing the Shell讲的很绝情:

Unlike most variables, the variable SHELL is never set from the environment.

既然改不了IB本身,那就只能对make下手了——首先看下自带的make版本信息

D:\SDK\android-ndk-r21b\prebuilt\windows-x86_64\bin>make --version
GNU Make 4.2.1
Built for x86_64-w64-mingw32
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

OK, 去官网下载对应make 4.2.1,解压之后在Developer Command Prompt for VS 2019里运行build_w32.bat。替换进去发现没啥问题:

D:\SDK\android-ndk-r21b\prebuilt\windows-x86_64\bin>make --version
GNU Make 4.2.1
Built for Windows32
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

强制设置SHELL
翻了下代码发现默认的shell使用的是sh.exe,这里直接改成cmd.exe即可。

--- job.c	Sun May 22 04:22:32 2016
+++ job.c	Tue Mar  2 18:46:55 2021
@@-31,7+31,7@@
 #ifdef WINDOWS32
 #include <windows.h>
 
-const char *default_shell = "sh.exe";
+const char *default_shell = "cmd.exe";
 int no_default_sh_exe = 1;
 int batch_mode_shell = 1;
 HANDLE main_thread;

IB传入参数应该是-j1024,但是windows版本使用的是信号量所以不能超过MAXIMUM_WAIT_OBJECTS即64,所以导致了问题的发生。找到根源之后就好办了:

--- main.c	Tue May 31 15:17:26 2016
+++ main.c	Tue Mar  2 18:57:39 2021
@@-2058,6+2058,7@@
      submakes it's the token they were given by their parent.  For the top
      make, we just subtract one from the number the user wants.  */
 
+  if (job_slots >= MAXIMUM_WAIT_OBJECTS) job_slots = MAXIMUM_WAIT_OBJECTS - 1;
   if (job_slots > 1 && jobserver_setup (job_slots - 1))
     {
       /* Fill in the jobserver_auth for our children.  */
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值