Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distributed compilation support #274

Closed
14 tasks done
waruqi opened this issue Dec 5, 2018 · 1 comment
Closed
14 tasks done

Distributed compilation support #274

waruqi opened this issue Dec 5, 2018 · 1 comment

Comments

@waruqi
Copy link
Member

waruqi commented Dec 5, 2018

Features

  • Cross-platform support
  • Support msvc, clang, gcc and cross-compilation
  • Support to build android, ios, linux, win, macOS programs
  • No dependencies other than the compilation toolchain
  • Support for load balancing scheduling
  • Support for real-time large file compression transfer (use lz4)
  • Almost zero configuration cost, no shared file system required, more convenient and secure

支持特性

  • 跨平台支持
  • 支持 msvc, clang, gcc 和交叉编译工具链
  • 支持构建 android, ios, linux, win, macOS 程序
  • 除了编译工具链,无任何其他依赖
  • 支持编译服务器负载均衡调度
  • 支持大文件实时压缩传输 (lz4)
  • 几乎零配置成本,无需共享文件系统,更加方便和安全

Auto-generate server/client configuration.

$ xmake service
generating the config file to /Users/ruki/.xmake/service/server.conf ..
an token(590234653af52e91b9e438ed860f1a2b) is generated, we can use this token to connect service.
generating the config file to /Users/ruki/.xmake/service/client.conf ..
<remote_build_server>: listening 0.0.0.0:9691 ..
<distcc_build_server>: listening 0.0.0.0:9692 ..
$ cat ~/.xmake/service/server.conf 
{
    distcc_build = {
        listen = "0.0.0.0:9692",
        toolchains = {
            ndk = { }
        },
        workdir = "/Users/ruki/.xmake/service/server/distcc_build"
    },
    known_hosts = { },
    logfile = "/Users/ruki/.xmake/service/server/logs.txt",
    tokens = {
        "590234653af52e91b9e438ed860f1a2b"
    }
}
$cat ~/.xmake/service/client.conf 
{
    distcc_build = {
        hosts = {
            {
                connect = "127.0.0.1:9692",
                token = "590234653af52e91b9e438ed860f1a2b"
            }
        }
    }
}

Start service

$ xmake service
<distcc_build_server>: listening 0.0.0.0:9692 ..

Start server as daemon

$ xmake service --start

Connect project to server

$ cd projectdir
$ xmake service --connect --distcc
<client>: connect 127.0.0.1:9692 ..
<client>: 127.0.0.1:9692 connected!

Build project for distributed build

$ xmake
...
[ 93%]: ccache compiling.release src/demo/network/unix_echo_client.c         ----> local job
[ 93%]: ccache compiling.release src/demo/network/ipv6.c
[ 93%]: ccache compiling.release src/demo/network/ping.c
[ 93%]: distcc compiling.release src/demo/network/unix_echo_server.c.         ----> distcc job
[ 93%]: distcc compiling.release src/demo/network/http.c
[ 93%]: distcc compiling.release src/demo/network/unixaddr.c
[ 93%]: distcc compiling.release src/demo/network/ipv4.c
[ 94%]: distcc compiling.release src/demo/network/ipaddr.c
[ 94%]: distcc compiling.release src/demo/math/fixed.c
[ 94%]: distcc compiling.release src/demo/libm/float.c
[ 95%]: ccache compiling.release src/demo/libm/double.c
[ 95%]: ccache compiling.release src/demo/other/test.cpp
[ 98%]: archiving.release libtbox.a
[ 99%]: linking.release demo
[100%]: build ok!

Default jobs count

the default jobs count of cpu core

local default_njob = math.ceil(ncpu * 3 / 2)

the max jobs counts

local maxjobs = local_maxjobs + server_maxjobs (server count * default_njob)

Modify local jobs count

$ xmake -jN

Modify server jobs count

$cat ~/.xmake/service/client.conf 
{
    distcc_build = {
        hosts = {
            {
                connect = "127.0.0.1:9692",
                token = "590234653af52e91b9e438ed860f1a2b",
                njob = 8   <------- modify here
            },
            {
                connect = "192.168.01:9692",
                token = "590234653af52e91b9e438ed860f1a2b",
                njob = 4
            }
        }
    }
}

Build android project

We need set NDK root path in server

$ cat ~/.xmake/service/server.conf 
{
    distcc_build = {
        listen = "0.0.0.0:9692",
        toolchains = {
            ndk = {
                ndk = "~/files/android-ndk-r21e"   <------------ here
            }
        },
        workdir = "/Users/ruki/.xmake/service/server/distcc_build"
    },
    known_hosts = { },
    logfile = "/Users/ruki/.xmake/service/server/logs.txt",
    tokens = {
        "590234653af52e91b9e438ed860f1a2b"
    }
}

Build project

$ xmake f -p android --ndk=~/files/xxxx
$ xmake

Cross-compilation

We need set cross-compilation toolchain sdk path in server

$ cat ~/.xmake/service/server.conf 
{
    distcc_build = {
        listen = "0.0.0.0:9692",
        toolchains = {
            cross = {
                sdkdir = "~/files/xxxx/sdk"   <------------ here
            }
        },
        workdir = "/Users/ruki/.xmake/service/server/distcc_build"
    },
    known_hosts = { },
    logfile = "/Users/ruki/.xmake/service/server/logs.txt",
    tokens = {
        "590234653af52e91b9e438ed860f1a2b"
    }
}

Build project

$ xmake f -p cross --sdk=~/files/xxxx
$ xmake

we can also set other configurations, e.g. bindir, cross

cross = {
    sdkdir = "~/files/xxxx/sdk",
    bindir = "~/files/xxxx/sdk/bin",
    cross = "arm-linux-"
}

Build ios project

$ xmake f -p iphoneos
$ xmake

More

More service-related configuration notes are available at: #622

@waruqi waruqi added this to the v2.2.5 milestone Dec 5, 2018
@waruqi waruqi modified the milestones: v2.2.6, v2.2.7 May 8, 2019
@waruqi waruqi modified the milestones: v2.2.7, todo Jun 15, 2019
@waruqi waruqi pinned this issue Nov 20, 2019
@waruqi waruqi unpinned this issue Apr 9, 2021
@waruqi waruqi pinned this issue Apr 20, 2022
@waruqi waruqi unpinned this issue Apr 20, 2022
@waruqi waruqi modified the milestones: todo, v2.6.6 May 15, 2022
@waruqi waruqi closed this as completed May 15, 2022
@waruqi
Copy link
Member Author

waruqi commented May 15, 2022

I have supported it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant