android ndk-build IncrediBuild 分布式编译设置

时间:2021-12-28 05:33:44

以前只知道IncrediBuild可以通过分布式加速vs的编译, 近来才发现, 此工具还是很强大的, android 的 ndk 也能用它来作加速处理(windows环境)

操作如下:

1.安装此软件并设置环境变量

2.修改 android-ndk 目录下的 ndk-build.cmd 文件 把其中的

"%NDK_ROOT%prebuilt/%NDK_WIN_HOST%/bin/make.exe" -f "%NDK_ROOT%build/core/build-local.mk" SHELL=cmd %*

修改为

XGConsole /command="%NDK_ROOT%prebuilt/%NDK_WIN_HOST%/bin/make.exe -f %NDK_ROOT%build/core/build-local.mk SHELL=cmd %*" /profile=Profile.xml


然后保存即可

3.在你的工程目录也就是在执行 ndk-build 命令的目录下 编写 Profile.xml 文件

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>  
<Profile FormatVersion="1">  
    <Tools>  
        <Tool Filename="make" AllowIntercept="true" />  
        <Tool Filename="cl" AllowRemote="true" />  
        <Tool Filename="link" AllowRemote="true" />  
        <Tool Filename="gcc" AllowRemote="true" />  
        <Tool Filename="gcc-3" AllowRemote="true" />  
        <Tool Filename="arm-linux-androideabi-g++" AllowRemote="true" />
        <Tool Filename="arm-linux-androideabi-gcc" AllowRemote="true" />  
    </Tools>  
</Profile> 
其中的 arm-linux-androideabi-gcc 等, 为 mk 中编译代码要用的工具的, 可以根据工程需要来添加或者删除 


4. 然后命令行编译的时候输入 ndk-build -j20 , 这时候就可以同时最多调用20个核心来编译你的工程了(当然前提是你的分式环境得有这么多电脑android ndk-build IncrediBuild 分布式编译设置, 哦,还有记得 ndk-build 所在目录也要添加到环境变量中)