Building NativeLink with Bazel
These instructions contain information on how to work with NativeLink for Bazel users.
If you’re using the Nix flake you’re all set.
If you’re running outside of nix, install bazelisk
manually and make sure you have a recent functional C++ toolchain with LLD as
linker. On Unix you’ll also have to add
--extra_toolchains=@rust_toolchains//:all
to all of your Bazel invocations to
allow the use of non-hermetic Rust toolchains. Windows is non-hermetic by
default.
Build
The following commands places an executable in ./bazel-bin/nativelink
and
starts the service:
bazel run nativelink -- \ $(pwd)/nativelink-config/examples/basic_cas.json5
bazel run --extra_toolchains=@rust_toolchains//:all nativelink -- \ $(pwd)/nativelink-config/examples/basic_cas.json5
bazel run --config=windows nativelink -- \ $(pwd)/nativelink-config/examples/basic_cas.json5
For optimized builds:
bazel run -c opt nativelink -- \ $(pwd)/nativelink-config/examples/basic_cas.json5
bazel run -c opt --extra_toolchains=@rust_toolchains//:all nativelink -- \ $(pwd)/nativelink-config/examples/basic_cas.json5
bazel run --config=windows -c opt nativelink -- \ $(pwd)/nativelink-config/examples/basic_cas.json5
Test
To run tests with Bazel:
bazel test //... --verbose_failures
bazel test --extra_toolchains=@rust_toolchains//:all //... --verbose_failures
bazel test --config=windows //... --verbose_failures