【问题标题】:Does bazel support remote execution on different platforms?bazel 是否支持不同平台上的远程执行?
【发布时间】:2019-12-20 13:26:59
【问题描述】:

具体来说,我想在 Mac 主机上对 Windows 工作者运行测试。

running bazel remote executor test on separate machines 上的评论表明这是 Bazel 团队正在处理的事情,但想要确认。

【问题讨论】:

    标签: bazel


    【解决方案1】:

    试试看吧!

    在您的 Windows 10 机器上构建并运行本地远程执行工作者:

    git clone https://github.com/bazelbuild/bazel.git
    cd bazel
    bazel build src/tools/remote:worker
    bazel-bin/src/tools/remote/worker --work_path=/tmp/test --listen_port=8080
    bazel-out/x64_windows-fastbuild/bin/src/tools/remote/worker.exe --listen_port=8080 --work_path=C:\tmp\lre --debug
    

    注意:如果它抱怨缺少某些命令,例如 zip,请打开 MSYS shell 并运行例如 pacman -Syu zip unzip

    设置您的 .bazelrc 以使用远程执行:

    # Remote Build Execution requires a strong hash function, such as SHA256.
    startup --host_jvm_args=-Dbazel.DigestFunction=SHA256
    
    # Depending on how many machines are in the remote execution instance, setting
    # this higher can make builds faster by allowing more jobs to run in parallel.
    # Setting it too high can result in jobs that timeout, however, while waiting
    # for a remote machine to execute them.
    build:remote --jobs=8
    
    
    # Set various strategies so that all actions execute remotely. Mixing remote
    # and local execution will lead to errors unless the toolchain and remote
    # machine exactly match the host machine.
    build:remote --spawn_strategy=remote
    build:remote --strategy=Javac=remote
    build:remote --strategy=Closure=remote
    build:remote --genrule_strategy=remote
    build:remote --define=EXECUTOR=remote
    
    # Enable the remote cache so action results can be shared across machines,
    # developers, and workspaces.
    build:remote --remote_cache=localhost:8080
    
    # Enable remote execution so actions are performed on the remote systems.
    build:remote --remote_executor=localhost:8080
    
    # Enable encryption.
    #build:remote --tls_enabled=true
    
    # Enforce stricter environment rules, which eliminates some non-hermetic
    # behavior and therefore improves both the remote cache hit rate and the
    # correctness and repeatability of the build.
    build:remote --experimental_strict_action_env=true
    
    # Set a higher timeout value, just in case.
    build:remote --remote_timeout=3600
    
    build:remote --auth_enabled=false
    
    # Since we're testing remote execution, let's make sure it always actually
    # happens.
    build:remote --remote_accept_cached=false
    test --cache_test_results=false
    
    test --test_output=errors
    
    # TODO(b/77217487): Needed for C++ builds until fix to
    # https://github.com/bazelbuild/bazel/issues/4883 is available.
    build --nocheck_visibility
    
    build:debug --verbose_failures
    build:debug --explain=explain.txt
    build:debug --verbose_explanations
    build:debug --toolchain_resolution_debug
    build:debug --subcommands
    

    现在从您的 Mac 进行远程构建(当然 localhost:8080 应该更改为您的 Windows 10 机器的 IP):

    bazel build --config=remote //:HelloWorld
    

    现在进行远程执行

    bazel run --config=remote //:HelloWorld
    

    注意:无耻盗取https://github.com/bazelbuild/bazel/issues/4962

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-14
      相关资源
      最近更新 更多