cargo raze

A cargo subcommand to generate platform-specific BUILD files.

Problem

You like cargo's package rich ecosystem, but are interested in using Bazel to build a multilanguage, large, or otherwise complex set of applications.

So far you've either stuck with Cargo and made do with build.rs files, or migrated to Bazel and avoided crates.io dependencies or manually generated a select set of BUILD files for vendored dependencies.

cargo raze gives you the best of both worlds: rust library downloading + resolution courtesy of Cargo with the power and scalability of Bazel.

How it looks (speculative and untested)

In a directory containing 'Cargo.toml' cargo install cargo-vendor cargo install cargo-raze cargo generate_lockfile cargo vendor -x cargo raze You dependencies each get a shiny new Cargo.bzl file that bazel can use to link your dependencies up.

Next, visit bazel-raze to see how to include these dependencies in your project.

How it works (soon!)

cargo raze uses Cargo's own internal dependency resolution, feature flag propagation, and platform introspection to link the vendored dependencies properly for your platform.

An example generated file

```python """ cargo-raze generated details for net2-0.2.29.

Generated for: platformtriple: x8664-unknown-linux-gnu platformattrs: [ "debugassertions", "targetarch: x8664", "targetendian: little", "targetenv: gnu", "targetfamily: unix", "targetfeature: sse", "targetfeature: sse2", "targethasatomic: 16", "targethasatomic: 32", "targethasatomic: 64", "targethasatomic: 8", "targethasatomic: ptr", "targetos: linux", "targetpointerwidth: 64", "targetthreadlocal", "target_vendor: unknown", "unix" ]

DO NOT MODIFY! Instead, add a CargoOverride.bzl mixin. """ description = struct( package = struct( pkgname = "net2", pkgversion = "0.2.29", ), dependencies = [ struct( name = "cfg-if", version = "0.1.0", ), struct( name = "libc", version = "0.2.22", ), ], builddependencies = [], devdependencies = [], features = [], targets = [ struct( name = "net2", kinds = [ "lib", ], path = "src/lib.rs", ), struct( name = "all", kinds = [ "test", ], path = "tests/all.rs", ), ], ) ```

TODO: